Försöker få in allt

This commit is contained in:
2019-07-23 12:43:50 +02:00
parent 0bf8211ebb
commit 44e615416e
27 changed files with 984 additions and 0 deletions

View File

@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.28803.352
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WindowsFormsApp1", "WindowsFormsApp1\WindowsFormsApp1.csproj", "{97198CCC-56C0-4ECD-AFC9-92CC531D57FD}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{97198CCC-56C0-4ECD-AFC9-92CC531D57FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{97198CCC-56C0-4ECD-AFC9-92CC531D57FD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{97198CCC-56C0-4ECD-AFC9-92CC531D57FD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{97198CCC-56C0-4ECD-AFC9-92CC531D57FD}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B4B6C059-3DF2-4020-BB41-EEA0D05B33AB}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApp1
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new StartShell());
}
}
}

View File

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("WindowsFormsApp1")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("WindowsFormsApp1")]
[assembly: AssemblyCopyright("Copyright © 2019")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("97198ccc-56c0-4ecd-afc9-92cc531d57fd")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -0,0 +1,71 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace WindowsFormsApp1.Properties
{
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan == null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WindowsFormsApp1.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
}
}

View File

@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,30 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace WindowsFormsApp1.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
return defaultInstance;
}
}
}
}

View File

@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

View File

@ -0,0 +1,176 @@
namespace WindowsFormsApp1
{
partial class StartShell
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.btnFromXml = new System.Windows.Forms.Button();
this.btnToXml = new System.Windows.Forms.Button();
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
this.lblFromXml = new System.Windows.Forms.Label();
this.lblToXml = new System.Windows.Forms.Label();
this.btnStart = new System.Windows.Forms.Button();
this.lvwResult = new System.Windows.Forms.ListView();
this.ColumnTagName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.ColumnDataValue = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.ColumnTagXPath = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.txtXPathAnalyse = new System.Windows.Forms.TextBox();
this.columnTagFound = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.SuspendLayout();
//
// btnFromXml
//
this.btnFromXml.Location = new System.Drawing.Point(13, 13);
this.btnFromXml.Name = "btnFromXml";
this.btnFromXml.Size = new System.Drawing.Size(75, 23);
this.btnFromXml.TabIndex = 0;
this.btnFromXml.Text = "FromXml";
this.btnFromXml.UseVisualStyleBackColor = true;
this.btnFromXml.Click += new System.EventHandler(this.BtnFromXml_Click);
//
// btnToXml
//
this.btnToXml.Location = new System.Drawing.Point(13, 43);
this.btnToXml.Name = "btnToXml";
this.btnToXml.Size = new System.Drawing.Size(75, 23);
this.btnToXml.TabIndex = 1;
this.btnToXml.Text = "ToXml";
this.btnToXml.UseVisualStyleBackColor = true;
this.btnToXml.Click += new System.EventHandler(this.BtnToXml_Click);
//
// openFileDialog1
//
this.openFileDialog1.FileName = "openFileDialog1";
//
// lblFromXml
//
this.lblFromXml.AutoSize = true;
this.lblFromXml.Location = new System.Drawing.Point(95, 22);
this.lblFromXml.Name = "lblFromXml";
this.lblFromXml.Size = new System.Drawing.Size(63, 13);
this.lblFromXml.TabIndex = 2;
this.lblFromXml.Text = "fromxmlpath";
//
// lblToXml
//
this.lblToXml.AutoSize = true;
this.lblToXml.Location = new System.Drawing.Point(95, 52);
this.lblToXml.Name = "lblToXml";
this.lblToXml.Size = new System.Drawing.Size(52, 13);
this.lblToXml.TabIndex = 3;
this.lblToXml.Text = "toxmlpath";
//
// btnStart
//
this.btnStart.Location = new System.Drawing.Point(13, 73);
this.btnStart.Name = "btnStart";
this.btnStart.Size = new System.Drawing.Size(75, 23);
this.btnStart.TabIndex = 4;
this.btnStart.Text = "Start Analyse";
this.btnStart.UseVisualStyleBackColor = true;
this.btnStart.Click += new System.EventHandler(this.BtnStart_Click);
//
// lvwResult
//
this.lvwResult.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.ColumnTagName,
this.ColumnDataValue,
this.ColumnTagXPath,
this.columnTagFound});
this.lvwResult.FullRowSelect = true;
this.lvwResult.Location = new System.Drawing.Point(98, 73);
this.lvwResult.MultiSelect = false;
this.lvwResult.Name = "lvwResult";
this.lvwResult.Size = new System.Drawing.Size(1015, 303);
this.lvwResult.TabIndex = 5;
this.lvwResult.UseCompatibleStateImageBehavior = false;
this.lvwResult.View = System.Windows.Forms.View.Details;
this.lvwResult.Click += new System.EventHandler(this.LvwResult_Click);
//
// ColumnTagName
//
this.ColumnTagName.Text = "Tagname";
this.ColumnTagName.Width = 200;
//
// ColumnDataValue
//
this.ColumnDataValue.Text = "DataValue";
this.ColumnDataValue.Width = 200;
//
// ColumnTagXPath
//
this.ColumnTagXPath.Text = "TagXPath";
this.ColumnTagXPath.Width = 400;
//
// txtXPathAnalyse
//
this.txtXPathAnalyse.Location = new System.Drawing.Point(98, 392);
this.txtXPathAnalyse.Name = "txtXPathAnalyse";
this.txtXPathAnalyse.Size = new System.Drawing.Size(592, 20);
this.txtXPathAnalyse.TabIndex = 6;
//
// columnTagFound
//
this.columnTagFound.Text = "FoundInSecFile";
this.columnTagFound.Width = 200;
//
// StartShell
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1171, 450);
this.Controls.Add(this.txtXPathAnalyse);
this.Controls.Add(this.lvwResult);
this.Controls.Add(this.btnStart);
this.Controls.Add(this.lblToXml);
this.Controls.Add(this.lblFromXml);
this.Controls.Add(this.btnToXml);
this.Controls.Add(this.btnFromXml);
this.Name = "StartShell";
this.Text = "StartShell";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Button btnFromXml;
private System.Windows.Forms.Button btnToXml;
private System.Windows.Forms.OpenFileDialog openFileDialog1;
private System.Windows.Forms.Label lblFromXml;
private System.Windows.Forms.Label lblToXml;
private System.Windows.Forms.Button btnStart;
private System.Windows.Forms.ListView lvwResult;
private System.Windows.Forms.ColumnHeader ColumnTagName;
private System.Windows.Forms.ColumnHeader ColumnDataValue;
private System.Windows.Forms.ColumnHeader ColumnTagXPath;
private System.Windows.Forms.TextBox txtXPathAnalyse;
private System.Windows.Forms.ColumnHeader columnTagFound;
}
}

