コード例 #1
0
        /// <summary>
        /// 获取通道服务成员配置信息。
        /// </summary>
        /// <param name="xmlDoc"></param>
        /// <returns></returns>
        public System.Xml.XmlNode GetConfig(System.Xml.XmlDocument xmlDoc)
        {
            System.Xml.XmlNode xnConfig = xmlDoc.CreateElement(this.GetType().Name);

            System.Xml.XmlNode xnAddresses = xmlDoc.CreateElement("Addresses");
            xnConfig.AppendChild(xnAddresses);

            foreach (IPAddress address in this.Addresses)
            {
                System.Xml.XmlNode xnAddress = xmlDoc.CreateElement("Address");
                xnAddress.InnerText = address.ToString();
                xnAddresses.AppendChild(xnAddress);
            }

            System.Xml.XmlNode xnPort = xmlDoc.CreateElement("Port");
            xnPort.InnerText = this.Port.ToString();
            xnConfig.AppendChild(xnPort);

            System.Xml.XmlNode xnPassword = xmlDoc.CreateElement("Password");
            xnPassword.InnerText = this.Password;
            xnConfig.AppendChild(xnPassword);

            System.Xml.XmlNode xnMaxConnection = xmlDoc.CreateElement("MaxConnection");
            xnMaxConnection.InnerText = this.MaxConnection.ToString();
            xnConfig.AppendChild(xnMaxConnection);

            System.Xml.XmlNode xnDelay = xmlDoc.CreateElement("Delay");
            xnDelay.InnerText = this.Delay.ToString();
            xnConfig.AppendChild(xnDelay);

            return(xnConfig);
        }
コード例 #2
0
        /// <summary>
        /// 获取当前配置信息,将序列化的内容填充至 XmlNode 的 InnerText 属性或者 ChildNodes 子节点中。
        /// </summary>
        /// <param name="xmlDoc">创建 XmlNode 时所需使用到的 System.Xml.XmlDocument。</param>
        public System.Xml.XmlNode GetConfig(System.Xml.XmlDocument xmlDoc)
        {
            System.Xml.XmlNode xnConfig = xmlDoc.CreateElement(this.GetType().Name);

            System.Xml.XmlNode xnListenPort = xmlDoc.CreateElement("ListenPort");
            xnListenPort.InnerText = this.ListenPort.ToString();
            xnConfig.AppendChild(xnListenPort);

            System.Xml.XmlNode xnBufferSize = xmlDoc.CreateElement("BufferSize");
            xnBufferSize.InnerText = this.BufferSize.ToString();
            xnConfig.AppendChild(xnBufferSize);

            if (this.ListenIp != null && this.ListenIp.Length > 0)
            {
                System.Xml.XmlNode xnListenIp = xmlDoc.CreateElement("ListenIp");
                xnListenIp.InnerText = this.ListenIp;
                xnConfig.AppendChild(xnListenIp);
            }

            System.Xml.XmlNode xnMaximumConnection = xmlDoc.CreateElement("MaximumConnection");
            xnMaximumConnection.InnerText = this.MaximumConnection.ToString();
            xnConfig.AppendChild(xnMaximumConnection);

            System.Xml.XmlNode xnListenBacklog = xmlDoc.CreateElement("ListenBacklog");
            xnListenBacklog.InnerText = this.ListenBacklog.ToString();
            xnConfig.AppendChild(xnListenBacklog);

            return(xnConfig);
        }
        private void Serialize(System.Xml.XmlNode Root, Object graph)
        {
            System.Xml.XmlElement Element = null;

            if (graph.GetType().Equals(typeof(System.String)))
            {
                Serialize((System.Xml.XmlElement)Root, graph);
            }
            else if (graph.GetType().GetInterface("IEnumerable") != null)
            {
                Element = AccuDataObjectFormatter.CreateElement(graph.GetType().Name.Replace("[]", ""));
                Serialize(Element, graph);
                Root.AppendChild(Element);
            }
            else if (graph.GetType().IsArray)
            {
                Element = AccuDataObjectFormatter.CreateElement(graph.GetType().BaseType.Name);
                Serialize(Element, graph);
                Root.AppendChild(Element);
            }
            else if (graph.GetType().IsClass)
            {
                Element = AccuDataObjectFormatter.CreateElement(graph.GetType().Name);
                Serialize(Element, graph);
                Root.AppendChild(Element);
            }
            else if (graph.GetType().IsPrimitive)
            {
                Serialize((System.Xml.XmlElement)Root, graph);
            }
            else if (graph.GetType().IsValueType)
            {
                Serialize((System.Xml.XmlElement)Root, graph);
            }
        }
コード例 #4
0
ファイル: Structure.cs プロジェクト: solutema/ultralight
        public System.Xml.XmlNode ToXml(System.Xml.XmlNode node)
        {
            System.Xml.XmlDocument document;
            if (node is System.Xml.XmlDocument)
            {
                document = (System.Xml.XmlDocument)node;
            }
            else
            {
                document = node.OwnerDocument;
            }

            System.Xml.XmlNode Res = document.CreateElement("Database");
            node.AppendChild(Res);

            foreach (string Tabla in Lfx.Data.DataBaseCache.DefaultCache.GetTableNames())
            {
                Res.AppendChild(Lfx.Workspace.Master.MasterConnection.GetTableStructure(Tabla, false).ToXml(Res));
            }

            IDictionary <string, ConstraintDefinition> Keys = Lfx.Workspace.Master.MasterConnection.GetConstraints();

            foreach (ConstraintDefinition Key in Keys.Values)
            {
                Res.AppendChild(Key.ToXml(Res));
            }

            return(Res);
        }
