本文整理汇总了C#中XmlElementHelper.ReadGuid方法的典型用法代码示例。如果您正苦于以下问题:C# XmlElementHelper.ReadGuid方法的具体用法?C# XmlElementHelper.ReadGuid怎么用?C# XmlElementHelper.ReadGuid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XmlElementHelper
的用法示例。
在下文中一共展示了XmlElementHelper.ReadGuid方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DummyNode
public DummyNode(int inputCount, int outputCount, string legacyName, XmlElement originalElement, string legacyAssembly, Nature nodeNature)
{
InputCount = inputCount;
OutputCount = outputCount;
LegacyNodeName = legacyName;
NickName = legacyName;
OriginalNodeContent = originalElement;
LegacyAssembly = legacyAssembly;
NodeNature = nodeNature;
Description = GetDescription();
ShouldDisplayPreviewCore = false;
UpdatePorts();
// Take the position from the old node (because a dummy node
// should always be created at the location of the old node).
var helper = new XmlElementHelper(originalElement);
X = helper.ReadDouble("x", 0.0);
Y = helper.ReadDouble("y", 0.0);
//Take the GUID from the old node (dummy nodes should have their
//GUID's. This will allow the Groups to work as expected. MAGN-7568)
GUID = helper.ReadGuid("guid", this.GUID);
}
示例2: DeserializeCore
protected override void DeserializeCore(XmlElement nodeElement, SaveContext context)
{
var helper = new XmlElementHelper(nodeElement);
GUID = helper.ReadGuid("guid", GUID);
Text = helper.ReadString("text", "New Note");
X = helper.ReadDouble("x", 0.0);
Y = helper.ReadDouble("y", 0.0);
}
示例3: DeserializeCore
protected override void DeserializeCore(XmlElement element, SaveContext context)
{
XmlElementHelper helper = new XmlElementHelper(element);
this.GUID = helper.ReadGuid("guid", this.GUID);
this.Text = helper.ReadString("text", "New Note");
this.X = helper.ReadDouble("x", 0.0);
this.Y = helper.ReadDouble("y", 0.0);
}
示例4: DeserializeCore
protected override void DeserializeCore(XmlElement nodeElement, SaveContext context)
{
var helper = new XmlElementHelper(nodeElement);
GUID = helper.ReadGuid("guid", GUID);
Text = helper.ReadString("text", "New Note");
X = helper.ReadDouble("x", 0.0);
Y = helper.ReadDouble("y", 0.0);
// Notify listeners that the position of the note has changed,
// then parent group will also redraw itself.
ReportPosition();
}
示例5: 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;
}
示例6: DeserializeCore
internal static DeleteModelCommand DeserializeCore(XmlElement element)
{
XmlElementHelper helper = new XmlElementHelper(element);
Guid modelGuid = helper.ReadGuid("ModelGuid");
return new DeleteModelCommand(modelGuid);
}
示例7: DeserializeCore
internal static ApplyPresetCommand DeserializeCore(XmlElement element)
{
var helper = new XmlElementHelper(element);
return new ApplyPresetCommand(helper.ReadGuid("WorkspaceID"), helper.ReadGuid("StateID"));
}
示例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);
}
示例9: 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();
}
}
示例10: DeserializeGuid
protected static IEnumerable<Guid> DeserializeGuid(XmlElement element, XmlElementHelper helper)
{
// Deserialize old type of commands
if (helper.HasAttribute("ModelGuid"))
{
Guid modelGuid = helper.ReadGuid("ModelGuid", Guid.Empty);
return new[] { modelGuid };
}
if (helper.HasAttribute("NodeId"))
{
Guid modelGuid = helper.ReadGuid("NodeId", Guid.Empty);
return new[] { modelGuid };
}
return (from XmlNode xmlNode in element.ChildNodes
where xmlNode.Name.Equals("ModelGuid")
select Guid.Parse(xmlNode.InnerText)).ToArray();
}
示例11: GetModelForElement
public ModelBase GetModelForElement(XmlElement modelData)
{
// TODO(Ben): This may or may not be true, but I guess we should be
// using "System.Type" (given the "type" information in "modelData"),
// and determine the matching category (e.g. is this a Node, or a
// Connector?) instead of checking in each and every collections we
// have in the workspace.
//
// System.Type type = System.Type.GetType(helper.ReadString("type"));
// if (typeof(Dynamo.Models.NodeModel).IsAssignableFrom(type))
// return Nodes.First((x) => (x.GUID == modelGuid));
var helper = new XmlElementHelper(modelData);
Guid modelGuid = helper.ReadGuid("guid");
ModelBase foundModel = GetModelInternal(modelGuid);
if (null != foundModel)
return foundModel;
throw new ArgumentException(
string.Format("Unhandled model type: {0}", helper.ReadString("type", modelData.Name)));
}
示例12: TestGuidAttributes
public void TestGuidAttributes()
{
XmlElement element = xmlDocument.CreateElement("element");
// Test attribute writing.
System.Guid guidValue = System.Guid.NewGuid();
XmlElementHelper writer = new XmlElementHelper(element);
writer.SetAttribute("ValidName", guidValue);
// Test reading of existing attribute.
XmlElementHelper reader = new XmlElementHelper(element);
Assert.AreEqual(guidValue, reader.ReadGuid("ValidName"));
// Test reading of non-existence attribute with default value.
System.Guid defaultGuid = System.Guid.NewGuid();
Assert.AreEqual(defaultGuid, reader.ReadGuid("InvalidName", defaultGuid));
// Test reading of non-existence attribute without default value.
Assert.Throws<InvalidOperationException>(() =>
{
reader.ReadGuid("InvalidName");
});
}
示例13: DeserializeCore
protected override void DeserializeCore(XmlElement element, SaveContext context)
{
XmlElementHelper helper = new XmlElementHelper(element);
this.GUID = helper.ReadGuid("guid", this.GUID);
this.annotationText = helper.ReadString("annotationText", Resources.GroupDefaultText);
this.X = helper.ReadDouble("left", DoubleValue);
this.Y = helper.ReadDouble("top", DoubleValue);
this.width = helper.ReadDouble("width", DoubleValue);
this.height = helper.ReadDouble("height", DoubleValue);
this.background = helper.ReadString("backgrouund", "");
this.fontSize = helper.ReadDouble("fontSize", fontSize);
this.textBlockHeight = helper.ReadDouble("TextblockHeight", DoubleValue);
this.InitialTop = helper.ReadDouble("InitialTop", DoubleValue);
this.InitialHeight = helper.ReadDouble("InitialHeight", DoubleValue);
//Deserialize Selected models
if (element.HasChildNodes)
{
var listOfModels = new List<ModelBase>();
foreach (var childnode in element.ChildNodes)
{
XmlElementHelper mhelper = new XmlElementHelper(childnode as XmlElement);
if (SelectedModels != null)
{
var result = mhelper.ReadGuid("ModelGuid", new Guid());
ModelBase model = null;
model = ModelBaseRequested != null ? ModelBaseRequested(result) :
SelectedModels.FirstOrDefault(x => x.GUID == result);
listOfModels.Add(model);
}
}
SelectedModels = listOfModels;
}
//On any Undo Operation, current values are restored to previous values.
//These properties should be Raised, so that they get the correct value on Undo.
RaisePropertyChanged("Background");
RaisePropertyChanged("FontSize");
RaisePropertyChanged("AnnotationText");
RaisePropertyChanged("SelectedModels");
}
示例14: 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();
}
}