static void PreparePath(PropPath path, HashSet <int> notUniqueCodes = null, string prefix = null) { notUniqueCodes = notUniqueCodes ?? new HashSet <int>(); prefix = $"{prefix}.{path.Info.Name}".TrimStart('.'); var propPath = make_property_path(prefix); var code = prefix.GetHashCode(); if (_pathsByCode.ContainsKey(code)) { notUniqueCodes.Add(code); _pathsByCode.Remove(code); _paths.Add(prefix, propPath); } else if (notUniqueCodes.Contains(code)) { _paths.Add(prefix, propPath); } else { _pathsByCode.Add(code, propPath); } foreach (var child in path.Children) { PreparePath(child, notUniqueCodes, prefix); } }
public override string GetName() { if (Context != null) { return(Context.Scope("." + PropPath.ToString())); } return($"Entity[{Container.Entity.Index}].{PropPath.ToString()}"); }
static PropPath GetPath(PropertyInfo info, PropPath owner) { var path = new PropPath { Dept = owner.Dept + 1, Info = info, Owner = owner, }; path.Children = GetPaths(path); //? recursion to GetPaths method return(path); }
static PropPath[] GetPaths() { var paths = Type.GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance) .Select(x => { var path = new PropPath { Dept = 1, Info = x, Owner = null }; path.Children = GetPaths(path); return(path); }).ToArray(); return(paths); }
static PropPath[] GetPaths(PropPath owner) { // 'Types' recursion is not checked for suppoting deep paths of hierarchical entities, like 'Parent.Parent.Parent...' if (owner.Dept >= 10) // think 10 is quite deep { return(new PropPath[0]); } var type = owner.Info.PropertyType; if (typeof(IEnumerable).IsAssignableFrom(type) || type.GetInfo().IsPrimitive) { return(new PropPath[0]); } var paths = type.GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance) .Select(x => GetPath(x, owner)) //? recursion .ToArray(); return(paths); }