コード例 #5
0
        /// <summary>
        /// 获取该数据库的配置,例如数据库连接信息等。该方法通常在配置数据库并完成数据库配置时调用。
        /// </summary>
        /// <returns>数据库的配置信息</returns>
        public System.Xml.XmlNode GetConfig(System.Xml.XmlDocument doc)
        {
            System.Xml.XmlNode xn = doc.CreateElement(this.GetType().Name);

            System.Xml.XmlNode xnInstanceName = doc.CreateElement("InstanceName");
            xnInstanceName.InnerText = this.InstanceName;
            xn.AppendChild(xnInstanceName);

            System.Xml.XmlNode xnLoginSecure = doc.CreateElement("LoginSecure");
            xnLoginSecure.InnerText = (this.LoginSecure ? "1" : "0");
            xn.AppendChild(xnLoginSecure);

            if (this.LoginSecure == false)
            {
                System.Xml.XmlNode xnUserName = doc.CreateElement("UserName");
                xnUserName.InnerText = this.UserName;
                xn.AppendChild(xnUserName);

                if (this.Password != null && this.Password.Length > 0)
                {
                    System.Xml.XmlNode xnPassword = doc.CreateElement("Password");
                    xnPassword.InnerText = this.Password;
                    xn.AppendChild(xnPassword);
                }
            }

            System.Xml.XmlNode xnDatabaseName = doc.CreateElement("DatabaseName");
            xnDatabaseName.InnerText = this.DatabaseName;
            xn.AppendChild(xnDatabaseName);

            return(xn);
        }
コード例 #6
0
ファイル: XmlFileMerger.cs プロジェクト: vackup/csesms
        public virtual void  parseElement(System.Xml.XmlNode oldEl, System.Xml.XmlNode newEl)
        {
            System.Xml.XmlNamedNodeMap nl = (System.Xml.XmlAttributeCollection)oldEl.Attributes;

            if (nl != null)
            {
                for (int i = 0; i < nl.Count; i++)
                {
                    if (((System.Xml.XmlAttributeCollection)newEl.Attributes).GetNamedItem(nl.Item(i).Name) == null)
                    {
                        //System.out.println(nl.item(i).getNodeName()+" attribute not present, adding the attribute");
                        //UPGRADE_TODO: Method 'org.w3c.dom.Element.setAttribute' was converted to 'System.Xml.XmlElement.SetAttribute' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_orgw3cdomElementsetAttribute_javalangString_javalangString'"
                        ((System.Xml.XmlElement)newEl).SetAttribute(nl.Item(i).Name, nl.Item(i).Value);
                    }
                }
            }
            //UPGRADE_TODO: Method 'org.w3c.dom.Node.getChildNodes' was converted to 'System.Xml.XmlNode.ChildNodes' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
            System.Xml.XmlNodeList oldNodes = oldEl.ChildNodes;
            //UPGRADE_TODO: Method 'org.w3c.dom.Node.getChildNodes' was converted to 'System.Xml.XmlNode.ChildNodes' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
            System.Xml.XmlNodeList newNodes = newEl.ChildNodes;

            int i2 = 0;
            int j  = 0;

            while (oldNodes.Item(i2) != null)
            {
                if (newNodes.Item(j) == null)
                {
                    //System.out.println(oldNodes.item(i)+" not present, adding the whole element");
                    if (!ignoreList.Contains(oldNodes.Item(i2).Name))
                    {
                        System.Xml.XmlNode n = newEl.OwnerDocument.ImportNode(oldNodes.Item(i2), true);
                        newEl.AppendChild(n);
                    }
                    i2++; j++;
                }
                else
                {
                    if ((System.Object)oldNodes.Item(i2).Name != (System.Object)newNodes.Item(j).Name)
                    {
                        if (!ignoreList.Contains(oldNodes.Item(i2).Name))
                        {
                            //System.out.println(oldNodes.item(i)+" not present, adding the whole element");
                            System.Xml.XmlNode n = newEl.OwnerDocument.ImportNode(oldNodes.Item(i2), true);
                            newEl.AppendChild(n);
                        }
                        i2++;
                    }
                    else
                    {
                        parseElement(oldNodes.Item(i2), newNodes.Item(j));
                        i2++; j++;
                    }
                }
            }
        }
コード例 #7
0
ファイル: FrmProjectInfo.cs プロジェクト: callme119/civil
 private void CreateInfoNode(ref System.Xml.XmlNode node)
 {
     System.Xml.XmlNode infoNode = doc.CreateElement("INFO");
     System.Xml.XmlNode nameNode = doc.CreateElement("NAME");
     System.Xml.XmlNode typeNode = doc.CreateElement("TYPE");
     nameNode.InnerText = TbxName.Text;
     typeNode.InnerText = CbxType.SelectedItem.ToString();
     infoNode.AppendChild(nameNode);
     infoNode.AppendChild(typeNode);
     node.AppendChild(infoNode);
 }