View File

@ -0,0 +1,201 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml;
using System.Xml.Linq;
using System.Xml.XPath;
using System.IO;
namespace WindowsFormsApp1
{
public partial class StartShell : Form
{
XmlDocument xpathTo = null;
public const string SearchFilter =
"xml files (*.xml)|*.xml|config files (*.config, xml)|*.config|All files (*.*)|*.*";
private string[] Levels = new string[100];
public StartShell()
{
InitializeComponent();
}
private void BtnFromXml_Click(object sender, EventArgs e)
{
openFileDialog1.Title = "Fetch XML-file keeping new values";
openFileDialog1.Filter = SearchFilter;
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
lblFromXml.Text = openFileDialog1.FileName;
}
}
private void BtnToXml_Click(object sender, EventArgs e)
{
openFileDialog1.Title = "Fetch XML-file to be updated";
openFileDialog1.Filter = SearchFilter;
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
lblToXml.Text = openFileDialog1.FileName;
}
}
private void BtnStart_Click(object sender, EventArgs e)
{
// XML-document analysed
XmlDocument xnode = new XmlDocument();
xnode.Load(lblFromXml.Text);
if (lblToXml.Text != "toxmlpath")
{
// XML-document for receiving file
xpathTo = new XmlDocument();
xpathTo.Load(lblToXml.Text);
}
lvwResult.Items.Clear();
Process(xnode);
// Saves to temporary file
xpathTo.Save("abc.xml");
// Move temporary file to original directory
FileInfo fi = new FileInfo(lblToXml.Text);
var actDir = fi.DirectoryName;
var createdFile = File.ReadAllBytes("abc.xml");
var fName = actDir + "\\default_" + DateTime.Now.ToShortDateString()+"__" + DateTime.Now.ToLongTimeString().Replace(":","-") + ".config";
File.WriteAllBytes(fName,createdFile);
File.Delete("abc.xml");
}
void Process(XmlNode node)
{
// Processing is a recurring process
Process(node, 0);
}
void Process(XmlNode node, int level)
{
if (node.NodeType == XmlNodeType.Text)
{
ListViewItem lviResult = new ListViewItem();
lviResult.Text = node.ParentNode.LocalName;
lviResult.SubItems.Add(node.Value);
// Find XPath for current node
var xPath = GetXPathToNode(node);
// Routine for XPath creates bad end on text-nodes / chenges to something seems working
if (xPath.Trim().Substring(xPath.Trim().Length - 9) == "/#text[1]")
{
xPath = xPath.Substring(0, xPath.Trim().Length - 9);
xPath = xPath + "/text()";
}
// Put data into ListView
lviResult.SubItems.Add(xPath);
if (lblToXml.Text != "toxmlpath")
{
XmlNode searchedField = xpathTo.SelectSingleNode(xPath);
if (searchedField != null)
{
lviResult.SubItems.Add(searchedField.InnerText);
searchedField.Value = node.Value;
}
else
{
searchedField = xpathTo.SelectSingleNode(xPath.Substring(0, xPath.Trim().Length-7));
if (searchedField.OuterXml != "")
{
lviResult.SubItems.Add(searchedField.OuterXml);
XmlElement elemSearchfield = (XmlElement) searchedField;
if (elemSearchfield.IsEmpty)
{
elemSearchfield.InnerXml = node.Value;
}
}
else lviResult.SubItems.Add("saknas!");
}
}
lvwResult.Items.Add(lviResult);
}
foreach (XmlNode child in node.ChildNodes)
{
Process(child, level + 1);
}
}
/// <summary>
/// Gets the X-Path to a given Node
/// </summary>
/// <param name="node">The Node to get the X-Path from</param>
/// <returns>The X-Path of the Node</returns>
public string GetXPathToNode(XmlNode node)
{
if (node.NodeType == XmlNodeType.Attribute)
{
// attributes have an OwnerElement, not a ParentNode; also they have
// to be matched by name, not found by position
return String.Format("{0}/@{1}", GetXPathToNode(((XmlAttribute)node).OwnerElement), node.Name);
}
if (node.ParentNode == null)
{
// the only node with no parent is the root node, which has no path
return "";
}
// Get the Index
int indexInParent = 1;
XmlNode siblingNode = node.PreviousSibling;
// Loop thru all Siblings
while (siblingNode != null)
{
// Increase the Index if the Sibling has the same Name
if (siblingNode.Name == node.Name)
{
indexInParent++;
}
siblingNode = siblingNode.PreviousSibling;
}
// the path to a node is the path to its parent, plus "/node()[n]", where n is its position among its siblings.
return String.Format("{0}/{1}[{2}]", GetXPathToNode(node.ParentNode), node.Name, indexInParent);
}
private void LvwResult_Click(object sender, EventArgs e)
{
var firstSelectedItem = lvwResult.SelectedItems[0];
var xpath = firstSelectedItem.SubItems[2].Text;
if (xpath.Trim().Substring(xpath.Trim().Length - 9) == "/#text[1]")
{
txtXPathAnalyse.Text = xpath.Substring(0, xpath.Trim().Length - 9);
}
else
{
txtXPathAnalyse.Text = xpath;
}
}
}
}

