public IndexDescriptor GetIndex(PropertyAccessor propertyAcessor) { var index = propertyAcessor.Position; if (index >= 0) { return(new IndexDescriptor(index)); } var name = propertyAcessor.Name; index = ~_AttributeNames.BinarySearch(name); _AttributeNames.Insert(index, name); _ReadProperties.Insert(index, propertyAcessor); for (var i = index; i < _ReadProperties.Count; i++) { _ReadProperties[i].Position = i; } return(new IndexDescriptor(index, true)); }
public PropertyAccessor GetAccessor(string propertyName) { return(_PropertyAccessoresDictionary.GetOrAddEntity(propertyName, pn => PropertyAccessor.FromDictionary <T>(pn, -1)));; }
internal DynamicObjectPropertyAccessor(DynamicObject @dynamicObject) { var type = @dynamicObject.GetType(); var staticPropertyInfo = type.GetPropertyInfoDescriptions().ToList(); var staticAttributesNames = new HashSet <string>(staticPropertyInfo.Select(p => p.PropertyInfo.Name)); var dynamicAttributesNames = @dynamicObject.GetDynamicMemberNames().Where(d => !staticAttributesNames.Contains(d)).ToList(); var staticPropertyAccessores = staticPropertyInfo.Select(property => new PropertyBuilder(property.PropertyInfo.Name, (pn, index) => new PropertyAccessor(type, property, index))); var dynamicPropertyAccessores = dynamicAttributesNames.Select(name => new PropertyBuilder(name, (pn, index) => PropertyAccessor.FromDynamicObject(type, pn, index))); _ReadProperties = staticPropertyAccessores.Concat(dynamicPropertyAccessores) .OrderBy(p => p.Name) .Select((p, i) => p.Builder(p.Name, i)) .ToList(); _PropertyAccessoresDictionary = _ReadProperties.ToDictionary(p => p.Name); _AttributeNames = _ReadProperties.Select(p => p.Name).ToList(); }
public IndexDescriptor GetIndex(PropertyAccessor propertyAcessor) => new IndexDescriptor(propertyAcessor.Position);
internal DynamicObjectPropertyAccessor(DynamicObject @dynamicObject) { var type = @dynamicObject.GetType(); var staticPropertyInfo = type.GetProperties(BindingFlags.Public | BindingFlags.Instance) .Where(p => p.CanRead && p.GetGetMethod(false) != null).ToList(); var staticAttributes = new HashSet <string>(staticPropertyInfo.Select(p => p.Name)); var dynamicAttributes = @dynamicObject.GetDynamicMemberNames().Where(d => !staticAttributes.Contains(d)).ToList(); var staticPropertyAccessores = staticPropertyInfo.Select(property => new PropertyBuilder(property.Name, (pn, index) => new PropertyAccessor(type, property, index))); var dynamicPropertyAccessores = dynamicAttributes.Select(name => new PropertyBuilder(name, (pn, index) => PropertyAccessor.FromDynamicObject(type, pn, index))); _ReadProperties = staticPropertyAccessores.Concat(dynamicPropertyAccessores) .OrderBy(p => p.Name) .Select((p, i) => p.Builder(p.Name, i)) .ToList(); _PropertyAccessoresDictionary = _ReadProperties.ToDictionary(p => p.Name); _AttributeNames = _ReadProperties.Select(p => p.Name).ToList(); }