示例#1
0
 /// <summary>
 /// добавить типы по шаблону
 /// </summary>
 /// <param name="dataObjectTypeTmplate"></param>
 /// <param name="usageTypes"></param>
 public void AddUseTypesAs(Type dataObjectTypeTmplate, params Type[] usageTypes)
 {
     lock (m_objNull)
     {
         ICSSoft.STORMNET.Collections.TypesArrayList types;
         if (usetypeascollection.Contains(dataObjectTypeTmplate))
         {
             types = (ICSSoft.STORMNET.Collections.TypesArrayList)usetypeascollection[dataObjectTypeTmplate];
             types.Clear();
         }
         else if (usageTypes == null)
         {
             types = new ICSSoft.STORMNET.Collections.TypesArrayList();
             types.Add(dataObjectTypeTmplate);
             usetypeascollection.Add(dataObjectTypeTmplate, types);
             return;
         }
         else
         {
             types = new ICSSoft.STORMNET.Collections.TypesArrayList();
             typeusagecollection.Add(dataObjectTypeTmplate, types);
         }
         foreach (Type t in usageTypes)
         {
             if (!types.Contains(t))
             {
                 types.Add(t);
             }
         }
     }
 }
        /// <summary>
        /// вернуть UsageTypes для заданного типа-свойства
        /// </summary>
        /// <param name="DataObjectType"></param>
        /// <param name="propertyName"></param>
        /// <returns></returns>
        public Type[] GetUsageTypes(Type DataObjectType, string propertyName)
        {
            string key = GetTypeUsageKey(DataObjectType, propertyName);

            lock (m_objNull)
            {
                if (!typeusagecollection.ContainsKey(key))
                {
                    System.Type propType = Information.GetPropertyType(DataObjectType, propertyName);
                    if (propType.IsSubclassOf(typeof(DetailArray)))
                    {
                        System.Type[] tps = Information.GetCompatibleTypesForDetailProperty(DataObjectType, propertyName);
                        ICSSoft.STORMNET.Collections.TypesArrayList types = new ICSSoft.STORMNET.Collections.TypesArrayList();
                        foreach (Type t in tps)
                        {
                            if (!types.Contains(t))
                            {
                                types.Add(t);
                            }
                        }

                        typeusagecollection.Add(key, types);
                    }
                    else
                    {
                        System.Type[] tps = Information.GetCompatibleTypesForProperty(DataObjectType, propertyName);
                        ICSSoft.STORMNET.Collections.TypesArrayList types = new ICSSoft.STORMNET.Collections.TypesArrayList();
                        foreach (Type t in tps)
                        {
                            if (!types.Contains(t))
                            {
                                types.Add(t);
                            }
                        }

                        typeusagecollection.Add(key, types);
                    }
                }
            }

            try
            {
                return(((ICSSoft.STORMNET.Collections.TypesArrayList)typeusagecollection[key]).ToArray());
            }
            catch
            {
                return(Type.EmptyTypes);
            }
        }
示例#3
0
        /// <summary>
        /// добавить UsageTypes для заданного типа-свойства
        /// </summary>
        /// <param name="DataObjectType"></param>
        /// <param name="propertyName"></param>
        /// <param name="addtypes"></param>
        public void AddUsageTypes(Type DataObjectType, string propertyName, params Type[] addtypes)
        {
            string key = GetTypeUsageKey(DataObjectType, propertyName);

            if (!typeusagecollection.ContainsKey(key))
            {
                GetUsageTypes(DataObjectType, propertyName);
            }
            lock (m_objNull)
            {
                ICSSoft.STORMNET.Collections.TypesArrayList types = (ICSSoft.STORMNET.Collections.TypesArrayList)typeusagecollection[key];
                foreach (Type t in addtypes)
                {
                    if (!types.Contains(t))
                    {
                        types.Add(t);
                    }
                }
            }
        }