public void SerializeTest() { var toolConfig = new CommandLineGuiConfig() { Executables = new ExecutableList { new Executable() { Name = "Exec1", Location = "/relative/Exec1.exe", Arguments = new ArgumentList() { new Argument() { Name = "Test1", Format = "/t", Multiplicity = Multiplicity.ExactlyOne } } } } }; using (var memStream = new MemoryStream()) { XmlSerializer <CommandLineGuiConfig> .Serialize(toolConfig, memStream); memStream.Position = 0; var reader = new StreamReader(memStream); TestContext.WriteLine("{0}", reader.ReadToEnd()); } }
private static CommandLineGuiConfig ReadToolSchema(string schemaFilePath) { var serializer = XmlSerializer <CommandLineGuiConfig> .CreateFromResource( SchemaNames.CommandLineGuiSchemaV1); CommandLineGuiConfig toolConfig = serializer.Read(schemaFilePath); return(toolConfig); }
public GuiSchema AddFromFile(string schemaFilePath) { // check if the schema already exists. var existingSchema = (from schema in this.GuiSchemas where schema.SchemaFilePath == schemaFilePath select schema).FirstOrDefault(); if (existingSchema != null) { return(existingSchema); } CommandLineGuiConfig toolConfig = ReadToolSchema(schemaFilePath); //var existingSchema = (from schema in GuiSchemas // where schema.SchemaFilePath.ToUpper() == schemaFilePath.ToUpper() // select schema).FirstOrDefault(); //if (existingSchema != null) //{ // var newExecs = toolConfig.Executables.Except(existingSchema.ToolConfig.Executables); // var existingExecs = toolConfig.Executables.Intersect(existingSchema.ToolConfig.Executables); // foreach (var exec in existingExecs) // { // var existingExec = existingSchema.FindExecutable(exec.Name); // var newGroups = exec.Gui.BindingGroupsAndBindings.Except(existingExec.Gui.BindingGroupsAndBindings); // var bindingList = new List<object>(existingExec.Gui.BindingGroupsAndBindings); // bindingList.AddRange(newGroups); // existingExec.Gui.BindingGroupsAndBindings = bindingList; // } // existingSchema.ToolConfig.Executables.AddRange(newExecs); // return existingSchema; //} //else { var guiSchema = new GuiSchema(); guiSchema.SchemaFilePath = schemaFilePath; guiSchema.ToolConfig = toolConfig; GuiSchemas.Add(guiSchema); return(guiSchema); } }