コード例 #1
0
        /// <summary>
        /// Builds the child items in this path.
        /// </summary>
        /// <param name="caller">The owner used to create the objects.</param>
        public ArrayList BuildChildItems(object caller)
        {
            var       codons = this.Codons;
            ArrayList items  = new ArrayList(codons.Count);

            foreach (Codon codon in codons)
            {
                ArrayList subItems = null;
                if (childNodes.ContainsKey(codon.Id))
                {
                    subItems = childNodes[codon.Id].BuildChildItems(caller);
                }
                object result = codon.BuildItem(caller, subItems);
                if (result == null)
                {
                    continue;
                }
                IBuildItemsModifier mod = result as IBuildItemsModifier;
                if (mod != null)
                {
                    mod.Apply(items);
                }
                else
                {
                    items.Add(result);
                }
            }
            return(items);
        }
コード例 #2
0
//
//		public void BinarySerialize(BinaryWriter writer)
//		{
//			if (!isSorted) {
//				(new SortCodons(this)).Execute();
//				isSorted = true;
//			}
//			writer.Write((ushort)codons.Count);
//			foreach (Codon codon in codons) {
//				codon.BinarySerialize(writer);
//			}
//
//			writer.Write((ushort)childNodes.Count);
//			foreach (KeyValuePair<string, AddInTreeNode> child in childNodes) {
//				writer.Write(AddInTree.GetNameOffset(child.Key));
//				child.Value.BinarySerialize(writer);
//			}
//		}

        /// <summary>
        /// Builds the child items in this path. Ensures that all items have the type T.
        /// </summary>
        /// <param name="caller">The owner used to create the objects.</param>
        public List <T> BuildChildItems <T>(object caller)
        {
            var      codons = this.Codons;
            List <T> items  = new List <T>(codons.Count);

            foreach (Codon codon in codons)
            {
                ArrayList subItems = null;
                if (childNodes.ContainsKey(codon.Id))
                {
                    subItems = childNodes[codon.Id].BuildChildItems(caller);
                }
                object result = codon.BuildItem(caller, subItems);
                if (result == null)
                {
                    continue;
                }
                IBuildItemsModifier mod = result as IBuildItemsModifier;
                if (mod != null)
                {
                    mod.Apply(items);
                }
                else if (result is T)
                {
                    items.Add((T)result);
                }
                else
                {
                    throw new InvalidCastException("The AddInTreeNode <" + codon.Name + " id='" + codon.Id
                                                   + "'> returned an instance of " + result.GetType().FullName
                                                   + " but the type " + typeof(T).FullName + " is expected.");
                }
            }
            return(items);
        }
コード例 #3
0
        /// <summary>
        /// Builds the child items in this path.
        /// </summary>
        /// <param name="caller">The owner used to create the objects.</param>
        public ArrayList BuildChildItems(object caller)
        {
            ArrayList items = new ArrayList(codons.Count);

            if (!isSorted)
            {
                codons   = (new TopologicalSort(codons)).Execute();
                isSorted = true;
            }
            foreach (Codon codon in codons)
            {
                ArrayList subItems = null;
                if (childNodes.ContainsKey(codon.Id))
                {
                    subItems = childNodes[codon.Id].BuildChildItems(caller);
                }
                object result = codon.BuildItem(caller, subItems);
                if (result == null)
                {
                    continue;
                }
                IBuildItemsModifier mod = result as IBuildItemsModifier;
                if (mod != null)
                {
                    mod.Apply(items);
                }
                else
                {
                    items.Add(result);
                }
            }
            return(items);
        }
コード例 #4
0
        /// <summary>
        /// Builds the child items in this path. Ensures that all items have the type T.
        /// </summary>
        /// <param name="parameter">A parameter that gets passed into the doozer and condition evaluators.</param>
        /// <param name="additionalConditions">Additional conditions applied to the node.</param>
        public List <T> BuildChildItems <T>(object parameter, IEnumerable <ICondition> additionalConditions = null)
        {
            var      codons = this.Codons;
            List <T> items  = new List <T>(codons.Count);

            foreach (Codon codon in codons)
            {
                object result = BuildChildItem(codon, parameter, additionalConditions);
                if (result == null)
                {
                    continue;
                }
                IBuildItemsModifier mod = result as IBuildItemsModifier;
                if (mod != null)
                {
                    mod.Apply(items);
                }
                else if (result is T)
                {
                    items.Add((T)result);
                }
                else
                {
                    throw new InvalidCastException("The AddInTreeNode <" + codon.Name + " id='" + codon.Id
                                                   + "'> returned an instance of " + result.GetType().FullName
                                                   + " but the type " + typeof(T).FullName + " is expected.");
                }
            }
            return(items);
        }
