示例#1
0
 /// <summary>
 /// Clear any attached data components (of any type)
 /// from the objects in this collection
 /// </summary>
 /// <param name="ofType"></param>
 public void ClearAttachedData()
 {
     foreach (ModelObject mO in this)
     {
         if (mO is DataOwner)
         {
             DataOwner dO = (DataOwner)mO;
             dO.ClearData();
         }
     }
 }
示例#2
0
        /// <summary>
        /// Get the subset of this collection which has an attached data component of the specified type
        /// </summary>
        /// <typeparam name="TCollection"></typeparam>
        /// <typeparam name="TItem"></typeparam>
        /// <typeparam name="TData">The type of data component to check for</typeparam>
        /// <param name="collection"></param>
        /// <returns></returns>
        public static TCollection AllWithDataComponent <TCollection, TItem, TData>(this TCollection collection)
            where TCollection : ModelObjectCollection <TItem>, new()
            where TItem : ModelObject
            where TData : class
        {
            TCollection result = new TCollection();

            foreach (TItem obj in collection)
            {
                DataOwner dO = obj as DataOwner;
                if (dO != null && dO.HasData(typeof(TData)))
                {
                    result.Add(obj);
                }
            }
            return(result);
        }
示例#3
0
        // TODO: Remove deleted objects to avoid the ghosts of long-gone objects from hanging around

        /// <summary>
        /// Remove from the items stored under greater history count numbers the component of
        /// the specified type
        /// </summary>
        /// <param name="componentType"></param>
        /// <param name="sourceRef"></param>
        /// <param name="iteration"></param>
        /// <param name="historyItemCount"></param>
        /// <remarks>Intended to help tidy up parametric assignments (such as node supports) which
        /// could persist while the input nodes have changed.  Not currently used.</remarks>
        public void CleanIterationData(Type componentType, string sourceRef, int iteration, int historyItemCount)
        {
            if (SourceMap.ContainsKey(sourceRef))
            {
                IList <IList <ModelObject> > iterations = SourceMap[sourceRef];
                for (int i = iteration + 1; i < iterations.Count; i++)
                {
                    IList <ModelObject> uniques = iterations[i];
                    for (int j = historyItemCount; j < uniques.Count; j++)
                    {
                        ModelObject unique = uniques[j];
                        if (unique != null && !unique.IsDeleted && unique is DataOwner)
                        {
                            DataOwner dO = (DataOwner)unique;
                            dO.ClearData(componentType);
                        }
                    }
                }
            }
        }
示例#4
0
 /// <summary
 /// Duplication constructor
 /// </summary>
 /// <param name="other"></param>
 protected DataOwner(DataOwner other) : base(other)
 {
 }