当前位置: 首页>>代码示例>>C#>>正文


C# XmlElementHelper.SetAttribute方法代码示例

本文整理汇总了C#中XmlElementHelper.SetAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# XmlElementHelper.SetAttribute方法的具体用法?C# XmlElementHelper.SetAttribute怎么用?C# XmlElementHelper.SetAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在XmlElementHelper的用法示例。


在下文中一共展示了XmlElementHelper.SetAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SerializeCore

 protected override void SerializeCore(XmlElement element, SaveContext context)
 {
     var helper = new XmlElementHelper(element);
     helper.SetAttribute("guid", GUID);
     helper.SetAttribute("text", Text);
     helper.SetAttribute("x", X);
     helper.SetAttribute("y", Y);
 }
开发者ID:ankushraizada,项目名称:Dynamo,代码行数:8,代码来源:NoteModel.cs

示例2: SerializeCore

        protected override void SerializeCore(XmlElement nodeElement, SaveContext context)
        {
            base.SerializeCore(nodeElement, context);
            XmlElement outEl = nodeElement.OwnerDocument.CreateElement(typeof(string).FullName);

            var helper = new XmlElementHelper(outEl);
            helper.SetAttribute("value", SerializeValue());
            nodeElement.AppendChild(outEl);
        }
开发者ID:norbertzsiros,项目名称:Dynamo,代码行数:9,代码来源:BaseTypes.cs

示例3: TestDoubleAttributes

        public void TestDoubleAttributes()
        {
            XmlElement element = xmlDocument.CreateElement("element");

            // Test attribute writing.
            XmlElementHelper writer = new XmlElementHelper(element);
            writer.SetAttribute("ValidName", -12.34);

            // Test reading of existing attribute.
            XmlElementHelper reader = new XmlElementHelper(element);
            Assert.AreEqual(-12.34, reader.ReadDouble("ValidName"));

            // Test reading of non-existence attribute with default value.
            Assert.AreEqual(56.78, reader.ReadDouble("InvalidName", 56.78));

            // Test reading of non-existence attribute without default value.
            Assert.Throws<InvalidOperationException>(() =>
            {
                reader.ReadDouble("InvalidName");
            });
        }
开发者ID:ankushraizada,项目名称:Dynamo,代码行数:21,代码来源:XmlHelperTests.cs

示例4: TestBooleanAttributes

        public void TestBooleanAttributes()
        {
            XmlElement element = xmlDocument.CreateElement("element");

            // Test attribute writing.
            XmlElementHelper writer = new XmlElementHelper(element);
            writer.SetAttribute("ValidName", true);

            // Test reading of existing attribute.
            XmlElementHelper reader = new XmlElementHelper(element);
            Assert.AreEqual(true, reader.ReadBoolean("ValidName"));

            // Test reading of non-existence attribute with default value.
            Assert.AreEqual(true, reader.ReadBoolean("InvalidName", true));
            Assert.AreEqual(false, reader.ReadBoolean("InvalidName", false));

            // Test reading of non-existence attribute without default value.
            Assert.Throws<InvalidOperationException>(() =>
            {
                reader.ReadBoolean("InvalidName");
            });
        }
开发者ID:ankushraizada,项目名称:Dynamo,代码行数:22,代码来源:XmlHelperTests.cs

示例5: SaveNode

 protected override void SaveNode(XmlDocument xmlDoc, XmlElement nodeElement, SaveContext context)
 {
     base.SaveNode(xmlDoc, nodeElement, context);
     var helper = new XmlElementHelper(nodeElement);
     helper.SetAttribute("CodeText", code);
     helper.SetAttribute("ShouldFocus", shouldFocus);
 }
开发者ID:TheChosen0ne,项目名称:Dynamo,代码行数:7,代码来源:CodeBlockNode.cs

示例6: SerializeCore

        protected override void SerializeCore(XmlElement element, SaveContext context)
        {
            base.SerializeCore(element, context);

            var helper = new XmlElementHelper(element);
            helper.SetAttribute("Script", this.Script);
        }
开发者ID:kscalvin,项目名称:Dynamo,代码行数:7,代码来源:dynPython.cs

示例7: SerializeCore

 protected override void SerializeCore(XmlElement element)
 {
     XmlElementHelper helper = new XmlElementHelper(element);
     helper.SetAttribute("NodeId", NodeId);
 }
开发者ID:heegwon,项目名称:Dynamo,代码行数:5,代码来源:RecordableCommands.cs

示例8: SerializeCore

 protected override void SerializeCore(XmlElement element, SaveContext context)
 {
     var helper = new XmlElementHelper(element);
     helper.SetAttribute("guid", GUID);
     helper.SetAttribute("start", Start.Owner.GUID);
     helper.SetAttribute("start_index", Start.Index);
     helper.SetAttribute("end", End.Owner.GUID);
     helper.SetAttribute("end_index", End.Index);
     //helper.SetAttribute("portType", ((int) End.PortType));
 }
开发者ID:ankushraizada,项目名称:Dynamo,代码行数:10,代码来源:ConnectorModel.cs

示例9: SerializeCore

 protected override void SerializeCore(XmlElement element, SaveContext context)
 {
     XmlElementHelper helper = new XmlElementHelper(element);
     helper.SetAttribute(DummyModel.RadiusName, this.Radius);
     helper.SetAttribute(DummyModel.IdName, this.Identifier);
 }
开发者ID:ankushraizada,项目名称:Dynamo,代码行数:6,代码来源:UndoRedoRecorderTests.cs

