Example #1
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
                    }));
                }
            }
        }
Example #2
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);
            }
        }
Example #3
0
        public void UpdateData(OBJS.Data CurrentData, OBJS.Data NewData)
        {
            if (!DoesDataStoreFileExist())
            {
                CreateDataStore();
            }

            XmlDocument Document = GetXMLDocument();

            XmlNode Node = Document.SelectSingleNode(CurrentData.Location);

            if (Node != null)
            {
                foreach (OBJS.Data.DataValue DV in NewData.GetDataValues())
                {
                    XmlNode NodeToUpdate = Node.SelectSingleNode(DV.Name);
                    if (NodeToUpdate != null)
                    {
                        NodeToUpdate.InnerText = DV.Value;
                    }
                    else
                    {
                        XmlNode ItemValue = Document.CreateNode(XmlNodeType.Element, DV.Name, null);
                        ItemValue.InnerText = DV.Value;
                        Node.AppendChild(ItemValue);
                    }
                }
            }

            SaveXMLDocument(Document);
        }
Example #4
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);
                }
            }
        }
Example #5
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);
                    }
                }
            }
        }
Example #6
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);
                    }
                }
            }
        }
Example #7
0
        private void AppendSettingsNode(OBJS.Data Data, XmlNode ParentRoot, XmlDocument Document)
        {
            foreach (OBJS.Data.DataValue DataValue in Data.GetDataValues())
            {
                XmlElement ItemValue = Document.CreateElement(DataValue.Name);
                if (DataValue.Value == string.Empty || DataValue.Value == null)
                {
                    ItemValue.IsEmpty = true;
                }
                else
                {
                    ItemValue.InnerText = DataValue.Value;
                }

                if (DataValue.Attributes.Count != 0)
                {
                    foreach (OBJS.Data.DataValue Attributes in DataValue.Attributes)
                    {
                        XmlAttribute typeAttr = Document.CreateAttribute(Attributes.Name);
                        typeAttr.InnerText = Attributes.Value;
                        ItemValue.Attributes.Append(typeAttr);
                    }
                }
                ParentRoot.AppendChild(ItemValue);
            }

            foreach (OBJS.Data NestedData in Data.GetNestedData())
            {
                HandleSetData(NestedData, ParentRoot, Document, "");
            }
        }
Example #8
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);
            }
        }
Example #9
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);
            });
        }
Example #10
0
        public static List <T> GetItems <T>(string DataSet, string DefaultItemName, XMLDataBase.DataBase DataBase, object[] args)
        {
            List <T> Items = new List <T>();

            OBJS.Data DataSetObject = GetDataSet(DataSet, DefaultItemName, typeof(T));

            Items = BuildObjects <T>(DataSetObject, DataBase, args);

            return(Items);
        }
Example #11
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);
            }
        }
Example #12
0
        public OBJS.Data LoadSetting(OBJS.Data DataSet)
        {
            if (!DoesDataStoreFileExist())
            {
                CreateDataStore();
                return(new OBJS.Data());
            }

            XmlDocument Document = GetXMLDocument();

            return(HandleLoadSettings(DataSet, Document));
        }
Example #13
0
        private static object GetItem(OBJS.Data Data, Type NewObject, object[] args)
        {
            object Item = GetItemObject(NewObject, Data.GetDataValues(), args);

            GetXmlDataDetails(Item, NewObject, Data);

            GetNestedSettings(Item, NewObject, Data);
            GetNestedItems(Item, NewObject, Data);
            GetNestedMulitNodeItems(Item, NewObject, Data);
            GetAttributeFillItems(Item, NewObject, Data);

            return(Item);
        }
Example #14
0
        private static OBJS.Data BuildData(Type BaseType, object Item, string DataSetString, string DefaultItemName)
        {
            OBJS.Data DataSet = new OBJS.Data();
            DataSet.DataSet         = DataSetString;
            DataSet.DefaultItemName = DefaultItemName;

            FillData(DataSet, BaseType, Item);

            FillNestedSettings(DataSet, BaseType, Item, DefaultItemName);
            FillNestedData(DataSet, BaseType, Item, DefaultItemName);
            FillNestedMultiNode(DataSet, BaseType, Item, DefaultItemName);
            FillAttributeFillData(DataSet, BaseType, Item, DefaultItemName);

            return(DataSet);
        }
Example #15
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);
            }
        }
Example #16
0
        private void HandleSetData(OBJS.Data Data, XmlNode ParentRoot, XmlDocument Document, string ParentNode = "//DataStore")
        {
            XmlNode NewNode = ParentRoot.SelectSingleNode(ParentNode + "/" + Data.DataSet);

            if (!DoesDataStoreHaveDataSet(ParentNode, Data.DataSet, ParentRoot))
            {
                NewNode = CreateDataSet(ParentNode, Data.DataSet, ParentRoot, Document);
            }

            if (Data.IsSettingsItem)
            {
                AppendSettingsNode(Data, NewNode, Document);
            }
            else
            {
                AppendNode(Data, NewNode, Document);
            }
        }
Example #17
0
        public void DeleteData(OBJS.Data Data)
        {
            if (!DoesDataStoreFileExist())
            {
                CreateDataStore();
                return;
            }

            XmlDocument Document = GetXMLDocument();

            XmlNode Node = Document.SelectSingleNode(Data.Location);

            if (Node != null)
            {
                DeleteNode(Node);
            }
            SaveXMLDocument(Document);
        }