コード例 #8
0
        public System.Xml.XmlNode GetSettings(System.Xml.XmlDocument document)
        {
            System.Xml.XmlNode settingsNode = document.CreateElement(this.Name);

            settingsNode.AppendChild(imageBrowseAndTestNewRun.GetSettings(document));
            settingsNode.AppendChild(imageBrowseAndTestRunEndPB.GetSettings(document));
            settingsNode.AppendChild(imageBrowseAndTestRunEndNoPB.GetSettings(document));
            settingsNode.AppendChild(imageBrowseAndTestReset.GetSettings(document));

            return(settingsNode);
        }
コード例 #9
0
        private void saveM3()
        {
            // Value Map
            System.Xml.XmlNodeList nodes = getFieldNodes(this.FieldGrid.SelectedIndex + 1);
            if (nodes != null)
            {
                DataGrid grid = this.Method3Grid as DataGrid;
                if (grid == null)
                {
                    return;
                }

                try
                {
                    string method = getMethodVal();
                    nodes[0].SelectSingleNode("Method").InnerText = method;
                    //DataGridRow row0 = (DataGridRow)Method3Grid.ItemContainerGenerator.ContainerFromIndex(0);
                    //TextBox txt = ((TextBox)Method3Grid.Columns[0].GetCellContent(row0));
                    trimNodes(nodes, 3);
                    System.Xml.XmlNode noder = nodes[0].SelectSingleNode(method);
                    if (noder == null)
                    {
                        noder = _xml.CreateElement(method);
                        nodes[0].AppendChild(noder);
                    }
                    noder.RemoveAll();
                    for (int s = 0; s < grid.Items.Count; s++)
                    {
                        object      values = grid.Items[s];
                        ValueMapRow row    = grid.Items.GetItemAt(s) as ValueMapRow;
                        if (row != null)
                        {
                            System.Xml.XmlNode snode = _xml.CreateElement("sValue");
                            snode.InnerText = row.Source;
                            noder.AppendChild(snode);
                            System.Xml.XmlNode tnode = _xml.CreateElement("tValue");
                            tnode.InnerText = row.Target;
                            noder.AppendChild(tnode);
                        }
                    }
                    System.Xml.XmlNode othnode = _xml.CreateElement("Otherwise");
                    string             oth     = Method3Otherwise.Text;
                    if (oth.StartsWith("\n ") || oth.Equals(""))
                    {
                        oth = "None";
                    }
                    othnode.InnerText = oth;
                    noder.AppendChild(othnode);
                    saveFieldGrid();
                }
                catch { }
            }
        }
コード例 #10
0
        /// <summary>
        /// 获取或设置配置[推荐使用]
        /// </summary>
        /// <param name="ClassName">类名</param>
        /// <param name="PropertyName">属性名(特殊值:InnerText)</param>
        /// <returns></returns>
        public override string this[string ClassName, string PropertyName]
        {
            get
            {
                if (xn != null)
                {
                    System.Xml.XmlNode xn1 = xn.SelectSingleNode(ClassName);
                    if (xn1 != null)
                    {
                        if (xn1.Attributes[PropertyName] != null)
                        {
                            return(xn1.Attributes[PropertyName].Value);
                        }

                        if (PropertyName == "InnerText")
                        {
                            return(xn1.InnerText);
                        }

                        // 支持子节点
                        if (xn1.HasChildNodes)
                        {
                            System.Xml.XmlNodeList xnl = xn1.SelectNodes(PropertyName);
                            if (xnl.Count > 0)
                            {
                                return(xnl[xnl.Count - 1].InnerText);
                            }
                        }
                    }
                }
                return(null);
            }
            set
            {
                if (xn == null)
                {
                    throw new System.Exception("请先设置 Root!");
                }

                System.Xml.XmlNode xn1 = xn.SelectSingleNode(ClassName);
                if (xn1 == null)
                {
                    xn1 = xd.CreateElement(ClassName);
                    xn.AppendChild(xn1);
                }
                if (xn1.Attributes[PropertyName] == null)
                {
                    xn1.Attributes.Append(xd.CreateAttribute(PropertyName));
                }
                xn1.Attributes[PropertyName].Value = value;
            }
        }
コード例 #11
0
ファイル: DbConnection.cs プロジェクト: jujianfei/AC
        /// <summary>
        /// 保存数据库连接配置文件。
        /// </summary>
        /// <param name="configFileName"></param>
        /// <param name="db"></param>
        public static void SaveDbConnectionConfig(string configFileName, IDb db)
        {
            System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();

            System.Xml.XmlNode xnConfig = xmlDoc.CreateElement("DbConnectionConfig");
            xmlDoc.AppendChild(xnConfig);

            System.Xml.XmlNode xnType = xmlDoc.CreateElement("Type");
            xnType.InnerText = db.GetType().FullName;
            xnConfig.AppendChild(xnType);

            xnConfig.AppendChild(db.GetConfig(xmlDoc));

            xmlDoc.Save(configFileName);
        }
