protected override void SerializeCore(XmlElement element) { XmlElementHelper helper = new XmlElementHelper(element); helper.SetAttribute("ShowErrors", ShowErrors); helper.SetAttribute("CancelRun", CancelRun); }
protected override void SerializeCore(XmlElement nodeElement, SaveContext context) { base.SerializeCore(nodeElement, context); var viewElement = nodeElement.OwnerDocument.CreateElement("view"); nodeElement.AppendChild(viewElement); var viewHelper = new XmlElementHelper(viewElement); WatchWidth = Width; WatchHeight = Height; viewHelper.SetAttribute("width", WatchWidth); viewHelper.SetAttribute("height", WatchHeight); // the view stores the latest position OnRequestUpdateLatestCameraPosition(); var camElement = nodeElement.OwnerDocument.CreateElement("camera"); viewElement.AppendChild(camElement); var camHelper = new XmlElementHelper(camElement); camHelper.SetAttribute("pos_x", CameraPosition.X); camHelper.SetAttribute("pos_y", CameraPosition.Y); camHelper.SetAttribute("pos_z", CameraPosition.Z); camHelper.SetAttribute("look_x", LookDirection.X); camHelper.SetAttribute("look_y", LookDirection.Y); camHelper.SetAttribute("look_z", LookDirection.Z); }
protected override void SerializeCore(XmlElement element) { XmlElementHelper helper = new XmlElementHelper(element); helper.SetAttribute("Tag", Tag); helper.SetAttribute("PauseDurationInMs", PauseDurationInMs); }
protected override void SaveNode(XmlDocument xmlDoc, XmlElement nodeElement, SaveContext context) { base.SaveNode(xmlDoc, nodeElement, context); var viewElement = xmlDoc.CreateElement("view"); nodeElement.AppendChild(viewElement); var viewHelper = new XmlElementHelper(viewElement); viewHelper.SetAttribute("width", Width); viewHelper.SetAttribute("height", Height); //Bail out early if the view hasn't been created. if (View == null) { return; } var camElement = xmlDoc.CreateElement("camera"); viewElement.AppendChild(camElement); var camHelper = new XmlElementHelper(camElement); camHelper.SetAttribute("pos_x", View.View.Camera.Position.X); camHelper.SetAttribute("pos_y", View.View.Camera.Position.Y); camHelper.SetAttribute("pos_z", View.View.Camera.Position.Z); camHelper.SetAttribute("look_x", View.View.Camera.LookDirection.X); camHelper.SetAttribute("look_y", View.View.Camera.LookDirection.Y); camHelper.SetAttribute("look_z", View.View.Camera.LookDirection.Z); }
protected override void SerializeCore(XmlElement element, SaveContext context) { XmlElementHelper helper = new XmlElementHelper(element); helper.SetAttribute(DummyModel.RadiusName, this.Radius); helper.SetAttribute(DummyModel.IdName, this.Identifier); }
protected override void SerializeCore(XmlElement element) { XmlElementHelper helper = new XmlElementHelper(element); helper.SetAttribute("ModelGuid", ModelGuid); helper.SetAttribute("EventName", EventName); }
public void GetNodeFromCommand_XMLTest() { //Arrange XmlDocument xmlDocument = new XmlDocument(); XmlElement elemTest = xmlDocument.CreateElement("TestCommand"); var helper = new XmlElementHelper(elemTest); //DeserializeCore method is looking for the attributes ShowErrors and CancelRun, then we need to set them up before calling the method. helper.SetAttribute("X", 100); helper.SetAttribute("Y", 100); helper.SetAttribute("DefaultPosition", true); helper.SetAttribute("TransformCoordinates", true); helper.SetAttribute("NodeName", "TestNode"); helper.SetAttribute("type", "Dynamo.Graph.Nodes.CodeBlockNodeModel"); XmlElement elemTestChild = xmlDocument.CreateElement("TestCommandChild"); var helper2 = new XmlElementHelper(elemTestChild); helper2.SetAttribute("type", "Dynamo.Graph.Nodes.CodeBlockNodeModel"); helper2.SetAttribute("ShouldFocus", true); helper2.SetAttribute("CodeText", "text"); elemTest.AppendChild(elemTestChild); //Act var createNodeCommand = DynamoModel.CreateNodeCommand.DeserializeCore(elemTest); //Calling Execute method will call internally the GetNodeFromCommand method createNodeCommand.Execute(CurrentDynamoModel); //Assert //Validating that the creageNodeCommand was successful Assert.IsNotNull(createNodeCommand); Assert.AreEqual(createNodeCommand.NodeXml.Name, "TestCommandChild"); }
protected override void SerializeCore(XmlElement element, SaveContext context) { base.SerializeCore(element, context); //Base implementation must be called if (context == SaveContext.Undo) { XmlElementHelper helper = new XmlElementHelper(element); helper.SetAttribute("functionId", Symbol); helper.SetAttribute("functionName", NickName); helper.SetAttribute("functionDesc", Description); XmlDocument xmlDoc = element.OwnerDocument; foreach (var input in InPortData.Select(x => x.NickName)) { var inputEl = xmlDoc.CreateElement("functionInput"); inputEl.SetAttribute("inputValue", input); element.AppendChild(inputEl); } foreach (var input in OutPortData.Select(x => x.NickName)) { var outputEl = xmlDoc.CreateElement("functionOutput"); outputEl.SetAttribute("outputValue", input); element.AppendChild(outputEl); } } }
internal string SaveRecordedCommands() { XmlDocument document = new XmlDocument(); XmlElement commandRoot = document.CreateElement("Commands"); document.AppendChild(commandRoot); // Create attributes that applied to the entire recording. XmlElementHelper helper = new XmlElementHelper(commandRoot); helper.SetAttribute(ExitAttribName, ExitAfterPlayback); helper.SetAttribute(PauseAttribName, PauseAfterPlayback); helper.SetAttribute(IntervalAttribName, CommandInterval); foreach (DynCmd.RecordableCommand command in recordedCommands) { commandRoot.AppendChild(command.Serialize(document)); } string format = "Commands-{0:yyyyMMdd-hhmmss}.xml"; string xmlFileName = string.Format(format, DateTime.Now); string xmlFilePath = Path.Combine(Path.GetTempPath(), xmlFileName); // Save recorded commands into XML file and open it in viewer. document.Save(xmlFilePath); return(xmlFilePath); }
internal string SaveRecordedCommands() { var document = new XmlDocument(); XmlElement commandRoot = document.CreateElement("Commands"); document.AppendChild(commandRoot); const string format = "Commands-{0:yyyyMMdd-hhmmss}.xml"; string xmlFileName = string.Format(format, DateTime.Now); string xmlFilePath = Path.Combine(Path.GetTempPath(), xmlFileName); // Create attributes that applied to the entire recording. var helper = new XmlElementHelper(commandRoot); helper.SetAttribute(EXIT_ATTRIB_NAME, ExitAfterPlayback); helper.SetAttribute(PAUSE_ATTRIB_NAME, PauseAfterPlayback); helper.SetAttribute(INTERVAL_ATTRIB_NAME, CommandInterval); // Serialization in SaveContext.File may need file path. Add it // temporarily and remove it after searilization. NodeUtils.SetDocumentXmlPath(document, xmlFilePath); foreach (DynamoModel.RecordableCommand command in recordedCommands) { commandRoot.AppendChild(command.Serialize(document)); } NodeUtils.SetDocumentXmlPath(document, null); // Save recorded commands into XML file and open it in viewer. document.Save(xmlFilePath); return(xmlFilePath); }
public void ForceRunCancelCommand_DeserializeCoreTest() { //Arrange string wspath = Path.Combine(TestDirectory, @"core\callsite\RebindingSingleDimension.dyn"); var fileCommand = new DynamoModel.OpenFileCommand(wspath); var runCancelCommand = new DynamoModel.ForceRunCancelCommand(false, false); CurrentDynamoModel.ExecuteCommand(runCancelCommand); XmlDocument xmlDocument = new XmlDocument(); XmlElement elemTest = xmlDocument.CreateElement("TestCommand"); //Act var helper = new XmlElementHelper(elemTest); //DeserializeCore method is looking for the attributes ShowErrors and CancelRun, then we need to set them up before calling the method. helper.SetAttribute("ShowErrors", true); helper.SetAttribute("CancelRun", true); var deserializedCommand = ForceRunCancelCommand.DeserializeCore(elemTest); //Assert Assert.IsNotNull(deserializedCommand); }
protected override void SerializeCore(XmlElement element) { XmlElementHelper helper = new XmlElementHelper(element); helper.SetAttribute("ModelGuid", ModelGuid); helper.SetAttribute("Modifiers", ((int)Modifiers)); }
public void CreateNodeCommandXML_ExecuteCore() { //Arrange XmlDocument xmlDocument = new XmlDocument(); //Act XmlElement elemTest = xmlDocument.CreateElement("TestCommand"); var helper = new XmlElementHelper(elemTest); //DeserializeCore method is looking for the attributes ShowErrors and CancelRun, then we need to set them up before calling the method. helper.SetAttribute("X", 100); helper.SetAttribute("Y", 100); helper.SetAttribute("DefaultPosition", true); helper.SetAttribute("TransformCoordinates", true); helper.SetAttribute("NodeName", "TestNode"); XmlElement elemTestChild = xmlDocument.CreateElement("TestCommandChild"); elemTest.AppendChild(elemTestChild); var createNodeCommand = DynCmd.CreateNodeCommand.DeserializeCore(elemTest); var serializedCommand = createNodeCommand.Serialize(xmlDocument); createNodeCommand.TrackAnalytics(); //Assert Assert.IsNotNull(createNodeCommand); Assert.IsNotNull(serializedCommand); }
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); }
protected override void SaveNode(XmlDocument xmlDoc, XmlElement nodeElement, SaveContext context) { base.SaveNode(xmlDoc, nodeElement, context); var helper = new XmlElementHelper(nodeElement); helper.SetAttribute("CodeText", code); helper.SetAttribute("ShouldFocus", shouldFocus); }
protected override void SerializeCore(XmlElement element, SaveContext context) { base.SerializeCore(element, context); var helper = new XmlElementHelper(element); helper.SetAttribute("CodeText", code); helper.SetAttribute("ShouldFocus", shouldFocus); }
protected override void SerializeCore(XmlElement element) { var helper = new XmlElementHelper(element); helper.SetAttribute("ModelGuid", ModelGuid); helper.SetAttribute("Name", Name); helper.SetAttribute("Value", Value); }
protected override void SerializeCore(XmlElement element) { XmlElementHelper helper = new XmlElementHelper(element); helper.SetAttribute("X", MouseCursor.X); helper.SetAttribute("Y", MouseCursor.Y); helper.SetAttribute("DragOperation", ((int)DragOperation)); }
protected override void SerializeCore(XmlElement element, SaveContext context) { base.SerializeCore(element, context); var helper = new XmlElementHelper(element); helper.SetAttribute("color", _plotColor); helper.SetAttribute("values", _values.ToString()); }
protected override void SerializeCore(XmlElement element) { XmlElementHelper helper = new XmlElementHelper(element); helper.SetAttribute("NodeId", NodeId); helper.SetAttribute("PortIndex", PortIndex); helper.SetAttribute("Type", ((int)Type)); helper.SetAttribute("ConnectionMode", ((int)ConnectionMode)); }
protected override void SerializeCore(XmlElement element, SaveContext context) { base.SerializeCore(element, context); // Base implementation must be called. var helper = new XmlElementHelper(element); helper.SetAttribute("conversionMetric", SelectedMetricConversion.ToString()); helper.SetAttribute("conversionFrom", SelectedFromConversion.ToString()); helper.SetAttribute("conversionTo", SelectedToConversion.ToString()); }
protected override void SerializeCore(XmlElement element) { XmlElementHelper helper = new XmlElementHelper(element); helper.SetAttribute("X", Region.X); helper.SetAttribute("Y", Region.Y); helper.SetAttribute("Width", Region.Width); helper.SetAttribute("Height", Region.Height); helper.SetAttribute("IsCrossSelection", IsCrossSelection); }
protected override void SerializeCore(XmlElement element) { XmlElementHelper helper = new XmlElementHelper(element); helper.SetAttribute("NodeId", NodeId); helper.SetAttribute("NoteText", NoteText); helper.SetAttribute("X", X); helper.SetAttribute("Y", Y); helper.SetAttribute("DefaultPosition", DefaultPosition); }
protected override void SerializeCore(XmlElement element) { XmlElementHelper helper = new XmlElementHelper(element); helper.SetAttribute("NodeId", NodeId); helper.SetAttribute("Name", Name); helper.SetAttribute("Category", Category); helper.SetAttribute("Description", Description); helper.SetAttribute("MakeCurrent", MakeCurrent); }
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); helper.SetAttribute("pinnedNode", pinnedNode == null ? Guid.Empty : pinnedNode.GUID); }
protected override void SerializeCore(XmlElement element, SaveContext context) { var helper = new XmlElementHelper(element); helper.SetAttribute("guid", GUID); helper.SetAttribute("start", Start.Owner.GUID); helper.SetAttribute("start_index", Start.Index); helper.SetAttribute("end", End.Owner.GUID); helper.SetAttribute("end_index", End.Index); //helper.SetAttribute("portType", ((int) End.PortType)); }
public void CreateProxyNodeCommand_SerializeDeserializeCore() { //Arrange XmlDocument xmlDocument = new XmlDocument(); XmlElement elemProxyTest = xmlDocument.CreateElement("TestProxyCommand"); XmlElement elemTestChild = xmlDocument.CreateElement("TestProxyCommandChild"); elemProxyTest.AppendChild(elemTestChild); var helper = new XmlElementHelper(elemProxyTest); //DeserializeCore method is checking several attributes, then we need to set them up before calling DeserializeCore helper.SetAttribute("NodeName", "ProxyNodeTest"); helper.SetAttribute("NickName", "ProxyNode"); helper.SetAttribute("X", 100); helper.SetAttribute("Y", 150); helper.SetAttribute("DefaultPosition", true); helper.SetAttribute("TransformCoordinates", true); helper.SetAttribute("Inputs", 1); helper.SetAttribute("Outputs", 1); //Act var proxyNodeCommandNode = CreateProxyNodeCommand.DeserializeCore(elemProxyTest); var xmlSerializedCommand = proxyNodeCommandNode.Serialize(xmlDocument); //Assert Assert.IsNotNull(proxyNodeCommandNode); Assert.AreEqual(proxyNodeCommandNode.NickName, "ProxyNode"); Assert.AreEqual(proxyNodeCommandNode.Inputs, 1); Assert.AreEqual(proxyNodeCommandNode.Outputs, 1); }
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"); }); }
protected override void SerializeCore(XmlElement element, SaveContext context) { base.SerializeCore(element, context); var helper = new XmlElementHelper(element); helper.SetAttribute("Script", Script); }
public override void SerializeCore(XmlElement element, SaveContext context) { base.SerializeCore(element, context); var helper = new XmlElementHelper(element); helper.SetAttribute("name", Definition.MangledName); }
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); }
public void TestDoubleAttributes() { XmlElement element = xmlDocument.CreateElement("element"); // Test attribute writing. XmlElementHelper writer = new XmlElementHelper(element); writer.SetAttribute("ValidName", -12.34); // Test reading of existing attribute. XmlElementHelper reader = new XmlElementHelper(element); Assert.AreEqual(-12.34, reader.ReadDouble("ValidName")); // Test reading of non-existence attribute with default value. Assert.AreEqual(56.78, reader.ReadDouble("InvalidName", 56.78)); // Test reading of non-existence attribute without default value. Assert.Throws<InvalidOperationException>(() => { reader.ReadDouble("InvalidName"); }); }
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"); }); }
protected override void SerializeCore(XmlElement element) { XmlElementHelper helper = new XmlElementHelper(element); helper.SetAttribute("NodeId", NodeId); helper.SetAttribute("NodeName", NodeName); helper.SetAttribute("X", X); helper.SetAttribute("Y", Y); helper.SetAttribute("DefaultPosition", DefaultPosition); helper.SetAttribute("TransformCoordinates", TransformCoordinates); }
protected override void SerializeCore(XmlElement element) { XmlElementHelper helper = new XmlElementHelper(element); helper.SetAttribute("XmlFilePath", XmlFilePath); }
internal string SaveRecordedCommands() { var document = new XmlDocument(); XmlElement commandRoot = document.CreateElement("Commands"); document.AppendChild(commandRoot); const string format = "Commands-{0:yyyyMMdd-hhmmss}.xml"; string xmlFileName = string.Format(format, DateTime.Now); string xmlFilePath = Path.Combine(Path.GetTempPath(), xmlFileName); // Create attributes that applied to the entire recording. var helper = new XmlElementHelper(commandRoot); helper.SetAttribute(EXIT_ATTRIB_NAME, ExitAfterPlayback); helper.SetAttribute(PAUSE_ATTRIB_NAME, PauseAfterPlayback); helper.SetAttribute(INTERVAL_ATTRIB_NAME, CommandInterval); // Serialization in SaveContext.File may need file path. Add it // temporarily and remove it after searilization. NodeUtils.SetDocumentXmlPath(document, xmlFilePath); foreach (DynamoModel.RecordableCommand command in recordedCommands) commandRoot.AppendChild(command.Serialize(document)); NodeUtils.SetDocumentXmlPath(document, null); // Save recorded commands into XML file and open it in viewer. document.Save(xmlFilePath); return xmlFilePath; }
protected override void SerializeCore(XmlElement element) { XmlElementHelper helper = new XmlElementHelper(element); helper.SetAttribute("CmdOperation", ((int)CmdOperation)); }
protected override void SerializeCore(XmlElement element) { XmlElementHelper helper = new XmlElementHelper(element); helper.SetAttribute("NodeId", NodeId); }
protected override void SerializeCore(XmlElement element, SaveContext context) { XmlElementHelper helper = new XmlElementHelper(element); // Set the type attribute helper.SetAttribute("type", this.GetType().ToString()); helper.SetAttribute("guid", this.GUID); helper.SetAttribute("nickname", this.NickName); helper.SetAttribute("x", this.X); helper.SetAttribute("y", this.Y); helper.SetAttribute("isVisible", this.IsVisible); helper.SetAttribute("isUpstreamVisible", this.IsUpstreamVisible); helper.SetAttribute("lacing", this.ArgumentLacing.ToString()); if (context == SaveContext.Undo) { // Fix: MAGN-159 (nodes are not editable after undo/redo). helper.SetAttribute("interactionEnabled", this.interactionEnabled); helper.SetAttribute("nodeState", this.state.ToString()); } }
protected override void SerializeCore(XmlElement element, SaveContext context) { base.SerializeCore(element, context); var helper = new XmlElementHelper(element); helper.SetAttribute("Script", this.Script); }
protected override void SerializeCore(XmlElement element) { XmlElementHelper helper = new XmlElementHelper(element); helper.SetAttribute("ModelGuid", ModelGuid); helper.SetAttribute("Name", Name); helper.SetAttribute("Value", Value); }
internal string SaveRecordedCommands() { XmlDocument document = new XmlDocument(); XmlElement commandRoot = document.CreateElement("Commands"); document.AppendChild(commandRoot); // Create attributes that applied to the entire recording. XmlElementHelper helper = new XmlElementHelper(commandRoot); helper.SetAttribute(ExitAttribName, ExitAfterPlayback); helper.SetAttribute(PauseAttribName, PauseAfterPlayback); helper.SetAttribute(IntervalAttribName, CommandInterval); foreach (DynCmd.RecordableCommand command in recordedCommands) commandRoot.AppendChild(command.Serialize(document)); string format = "Commands-{0:yyyyMMdd-hhmmss}.xml"; string xmlFileName = string.Format(format, DateTime.Now); string xmlFilePath = Path.Combine(Path.GetTempPath(), xmlFileName); // Save recorded commands into XML file and open it in viewer. document.Save(xmlFilePath); return xmlFilePath; }
protected override void SerializeCore(XmlElement element, SaveContext context) { base.SerializeCore(element, context); //Base implementation must be called if (context != SaveContext.Undo) return; var helper = new XmlElementHelper(element); helper.SetAttribute("functionId", Definition.FunctionId.ToString()); helper.SetAttribute("functionName", NickName); helper.SetAttribute("functionDesc", Description); XmlDocument xmlDoc = element.OwnerDocument; foreach (string input in InPortData.Select(x => x.NickName)) { XmlElement inputEl = xmlDoc.CreateElement("functionInput"); inputEl.SetAttribute("inputValue", input); element.AppendChild(inputEl); } foreach (string input in OutPortData.Select(x => x.NickName)) { XmlElement outputEl = xmlDoc.CreateElement("functionOutput"); outputEl.SetAttribute("outputValue", input); element.AppendChild(outputEl); } }
void SerializeCore(XmlElement element, SaveContext context) { XmlElementHelper helper = new XmlElementHelper(element); helper.SetAttribute("guid", this.GUID); helper.SetAttribute("annotationText", this.AnnotationText); helper.SetAttribute("left", this.X); helper.SetAttribute("top", this.Y); helper.SetAttribute("width", this.Width); helper.SetAttribute("height", this.Height); helper.SetAttribute("fontSize", this.FontSize); helper.SetAttribute("InitialTop", this.InitialTop); helper.SetAttribute("InitialHeight", this.InitialHeight); helper.SetAttribute("TextblockHeight", this.TextBlockHeight); helper.SetAttribute("backgrouund", (this.Background == null ? "" : this.Background.ToString())); //Serialize Selected models XmlDocument xmlDoc = element.OwnerDocument; foreach (var guids in this.SelectedModels.Select(x => x.GUID)) { if (xmlDoc != null) { var modelElement = xmlDoc.CreateElement("Models"); element.AppendChild(modelElement); XmlElementHelper mhelper = new XmlElementHelper(modelElement); modelElement.SetAttribute("ModelGuid", guids.ToString()); } } }
protected override void SerializeCore(XmlElement element) { XmlElementHelper helper = new XmlElementHelper(element); helper.SetAttribute("TabIndex", TabIndex); }