private DataHelper CreateDataHelper(DataItemInfo info) { DataHelper helper = new DataHelper(info.TargetType, this, Database, info.DisplayName, info.CodeName, info.FieldName, info.Sorts); this.DataHelpers.Add(helper); return(helper); }
private DataHelper CreateDataHelper(DataItemInfo info, out bool valid) { DataHelper helper = new DataHelper(info.TargetType, this, Database, info.DataName, info.FieldName, info.Sorts, out valid); this.HelperOrder.Add(info.DataName); this.DataHelpers.Add(info.DataName, helper); return(helper); }
public void Initialize(EditorLSDatabaseWindow window, LSDatabase database) { this.MainWindow = window; Database = database; InitializeData(); for (int i = 0; i < DataItemInfos.Count; i++) { DataItemInfo info = DataItemInfos[i]; CreateDataHelper(info); } }
public void Initialize(EditorLSDatabaseWindow window, LSDatabase database, out bool valid) { this.MainWindow = window; Database = database; InitializeData(); IsValid = true; for (int i = 0; i < DataItemInfos.Count; i++) { DataItemInfo info = DataItemInfos[i]; bool isValid; CreateDataHelper(info, out isValid); if (!isValid) { Debug.LogError("Database does not match database type described by the database editor. Make sure Lockstep_Database.asset is the correct database type."); IsValid = false; break; } } valid = IsValid; }
public void RegisterData(DataItemInfo info) { DataItemInfos.Add(info); }
private void InitializeData() { Type databaseType = Database.GetType(); Type foundationType = typeof(LSDatabase); if (!databaseType.IsSubclassOf(foundationType)) { throw new System.Exception("Database does not inherit from LSDatabase and cannot be edited."); } HashSet <string> nameCollisionChecker = new HashSet <string>(); FastList <SortInfo> sortInfos = new FastList <SortInfo>(); while (databaseType != foundationType) { FieldInfo[] fields = databaseType.GetFields((BindingFlags) ~0); for (int i = 0; i < fields.Length; i++) { FieldInfo field = fields [i]; object[] attributes = field.GetCustomAttributes(typeof(RegisterDataAttribute), false); for (int j = 0; j < attributes.Length; j++) { RegisterDataAttribute registerDataAttribute = attributes [j] as RegisterDataAttribute; if (registerDataAttribute != null) { if (!field.FieldType.IsArray) { Debug.LogError("Serialized data field must be array"); continue; } if (!field.FieldType.GetElementType().IsSubclassOf(typeof(DataItem))) { Debug.LogError("Serialized data type must be derived from DataItem"); continue; } object[] sortAttributes = field.GetCustomAttributes(typeof(RegisterSortAttribute), false); sortInfos.FastClear(); foreach (object obj in sortAttributes) { RegisterSortAttribute sortAtt = obj as RegisterSortAttribute; if (sortAtt != null) { sortInfos.Add(new SortInfo(sortAtt.Name, sortAtt.DegreeGetter)); } } DataItemInfo dataInfo = new DataItemInfo( field.FieldType.GetElementType(), registerDataAttribute.DisplayName, field.Name, sortInfos.ToArray() ); if (nameCollisionChecker.Add(dataInfo.DataName) == false) { throw new System.Exception("Data Name collision detected for '" + dataInfo.DataName + "'."); } RegisterData(dataInfo); break; } } } databaseType = databaseType.BaseType; } }
public static void RegisterData(DataItemInfo info) { DataItemInfos.Add (info); }
private DataHelper CreateDataHelper(DataItemInfo info) { DataHelper helper = new DataHelper(info.TargetType, this, Database, info.DisplayName, info.CodeName, info.FieldName, info.Sorts); this.DataHelpers.Add (helper); return helper; }
private DataHelper CreateDataHelper(DataItemInfo info, out bool valid) { DataHelper helper = new DataHelper(info.TargetType, this, Database, info.DataName,info.FieldName, info.Sorts, out valid); this.HelperOrder.Add (info.DataName); this.DataHelpers.Add (info.DataName,helper); return helper; }