3using System.Threading.Tasks;
13 [CollectionName(
"Languages")]
18 private readonly SortedDictionary<string, Namespace> namespacesByName =
new SortedDictionary<string, Namespace>(StringComparer.CurrentCultureIgnoreCase);
19 private readonly
object synchObject =
new object();
20 private Guid objectId = Guid.Empty;
21 private string code =
string.Empty;
22 private string name =
string.Empty;
23 private byte[] flag =
null;
24 private int flagWidth = 0;
25 private int flagHeight = 0;
26 private bool namespacesLoaded =
false;
42 set => this.objectId = value;
51 set => this.code = value;
57 [DefaultValueStringEmpty]
61 set => this.name = value;
71 set => this.flag = value;
80 get => this.flagWidth;
81 set => this.flagWidth = value;
90 get => this.flagHeight;
91 set => this.flagHeight = value;
101 lock (this.synchObject)
103 if (this.namespacesByName.TryGetValue(
Name, out
Namespace Result))
112 lock (this.synchObject)
114 if (this.namespacesByName.TryGetValue(
Name, out
Namespace Result))
133 if (ns is
null && CreateIfNotFound)
145 if (!this.namespacesLoaded)
150 lock (this.synchObject)
159 this.namespacesLoaded =
true;
162 lock (this.synchObject)
165 this.namespacesByName.Values.CopyTo(Result, 0);
178 if (!(Result is
null))
182 lock (this.synchObject)
184 if (this.namespacesByName.TryGetValue(
Name, out Result))
189 LanguageId = this.objectId,
193 this.namespacesByName[
Name] = Result;
232 if (
string.IsNullOrEmpty(this.name))
235 return this.name +
" (" + this.code +
")";
Static interface for database persistence. In order to work, a database provider has to be assigned t...
static Task< IEnumerable< object > > Find(string Collection, params string[] SortOrder)
Finds objects in a given collection.
static async Task Insert(object Object)
Inserts an object into the default collection of the database.
This filter selects objects that conform to all child-filters provided.
This filter selects objects that have a named field equal to a given value.
Contains information about a language.
Language()
Contains information about a language.
async Task< string > GetStringAsync(Type Type, string Id, string Default)
Gets the string value of a string ID. If no such string exists, a string is created with the default ...
int FlagWidth
Width of flag.
int FlagHeight
Height of flag.
override string ToString()
async Task< Namespace > GetNamespaceAsync(string Name, bool CreateIfNotFound)
Gets the namespace object, given its name, if available.
Task< string > GetStringAsync(Type Type, int Id, string Default)
Gets the string value of a string ID. If no such string exists, a string is created with the default ...
async Task< Namespace > GetNamespaceAsync(string Name)
Gets the namespace object, given its name, if available.
string Code
Language code.
async Task< Namespace > CreateNamespaceAsync(string Name)
Creates a new language namespace, or updates an existing language namespace, if one exist with the sa...
string Name
Language name.
byte[] Flag
Language flag.
async Task< Namespace[]> GetNamespacesAsync()
Gets available namespaces.
Contains information about a namespace in a language.
Task< LanguageString > GetStringAsync(int Id)
Gets the string object, given its ID, if available.
TypeNameSerialization
How the type name should be serialized.