//Internals internal static void FixIndex(IUnifiedIMObject obj, Type t, string property, object oldValue) { if (Indexes.ContainsKey(t)) { ObjectIndexer <IUnifiedIMObject> pIndexes = Indexes[t]; object cVal = Property.Get(obj, property) ?? null; pIndexes.RemoveIndex(property, oldValue, obj); pIndexes.AddIndex(property, cVal, obj); } }
internal static void HandleObjectCreation <T>(IUnifiedIMObject obj) { if (UnifiedSystem.AllowReferences) { UnifiedSystem.ResolveReferences(obj, typeof(T)); } if (UnifiedSystem.UseOmniBase) { lock (UnifiedSystem.OmniBase) UnifiedSystem.OmniBase.Add(obj.ObjectID, obj); } List <string> indexesToAdd = new List <string>(); if (UnifiedSystem.AllowReferences) { List <UnifiedIMReference> refs = new List <UnifiedIMReference>(); if (TypeReferences.ContainsKey(typeof(T))) { refs = TypeReferences[typeof(T)]; } /* * ObjectIndex<IUnifiedIMObject> oi = null; * if (CreateReferenceIndexes) * if (Indexes.ContainsKey(typeof(T))) * oi = Indexes[typeof(T)];*/ foreach (UnifiedIMReference reff in refs) { if (reff.HostType == typeof(T)) { //object value = reff.GetHostProperty(obj); //if(!obj.PropertyStates.ContainsKey(reff.HostProperty)) //obj.PropertyStates.Add(reff.HostProperty, new UIMPropertyState(value)); if (CreateReferenceIndexes && reff.HostProperty != "ObjectID") { // oi.AddIndex(reff.HostProperty, value, obj); indexesToAdd.Add(reff.HostProperty); } } else if (reff.TargetType == typeof(T)) { //object value = reff.GetTargetProperty(obj); //if (!obj.PropertyStates.ContainsKey(reff.TargetProperty)) // obj.PropertyStates.Add(reff.TargetProperty, new UIMPropertyState(value)); if (CreateReferenceIndexes && reff.TargetProperty != "ObjectID") { //oi.AddIndex(reff.TargetProperty, value, obj); indexesToAdd.Add(reff.TargetProperty); } } } } if (AllowIndexes) { if (IndexProperties.ContainsKey(typeof(T))) { indexesToAdd.AddRange(IndexProperties[typeof(T)]); } ObjectIndexer <IUnifiedIMObject> oi = null; if (Indexes.ContainsKey(typeof(T))) { oi = Indexes[typeof(T)]; } if (oi != null) { foreach (string idx in indexesToAdd.Distinct()) { object value = Property.Get(obj, idx); if (!obj.PropertyStates.ContainsKey(idx)) { obj.PropertyStates.Add(idx, new UIMPropertyState(value)); } oi.AddIndex(idx, value, obj); } } } }