Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
CollectionInformation.cs
1using System;
4
6{
10 [TypeName(TypeNameSerialization.FullName)]
12 {
17 {
18 this.IndexCollectionName = string.Empty;
19 this.CollectionName = string.Empty;
20 this.IndexForFullTextSearch = false;
21 this.Properties = Array.Empty<PropertyDefinition>();
22 }
23
33 {
34 this.IndexCollectionName = IndexCollectionName;
35 this.CollectionName = CollectionName;
36 this.IndexForFullTextSearch = IndexForFullTextSearch;
37 this.Properties = Properties;
38 }
39
43 public string IndexCollectionName { get; set; }
44
48 public string CollectionName { get; set; }
49
53 public bool IndexForFullTextSearch { get; set; }
54
58 public PropertyDefinition[] Properties { get; set; }
59
63 public PropertyType[] PropertyTypes { get; set; }
64
72 {
73 Dictionary<string, PropertyDefinition> ByName = new Dictionary<string, PropertyDefinition>();
74 bool New = false;
75
76 foreach (PropertyDefinition Property in this.Properties)
77 ByName[Property.Definition] = Property;
78
79 foreach (PropertyDefinition Property in Properties)
80 {
81 if (!ByName.TryGetValue(Property.Definition, out PropertyDefinition Prev) ||
82 Property.Definition != Prev.Definition ||
83 Property.ExternalSource != Prev.ExternalSource ||
84 Property.Type != Prev.Type)
85 {
86 ByName[Property.Definition] = Property;
87 New = true;
88 }
89 }
90
91 if (!New)
92 return false;
93
94 int c = ByName.Count;
95 PropertyDefinition[] Definitions = new PropertyDefinition[c];
96
97 ByName.Values.CopyTo(Definitions, 0);
98
99 this.Properties = Definitions;
100 this.IndexForFullTextSearch = true;
101
102 return true;
103 }
104
112 {
113 Dictionary<string, PropertyDefinition> ByName = new Dictionary<string, PropertyDefinition>();
114 bool Removed = false;
115
116 foreach (PropertyDefinition Property in this.Properties)
117 ByName[Property.Definition] = Property;
118
119 foreach (PropertyDefinition Property in Properties)
120 {
121 if (ByName.Remove(Property.Definition))
122 Removed = true;
123 }
124
125 if (!Removed)
126 return false;
127
128 int c = ByName.Count;
129 PropertyDefinition[] Definitions = new PropertyDefinition[c];
130
131 ByName.Values.CopyTo(Definitions, 0);
132
133 this.Properties = Definitions;
134 this.IndexForFullTextSearch = c > 0;
135
136 return true;
137 }
138 }
139}
Contains information about a collection, in relation to full-text-search.
bool IndexForFullTextSearch
If collection should be indexed.
bool AddIndexableProperties(params PropertyDefinition[] Properties)
Adds properties for full-text-search indexation.
PropertyDefinition[] Properties
Properties to index
CollectionInformation(string IndexCollectionName, string CollectionName, bool IndexForFullTextSearch, params PropertyDefinition[] Properties)
Contains information about a collection, in relation to full-text-search.
bool RemoveIndexableProperties(params PropertyDefinition[] Properties)
Removes properties from full-text-search indexation.
PropertyType[] PropertyTypes
Types of indexed properties.
CollectionInformation()
Contains information about a collection, in relation to full-text-search.
PropertyType Type
Type of property definition
TypeNameSerialization
How the type name should be serialized.
PropertyType
Type of indexed property.