コード例 #12
0
        private void BtnSave_Click(object sender, EventArgs e)
        {
            string path = System.IO.Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) + @"\data\produkter.xml";

            if (this.productName != "NEW")
            {
                XDocument xmlFile = XDocument.Load(path);
                var       query   = from c in xmlFile.Elements("produkter").Elements("produkt")
                                    where (string)(c.Element("pnamn")) == this.productName
                                    select c;
                foreach (XElement foretag in query)
                {
                    foretag.Element("pnamn").Value = textBoxName.Text;
                    foretag.Element("pris").Value  = textBoxPris.Text;
                }
                xmlFile.Save(path);
            }
            else
            {
                string filename = path;

                //create new instance of XmlDocument
                System.Xml.XmlDocument doc = new System.Xml.XmlDocument();

                //load from file
                doc.Load(filename);

                //create node and add value
                System.Xml.XmlNode node = doc.CreateNode(System.Xml.XmlNodeType.Element, "produkt", null);

                System.Xml.XmlNode nodeNamn = doc.CreateElement("pnamn");
                nodeNamn.InnerText = textBoxName.Text;

                System.Xml.XmlNode nodeER = doc.CreateElement("pris");
                nodeER.InnerText = textBoxPris.Text;

                //add to parent node
                node.AppendChild(nodeNamn);
                node.AppendChild(nodeER);

                //add to elements collection
                doc.DocumentElement.AppendChild(node);

                //save back
                doc.Save(filename);
            }
            toolStripStatusLabel1.Text = "Sparade";
        }
コード例 #13
0
        /// <summary>
        /// XML序列化
        /// </summary>
        /// <param name="obj">对象</param>
        /// <param name="node">节点</param>
        /// <param name="typeName">是否创建类型名父节点</param>
        /// <returns></returns>
        public static System.Xml.XmlNode Serialize(object obj, System.Xml.XmlNode node, bool typeName)
        {
            var type = obj.GetType();

            var fnode = node;

            if (typeName)
            {
                fnode = node.OwnerDocument.CreateElement(type.Name);
                node.AppendChild(fnode);
            }
            var pros = type.GetProperties();//(xtertor.Current.Name, bindingAttr);

            foreach (var pro in pros)
            {
                if (pro.GetIndexParameters().Length == 0)
                {
                    var value = pro.GetValue(obj, null);
                    if (value != null)
                    {
                        var cnode = node.OwnerDocument.CreateElement(pro.Name);
                        fnode.AppendChild(cnode);
                        var s = value.ToString();
                        cnode.AppendChild(node.OwnerDocument.CreateCDataSection(s));
                    }
                }
            }
            return(fnode);
        }
コード例 #14
0
        private static void SetNode(string cpath)
        {
            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            doc.Load(cpath);
            Console.WriteLine("Adding to machine.config path: {0}", cpath);

            foreach (DataProvider dp in dataproviders)
            {
                System.Xml.XmlNode node = doc.SelectSingleNode("configuration/system.data/DbProviderFactories/add[@invariant=\"" + dp.invariant + "\"]");
                if (node == null)
                {
                    System.Xml.XmlNode root = doc.SelectSingleNode("configuration/system.data/DbProviderFactories");
                    node = doc.CreateElement("add");
                    System.Xml.XmlAttribute at = doc.CreateAttribute("name");
                    node.Attributes.Append(at);
                    at = doc.CreateAttribute("invariant");
                    node.Attributes.Append(at);
                    at = doc.CreateAttribute("description");
                    node.Attributes.Append(at);
                    at = doc.CreateAttribute("type");
                    node.Attributes.Append(at);
                    root.AppendChild(node);
                }
                node.Attributes["name"].Value        = dp.name;
                node.Attributes["invariant"].Value   = dp.invariant;
                node.Attributes["description"].Value = dp.description;
                node.Attributes["type"].Value        = dp.type;
                Console.WriteLine("Added Data Provider node in machine.config.");
            }

            doc.Save(cpath);
            Console.WriteLine("machine.config saved: {0}", cpath);
        }
コード例 #15
0
        public void AddToXml(System.Xml.XmlNode xmlNode)
        {
//			System.Xml.Serialization.XmlSerializer ser = new System.Xml.Serialization.XmlSerializer(
            System.Xml.XmlDocument doc;
            if (xmlNode.GetType() == typeof(System.Xml.XmlDocument))
            {
                doc = (System.Xml.XmlDocument)xmlNode;
            }
            else
            {
                doc = xmlNode.OwnerDocument;
            }

            for (int i = 0; i < this.ChildNodes.Count; i++)
            {
                System.Xml.XmlNode xmlNew;
                Node child = (Node)this.ChildNodes.GetByIndex(i);
                try
                {
                    xmlNew = doc.CreateElement(child.Name);
                }
                catch
                {
                    xmlNew = doc.CreateElement("IncorrectXmlName");
                }
                if (child.Value != null)
                {
                    System.Xml.XmlAttribute attrib = doc.CreateAttribute("value");
                    attrib.InnerText = child.Value.ToString();
                    xmlNew.Attributes.Append(attrib);
                }
                xmlNode.AppendChild(xmlNew);
                child.AddToXml(xmlNew);
            }
        }
