Пример #1
0
        private static void FillNestedData(OBJS.Data DataSet, Type BaseType, object Item, string DefaultItemName)
        {
            List <PropertyInfo> NestedSettings = GetProprites(OBJS.Types.NestedList, BaseType);

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

                string DataSetName = (XMLDatabaseRetriveItem.DataSet == string.Empty) ? Prop.Name : XMLDatabaseRetriveItem.DataSet;
                DefaultItemName = (XMLDatabaseRetriveItem.ItemName != string.Empty) ? XMLDatabaseRetriveItem.ItemName : DefaultItemName;

                Type ListType = Prop.PropertyType.GetGenericArguments()[0];
                if (XMLDatabaseRetriveItem.NestedListClassType != null)
                {
                    ListType = XMLDatabaseRetriveItem.NestedListClassType;
                }

                System.Collections.IList IList = (System.Collections.IList)Prop.GetValue(Item, null);
                if (IList != null)
                {
                    foreach (Object ListItem in IList)
                    {
                        OBJS.Data NestedDataSet = BuildData(ListType, ListItem, DataSetName, DefaultItemName);
                        DataSet.SetRetriveValue(NestedDataSet);
                    }
                }
            }
        }
Пример #2
0
        private static void FillAttributeFillData(OBJS.Data DataSet, Type BaseType, object Item, string DefaultItemName)
        {
            List <PropertyInfo> NestedProps = GetProprites(OBJS.Types.AttributeFill, BaseType);

            if (NestedProps.Count == 0)
            {
                return;
            }

            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;
                DefaultItemName = (XMLDatabaseRetriveItem.ItemName != string.Empty) ? XMLDatabaseRetriveItem.ItemName : DefaultItemName;

                Type ListType = NestedProp.PropertyType.GetGenericArguments()[0];

                System.Collections.IList IList = (System.Collections.IList)NestedProp.GetValue(Item, null);
                if (IList != null)
                {
                    foreach (Object ListItem in IList)
                    {
                        FillData(DataSet, ListType, ListItem);
                    }
                }
            }
        }
Пример #3
0
        private static void FillNestedSettings(OBJS.Data DataSet, Type BaseType, object Item, string DefaultItemName)
        {
            List <PropertyInfo> NestedSettings = GetProprites(OBJS.Types.NestedSettings, BaseType);

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

                string DataSetName = (XMLDatabaseRetriveItem.DataSet == string.Empty) ? Prop.Name : XMLDatabaseRetriveItem.DataSet;
                DefaultItemName = (XMLDatabaseRetriveItem.ItemName != string.Empty) ? XMLDatabaseRetriveItem.ItemName : DefaultItemName;

                Type PropType = Prop.PropertyType;
                if (XMLDatabaseRetriveItem.NestedClassType != null)
                {
                    PropType = XMLDatabaseRetriveItem.NestedClassType;
                }
                object NestedObject = Prop.GetValue(Item, null);

                if (NestedObject == null)
                {
                    continue;
                }

                OBJS.Data NestedDataSet = BuildData(PropType, NestedObject, DataSetName, DefaultItemName);
                NestedDataSet.IsSettingsItem = true;
                DataSet.AddData(NestedDataSet);
            }
        }
Пример #4
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);
            }
        }
Пример #5
0
        private static void FillNestedMultiNode(OBJS.Data DataSet, Type BaseType, object Item, string DefaultItemName)
        {
            List <PropertyInfo> NestedProps = GetProprites(OBJS.Types.NestedMulitNode, BaseType);

            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;
                DefaultItemName = (XMLDatabaseRetriveItem.ItemName != string.Empty) ? XMLDatabaseRetriveItem.ItemName : DefaultItemName;

                Type ListType = NestedProp.PropertyType.GetGenericArguments()[0];

                System.Collections.IList IList = (System.Collections.IList)NestedProp.GetValue(Item, null);
                if (IList != null)
                {
                    OBJS.Data Data = new OBJS.Data();
                    Data.DataSet        = DataSetName;
                    Data.IsSettingsItem = true;

                    foreach (Object ListItem in IList)
                    {
                        FillData(Data, ListType, ListItem);
                    }
                    DataSet.SetRetriveValue(Data);
                }
            }
        }
