本文整理汇总了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");
});
}
示例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");
}
示例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();
}
}
示例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"));
}
示例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();
}
}
示例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();
}
示例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));
}
示例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();
}
}
示例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);
}
示例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();
}