コード例 #16
0
 System.Xml.XmlElement GetServiceElement(string name, System.Xml.XmlNode serviceNode, System.Xml.XmlNode orderNode = null)
 {
     System.Xml.XmlNode node = null;
     foreach (System.Xml.XmlNode item in serviceNode.ChildNodes)
     {
         if (item.Name != name)
         {
             continue;
         }
         node = item;
         break;
     }
     if (node == null)
     {
         node = serviceNode.OwnerDocument.CreateElement(name, serviceNode.OwnerDocument.DocumentElement.NamespaceURI);
         if (orderNode == null)
         {
             serviceNode.AppendChild(node);
         }
         else
         {
             serviceNode.InsertAfter(node, orderNode);
         }
     }
     return((System.Xml.XmlElement)node);
 }
コード例 #17
0
ファイル: FilterCollection.cs プロジェクト: jujianfei/AC
        /// <summary>
        /// 获取当前筛选器的状态,将序列化的内容填充至 XmlNode 的 InnerText 属性或者 ChildNodes 子节点中。
        /// </summary>
        /// <param name="xmlDoc">创建 XmlNode 时所需使用到的 System.Xml.XmlDocument。</param>
        public System.Xml.XmlNode GetFilterConfig(System.Xml.XmlDocument xmlDoc)
        {
            System.Xml.XmlNode xn = xmlDoc.CreateElement(this.GetType().Name);

            System.Xml.XmlAttribute xaFilterLogicOperator = xmlDoc.CreateAttribute("FilterLogicOperator");
            xaFilterLogicOperator.InnerText = Function.ToInt(this.LogicOperator).ToString();
            xn.Attributes.Append(xaFilterLogicOperator);

            foreach (F _Filter in this)
            {
                System.Xml.XmlNode xnFilter = _Filter.GetFilterConfig(xmlDoc);

                //类型名
                System.Xml.XmlAttribute xaType = xmlDoc.CreateAttribute("Type");
                xaType.Value = _Filter.GetType().FullName;
                xnFilter.Attributes.Append(xaType);

                //程序集名
                System.Xml.XmlAttribute xaAssembly = xmlDoc.CreateAttribute("Assembly");
                xaAssembly.Value = _Filter.GetType().Assembly.FullName.Substring(0, _Filter.GetType().Assembly.FullName.IndexOf(","));
                xnFilter.Attributes.Append(xaAssembly);

                xn.AppendChild(xnFilter);
            }
            return(xn);
        }
コード例 #18
0
        /// <summary>
        /// Writes the current element's content
        /// </summary>
        /// <param name="doc"></param>
        /// <param name="currentNode"></param>
        protected override void WriteXml(System.Xml.XmlDocument doc, System.Xml.XmlNode currentNode)
        {
            var en = Utility.EncodeFDOName(this.Name);

            var geom = doc.CreateElement("xs", "element", XmlNamespaces.XS);                                //NOXLATE

            geom.SetAttribute("name", en);                                                                  //NOXLATE
            geom.SetAttribute("type", "gml:AbstractGeometryType");                                          //NOXLATE
            geom.SetAttribute("hasMeasure", XmlNamespaces.FDO, this.HasMeasure.ToString().ToLower());       //NOXLATE
            geom.SetAttribute("hasElevation", XmlNamespaces.FDO, this.HasElevation.ToString().ToLower());   //NOXLATE
            geom.SetAttribute("srsName", XmlNamespaces.FDO, this.SpatialContextAssociation);                //NOXLATE
            geom.SetAttribute("geometricTypes", XmlNamespaces.FDO, GeometryTypesToString());                //NOXLATE
            geom.SetAttribute("geometryTypes", XmlNamespaces.FDO, GeometricTypesToString());                //NOXLATE
            geom.SetAttribute("geometryReadOnly", XmlNamespaces.FDO, this.IsReadOnly.ToString().ToLower()); //NOXLATE

            //Write description node
            var anno = doc.CreateElement("xs", "annotation", XmlNamespaces.XS);    //NOXLATE
            var docN = doc.CreateElement("xs", "documentation", XmlNamespaces.XS); //NOXLATE

            docN.InnerText = this.Description;
            geom.AppendChild(anno);
            anno.AppendChild(docN);

            currentNode.AppendChild(geom);
        }
コード例 #19
0
 public void AddTextEx(int color, Font ft, string text)
 {
     System.Xml.XmlDocument xml = new System.Xml.XmlDocument();
     if (Value == null)
     {
         xml.LoadXml("<root></root>");
     }
     else
     {
         xml.LoadXml(Value.ToString());
     }
     System.Xml.XmlNode root = xml.FirstChild;
     if (root == null)
     {
         xml.LoadXml("<root></root>");
         root = xml.FirstChild;
     }
     System.Xml.XmlNode node = xml.CreateElement("text");
     if (color != -1)
     {
         System.Xml.XmlAttribute xmlAttr = xml.CreateAttribute("color");
         xmlAttr.Value = color.ToString();
         node.Attributes.Append(xmlAttr);
     }
     if (ft != null)
     {
         System.Xml.XmlAttribute xmlAttr = xml.CreateAttribute("font");
         xmlAttr.Value = Core.General.FontToString(ft);
         node.Attributes.Append(xmlAttr);
     }
     node.InnerText = text;
     root.AppendChild(node);
     Value = xml.InnerXml;
 }
