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


C# XmlElementHelper.ReadBoolean方法代码示例

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


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

示例1: 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:algobasket,项目名称:Dynamo,代码行数:22,代码来源:XmlHelperTests.cs

示例2: LoadNode

 protected override void LoadNode(XmlNode nodeElement)
 {
     base.LoadNode(nodeElement);
     var helper = new XmlElementHelper(nodeElement as XmlElement);
     code = helper.ReadString("CodeText");
     ProcessCodeDirect();
     shouldFocus = helper.ReadBoolean("ShouldFocus");
 }
开发者ID:TheChosen0ne,项目名称:Dynamo,代码行数:8,代码来源:CodeBlockNode.cs

示例3: DeserializeCore

 protected override void DeserializeCore(XmlElement element, SaveContext context)
 {
     base.DeserializeCore(element, context);
     if (context == SaveContext.Undo)
     {
         var helper = new XmlElementHelper(element);
         shouldFocus = helper.ReadBoolean("ShouldFocus");
         code = helper.ReadString("CodeText");
         ProcessCodeDirect();
     }
 }
开发者ID:TheChosen0ne,项目名称:Dynamo,代码行数:11,代码来源:CodeBlockNode.cs

示例4: DeserializeCore

            internal static CreateCustomNodeCommand DeserializeCore(XmlElement element)
            {
                XmlElementHelper helper = new XmlElementHelper(element);

                return new CreateCustomNodeCommand(
                    helper.ReadGuid("NodeId"),
                    helper.ReadString("Name"),
                    helper.ReadString("Category"),
                    helper.ReadString("Description"),
                    helper.ReadBoolean("MakeCurrent"));
            }
开发者ID:heegwon,项目名称:Dynamo,代码行数:11,代码来源:RecordableCommands.cs

示例5: DeserializeCore

        protected override void DeserializeCore(XmlElement element, SaveContext context)
        {
            XmlElementHelper helper = new XmlElementHelper(element);
            this.GUID = helper.ReadGuid("guid", Guid.NewGuid());

            // Resolve node nick name.
            string nickName = helper.ReadString("nickname", string.Empty);
            if (!string.IsNullOrEmpty(nickName))
                this.nickName = nickName;
            else
            {
                System.Type type = this.GetType();
                var attribs = type.GetCustomAttributes(typeof(NodeNameAttribute), true);
                NodeNameAttribute attrib = attribs[0] as NodeNameAttribute;
                if (null != attrib)
                    this.nickName = attrib.Name;
            }

            this.X = helper.ReadDouble("x", 0.0);
            this.Y = helper.ReadDouble("y", 0.0);
            this.isVisible = helper.ReadBoolean("isVisible", true);
            this.isUpstreamVisible = helper.ReadBoolean("isUpstreamVisible", true);
            this.argumentLacing = helper.ReadEnum("lacing", LacingStrategy.Disabled);

            if (context == SaveContext.Undo)
            {
                // Fix: MAGN-159 (nodes are not editable after undo/redo).
                interactionEnabled = helper.ReadBoolean("interactionEnabled", true);
                this.state = helper.ReadEnum("nodeState", ElementState.ACTIVE);

                // We only notify property changes in an undo/redo operation. Normal
                // operations like file loading or copy-paste have the models created
                // in different ways and their views will always be up-to-date with
                // respect to their models.
                RaisePropertyChanged("InteractionEnabled");
                RaisePropertyChanged("State");
                RaisePropertyChanged("NickName");
                RaisePropertyChanged("ArgumentLacing");
                RaisePropertyChanged("IsVisible");
                RaisePropertyChanged("IsUpstreamVisible");

                // Notify listeners that the position of the node has changed,
                // then all connected connectors will also redraw themselves.
                this.ReportPosition();
            }
        }
开发者ID:riteshchandawar,项目名称:Dynamo,代码行数:46,代码来源:NodeModel.cs

示例6: DeserializeCore

        protected override void DeserializeCore(XmlElement nodeElement, SaveContext context)
        {
            base.DeserializeCore(nodeElement, context);
            var helper = new XmlElementHelper(nodeElement);
            shouldFocus = helper.ReadBoolean("ShouldFocus");
            code = helper.ReadString("CodeText");

            // Lookup namespace resolution map if available and initialize new instance of ElementResolver
            var resolutionMap = CodeBlockUtils.DeserializeElementResolver(nodeElement);
            ElementResolver = new ElementResolver(resolutionMap);

            ProcessCodeDirect();
        }
开发者ID:RevitLution,项目名称:Dynamo,代码行数:13,代码来源:CodeBlockNode.cs

示例7: 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