View File

@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="openFileDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View File

@ -0,0 +1,84 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{97198CCC-56C0-4ECD-AFC9-92CC531D57FD}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>WindowsFormsApp1</RootNamespace>
<AssemblyName>WindowsFormsApp1</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="StartShell.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="StartShell.Designer.cs">
<DependentUpon>StartShell.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="XpathUpd.cs" />
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<EmbeddedResource Include="StartShell.resx">
<DependentUpon>StartShell.cs</DependentUpon>
</EmbeddedResource>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@ -0,0 +1,64 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
namespace WindowsFormsApp1
{
public class XpathUpd
{
public void testXpathModifying()
{
// text xml
var xml = @"<Data >
<Inputs>
<a:ImageInput>
<a:Name>BSE</a:Name>
</a:ImageInput>
</Inputs>
</Data>";
XmlDocument xmld = new XmlDocument();
XmlNamespaceManager nsmgr; // this will hold our namespaces with their prefixes
xmld.Load(GetReader(xml, out nsmgr)); // xml can also be your file
// we are going to find a text node, hence cast to XmlText
var name2 = (XmlText)xmld.SelectSingleNode(
"/Data/Inputs/a:ImageInput/a:Name[.='BSE']/text()",
nsmgr); // here is the namespace manager so it knows what a is
if (name2 != null)
{
//name2.SetAttribute("a:Name", "{{16}}");
name2.Value = "{{16}}";
}
string AmmendedFile = @"C:\ProgramData\Oxford Instruments NanoAnalysis\XXXX NewXMLReader\Xpath_Mics_Sim.xml";
xmld.Save(AmmendedFile);
}
// Creates a reader and outputs a namespacemanager that fits for the missing namespace prefixes
XmlReader GetReader(string xml, out XmlNamespaceManager nsmgr)
{
// code example taken from
// https://blogs.msdn.microsoft.com/runeetv/2009/02/12/undeclared-namespace-in-xml-eg-xsi-is-an-undeclared-namespace/
// from author runeetv and https://blogs.msdn.microsoft.com/runeetv/author/runeetvashisht/
NameTable nt = new NameTable();
// add missing namespace prefixes
nsmgr = new XmlNamespaceManager(nt);
nsmgr.AddNamespace("a", "urn:why-was-this-left-out?");
XmlParserContext context = new XmlParserContext(null, nsmgr, null, XmlSpace.None);
XmlReaderSettings xset = new XmlReaderSettings();
xset.ConformanceLevel = ConformanceLevel.Fragment;
// return XmlReader.Create(xml, xset, context); // use this if you want xml to be a filepath
return XmlReader.Create(new StringReader(xml), xset, context);
}
}
}

