2using System.Collections.Generic;
4using System.Reflection;
13 Dictionary<string, DatabaseObjectType> dictionary = [];
15 foreach (XElement item
in xElement.Elements()) {
34 dictionary.Add(attributeValue, value);
36 foreach (XElement item2
in xElement.Elements()) {
41 List<DatabaseObjectType> list = [];
42 string[] array = attributeValue10.Split([
',',
' '], StringSplitOptions.RemoveEmptyEntries);
43 foreach (
string text
in array) {
45 throw new InvalidOperationException($
"Database object type \"{text}\" not found.");
49 List<DatabaseObjectType> list2 = [];
50 array = attributeValue11.Split([
',',
' '], StringSplitOptions.RemoveEmptyEntries);
51 foreach (
string text2
in array) {
53 throw new InvalidOperationException($
"Database object type \"{text2}\" not found.");
58 if (!
string.IsNullOrEmpty(attributeValue12)
59 && !dictionary.TryGetValue(attributeValue12, out value4)) {
60 throw new InvalidOperationException($
"Database object type \"{attributeValue12}\" not found.");
67 Assembly.Load(
new AssemblyName(attributeValue13));
69 catch (Exception ex) {
70 Log.
Warning($
"Error loading assembly {attributeValue13}. {ex}");
77 databaseObjectType: dictionary[
"Root"],
84 item4.NestingParent = database.Root;
93 Dictionary<DatabaseObject, Guid> dictionary = [];
94 Dictionary<DatabaseObject, Guid> dictionary2 = [];
95 Dictionary<Guid, Guid> dictionary3 = generateNewGuids ? [] :
null;
97 Dictionary<Guid, DatabaseObject> dictionary4 = [];
99 dictionary4.Add(item.
Guid, item);
101 dictionary4.Add(explicitNestingChild.
Guid, explicitNestingChild);
104 foreach (KeyValuePair<DatabaseObject, Guid> item2
in dictionary) {
105 Guid key = item2.Value;
106 if (dictionary3 !=
null
107 && dictionary3.TryGetValue(key, out Guid value)) {
111 throw new InvalidOperationException($
"Required nesting parent {item2.Value} not found in database objects list.");
113 item2.Key.NestingParent = value2;
115 foreach (KeyValuePair<DatabaseObject, Guid> item3
in dictionary2) {
116 Guid guid = item3.Value;
117 if (dictionary3 !=
null
118 && dictionary3.TryGetValue(guid, out Guid value3)) {
121 item3.Key.ExplicitInheritanceParent = dictionary4.TryGetValue(guid, out
DatabaseObject value4)
125 return list.Where(x => x.NestingParent ==
null).ToList();
129 Dictionary<DatabaseObject, Guid> dictionary = [];
131 foreach (KeyValuePair<DatabaseObject, Guid> item
in dictionary) {
146 !
string.IsNullOrEmpty(databaseObjectType.
IconName) ? databaseObjectType.
IconName :
string.Empty
155 "AllowedNestingParents",
156 databaseObjectType.
AllowedNestingParents.Aggregate(
string.Empty, (r, d) => r.Length != 0 ? $
"{r},{d.Name}" : d.Name)
160 "AllowedInheritanceParents",
169 List<Type> list = [];
171 List<Assembly> list2 = [];
172 foreach (Type item
in list) {
173 if (!list2.Contains(item.GetTypeInfo().Assembly)) {
174 list2.Add(item.GetTypeInfo().Assembly);
177 list2.Sort((a1, a2) =>
string.CompareOrdinal(a1.FullName, a2.FullName));
179 foreach (Assembly item2
in list2) {
188 List<DatabaseObject> list = [];
189 IEnumerable<DatabaseObject> enumerable = databaseObjects as
DatabaseObject[] ?? databaseObjects.ToArray();
203 Dictionary<DatabaseObject, Guid> nestingParents,
204 Dictionary<DatabaseObject, Guid> inheritanceParents,
205 Dictionary<Guid, Guid> guidTranslation) {
206 List<DatabaseObject> list = [];
207 foreach (XElement item2
in node.Elements()) {
216 Dictionary<DatabaseObject, Guid> nestingParents,
217 Dictionary<DatabaseObject, Guid> inheritanceParents,
218 Dictionary<Guid, Guid> guidTranslation) {
225 if (guid == Guid.Empty) {
226 guid = Guid.NewGuid();
228 if (guidTranslation !=
null) {
229 Guid guid2 = Guid.NewGuid();
230 guidTranslation.Add(guid, guid2);
235 if (!
string.IsNullOrEmpty(attributeValue5)) {
239 DatabaseObject databaseObject =
new(databaseObjectType, guid, attributeValue, value) { Description = attributeValue2 };
240 if (nestingParents !=
null
241 && attributeValue3 != Guid.Empty) {
242 nestingParents.Add(databaseObject, attributeValue3);
244 if (inheritanceParents !=
null
245 && attributeValue4 != Guid.Empty) {
246 inheritanceParents.Add(databaseObject, attributeValue4);
249 item.NestingParent = databaseObject;
251 return databaseObject;
255 List<DatabaseObject> list =
new(databaseObjects);
256 list.Sort((o1, o2) => o1.Type.Order != o2.Type.Order ? o1.Type.Order - o2.Type.Order : o1.Guid.CompareTo(o2.Guid));
264 if (!
string.IsNullOrEmpty(databaseObject.
Description)) {
268 if (databaseObject.
Value !=
null) {
275 if (saveNestingParent && databaseObject.
NestingParent !=
null) {
static void Warning(object message)
static Type FindType(string typeName, bool skipSystemAssemblies, bool throwIfNotFound)
static string GetShortTypeName(string longTypeName)
DatabaseObjectType FindDatabaseObjectType(string name, bool throwIfNotFound)
IList< DatabaseObjectType > DatabaseObjectTypes
void FindUsedValueTypes(List< Type > typesList)
DatabaseObject FindDatabaseObject(Guid guid, DatabaseObjectType type, bool throwIfNotFound)
DatabaseObject ExplicitInheritanceParent
DatabaseObject NestingParent
IEnumerable< DatabaseObject > GetExplicitNestingChildren(DatabaseObjectType type, bool directChildrenOnly)
DatabaseObjectType NestedValueType
string DefaultInstanceName
ReadOnlyList< DatabaseObjectType > AllowedNestingParents
ReadOnlyList< DatabaseObjectType > AllowedInheritanceParents
void InitializeRelations(IEnumerable< DatabaseObjectType > allowedNestingParents, IEnumerable< DatabaseObjectType > allowedInheritanceParents, DatabaseObjectType nestedValueType)
static DatabaseObject InternalLoadDatabaseObject(XElement node, Database database, Dictionary< DatabaseObject, Guid > nestingParents, Dictionary< DatabaseObject, Guid > inheritanceParents, Dictionary< Guid, Guid > guidTranslation)
static void SaveDatabaseObjectsList(XElement node, IEnumerable< DatabaseObject > databaseObjects)
static List< DatabaseObject > LoadDatabaseObjectsList(XElement node, Database database, bool generateNewGuids)
static Database LoadDatabase(XElement node)
static void InternalSaveDatabaseObjectsList(XElement node, IEnumerable< DatabaseObject > databaseObjects, bool saveNestingParents)
static List< DatabaseObject > LoadDatabaseObjectsList(XElement node, Database database)
static void SaveDatabase(XElement node, Database database)
static void SaveDatabaseObject(XElement node, DatabaseObject databaseObject)
static List< DatabaseObject > InternalLoadDatabaseObjectsList(XElement node, Database database, Dictionary< DatabaseObject, Guid > nestingParents, Dictionary< DatabaseObject, Guid > inheritanceParents, Dictionary< Guid, Guid > guidTranslation)
static DatabaseObject LoadDatabaseObject(XElement node, Database database)
static void InternalSaveDatabaseObject(XElement node, DatabaseObject databaseObject, bool saveNestingParent)
static void SetAttributeValue(XElement node, string attributeName, object value)
static object GetAttributeValue(XElement node, string attributeName, Type type)
static XElement AddElement(XElement parentNode, string name)
static XElement FindChildElement(XElement node, string elementName, bool throwIfNotFound)