コード例 #20
0
ファイル: IndexDefinition.cs プロジェクト: njmube/lazaro
        public System.Xml.XmlNode ToXml(System.Xml.XmlNode node)
        {
            System.Xml.XmlDocument document;
            if (node is System.Xml.XmlDocument)
            {
                document = (System.Xml.XmlDocument)node;
            }
            else
            {
                document = node.OwnerDocument;
            }

            System.Xml.XmlNode Res = document.CreateElement("Index");

            Res.Attributes.Append(node.OwnerDocument.CreateAttribute("table"));
            Res.Attributes["table"].Value = this.TableName;

            Res.Attributes.Append(node.OwnerDocument.CreateAttribute("name"));
            Res.Attributes["name"].Value = this.Name;

            Res.Attributes.Append(node.OwnerDocument.CreateAttribute("columns"));
            Res.Attributes["columns"].Value = string.Join(",", this.Columns.ToArray());

            Res.Attributes.Append(node.OwnerDocument.CreateAttribute("unique"));
            Res.Attributes["unique"].Value = this.Unique ? "1" : "0";

            Res.Attributes.Append(node.OwnerDocument.CreateAttribute("primary"));
            Res.Attributes["primary"].Value = this.Primary ? "1" : "0";

            node.AppendChild(Res);

            return(Res);
        }
コード例 #21
0
        /// <summary>
        /// 根据Key修改Value
        /// </summary>
        /// <param name="key">要修改的Key</param>
        /// <param name="value">要修改为的值</param>
        public static void SetValue(string key, string value)
        {
            System.Xml.XmlDocument xDoc = new System.Xml.XmlDocument();
            xDoc.Load(HttpContext.Current.Server.MapPath("~/XmlConfig/system.config"));

            System.Xml.XmlNode xNode = xDoc.SelectSingleNode("//appSettings");

            if (xNode != null)
            {
                System.Xml.XmlElement xElem1;
                System.Xml.XmlElement xElem2;

                xElem1 = (System.Xml.XmlElement)xNode.SelectSingleNode("//add[@key='" + key + "']");
                if (xElem1 != null)
                {
                    xElem1.SetAttribute("value", value);
                }
                else
                {
                    xElem2 = xDoc.CreateElement("add");
                    xElem2.SetAttribute("key", key);
                    xElem2.SetAttribute("value", value);
                    xNode.AppendChild(xElem2);
                }
            }
            xDoc.Save(HttpContext.Current.Server.MapPath("~/XmlConfig/system.config"));
        }
コード例 #22
0
ファイル: OdsReaderWriter.cs プロジェクト: bixiu/BlueMine
        }     // End Sub SaveRows

        private void SaveCell(System.Data.DataRow row
                              , System.Xml.XmlNode rowNode,
                              System.Xml.XmlDocument ownerDocument)
        {
            object[] cells = row.ItemArray;

            for (int i = 0; i < cells.Length; i++)
            {
                System.Xml.XmlElement cellNode =
                    ownerDocument.CreateElement("table:table-cell", this.GetNamespaceUri("table"));

                if (row[i] != System.DBNull.Value)
                {
                    // We save values as text (string)
                    System.Xml.XmlAttribute valueType =
                        ownerDocument.CreateAttribute("office:value-type", this.GetNamespaceUri("office"));
                    valueType.Value = "string";
                    cellNode.Attributes.Append(valueType);

                    System.Xml.XmlElement cellValue =
                        ownerDocument.CreateElement("text:p", this.GetNamespaceUri("text"));
                    cellValue.InnerText = row[i].ToString();
                    cellNode.AppendChild(cellValue);
                } // End if (row[i] != System.DBNull.Value)

                rowNode.AppendChild(cellNode);
            } // Next i
        }     // End Sub SaveCell
コード例 #23
0
        public override System.Xml.XmlDocument XmlSerialize()
        {
            System.Xml.XmlDocument document = base.XmlSerialize();

            System.Xml.XmlNode definitionsNode = document.CreateElement("Definitions");

            document.ChildNodes[1].AppendChild(definitionsNode);


            foreach (MedicalServices.Definitions.ServiceSingletonDefinition currentDefinition in definitions)
            {
                try {
                    currentDefinition.Application = base.application;

                    System.Xml.XmlNode definitionNode = currentDefinition.XmlSerialize().LastChild;

                    definitionsNode.AppendChild(document.ImportNode(definitionNode, true));
                }

                catch (Exception applicationException) {
                    System.Diagnostics.Debug.WriteLine(applicationException.Message);
                }
            }


            return(document);
        }
コード例 #24
0
ファイル: cfgHelper.cs プロジェクト: g82tt/xcore
 /// <summary>
 /// 设置 web.config 的 AppSettings 中某项的值
 /// </summary>
 /// <param name="key">项的名称</param>
 /// <param name="value">项的值</param>
 /// <returns>返回结果</returns>
 public static Boolean SetAppSettings(String key, String value)
 {
     try
     {
         //指定超级管理员
         String XmlPath = System.IO.PathTool.ServerMap("~/web.config");
         System.Xml.XmlDocument xmldoc = new System.Xml.XmlDocument();
         xmldoc.Load(XmlPath);
         System.Xml.XmlNode    root       = xmldoc.DocumentElement.SelectSingleNode("appSettings");
         System.Xml.XmlElement subElement = (System.Xml.XmlElement)root.SelectSingleNode("//add[@key='" + key + "']");
         if (subElement == null)
         {
             subElement = xmldoc.CreateElement("add");
             subElement.SetAttribute("key", key);
             subElement.SetAttribute("value", value);
             root.AppendChild(subElement);
             xmldoc.Save(XmlPath);
         }
         else
         {
             subElement.SetAttribute("value", value);
             xmldoc.Save(XmlPath);
         }
         return(true);
     }
     catch { return(false); }
 }
