/// <summary> /// Sets the property and save. /// </summary> /// <param name="collection">The collection.</param> /// <param name="prop">The prop.</param> /// <param name="save">if set to <c>true</c> [save].</param> private void SetPropertyAndSave(PropertyInfoCollection collection, PropertyInfo property, bool save, bool overwrite) { if (collection != null) { PropertyInfo setProperty = collection[property.Name]; if (setProperty == null) { collection.Add(property); } else if (overwrite == true) { setProperty.Namespace = property.Namespace; //Calculated property not set if (property.Calculated == false) { setProperty.Value = property.Value; } } if (save == true) { SavePropertyCollection(collection); } } }
internal static InformationApi.Collections.PropertyInfoCollection BuildPropInfoCol(Type t) { var props = t.GetProperties(); var ret = new PropertyInfoCollection(); foreach (var p in props) { ret.Add(BuildPropInfo(p)); } return(ret); }
private static PropertyInfoCollection GetCloneableProperties(Type destinationType, Type baseType) { PropertyInfoCollection descriptor; if (!PropertiesDescriptorCache.TryGetValue(destinationType, out descriptor)) { descriptor = new PropertyInfoCollection(); foreach (var propertyInfo in destinationType.GetProperties()) { var item = GetCloneableProperty(propertyInfo, baseType); if (item != null) { descriptor.Add(item.Name, item); } } PropertiesDescriptorCache.Add(destinationType, descriptor); } return(descriptor); }
private void SetProperty(PropertyInfoCollection collection, PropertyInfo property, bool overwrite) { if (collection != null) { PropertyInfo setProperty = collection[property.Name]; if (setProperty == null) { collection.Add(property); } else if (overwrite == true) { setProperty.Namespace = property.Namespace; //Calculated property not set if (property.Calculated == false) setProperty.Value = property.Value; } } }