Beispiel #1
0
        public HashSet <ItemType> GetValidItemTypes(string typeCode, List <string> invalidTypes = null)
        {
            HashSet <ItemType> validTypes = new HashSet <ItemType>();

            if (ItemTypes.ContainsKey(typeCode))
            {
                if (IsValidType(typeCode, invalidTypes))
                {
                    validTypes.Add(ItemTypes[typeCode]);
                    if (ItemTypes[typeCode].Children == null)
                    {
                        return(validTypes);
                    }
                    foreach (var child in ItemTypes[typeCode].Children)
                    {
                        var childTypes = GetValidItemTypes(child.Code, invalidTypes);
                        if (childTypes != null && childTypes.Count > 0)
                        {
                            validTypes.UnionWith(childTypes);
                        }
                    }
                }
            }
            return(validTypes);
        }
Beispiel #2
0
 public string GetTypeFromMap(string type)
 {
     if (TypeMap == null)
     {
         InitTypeMap();
     }
     if (TypeMap.ContainsKey(type))
     {
         return(TypeMap[type]);
     }
     else
     {
         if (ItemTypes.ContainsKey(type))
         {
             return(ItemTypes[type].Type);
         }
     }
     return("");
 }
Beispiel #3
0
 private void BuildItemTypeTree()
 {
     foreach (ItemType item in ItemTypes.Values)
     {
         if (string.IsNullOrEmpty(item.Code))
         {
             continue;
         }
         item.Parents = new List <ItemType>();
         if (!string.IsNullOrEmpty(item.Parent1))
         {
             if (ItemTypes.ContainsKey(item.Parent1))
             {
                 var parent = ItemTypes[item.Parent1];
                 item.Parents.Add(parent);
                 if (parent.Children == null)
                 {
                     parent.Children = new List <ItemType>();
                 }
                 parent.Children.Add(item);
             }
         }
         if (!string.IsNullOrEmpty(item.Parent2))
         {
             if (ItemTypes.ContainsKey(item.Parent2))
             {
                 var parent = ItemTypes[item.Parent2];
                 item.Parents.Add(parent);
                 if (parent.Children == null)
                 {
                     parent.Children = new List <ItemType>();
                 }
                 parent.Children.Add(item);
             }
         }
     }
 }