public void AddStrictly(T objSource) { string sKey = LineObjectCollection <T> .GetKeyName(objSource); ExcpHelper.ThrowIf(base.ContainsKey(sKey), "LineObjectCollection<{0}>.AddStrictly({1}) ERROR. Such object already exists in database.", m_type.Name, objSource); lock (m_oLocker) { base.Add(sKey, objSource); } }
private void RemoveObjectsAfterCommit <T>(DelegateSetCacheItem <T> func) where T : ILineObject <T> { LineObjectCollection <T> loc = LineSr.Instance.ObjectsToRemove.GetLineObjectCollection <T>(); if (loc != null) { foreach (T obj in loc.Values) { func(obj); } } }
private void UnsetPropertiesChanged <T>() where T : ILineObject <T> { Type type = typeof(T); if (this.ContainsKey(type)) { LineObjectCollection <T> loc = this[type] as LineObjectCollection <T>; foreach (T obj in loc.Values) { obj.UnsetPropertiesChanged(); } } }
public bool ContainsObjectByKey <T>(string sKey) where T : ILineObject <T> { Type type = typeof(T); LineObjectCollection <T> collection = null; lock (m_oLocker) { collection = m_di.ContainsKey(type) ? m_di[type] as LineObjectCollection <T> : null; } if (collection != null) { return(collection.ContainsKey(sKey)); } return(false); }
public void SafelyAddObject <T>(T obj) where T : ILineObject <T> { Type type = typeof(T); LineObjectCollection <T> collection = null; lock (m_oLocker) { if (m_di.ContainsKey(type)) { collection = m_di[type] as LineObjectCollection <T>; } else { collection = new LineObjectCollection <T>(); m_di.Add(type, collection); } } Debug.Assert(collection != null); collection.AddSafely(obj); }