コード例 #5
0
ファイル: AddInTreeNode.cs プロジェクト: wwcc19870805/DIFGIS
 public System.Collections.ArrayList BuildChildItems(object caller)
 {
     System.Collections.ArrayList arrayList = new System.Collections.ArrayList(this.codons.Count);
     if (!this.isSorted)
     {
         this.codons   = new AddInTreeNode.TopologicalSort(this.codons).Execute();
         this.isSorted = true;
     }
     foreach (Codon current in this.codons)
     {
         System.Collections.ArrayList subItems = null;
         if (this.childNodes.ContainsKey(current.Id))
         {
             subItems = this.childNodes[current.Id].BuildChildItems(caller);
         }
         object obj = current.BuildItem(caller, subItems);
         if (obj != null)
         {
             IBuildItemsModifier buildItemsModifier = obj as IBuildItemsModifier;
             if (buildItemsModifier != null)
             {
                 buildItemsModifier.Apply(arrayList);
             }
             else
             {
                 arrayList.Add(obj);
             }
         }
     }
     return(arrayList);
 }
コード例 #6
0
ファイル: AddInTreeNode.cs プロジェクト: wwcc19870805/DIFGIS
 public System.Collections.Generic.List <T> BuildChildItems <T>(object caller)
 {
     System.Collections.Generic.List <T> list = new System.Collections.Generic.List <T>(this.codons.Count);
     if (!this.isSorted)
     {
         this.codons   = new AddInTreeNode.TopologicalSort(this.codons).Execute();
         this.isSorted = true;
     }
     foreach (Codon current in this.codons)
     {
         System.Collections.ArrayList subItems = null;
         if (this.childNodes.ContainsKey(current.Id))
         {
             subItems = this.childNodes[current.Id].BuildChildItems(caller);
         }
         object obj = current.BuildItem(caller, subItems);
         if (obj != null)
         {
             IBuildItemsModifier buildItemsModifier = obj as IBuildItemsModifier;
             if (buildItemsModifier != null)
             {
                 buildItemsModifier.Apply(list);
             }
             else
             {
                 if (!(obj is T))
                 {
                     throw new System.InvalidCastException(string.Concat(new string[]
                     {
                         "The AddInTreeNode <",
                         current.Name,
                         " id='",
                         current.Id,
                         "' returned an instance of ",
                         obj.GetType().FullName,
                         " but the type ",
                         typeof(T).FullName,
                         " is expected."
                     }));
                 }
                 list.Add((T)obj);
             }
         }
     }
     return(list);
 }
コード例 #7
0
        /// <summary>
        /// Builds the child items in this path. Ensures that all items have the type T.
        /// </summary>
        /// <param name="caller">The owner used to create the objects.</param>
        public List <T> BuildChildItems <T>(object caller)
        {
            List <T> items = new List <T>(extensions.Count);

            if (!isSorted)
            {
                extensions = (new TopologicalSort(extensions)).Execute();
                isSorted   = true;
            }
            foreach (Extension extension in extensions)
            {
                ArrayList subItems = null;
                if (childNodes.ContainsKey(extension.Id))
                {
                    subItems = childNodes[extension.Id].BuildChildItems(caller);
                }
                object result = extension.BuildItem(caller, subItems);
                if (result == null)
                {
                    continue;
                }
                IBuildItemsModifier mod = result as IBuildItemsModifier;
                if (mod != null)
                {
                    mod.Apply(items);
                }
                else if (result is T)
                {
                    items.Add((T)result);
                }
                else
                {
                    throw new InvalidCastException("The PluginTreeNode <" + extension.Type + " id='" + extension.Id
                                                   + "' returned an instance of " + result.GetType().FullName
                                                   + " but the type " + typeof(T).FullName + " is expected.");
                }
            }
            return(items);
        }