Beispiel #1
0
        private static void GetNestedSettings(object Item, Type NewObject, OBJS.Data Data)
        {
            List <PropertyInfo> NestedProps = GetProprites(OBJS.Types.NestedSettings, NewObject);

            foreach (PropertyInfo NestedProp in NestedProps)
            {
                OBJS.Data NestedDettingsData;
                OBJS.XMLDatabaseRetriveItem XMLDatabaseRetriveItem = (OBJS.XMLDatabaseRetriveItem)NestedProp.GetCustomAttributes(typeof(OBJS.XMLDatabaseRetriveItem), true).FirstOrDefault();
                if (XMLDatabaseRetriveItem.DataSet != string.Empty)
                {
                    NestedDettingsData = Data.GetSettingsNestedData(XMLDatabaseRetriveItem.DataSet);
                }
                else
                {
                    NestedDettingsData = Data.GetSettingsNestedData(NestedProp.Name);
                }

                Type ClassType = NestedProp.PropertyType;
                if (XMLDatabaseRetriveItem.NestedClassType != null)
                {
                    ClassType = XMLDatabaseRetriveItem.NestedClassType;
                }

                object NestedSettingsObject = GetItem(NestedDettingsData, ClassType, null);
                NestedProp.SetValue(Item, NestedSettingsObject, null);
            }
        }
Beispiel #2
0
        private static void GetNestedItems(object Item, Type NewObject, OBJS.Data Data)
        {
            List <PropertyInfo> NestedProps = GetProprites(OBJS.Types.NestedList, NewObject);

            foreach (PropertyInfo NestedProp in NestedProps)
            {
                OBJS.XMLDatabaseRetriveItem XMLDatabaseRetriveItem = (OBJS.XMLDatabaseRetriveItem)NestedProp.GetCustomAttributes(typeof(OBJS.XMLDatabaseRetriveItem), true).FirstOrDefault();

                string DataSetName = (XMLDatabaseRetriveItem.DataSet == string.Empty) ? NestedProp.Name : XMLDatabaseRetriveItem.DataSet;

                List <OBJS.Data> NestedDettingsData = Data.GetNestedData(DataSetName);

                try
                {
                    foreach (OBJS.Data DataValues in NestedDettingsData)
                    {
                        Type ListType = NestedProp.PropertyType.GetGenericArguments()[0];
                        if (XMLDatabaseRetriveItem.NestedListClassType != null)
                        {
                            ListType = XMLDatabaseRetriveItem.NestedListClassType;
                        }

                        System.Collections.IList IList = (System.Collections.IList)NestedProp.GetValue(Item, null);
                        if (IList == null)
                        {
                            Type   genericListType = typeof(List <>);
                            Type[] typeArgs        = new[] { ListType };
                            var    generic         = genericListType.MakeGenericType(typeArgs);
                            IList = (System.Collections.IList)Activator.CreateInstance(generic);
                            NestedProp.SetValue(Item, IList, null);
                        }
                        object ItemObject = GetItem(DataValues, ListType, null);
                        IList.Add(ItemObject);
                    }
                }
                catch (Exception e)
                {
                    e.ToString();
                }
            }
        }