コード例 #1
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);
            }
        }
コード例 #2
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);
            });
        }
コード例 #3
0
        private List <OBJS.Data> HandleLoadData(OBJS.Data DataSet, XmlNode Document, string ParentNode = "//DataStore/", string Location = "//DataStore")
        {
            List <OBJS.Data> Data = new List <OBJS.Data>();

            int id = 1;

            string SearchClause = "";

            if (DataSet.SearchClause != string.Empty)
            {
                SearchClause = "[" + DataSet.SearchClause + "]";
            }

            XmlNodeList nodes = Document.SelectNodes(ParentNode + DataSet.DataSet + "/" + DataSet.DefaultItemName + SearchClause);

            foreach (XmlNode node in nodes)
            {
                OBJS.Data FoundData = new OBJS.Data();

                FoundData.DataSet  = DataSet.DataSet;
                FoundData.ID       = id;
                FoundData.Location = Location + "/" + DataSet.DataSet + "/" + DataSet.DefaultItemName + "[" + id + "]";

                foreach (OBJS.Data.DataValue DataValue in DataSet.GetDataValues())
                {
                    string      value     = string.Empty;
                    XmlNodeList DataNodes = node.SelectNodes(DataValue.Name);

                    foreach (XmlNode DataNode in DataNodes)
                    {
                        OBJS.Data.DataValue DataValues = new OBJS.Data.DataValue();

                        if (DataNode != null)
                        {
                            value = DataNode.InnerText;
                            foreach (XmlAttribute XmlAttribute in DataNode.Attributes)
                            {
                                OBJS.Data.DataValue Attribute = new OBJS.Data.DataValue();

                                Attribute.Name     = XmlAttribute.Name;
                                Attribute.Value    = XmlAttribute.Value;
                                Attribute.Location = Location + "/" + DataSet.DataSet + "/" + DataSet.DefaultItemName + "[" + id + "]/" + DataValue.Name;

                                DataValues.Attributes.Add(Attribute);
                            }
                        }

                        DataValues.Value    = value;
                        DataValues.Name     = DataValue.Name;
                        DataValues.Location = Location + "/" + DataSet.DataSet + "/" + DataSet.DefaultItemName + "[" + id + "]/" + DataValue.Name;

                        FoundData.GetDataValues().Add(DataValues);
                    }
                }

                foreach (OBJS.Data DataValue in DataSet.GetNestedData())
                {
                    if (DataValue.IsSettingsItem)
                    {
                        OBJS.Data NestedData = HandleLoadSettings(DataValue, node, FoundData.Location + "/", FoundData.Location);
                        FoundData.AddData(NestedData);
                    }
                    else
                    {
                        List <OBJS.Data> NestedData = HandleLoadData(DataValue, node, FoundData.Location + "/", FoundData.Location);
                        FoundData.AddData(NestedData);
                    }
                }

                Data.Add(FoundData);
                id++;
            }

            return(Data);
        }