Example #18
0
        public void DeleteDataFromID(OBJS.Data Data)
        {
            if (!DoesDataStoreFileExist())
            {
                CreateDataStore();
                return;
            }

            XmlDocument Document = GetXMLDocument();

            XmlNode Node = Document.SelectSingleNode("//DataStore/" + Data.DataSet + "/" + Data.DefaultItemName + "[" + Data.ID + "]");

            if (Node != null)
            {
                DeleteNode(Node);
            }
            SaveXMLDocument(Document);
        }
Example #19
0
        public void SetData(OBJS.Data Data, XmlDocument Document = null, bool AutoSave = true)
        {
            if (!DoesDataStoreFileExist())
            {
                CreateDataStore();
            }

            if (Document == null)
            {
                Document = GetXMLDocument();
            }

            HandleSetData(Data, Document.SelectSingleNode("//DataStore"), Document);
            if (AutoSave)
            {
                SaveXMLDocument(Document);
            }
        }
Example #20
0
        private static void GetXmlDataDetails(object Item, Type NewObject, OBJS.Data Data)
        {
            List <PropertyInfo> NodedLocationProps = GetProprites(OBJS.Types.NodedLocation, NewObject);

            if (NodedLocationProps.Count != 0)
            {
                PropertyInfo NodedLocationProp = NodedLocationProps[0];
                NodedLocationProp.SetValue(Item, Data.Location, null);
            }

            List <PropertyInfo> NodeIDProps = GetProprites(OBJS.Types.NodeID, NewObject);

            if (NodeIDProps.Count != 0)
            {
                PropertyInfo NodeIDProp = NodeIDProps[0];
                NodeIDProp.SetValue(Item, Data.ID, null);
            }
        }
Example #21
0
        private static List <T> BuildObjects <T>(OBJS.Data DataSetObject, XMLDataBase.DataBase DataBase, object[] args)
        {
            List <T> Items = new List <T>();

            try
            {
                List <OBJS.Data> DataItems = DataBase.LoadData(DataSetObject);

                foreach (OBJS.Data Data in DataItems)
                {
                    Items.Add((T)GetItem(Data, typeof(T), args));
                }
            }
            catch (Exception e)
            {
                e.ToString();
            }

            return(Items);
        }
Example #22
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();
                }
            }
        }
Example #23
0
        public List <OBJS.Data> LoadData(OBJS.Data DataSet)
        {
            if (!DoesDataStoreFileExist())
            {
                CreateDataStore();
                return(new List <OBJS.Data>());
            }

            XmlDocument Document = GetXMLDocument(true);

            if (DataSet.Location != null)
            {
                string ParrentNode = DataSet.Location + "/";

                return(HandleLoadData(DataSet, Document, ParrentNode, DataSet.Location));
            }
            else
            {
                return(HandleLoadData(DataSet, Document));
            }
        }
Example #24
0
        private static OBJS.Data GetDataSet(string DataSetString, string DefaultItemName, Type BaseType)
        {
            OBJS.Data DataSet = new OBJS.Data();
            DataSet.DataSet         = DataSetString;
            DataSet.DefaultItemName = DefaultItemName;

            List <PropertyInfo> Props = GetProprites(OBJS.Types.Prop, BaseType);

            foreach (PropertyInfo Prop in Props)
            {
                DataSet.SetRetriveValue(Prop.Name);
            }

            AddAttributes(BaseType, DataSet);
            GetNestedSettingsDataSet(DefaultItemName, BaseType, DataSet);
            GetNestedDataSet(DefaultItemName, BaseType, DataSet);
            GetNestedMulitNodeDataSet(DefaultItemName, BaseType, DataSet);
            GetAttributeFillDataSet(BaseType, DataSet);

            return(DataSet);
        }
Example #25
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);
            }
        }
Example #26
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);
            }
        }
Example #27
0
        private bool AppendNode(OBJS.Data Data, XmlNode ParentRoot, XmlDocument Document)
        {
            XmlNode NewItem = Document.CreateNode(XmlNodeType.Element, Data.DefaultItemName, null);

            foreach (OBJS.Data.DataValue DataValue in Data.GetDataValues())
            {
                XmlElement ItemValue = Document.CreateElement(DataValue.Name);
                if (DataValue.Value == string.Empty || DataValue.Value == null)
                {
                    ItemValue.IsEmpty = true;
                }
                else
                {
                    ItemValue.InnerText = DataValue.Value;
                }

                if (DataValue.Attributes.Count != 0)
                {
                    foreach (OBJS.Data.DataValue Attributes in DataValue.Attributes)
                    {
                        XmlAttribute typeAttr = Document.CreateAttribute(Attributes.Name);
                        typeAttr.InnerText = Attributes.Value;
                        ItemValue.Attributes.Append(typeAttr);
                    }
                }
                NewItem.AppendChild(ItemValue);
            }

            foreach (OBJS.Data NestedData in Data.GetNestedData())
            {
                HandleSetData(NestedData, NewItem, Document, "");
            }

            ParentRoot.AppendChild(NewItem);

            return(true);
        }
Example #28
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);
        }