/// <summary> /// Generates the code from the contents of the address space. /// </summary> public void Validate(Stream stream) { m_schema.Load(stream); foreach (XmlNode import in m_schema.ChildNodes) { if (import.NamespaceURI == Namespaces.OpcUa) { StreamReader strm = new StreamReader(Assembly.Load(new AssemblyName("Opc.Ua.Core")).GetManifestResourceStream("Opc.Ua.Model.Opc.Ua.Types.xsd")); m_schema.Load(strm); continue; } string location = null; if (!KnownFiles.TryGetValue(import.NamespaceURI, out location)) { location = import.NamespaceURI; } FileInfo fileInfo = new FileInfo(location); if (!fileInfo.Exists) { StreamReader strm = new StreamReader(Assembly.Load(new AssemblyName("Opc.Ua.Core")).GetManifestResourceStream(location)); m_schema.Load(strm); } else { Stream strm = File.OpenRead(location); m_schema.Load(strm); } } }
public bool Exists(string Uri) { string toMatch = TrimTilde(Uri); if (Path.DirectorySeparatorChar == '\\') { toMatch = toMatch.Replace("/", "\\"); } if (!this.IsCaseSensitive) { toMatch = toMatch.ToLower(CultureInfo.CurrentCulture); } if (KnownFiles.TryGetValue(Uri, out bool result)) { return(result); } else { result = File.Exists(Path.Combine(this.ApplicationPath, toMatch)); KnownFiles.TryAdd(toMatch, result); return(result); } }
/// <summary> /// Generates the code from the contents of the address space. /// </summary> public void Validate(Stream stream) { using (var xmlReader = XmlReader.Create(stream, Utils.DefaultXmlReaderSettings())) { m_schema.Load(xmlReader); } foreach (XmlNode import in m_schema.ChildNodes) { if (import.NamespaceURI == Namespaces.OpcUa) { using (StreamReader strm = new StreamReader(Assembly.Load(new AssemblyName("Opc.Ua.Core")).GetManifestResourceStream("Opc.Ua.Model.Opc.Ua.Types.xsd"))) using (var xmlReader = XmlReader.Create(strm, Utils.DefaultXmlReaderSettings())) { m_schema.Load(xmlReader); } continue; } string location = null; if (!KnownFiles.TryGetValue(import.NamespaceURI, out location)) { location = import.NamespaceURI; } FileInfo fileInfo = new FileInfo(location); if (!fileInfo.Exists) { using (StreamReader strm = new StreamReader(Assembly.Load(new AssemblyName("Opc.Ua.Core")).GetManifestResourceStream(location))) using (var xmlReader = XmlReader.Create(strm, Utils.DefaultXmlReaderSettings())) { m_schema.Load(xmlReader); } } else { using (Stream strm = File.OpenRead(location)) using (var xmlReader = XmlReader.Create(strm, Utils.DefaultXmlReaderSettings())) { m_schema.Load(xmlReader); } } } }
/// <summary> /// Generates the code from the contents of the address space. /// </summary> public void Validate(Stream stream) { m_schema = XmlSchema.Read(stream, new ValidationEventHandler(OnValidate)); foreach (XmlSchemaImport import in m_schema.Includes) { if (import.Namespace == Namespaces.OpcUa) { StreamReader strm = new StreamReader(Assembly.Load("Opc.Ua.Core").GetManifestResourceStream("Opc.Ua.Model.Opc.Ua.Types.xsd")); import.Schema = XmlSchema.Read(strm, new ValidationEventHandler(OnValidate)); continue; } string location = null; if (!KnownFiles.TryGetValue(import.Namespace, out location)) { location = import.SchemaLocation; } FileInfo fileInfo = new FileInfo(location); if (!fileInfo.Exists) { using (StreamReader strm = new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream(location))) { import.Schema = XmlSchema.Read(strm, new ValidationEventHandler(OnValidate)); } } else { using (Stream strm = File.OpenRead(location)) { import.Schema = XmlSchema.Read(strm, new ValidationEventHandler(OnValidate)); } } } m_schemaSet = new XmlSchemaSet(); m_schemaSet.Add(m_schema); m_schemaSet.Compile(); }
/// <summary> /// Generates the code from the contents of the address space. /// </summary> public void Validate(Stream stream) { using (var xmlReader = XmlReader.Create(stream, Utils.DefaultXmlReaderSettings())) { m_schema = XmlSchema.Read(xmlReader, new ValidationEventHandler(OnValidate)); var assembly = typeof(XmlSchemaValidator).GetTypeInfo().Assembly; foreach (XmlSchemaImport import in m_schema.Includes) { string location = null; if (!KnownFiles.TryGetValue(import.Namespace, out location)) { location = import.SchemaLocation; } FileInfo fileInfo = new FileInfo(location); var settings = Utils.DefaultXmlReaderSettings(); if (!fileInfo.Exists) { using (StreamReader strm = new StreamReader(assembly.GetManifestResourceStream(location))) using (var schemaReader = XmlReader.Create(strm, settings)) { import.Schema = XmlSchema.Read(schemaReader, new ValidationEventHandler(OnValidate)); } } else { using (Stream strm = File.OpenRead(location)) using (var schemaReader = XmlReader.Create(strm, settings)) { import.Schema = XmlSchema.Read(schemaReader, new ValidationEventHandler(OnValidate)); } } } m_schemaSet = new XmlSchemaSet(); m_schemaSet.Add(m_schema); m_schemaSet.Compile(); } }