コード例 #25
0
 public static void AppendIfExists(System.Xml.XmlNode node, System.Xml.XmlNode nodeChild)
 {
     if (nodeChild != null)
     {
         node.AppendChild(nodeChild);
     }
 }
コード例 #26
0
        public string ToXml()
        {
            StringBuilder sbXml = new StringBuilder();

            System.Xml.XmlDocument document = new System.Xml.XmlDocument();
            System.Xml.XmlNode     root     = document.CreateElement("Condictions");

            foreach (QueryItem qc in queryItems)
            {
                System.Xml.XmlNode node = document.CreateElement("Condiction");

                System.Xml.XmlAttribute attributeName = document.CreateAttribute("Name");
                attributeName.Value = qc.Name;

                System.Xml.XmlAttribute attributeFields = document.CreateAttribute("MappingField");
                attributeFields.Value = qc.MappingFeild;

                System.Xml.XmlAttribute attributeDataType = document.CreateAttribute("DataType");
                attributeDataType.Value = qc.DataType.ToString();

                node.Attributes.Append(attributeName);
                node.Attributes.Append(attributeFields);
                node.Attributes.Append(attributeDataType);

                node.InnerText = qc.Value == null ? "" : qc.Value.ToString();

                root.AppendChild(node);
            }
            document.AppendChild(root);
            return(document.InnerXml.ToString());
        }
コード例 #27
0
 protected virtual void AddExtraStoredProcInfo(System.Xml.XmlNode node,
                                               string databaseName,
                                               string schemaName,
                                               string tableName,
                                               string modeName)
 {
     // Get Stored Proc Privileges
     System.Data.DataRow[] rowPrivileges;
     rowPrivileges = mdtStoredProcPrivileges.Select("Object = '" + tableName + "'");
     System.Xml.XmlNode nodePrivileges = this.CreateElement(modeName + "Privileges");
     System.Xml.XmlNode nodePrivilege;
     foreach (System.Data.DataRow rowPrivilege in rowPrivileges)
     {
         nodePrivilege = this.CreateElement(modeName + "Privilege");
         nodePrivilege.Attributes.Append(Utility.xmlHelpers.NewAttribute(
                                             mXMLDoc, "Grantor", rowPrivilege["Grantor"].ToString()));
         nodePrivilege.Attributes.Append(Utility.xmlHelpers.NewAttribute(
                                             mXMLDoc, "Grantee", rowPrivilege["Grantee"].ToString()));
         nodePrivilege.Attributes.Append(Utility.xmlHelpers.NewAttribute(
                                             mXMLDoc, "Type", rowPrivilege["Action"].ToString()));
         nodePrivilege.Attributes.Append(Utility.xmlHelpers.NewAttribute(
                                             mXMLDoc, "ProtectType", rowPrivilege["ProtectType"].ToString()));
         nodePrivileges.AppendChild(nodePrivilege);
         // NOTE: We are not yet supporting column privileges or Deny access!!!
     }
     node.AppendChild(nodePrivileges);
 }
コード例 #28
0
        private void XmlRegion(System.Xml.XmlNode parent, int dice, string name, UWP uwp)
        {
            System.Xml.XmlElement region  = parent.OwnerDocument.CreateElement("Region");
            System.Xml.XmlElement nameEle = parent.OwnerDocument.CreateElement("name");
            nameEle.InnerText = name;
            region.AppendChild(nameEle);

            if (dice == 1)
            {
                XmlCritter(region, 1);
                XmlCritter(region, 2);
                XmlCritter(region, 3);
                XmlCritter(region, 4);
                XmlCritter(region, 5);
                XmlCritter(region, 6);
            }
            else
            {
                XmlCritter(region, 2);
                XmlCritter(region, 3);
                XmlCritter(region, 4);
                XmlCritter(region, 5);
                XmlCritter(region, 6);
                XmlCritter(region, 7);
                XmlCritter(region, 8);
                XmlCritter(region, 9);
                XmlCritter(region, 10);
                XmlCritter(region, 11);
                XmlCritter(region, 12);
            }
            parent.AppendChild(region);
        }
コード例 #29
0
        public static System.Xml.XmlNode SetNode(System.Xml.XmlNode parentNode, string nodeName, string nodeValue = "")
        {
            System.Xml.XmlDocument xmlDoc = default(System.Xml.XmlDocument);
            xmlDoc = parentNode.OwnerDocument;

            // search node
            System.Xml.XmlNode xmlNewElem = RoutinesLibrary.Data.Xml.XMLUtils.GetFirstChild(parentNode, nodeName);
            if (xmlNewElem != null)
            {
                if (nodeValue != "")
                {
                    xmlNewElem.InnerText = nodeValue;
                }
            }
            else
            {
                // if not exists, create and append
                xmlNewElem = xmlDoc.CreateElement(nodeName);
                if (nodeValue != "")
                {
                    xmlNewElem.InnerText = nodeValue;
                }
                parentNode.AppendChild(xmlNewElem);
            }

            return(xmlNewElem);
        }