View File

@ -0,0 +1 @@
6c5f03965c3e08c229aab2472d3cf7433561affc

View File

@ -0,0 +1,20 @@
D:\SebastianProblem\MoveXMLData\WindowsFormsApp1\bin\Debug\WindowsFormsApp1.exe.config
D:\SebastianProblem\MoveXMLData\WindowsFormsApp1\bin\Debug\WindowsFormsApp1.exe
D:\SebastianProblem\MoveXMLData\WindowsFormsApp1\bin\Debug\WindowsFormsApp1.pdb
D:\SebastianProblem\MoveXMLData\WindowsFormsApp1\obj\Debug\WindowsFormsApp1.csprojAssemblyReference.cache
D:\SebastianProblem\MoveXMLData\WindowsFormsApp1\obj\Debug\WindowsFormsApp1.Properties.Resources.resources
D:\SebastianProblem\MoveXMLData\WindowsFormsApp1\obj\Debug\WindowsFormsApp1.StartShell.resources
D:\SebastianProblem\MoveXMLData\WindowsFormsApp1\obj\Debug\WindowsFormsApp1.csproj.GenerateResource.cache
D:\SebastianProblem\MoveXMLData\WindowsFormsApp1\obj\Debug\WindowsFormsApp1.csproj.CoreCompileInputs.cache
D:\SebastianProblem\MoveXMLData\WindowsFormsApp1\obj\Debug\WindowsFormsApp1.exe
D:\SebastianProblem\MoveXMLData\WindowsFormsApp1\obj\Debug\WindowsFormsApp1.pdb
D:\Sebastian\ConfigFix\MoveXMLData\WindowsFormsApp1\bin\Debug\WindowsFormsApp1.exe.config
D:\Sebastian\ConfigFix\MoveXMLData\WindowsFormsApp1\bin\Debug\WindowsFormsApp1.exe
D:\Sebastian\ConfigFix\MoveXMLData\WindowsFormsApp1\bin\Debug\WindowsFormsApp1.pdb
D:\Sebastian\ConfigFix\MoveXMLData\WindowsFormsApp1\obj\Debug\WindowsFormsApp1.csprojAssemblyReference.cache
D:\Sebastian\ConfigFix\MoveXMLData\WindowsFormsApp1\obj\Debug\WindowsFormsApp1.Properties.Resources.resources
D:\Sebastian\ConfigFix\MoveXMLData\WindowsFormsApp1\obj\Debug\WindowsFormsApp1.StartShell.resources
D:\Sebastian\ConfigFix\MoveXMLData\WindowsFormsApp1\obj\Debug\WindowsFormsApp1.csproj.GenerateResource.cache
D:\Sebastian\ConfigFix\MoveXMLData\WindowsFormsApp1\obj\Debug\WindowsFormsApp1.csproj.CoreCompileInputs.cache
D:\Sebastian\ConfigFix\MoveXMLData\WindowsFormsApp1\obj\Debug\WindowsFormsApp1.exe
D:\Sebastian\ConfigFix\MoveXMLData\WindowsFormsApp1\obj\Debug\WindowsFormsApp1.pdb

View File

@ -0,0 +1 @@
64189f8a8db434f4fb2fa6b7a4d692e3501df3ab