示例10: SaveRecordedCommands

        internal string SaveRecordedCommands()
        {
            var document = new XmlDocument();
            XmlElement commandRoot = document.CreateElement("Commands");
            document.AppendChild(commandRoot);

            const string format = "Commands-{0:yyyyMMdd-hhmmss}.xml";
            string xmlFileName = string.Format(format, DateTime.Now);
            string xmlFilePath = Path.Combine(Path.GetTempPath(), xmlFileName);
            
            // Create attributes that applied to the entire recording.
            var helper = new XmlElementHelper(commandRoot);
            helper.SetAttribute(EXIT_ATTRIB_NAME, ExitAfterPlayback);
            helper.SetAttribute(PAUSE_ATTRIB_NAME, PauseAfterPlayback);
            helper.SetAttribute(INTERVAL_ATTRIB_NAME, CommandInterval);
            // Serialization in SaveContext.File may need file path. Add it
            // temporarily and remove it after searilization.
            NodeUtils.SetDocumentXmlPath(document, xmlFilePath);

            foreach (DynamoModel.RecordableCommand command in recordedCommands)
                commandRoot.AppendChild(command.Serialize(document));

            NodeUtils.SetDocumentXmlPath(document, null);

            // Save recorded commands into XML file and open it in viewer.
            document.Save(xmlFilePath);
            return xmlFilePath;
        }
开发者ID:Conceptual-Design,项目名称:Dynamo,代码行数:28,代码来源:AutomationSettings.cs

示例11: SaveRecordedCommands

        internal string SaveRecordedCommands()
        {
            XmlDocument document = new XmlDocument();
            XmlElement commandRoot = document.CreateElement("Commands");
            document.AppendChild(commandRoot);

            // Create attributes that applied to the entire recording.
            XmlElementHelper helper = new XmlElementHelper(commandRoot);
            helper.SetAttribute(ExitAttribName, ExitAfterPlayback);
            helper.SetAttribute(PauseAttribName, PauseAfterPlayback);
            helper.SetAttribute(IntervalAttribName, CommandInterval);

            foreach (DynCmd.RecordableCommand command in recordedCommands)
                commandRoot.AppendChild(command.Serialize(document));

            string format = "Commands-{0:yyyyMMdd-hhmmss}.xml";
            string xmlFileName = string.Format(format, DateTime.Now);
            string xmlFilePath = Path.Combine(Path.GetTempPath(), xmlFileName);

            // Save recorded commands into XML file and open it in viewer.
            document.Save(xmlFilePath);
            return xmlFilePath;
        }
开发者ID:RobertiF,项目名称:Dynamo,代码行数:23,代码来源:AutomationSettings.cs

示例12: SerializeCore

        protected override void SerializeCore(XmlElement element, SaveContext context)
        {
            base.SerializeCore(element, context); // Base implementation must be called.

            var helper = new XmlElementHelper(element);
            helper.SetAttribute("conversionMetric", SelectedMetricConversion.ToString());
            helper.SetAttribute("conversionFrom", SelectedFromConversion.ToString());
            helper.SetAttribute("conversionTo", SelectedToConversion.ToString());
        }
开发者ID:Conceptual-Design,项目名称:Dynamo,代码行数:9,代码来源:DynamoConvert.cs

示例13: SerializeCore

        protected override void SerializeCore(XmlElement element, SaveContext context)
        {
            XmlElementHelper helper = new XmlElementHelper(element);

            // Set the type attribute
            helper.SetAttribute("type", this.GetType().ToString());
            helper.SetAttribute("guid", this.GUID);
            helper.SetAttribute("nickname", this.NickName);
            helper.SetAttribute("x", this.X);
            helper.SetAttribute("y", this.Y);
            helper.SetAttribute("isVisible", this.IsVisible);
            helper.SetAttribute("isUpstreamVisible", this.IsUpstreamVisible);
            helper.SetAttribute("lacing", this.ArgumentLacing.ToString());

            if (context == SaveContext.Undo)
            {
                // Fix: MAGN-159 (nodes are not editable after undo/redo).
                helper.SetAttribute("interactionEnabled", this.interactionEnabled);
                helper.SetAttribute("nodeState", this.state.ToString());
            }
        }
开发者ID:riteshchandawar,项目名称:Dynamo,代码行数:21,代码来源:NodeModel.cs

示例14: SerializeCore

 public override void SerializeCore(XmlElement element, SaveContext context)
 {
     base.SerializeCore(element, context);
     var helper = new XmlElementHelper(element);
     helper.SetAttribute("name", Definition.MangledName);
 }
开发者ID:khoaho,项目名称:Dynamo,代码行数:6,代码来源:DSFunction.cs

示例15: SerializeCore

        protected override void SerializeCore(XmlElement element, SaveContext context)
        {
            base.SerializeCore(element, context); //Base implementation must be called
            
            if (context != SaveContext.Undo) return;

            var helper = new XmlElementHelper(element);
            helper.SetAttribute("functionId", Definition.FunctionId.ToString());
            helper.SetAttribute("functionName", NickName);
            helper.SetAttribute("functionDesc", Description);

            XmlDocument xmlDoc = element.OwnerDocument;
            foreach (string input in InPortData.Select(x => x.NickName))
            {
                XmlElement inputEl = xmlDoc.CreateElement("functionInput");
                inputEl.SetAttribute("inputValue", input);
                element.AppendChild(inputEl);
            }

            foreach (string input in OutPortData.Select(x => x.NickName))
            {
                XmlElement outputEl = xmlDoc.CreateElement("functionOutput");
                outputEl.SetAttribute("outputValue", input);
                element.AppendChild(outputEl);
            }
        }
开发者ID:khoaho,项目名称:Dynamo,代码行数:26,代码来源:Function.cs


注:本文中的XmlElementHelper.SetAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。