コード例 #30
0
        /// <summary>
        /// 设置表类型配置
        /// </summary>
        /// <param name="ClassName">类名</param>
        /// <param name="TableElementName">表元素名</param>
        /// <param name="dt">表配置</param>
        public void SetTableConfig(string ClassName, string TableElementName, System.Data.DataTable dt)
        {
            if (xn == null)
            {
                throw new System.Exception("请先设置 Root!");
            }

            System.Xml.XmlNode xn1 = xn.SelectSingleNode(ClassName);
            if (xn1 == null)
            {
                xn1 = xd.CreateElement(ClassName);
                xn.AppendChild(xn1);
            }

            System.Xml.XmlNode xn2 = xn1.SelectSingleNode(TableElementName);
            if (xn2 == null)
            {
                xn2 = xd.CreateElement(TableElementName);
                xn1.AppendChild(xn2);
            }

            if (xn2 != null && xn2.ChildNodes.Count > 0)
            {
                xn2.InnerXml = string.Empty;
            }

            StringWriter sw = new StringWriter();

            dt.WriteXml(sw, System.Data.XmlWriteMode.WriteSchema);
            xn2.InnerXml = sw.ToString();
        }
コード例 #31
0
        internal VerificationFile(IEnumerable<ManifestEntry> parentChain, FilenameStrategy str)
        {
            m_doc = new System.Xml.XmlDocument();
            System.Xml.XmlNode root = m_doc.AppendChild(m_doc.CreateElement("Verify"));
            root.Attributes.Append(m_doc.CreateAttribute("hash-algorithm")).Value = Utility.Utility.HashAlgorithm;
            root.Attributes.Append(m_doc.CreateAttribute("version")).Value = "1";

            m_node = root.AppendChild(m_doc.CreateElement("Files"));

            foreach (ManifestEntry mfe in parentChain)
            {
                System.Xml.XmlNode f = m_node.AppendChild(m_doc.CreateElement("File"));
                f.Attributes.Append(m_doc.CreateAttribute("type")).Value = "manifest";
                f.Attributes.Append(m_doc.CreateAttribute("name")).Value = mfe.Filename;
                f.Attributes.Append(m_doc.CreateAttribute("size")).Value = mfe.Filesize.ToString();
                f.InnerText = Utility.Utility.ByteArrayAsHexString(Convert.FromBase64String(mfe.RemoteHash));

                for (int i = 0; i < mfe.ParsedManifest.SignatureHashes.Count; i++)
                {
                    string sigfilename = mfe.ParsedManifest.SignatureHashes[i].Name;
                    string contentfilename = mfe.ParsedManifest.ContentHashes[i].Name;
                    bool missing = i >= mfe.Volumes.Count;

                    if (string.IsNullOrEmpty(sigfilename) || string.IsNullOrEmpty(contentfilename))
                    {
                        if (missing)
                        {
                            sigfilename = str.GenerateFilename(new SignatureEntry(mfe.Time, mfe.IsFull, i + 1));
                            contentfilename = str.GenerateFilename(new ContentEntry(mfe.Time, mfe.IsFull, i + 1));

                            //Since these files are missing, we have to guess what their real names were
                            string compressionGuess;
                            if (mfe.Volumes.Count <= 0)
                                compressionGuess = ".zip"; //Default if we have no knowledge
                            else
                                compressionGuess = "." + mfe.Volumes[0].Key.Compression; //Most likely the same as all the others

                            //Encryption will likely be the same as the one the manifest uses
                            string encryptionGuess = string.IsNullOrEmpty(mfe.EncryptionMode) ? "" : "." + mfe.EncryptionMode;

                            sigfilename += compressionGuess + encryptionGuess;
                            contentfilename += compressionGuess + encryptionGuess;
                        }
                        else
                        {
                            sigfilename = mfe.Volumes[i].Key.Filename;
                            contentfilename = mfe.Volumes[i].Value.Filename;
                        }
                    }

                    f = m_node.AppendChild(m_doc.CreateElement("File"));
                    f.Attributes.Append(m_doc.CreateAttribute("type")).Value = "signature";
                    f.Attributes.Append(m_doc.CreateAttribute("name")).Value = sigfilename;
                    f.Attributes.Append(m_doc.CreateAttribute("size")).Value = mfe.ParsedManifest.SignatureHashes[i].Size.ToString();
                    if (missing) f.Attributes.Append(m_doc.CreateAttribute("missing")).Value = "true";
                    f.InnerText = Utility.Utility.ByteArrayAsHexString(Convert.FromBase64String(mfe.ParsedManifest.SignatureHashes[i].Hash));

                    f = m_node.AppendChild(m_doc.CreateElement("File"));
                    f.Attributes.Append(m_doc.CreateAttribute("type")).Value = "content";
                    f.Attributes.Append(m_doc.CreateAttribute("name")).Value = contentfilename;
                    f.Attributes.Append(m_doc.CreateAttribute("size")).Value = mfe.ParsedManifest.ContentHashes[i].Size.ToString();
                    if (missing) f.Attributes.Append(m_doc.CreateAttribute("missing")).Value = "true";
                    f.InnerText = Utility.Utility.ByteArrayAsHexString(Convert.FromBase64String(mfe.ParsedManifest.ContentHashes[i].Hash));
                }
            }
        }