/// <summary> /// Given the property name and its instance, it sets in the corresponding bit array at /// the corresponding index (of the property) the value to true (modified) /// Assumming that model is not a dirty model /// </summary> /// <param name="model">The instance of IChangesTrackeable</param> /// <param name="property">The name of the property</param> public void MarkAsModified(IStateObject model, string property) { if (model.UniqueID == null || IsDirtyModel(model) || !StateManager.AllBranchesAttached(model)) { return; } PropertiesExDictionary typeProperties = TypePropertiesCache.GetPropertiesIndexPositionOfType(model.GetType()); int propertyIndex; if (!typeProperties.TryGetValue(property, out propertyIndex)) { return; } BitArray data; lock (modifiedLock) { if (!bitArrays.TryGetValue(model, out data)) { bitArrays.Add(model, data = new BitArray(typeProperties.PropertiesList.Count)); } if (data == null) { bitArrays[model] = data = new BitArray(typeProperties.PropertiesList.Count); } } data.Set(propertyIndex, true); }
private static void RegisterProperty(PropertyInfoEx propEx, PropertiesExDictionary properties, bool hasIndexParameters) { var prop = propEx.prop; if (!hasIndexParameters) { var propName = prop.Name; //A property might be overriden by a descendant class int existingPos = -1; //If we have already registered then we check //Descendant property will always win if (!properties.TryGetValue(propName, out existingPos)) { properties.AddProperty(propName, propEx); } else { propEx.propertyPositionIndex = (short)existingPos; properties.PropertiesList[existingPos] = propEx; } } }
public PropertiesExDictionary(PropertiesExDictionary parentDict) : base(parentDict, StringComparer.Ordinal) { PropertiesList = new List <PropertyInfoEx>(parentDict.PropertiesList); }