示例8: DeserializeCore

        protected override void DeserializeCore(XmlElement nodeElement, SaveContext context)
        {
            var helper = new XmlElementHelper(nodeElement); 
            
            if (context != SaveContext.Copy)
                GUID = helper.ReadGuid("guid", GUID);

            // Resolve node nick name.
            string name = helper.ReadString("nickname", string.Empty);
            if (!string.IsNullOrEmpty(name))
                nickName = name;
            else
            {
                Type type = GetType();
                object[] attribs = type.GetCustomAttributes(typeof(NodeNameAttribute), true);
                var attrib = attribs[0] as NodeNameAttribute;
                if (null != attrib)
                    nickName = attrib.Name;
            }

            X = helper.ReadDouble("x", 0.0);
            Y = helper.ReadDouble("y", 0.0);
            isVisible = helper.ReadBoolean("isVisible", true);
            isUpstreamVisible = helper.ReadBoolean("isUpstreamVisible", true);
            argumentLacing = helper.ReadEnum("lacing", LacingStrategy.Disabled);

            var portInfoProcessed = new HashSet<int>();

            //read port information
            foreach (XmlNode subNode in nodeElement.ChildNodes)
            {
                if (subNode.Name == "PortInfo")
                {
                    int index = int.Parse(subNode.Attributes["index"].Value);
                    if (index < InPorts.Count)
                    {
                        portInfoProcessed.Add(index);
                        bool def = bool.Parse(subNode.Attributes["default"].Value);
                        inPorts[index].UsingDefaultValue = def;
                    }
                }
            }

            //set defaults
            foreach (
                var port in
                    inPorts.Select((x, i) => new { x, i }).Where(x => !portInfoProcessed.Contains(x.i)))
                port.x.UsingDefaultValue = false;

            if (context == SaveContext.Undo)
            {
                // Fix: MAGN-159 (nodes are not editable after undo/redo).
                //interactionEnabled = helper.ReadBoolean("interactionEnabled", true);
                state = helper.ReadEnum("nodeState", ElementState.Active);

                // We only notify property changes in an undo/redo operation. Normal
                // operations like file loading or copy-paste have the models created
                // in different ways and their views will always be up-to-date with 
                // respect to their models.
                RaisePropertyChanged("InteractionEnabled");
                RaisePropertyChanged("State");
                RaisePropertyChanged("NickName");
                RaisePropertyChanged("ArgumentLacing");
                RaisePropertyChanged("IsVisible");
                RaisePropertyChanged("IsUpstreamVisible");

                // Notify listeners that the position of the node has changed,
                // then all connected connectors will also redraw themselves.
                ReportPosition();
            }
        }
开发者ID:w-fish,项目名称:Dynamo,代码行数:71,代码来源:NodeModel.cs

示例9: DeserializeCore

            internal static CreateAndConnectNodeCommand DeserializeCore(XmlElement element)
            {
                var helper = new XmlElementHelper(element);
                string newNodeName = helper.ReadString("NewNodeName");
                double x = helper.ReadDouble("X");
                double y = helper.ReadDouble("Y");
                bool createAsDownstreamNode = helper.ReadBoolean("CreateAsDownstreamNode");
                bool addNewNodeToSelection = helper.ReadBoolean("AddNewNodeToSelection");

                var guids = DeserializeGuid(element, helper).ToList();
                var newNodeGuid = guids.ElementAt(0);
                var existingNodeGuid = guids.ElementAt(1);

                int outPortIndex = helper.ReadInteger("OutPortIndex");
                int inPortIndex = helper.ReadInteger("InPortIndex");

                return new CreateAndConnectNodeCommand(newNodeGuid, existingNodeGuid, newNodeName, outPortIndex, inPortIndex,
                    x, y, createAsDownstreamNode, addNewNodeToSelection);
            }
开发者ID:Randy-Ma,项目名称:Dynamo,代码行数:19,代码来源:RecordableCommands.cs

示例10: DeserializeCore

        protected override void DeserializeCore(XmlElement nodeElement, SaveContext context)
        {
            base.DeserializeCore(nodeElement, context);
            var helper = new XmlElementHelper(nodeElement);
            shouldFocus = helper.ReadBoolean("ShouldFocus");
            code = helper.ReadString("CodeText");

            var childNodes = nodeElement.ChildNodes.Cast<XmlElement>().ToList();
            var inputPortHelpers =
                childNodes.Where(node => node.Name.Equals("PortInfo")).Select(x => new XmlElementHelper(x));

            // read and set input port info
            inputPortNames =
                inputPortHelpers.Select(x => x.ReadString("name", String.Empty))
                    .Where(y => !string.IsNullOrEmpty(y))
                    .ToList();
            SetInputPorts();

            // read and set ouput port info
            var outputPortHelpers =
                childNodes.Where(node => node.Name.Equals("OutPortInfo")).Select(x => new XmlElementHelper(x));
            var lineNumbers = outputPortHelpers.Select(x => x.ReadInteger("LineIndex")).ToList();
            foreach (var line in lineNumbers)
            {
                var tooltip = Formatting.TOOL_TIP_FOR_TEMP_VARIABLE;
                OutPorts.Add(new PortModel(PortType.Output, this, new PortData(string.Empty, tooltip)
                {
                    LineIndex = line, // Logical line index.
                    Height = Configurations.CodeBlockPortHeightInPixels
                }));
            }

            ProcessCodeDirect();
        }
开发者ID:DynamoDS,项目名称:Dynamo,代码行数:34,代码来源:CodeBlockNode.cs


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