本文整理汇总了C#中SaveContext类的典型用法代码示例。如果您正苦于以下问题:C# SaveContext类的具体用法?C# SaveContext怎么用?C# SaveContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SaveContext类属于命名空间,在下文中一共展示了SaveContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SaveNode
protected override void SaveNode(XmlDocument xmlDoc, XmlElement nodeElement, SaveContext context)
{
Controller.SaveNode(xmlDoc, nodeElement, context);
var outEl = xmlDoc.CreateElement("Name");
outEl.SetAttribute("value", NickName);
nodeElement.AppendChild(outEl);
outEl = xmlDoc.CreateElement("Description");
outEl.SetAttribute("value", Description);
nodeElement.AppendChild(outEl);
outEl = xmlDoc.CreateElement("Inputs");
foreach (string input in InPortData.Select(x => x.NickName))
{
XmlElement inputEl = xmlDoc.CreateElement("Input");
inputEl.SetAttribute("value", input);
outEl.AppendChild(inputEl);
}
nodeElement.AppendChild(outEl);
outEl = xmlDoc.CreateElement("Outputs");
foreach (string output in OutPortData.Select(x => x.NickName))
{
XmlElement outputEl = xmlDoc.CreateElement("Output");
outputEl.SetAttribute("value", output);
outEl.AppendChild(outputEl);
}
nodeElement.AppendChild(outEl);
}
示例2: 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("exportedUnit", SelectedExportedUnit.ToString());
}
示例3: SaveNode
//public override FScheme.Value Evaluate(FSharpList<FScheme.Value> args)
//{
// dynRevitSettings.ElementsContainers.Push(ElementsContainer);
// var result = base.Evaluate(args);
// dynRevitSettings.ElementsContainers.Pop();
// return result;
//}
protected override void SaveNode(XmlDocument xmlDoc, XmlElement nodeElement, SaveContext context)
{
base.SaveNode(xmlDoc, nodeElement, context);
if (context == SaveContext.Copy)
return;
foreach (var node in ElementsContainer.Nodes)
{
var outEl = xmlDoc.CreateElement("InnerNode");
outEl.SetAttribute("id", node.ToString());
foreach (var run in ElementsContainer[node])
{
var runEl = xmlDoc.CreateElement("Run");
foreach (var id in run)
{
Element e;
if (dynUtils.TryGetElement(id, out e))
{
var elementStore = xmlDoc.CreateElement("Element");
elementStore.InnerText = e.UniqueId;
runEl.AppendChild(elementStore);
}
}
outEl.AppendChild(runEl);
}
nodeElement.AppendChild(outEl);
}
}
示例4: SerializeCore
protected override void SerializeCore(XmlElement element, SaveContext context)
{
base.SerializeCore(element, context); //Base implementation must be called
var formStringNode = element.OwnerDocument.CreateElement("FormulaText");
formStringNode.InnerText = FormulaString;
element.AppendChild(formStringNode);
}
示例5: DeserializeCore
protected override void DeserializeCore(XmlElement element, SaveContext context)
{
base.DeserializeCore(element, context); //Base implementation must be called
if (context == SaveContext.Undo)
{
//Reads in the new number of ports required from the data stored in the Xml Element
//during Serialize (nextLength). Changes the current In Port Data to match the
//required size by adding or removing port data.
int currLength = InPortData.Count;
XmlNodeList inNodes = element.SelectNodes("Input");
int nextLength = inNodes.Count;
if (nextLength > currLength)
{
for (; currLength < nextLength; currLength++)
{
XmlNode subNode = inNodes.Item(currLength);
string nickName = subNode.Attributes["name"].Value;
InPortData.Add(new PortData(nickName, "", typeof(object)));
}
}
else if (nextLength < currLength)
InPortData.RemoveRange(nextLength, currLength - nextLength);
RegisterAllPorts();
}
}
示例6: SaveNode
SaveNode(XmlDocument xmlDoc, XmlElement nodeElement, SaveContext context)
{
//Don't copy over stored references
if (context == SaveContext.Copy)
return;
//Only save elements in the home workspace
if (WorkSpace is CustomNodeWorkspaceModel)
return;
foreach (var run in elements)
{
var outEl = xmlDoc.CreateElement("Run");
foreach (var id in run)
{
Element e;
if (dynUtils.TryGetElement(id, out e))
{
var elementStore = xmlDoc.CreateElement("Element");
elementStore.InnerText = e.UniqueId;
outEl.AppendChild(elementStore);
}
}
nodeElement.AppendChild(outEl);
}
}
示例7: SaveNode
protected override void SaveNode(XmlDocument xmlDoc, XmlElement nodeElement, SaveContext context)
{
//Debug.WriteLine(pd.Object.GetType().ToString());
XmlElement outEl = xmlDoc.CreateElement(typeof(double).FullName);
outEl.SetAttribute("value", port.PortName);
nodeElement.AppendChild(outEl);
}
示例8: 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);
}
示例9: 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);
}
示例10: 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);
}
示例11: 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);
}
示例12: 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();
}
示例13: DeserializeCore
protected override void DeserializeCore(XmlElement nodeElement, SaveContext context)
{
base.DeserializeCore(nodeElement, context);
foreach (XmlNode subNode in nodeElement.ChildNodes)
{
if (subNode.Name.Equals(typeof(string).FullName))
{
foreach (XmlAttribute attr in subNode.Attributes)
{
if (attr.Name.Equals("value"))
{
Value = DeserializeValue(attr.Value);
}
}
}
}
}
示例14: DeserializeCore
protected override void DeserializeCore(XmlElement nodeElement, SaveContext context)
{
base.DeserializeCore(nodeElement, context); //Base implementation must be called
if (nodeElement.Attributes != null)
{
var formulaAttr = nodeElement.Attributes["formula"];
if (formulaAttr != null)
{
FormulaString = formulaAttr.Value;
return;
}
}
var formStringNode = nodeElement.ChildNodes.Cast<XmlNode>().FirstOrDefault(childNode => childNode.Name == "FormulaText");
FormulaString = formStringNode != null
? formStringNode.InnerText
: nodeElement.InnerText;
}
示例15: DeserializeCore
protected override void DeserializeCore(XmlElement element, SaveContext context)
{
base.DeserializeCore(element, context); //Base implementation must be called
if (context != SaveContext.Undo) return;
var helper = new XmlElementHelper(element);
NickName = helper.ReadString("functionName");
Controller.DeserializeCore(element, context);
XmlNodeList inNodes = element.SelectNodes("functionInput");
XmlNodeList outNodes = element.SelectNodes("functionOutput");
var inData =
inNodes.Cast<XmlNode>()
.Select(
(inputNode, i) =>
new
{
data = new PortData(inputNode.Attributes[0].Value, "Input #" + (i + 1)),
idx = i
});
foreach (var dataAndIdx in inData)
{
if (InPortData.Count > dataAndIdx.idx)
InPortData[dataAndIdx.idx] = dataAndIdx.data;
else
InPortData.Add(dataAndIdx.data);
}
var outData =
outNodes.Cast<XmlNode>()
.Select(
(outputNode, i) =>
new
{
data = new PortData(outputNode.Attributes[0].Value, "Output #" + (i + 1)),
idx = i
});
foreach (var dataAndIdx in outData)
{
if (OutPortData.Count > dataAndIdx.idx)
OutPortData[dataAndIdx.idx] = dataAndIdx.data;
else
OutPortData.Add(dataAndIdx.data);
}
//Added it the same way as LoadNode. But unsure of when 'Output' ChildNodes will
//be added to element. As of now I dont think it is added during serialize
#region Legacy output support
foreach (var portData in
from XmlNode subNode in element.ChildNodes
where subNode.Name.Equals("Output")
select new PortData(subNode.Attributes[0].Value, "function output"))
{
if (OutPortData.Any())
OutPortData[0] = portData;
else
OutPortData.Add(portData);
}
#endregion
RegisterAllPorts();
Description = helper.ReadString("functionDesc");
}