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


C# XmlElementHelper.ReadInteger方法代码示例

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


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

示例1: TestIntegerAttributes

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

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

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

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

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

示例2: LoadConnectorFromXml

        /// <summary>
        ///     Creates and initializes a ConnectorModel from its Xml representation.
        /// </summary>
        /// <param name="connEl">XmlElement for a ConnectorModel.</param>
        /// <param name="nodes">Dictionary to be used for looking up a NodeModel by it's Guid.</param>
        /// <returns>Returns the new instance of ConnectorModel loaded from XmlElement.</returns>
        public static ConnectorModel LoadConnectorFromXml(XmlElement connEl, IDictionary<Guid, NodeModel> nodes)
        {
            var helper = new XmlElementHelper(connEl);

            var guid = helper.ReadGuid("guid", Guid.NewGuid());
            var guidStart = helper.ReadGuid("start");
            var guidEnd = helper.ReadGuid("end");
            int startIndex = helper.ReadInteger("start_index");
            int endIndex = helper.ReadInteger("end_index");

            //find the elements to connect
            NodeModel start;
            if (nodes.TryGetValue(guidStart, out start))
            {
                NodeModel end;
                if (nodes.TryGetValue(guidEnd, out end))
                {
                    return ConnectorModel.Make(start, end, startIndex, endIndex, guid);
                }
            }

            return null;
        }
开发者ID:norbertzsiros,项目名称:Dynamo,代码行数:29,代码来源:NodeGraph.cs

示例3: DeserializeCore

 internal static PausePlaybackCommand DeserializeCore(XmlElement element)
 {
     XmlElementHelper helper = new XmlElementHelper(element);
     var pauseDurationInMs = helper.ReadInteger("PauseDurationInMs");
     return new PausePlaybackCommand(pauseDurationInMs);
 }
开发者ID:heegwon,项目名称:Dynamo,代码行数:6,代码来源:RecordableCommands.cs

示例4: DeserializeCore

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

示例5: GetModelForElement

 public ModelBase GetModelForElement(XmlElement modelData)
 {
     XmlElementHelper helper = new XmlElementHelper(modelData);
     int identifier = helper.ReadInteger(DummyModel.IdName);
     return (models.Find((x) => (x.Identifier == identifier)));
 }
开发者ID:ankushraizada,项目名称:Dynamo,代码行数:6,代码来源:UndoRedoRecorderTests.cs

示例6: ReloadModel

 public void ReloadModel(XmlElement modelData)
 {
     XmlElementHelper helper = new XmlElementHelper(modelData);
     int identifier = helper.ReadInteger(DummyModel.IdName);
     DummyModel model = models.First((x) => (x.Identifier == identifier));
     model.Deserialize(modelData, SaveContext.Undo);
 }
开发者ID:ankushraizada,项目名称:Dynamo,代码行数:7,代码来源:UndoRedoRecorderTests.cs

示例7: DeserializeCore

            internal static SelectModelCommand DeserializeCore(XmlElement element)
            {
                var helper = new XmlElementHelper(element);
                var modifiers = ((ModifierKeys)helper.ReadInteger("Modifiers"));

                var modelGuids = DeserializeGuid(element, helper);

                return new SelectModelCommand(modelGuids, modifiers);
            }
开发者ID:Randy-Ma,项目名称:Dynamo,代码行数:9,代码来源:RecordableCommands.cs

示例8: DeserializeCore

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

            // Restore some information from the node attributes.
            this.GUID = helper.ReadGuid("guid", this.GUID);
            Guid startNodeId = helper.ReadGuid("start");
            int startIndex = helper.ReadInteger("start_index");
            Guid endNodeId = helper.ReadGuid("end");
            int endIndex = helper.ReadInteger("end_index");
            PortType portType = ((PortType)helper.ReadInteger("portType"));

            // Get to the start and end nodes that this connector connects to.
            WorkspaceModel workspace = dynSettings.Controller.DynamoModel.CurrentWorkspace;
            NodeModel startNode = workspace.GetModelInternal(startNodeId) as NodeModel;
            NodeModel endNode = workspace.GetModelInternal(endNodeId) as NodeModel;

            pStart = startNode.OutPorts[startIndex];
            PortModel endPort = null;
            if (portType == PortType.INPUT)
                endPort = endNode.InPorts[endIndex];

            pStart.Connect(this);
            this.Connect(endPort);
        }
开发者ID:algobasket,项目名称:Dynamo,代码行数:25,代码来源:ConnectorModel.cs

示例9: LoadCommandFromFile

        private bool LoadCommandFromFile(string commandFilePath)
        {
            if (string.IsNullOrEmpty(commandFilePath))
                return false;
            if (File.Exists(commandFilePath) == false)
                return false;

            if (null != loadedCommands)
            {
                throw new InvalidOperationException(
                    "Internal error: 'LoadCommandFromFile' called twice");
            }

            try
            {
                // Attempt to load the XML from the specified path.
                var document = new XmlDocument();
                document.Load(commandFilePath);

                // Get to the root node of this Xml document.
                var commandRoot = document.FirstChild as XmlElement;
                if (null == commandRoot)
                    return false;

                // Read in optional attributes from the command root element.
                var helper = new XmlElementHelper(commandRoot);
                ExitAfterPlayback = helper.ReadBoolean(EXIT_ATTRIB_NAME, true);
                PauseAfterPlayback = helper.ReadInteger(PAUSE_ATTRIB_NAME, 10);
                CommandInterval = helper.ReadInteger(INTERVAL_ATTRIB_NAME, 20);

                loadedCommands = new List<DynamoModel.RecordableCommand>();
                foreach (
                    DynamoModel.RecordableCommand command in
                        commandRoot.ChildNodes.Cast<XmlNode>()
                            .Select(
                                node => DynamoModel.RecordableCommand.Deserialize(
                                    node as XmlElement))
                            .Where(command => null != command))
                {
                    loadedCommands.Add(command);
                }
            }
            catch (Exception)
            {
                // Something is wrong with the Xml file, invalidate the 
                // data member that points to it, and return from here.
                return false;
            }

            // Even though the Xml file can properly be loaded, it is still 
            // possible that the loaded content did not result in any useful 
            // commands. In this case simply return false, indicating failure.
            // 
            return (null != loadedCommands && (loadedCommands.Count > 0));
        }
开发者ID:Conceptual-Design,项目名称:Dynamo,代码行数:55,代码来源:AutomationSettings.cs

示例10: DeleteModel

 public void DeleteModel(XmlElement modelData)
 {
     XmlElementHelper helper = new XmlElementHelper(modelData);
     int identifier = helper.ReadInteger(DummyModel.IdName);
     models.RemoveAll((x) => (x.Identifier == identifier));
 }
开发者ID:ankushraizada,项目名称:Dynamo,代码行数:6,代码来源:UndoRedoRecorderTests.cs


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