Пример #6
0
        private static void GetAttributeFillItems(object Item, Type NewObject, OBJS.Data Data)
        {
            List <PropertyInfo> NestedProps = GetProprites(OBJS.Types.AttributeFill, NewObject);

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

                List <OBJS.Data.DataValue> DataItem = Data.GetAllNodes(XMLDatabaseRetriveItem.NodeName);

                if (DataItem.Count == 0)
                {
                    continue;
                }

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

                List <OBJS.Data.DataValue> NestedDettingsData = Data.GetAllNodes(XMLDatabaseRetriveItem.NodeName);

                Type ListType = NestedProp.PropertyType.GetGenericArguments()[0];

                System.Collections.IList IList = (System.Collections.IList)NestedProp.GetValue(Item, null);
                foreach (OBJS.Data.DataValue Node in NestedDettingsData)
                {
                    IList.Add(GetItemObject(ListType, new List <OBJS.Data.DataValue>()
                    {
                        Node
                    }));
                }
            }
        }
Пример #7
0
        public static object GetItemObject(Type ListType, List <OBJS.Data.DataValue> DataValues, object[] args = null)
        {
            object SubItem = Activator.CreateInstance(ListType, args);

            try
            {
                List <PropertyInfo> ListProp = GetProprites(OBJS.Types.Prop, ListType);

                foreach (PropertyInfo PropInfo in ListProp)
                {
                    OBJS.Data.DataValue Item = DataValues.FirstOrDefault(A => A.Name == PropInfo.Name);
                    if (Item == null)
                    {
                        continue;
                    }

                    OBJS.XMLDatabaseRetriveItem XMLDatabaseRetriveItem = (OBJS.XMLDatabaseRetriveItem)PropInfo.GetCustomAttributes(typeof(OBJS.XMLDatabaseRetriveItem), true).FirstOrDefault();

                    string DataValue = Item.Value;

                    object Value = GetValue(PropInfo.PropertyType, DataValue);
                    PropInfo.SetValue(SubItem, Value, null);
                    XMLDatabaseRetriveItem.Location = Item.Location;
                }

                List <PropertyInfo> AttributePop = GetProprites(OBJS.Types.Attribute, ListType);

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

                    OBJS.Data.DataValue Item = DataValues.FirstOrDefault(A => A.Name == XMLDatabaseRetriveItem.NodeName);
                    if (Item == null)
                    {
                        continue;
                    }

                    OBJS.Data.DataValue DataValueItem = Item.Attributes.FirstOrDefault(B => B.Name == XMLDatabaseRetriveItem.AttributeName);

                    if (DataValueItem == null)
                    {
                        continue;
                    }

                    string DataValue = DataValueItem.Value;

                    object Value = GetValue(PropInfo.PropertyType, DataValue);
                    PropInfo.SetValue(SubItem, Value, null);
                    XMLDatabaseRetriveItem.Location = Item.Location;
                }
            }
            catch (Exception e)
            {
                e.ToString();
            }

            return(SubItem);
        }
