|
@@ -9,7 +9,7 @@ namespace InABox.Core
|
|
public static class DatabaseSchema
|
|
public static class DatabaseSchema
|
|
{
|
|
{
|
|
// {className: {propertyName: property}}
|
|
// {className: {propertyName: property}}
|
|
- private static Dictionary<string, Dictionary<string, IProperty>> _properties { get; }
|
|
|
|
|
|
+ private static Dictionary<string, Dictionary<string, IProperty>> _properties
|
|
= new Dictionary<string, Dictionary<string, IProperty>>();
|
|
= new Dictionary<string, Dictionary<string, IProperty>>();
|
|
|
|
|
|
private struct SubObject
|
|
private struct SubObject
|
|
@@ -52,54 +52,6 @@ namespace InABox.Core
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- /*private static BaseEditor GetPropertyEditor(Type type, PropertyInfo property, string propertyName)
|
|
|
|
- {
|
|
|
|
- BaseEditor editor = new NullEditor();
|
|
|
|
-
|
|
|
|
- var parts = propertyName.Split('.');
|
|
|
|
- var caption = "";
|
|
|
|
- var page = "";
|
|
|
|
- int? sequence = null;
|
|
|
|
-
|
|
|
|
- for (var i = 0; i < parts.Length; i++)
|
|
|
|
- {
|
|
|
|
- var column = string.Join(".", parts.Take(i + 1));
|
|
|
|
- var prop = CoreUtils.GetProperty(type, column);
|
|
|
|
- if (column.Equals(propertyName))
|
|
|
|
- {
|
|
|
|
- editor = property.GetEditor() ?? new NullEditor();
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- var pedit = prop.GetEditor();
|
|
|
|
- if (pedit is NullEditor) return pedit;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- editor = editor == null ? new NullEditor() : (editor.Clone() as BaseEditor)!;
|
|
|
|
-
|
|
|
|
- var capattr = prop.GetCustomAttribute<Caption>();
|
|
|
|
- var subcap = capattr != null ? capattr.Text : parts[i];
|
|
|
|
- var path = capattr == null || capattr.IncludePath;
|
|
|
|
- if (!string.IsNullOrWhiteSpace(subcap))
|
|
|
|
- caption = string.IsNullOrWhiteSpace(caption) || path == false ? subcap : string.Format("{0} {1}", caption, subcap);
|
|
|
|
-
|
|
|
|
- if (string.IsNullOrWhiteSpace(page))
|
|
|
|
- {
|
|
|
|
- var pageattr = prop.GetCustomAttribute<EditorSequence>();
|
|
|
|
- if (pageattr != null)
|
|
|
|
- {
|
|
|
|
- page = pageattr.Page;
|
|
|
|
- sequence = pageattr.Sequence;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- editor.Caption = caption;
|
|
|
|
- editor.Page = page;
|
|
|
|
- editor.EditorSequence = sequence ?? 999;
|
|
|
|
- return editor;
|
|
|
|
- }*/
|
|
|
|
-
|
|
|
|
private static void RegisterSubObject(Type objectType, Type propertyType, string name)
|
|
private static void RegisterSubObject(Type objectType, Type propertyType, string name)
|
|
{
|
|
{
|
|
lock (_updatelock)
|
|
lock (_updatelock)
|
|
@@ -127,14 +79,13 @@ namespace InABox.Core
|
|
x.GetGetMethod()?.IsPublic == true &&
|
|
x.GetGetMethod()?.IsPublic == true &&
|
|
(x.DeclaringType.IsSubclassOf(typeof(BaseObject))
|
|
(x.DeclaringType.IsSubclassOf(typeof(BaseObject))
|
|
|| x.DeclaringType.IsSubclassOf(typeof(BaseEditor)))
|
|
|| x.DeclaringType.IsSubclassOf(typeof(BaseEditor)))
|
|
- ); //.OrderBy(x=>x.Name);
|
|
|
|
|
|
+ );
|
|
var classProps = _properties.GetValueOrDefault(classname);
|
|
var classProps = _properties.GetValueOrDefault(classname);
|
|
|
|
|
|
foreach (var prop in properties)
|
|
foreach (var prop in properties)
|
|
{
|
|
{
|
|
var name = string.IsNullOrWhiteSpace(prefix) ? prop.Name : string.Format("{0}.{1}", prefix, prop.Name);
|
|
var name = string.IsNullOrWhiteSpace(prefix) ? prop.Name : string.Format("{0}.{1}", prefix, prop.Name);
|
|
var p = classProps?.GetValueOrDefault(name);
|
|
var p = classProps?.GetValueOrDefault(name);
|
|
- //.ToArray().FirstOrDefault(x => x.Class == classname && x.Name == name);
|
|
|
|
if (p == null)
|
|
if (p == null)
|
|
{
|
|
{
|
|
var isstatic = prop.GetAccessors(true)[0].IsStatic;
|
|
var isstatic = prop.GetAccessors(true)[0].IsStatic;
|
|
@@ -240,7 +191,6 @@ namespace InABox.Core
|
|
}
|
|
}
|
|
|
|
|
|
if (type.IsSubclassOf(typeof(BaseObject)))
|
|
if (type.IsSubclassOf(typeof(BaseObject)))
|
|
- //if ((type.BaseType != null) && (type.BaseType != typeof(BaseObject)))
|
|
|
|
RegisterProperties(master, type.BaseType, prefix, parent);
|
|
RegisterProperties(master, type.BaseType, prefix, parent);
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
catch (Exception e)
|
|
@@ -272,9 +222,6 @@ namespace InABox.Core
|
|
if (!_properties.ContainsKey(entry.Class))
|
|
if (!_properties.ContainsKey(entry.Class))
|
|
_properties[entry.Class] = new Dictionary<string, IProperty>();
|
|
_properties[entry.Class] = new Dictionary<string, IProperty>();
|
|
_properties[entry.Class][entry.Name] = entry;
|
|
_properties[entry.Class][entry.Name] = entry;
|
|
-
|
|
|
|
- //var dict = _Properties.GetOrAdd(entry.Class, className => new Dictionary<string, IProperty>());
|
|
|
|
- //dict.TryAdd(entry.Name, entry);
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -305,7 +252,6 @@ namespace InABox.Core
|
|
CheckProperties(type);
|
|
CheckProperties(type);
|
|
var entityName = type.EntityName();
|
|
var entityName = type.EntityName();
|
|
|
|
|
|
- //IProperty prop = _Properties.ToArray().FirstOrDefault(x => (x.Class.Equals(type.EntityName())) && (x.Name.Equals(name)));
|
|
|
|
var prop = _properties.GetValueOrDefault(entityName)?.GetValueOrDefault(name);
|
|
var prop = _properties.GetValueOrDefault(entityName)?.GetValueOrDefault(name);
|
|
|
|
|
|
// Walk up the inheritance tree, see if an ancestor has this property
|
|
// Walk up the inheritance tree, see if an ancestor has this property
|