Пример #8
0
        private static void FillData(OBJS.Data DataSet, Type BaseType, object Item)
        {
            List <PropertyInfo> Props = GetProprites(OBJS.Types.Prop, BaseType);

            List <OBJS.Data.DataValue> DataValues = new List <OBJS.Data.DataValue>();

            foreach (PropertyInfo Prop in Props)
            {
                object ItemObject = Prop.GetValue(Item, null);
                string ItemValue  = (ItemObject != null) ? ItemObject.ToString() : "";

                OBJS.Data.DataValue DataValue = new OBJS.Data.DataValue();
                DataValue.Name  = Prop.Name;
                DataValue.Value = ItemValue;

                DataValues.Add(DataValue);
            }


            List <PropertyInfo> AttributePop = GetProprites(OBJS.Types.Attribute, BaseType);

            foreach (PropertyInfo PropInfo in AttributePop)
            {
                OBJS.XMLDatabaseRetriveItem XMLDatabaseRetriveItem = (OBJS.XMLDatabaseRetriveItem)PropInfo.GetCustomAttributes(typeof(OBJS.XMLDatabaseRetriveItem), true).FirstOrDefault();
                object ItemObject = PropInfo.GetValue(Item, null);
                string ItemValue  = (ItemObject != null) ? ItemObject.ToString() : "";

                OBJS.Data.DataValue DataValue = DataValues.Find(A => A.Name == XMLDatabaseRetriveItem.NodeName);

                if (DataValue != null)
                {
                    DataValue.Attributes.Add(new OBJS.Data.DataValue()
                    {
                        Name  = XMLDatabaseRetriveItem.AttributeName,
                        Value = ItemValue
                    });
                }
                else
                {
                    DataValue      = new OBJS.Data.DataValue();
                    DataValue.Name = XMLDatabaseRetriveItem.NodeName;

                    DataValue.Attributes.Add(new OBJS.Data.DataValue()
                    {
                        Name  = XMLDatabaseRetriveItem.AttributeName,
                        Value = ItemValue
                    });
                    DataValues.Add(DataValue);
                }
            }

            DataValues.ForEach(T =>
            {
                DataSet.AddData(T);
            });
        }
Пример #9
0
        private static void GetAttributeFillDataSet(Type BaseType, OBJS.Data DataSet)
        {
            List <PropertyInfo> AttributeFillNodes = GetProprites(OBJS.Types.AttributeFill, BaseType);

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

                DataSet.SetRetriveValue(XMLDatabaseRetriveItem.NodeName);
            }
        }
Пример #10
0
        private static void GetNestedMulitNodeDataSet(string DefaultItemName, Type BaseType, OBJS.Data DataSet)
        {
            List <PropertyInfo> NestedMulitNode = GetProprites(OBJS.Types.NestedMulitNode, BaseType);

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

                string DataSetName = (XMLDatabaseRetriveItem.DataSet == string.Empty) ? Prop.Name : XMLDatabaseRetriveItem.DataSet;
                DefaultItemName = (XMLDatabaseRetriveItem.ItemName != string.Empty) ? XMLDatabaseRetriveItem.ItemName : DefaultItemName;

                Type      ListType      = Prop.PropertyType.GetGenericArguments()[0];
                OBJS.Data NestedDataSet = GetDataSet(DataSetName, DefaultItemName, ListType);
                NestedDataSet.IsSettingsItem = true;
                DataSet.SetRetriveValue(NestedDataSet);
            }
        }
Пример #11
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();
                }
            }
        }
Пример #12
0
        private static void AddAttributes(Type BaseType, OBJS.Data DataSet)
        {
            List <PropertyInfo> Props = GetProprites(OBJS.Types.Attribute, BaseType);

            List <string> Values = new List <string>();

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

                if (Values.Contains(XMLDatabaseRetriveItem.NodeName) == false)
                {
                    Values.Add(XMLDatabaseRetriveItem.NodeName);
                }
            }

            foreach (string Value in Values)
            {
                DataSet.SetRetriveValue(Value);
            }
        }
Пример #13
0
        private static void GetNestedSettingsDataSet(string DefaultItemName, Type BaseType, OBJS.Data DataSet)
        {
            List <PropertyInfo> NestedSettings = GetProprites(OBJS.Types.NestedSettings, BaseType);

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

                string DataSetName = Prop.Name;

                if (XMLDatabaseRetriveItem.DataSet != string.Empty)
                {
                    DataSetName = XMLDatabaseRetriveItem.DataSet;
                }

                Type PropType = Prop.PropertyType;

                OBJS.Data NestedDataSet = GetDataSet(DataSetName, DefaultItemName, PropType);
                NestedDataSet.IsSettingsItem = true;
                DataSet.SetRetriveValue(NestedDataSet);
            }
        }