diff --git a/src/AasCore.Aas3_0/LICENSE.txt b/src/AasCore.Aas3_0/LICENSE.txt index 2e5ee87b9..75f36a4ff 100644 --- a/src/AasCore.Aas3_0/LICENSE.txt +++ b/src/AasCore.Aas3_0/LICENSE.txt @@ -1,4 +1,4 @@ -Copyright (c) 2018-2021 Festo AG & Co. KG +Copyright (c) 2018-2023 Festo AG & Co. KG , author: Michael Hoffmeister diff --git a/src/AasxAmlImExport/AasAmlMatcher.cs b/src/AasxAmlImExport/AasAmlMatcher.cs index fbab2434b..3b0b08e85 100644 --- a/src/AasxAmlImExport/AasAmlMatcher.cs +++ b/src/AasxAmlImExport/AasAmlMatcher.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018-2021 Festo AG & Co. KG +Copyright (c) 2018-2023 Festo AG & Co. KG Author: Michael Hoffmeister This source code is licensed under the Apache License 2.0 (see LICENSE.txt). diff --git a/src/AasxAmlImExport/AmlConst.cs b/src/AasxAmlImExport/AmlConst.cs index 0d4339843..6ef720305 100644 --- a/src/AasxAmlImExport/AmlConst.cs +++ b/src/AasxAmlImExport/AmlConst.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018-2021 Festo AG & Co. KG +Copyright (c) 2018-2023 Festo AG & Co. KG Author: Michael Hoffmeister This source code is licensed under the Apache License 2.0 (see LICENSE.txt). diff --git a/src/AasxAmlImExport/AmlExport.cs b/src/AasxAmlImExport/AmlExport.cs index 08500926c..a6df6e5cd 100644 --- a/src/AasxAmlImExport/AmlExport.cs +++ b/src/AasxAmlImExport/AmlExport.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018-2021 Festo AG & Co. KG +Copyright (c) 2018-2023 Festo AG & Co. KG Author: Michael Hoffmeister This source code is licensed under the Apache License 2.0 (see LICENSE.txt). diff --git a/src/AasxAmlImExport/AmlImport.cs b/src/AasxAmlImExport/AmlImport.cs index 85ce92d6d..f878c7785 100644 --- a/src/AasxAmlImExport/AmlImport.cs +++ b/src/AasxAmlImExport/AmlImport.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018-2021 Festo AG & Co. KG +Copyright (c) 2018-2023 Festo AG & Co. KG Author: Michael Hoffmeister This source code is licensed under the Apache License 2.0 (see LICENSE.txt). diff --git a/src/AasxAmlImExport/LICENSE.txt b/src/AasxAmlImExport/LICENSE.txt index 2e5ee87b9..75f36a4ff 100644 --- a/src/AasxAmlImExport/LICENSE.txt +++ b/src/AasxAmlImExport/LICENSE.txt @@ -1,4 +1,4 @@ -Copyright (c) 2018-2021 Festo AG & Co. KG +Copyright (c) 2018-2023 Festo AG & Co. KG , author: Michael Hoffmeister diff --git a/src/AasxBammRdfImExport/LICENSE.txt b/src/AasxBammRdfImExport/LICENSE.txt index 2e5ee87b9..75f36a4ff 100644 --- a/src/AasxBammRdfImExport/LICENSE.txt +++ b/src/AasxBammRdfImExport/LICENSE.txt @@ -1,4 +1,4 @@ -Copyright (c) 2018-2021 Festo AG & Co. KG +Copyright (c) 2018-2023 Festo AG & Co. KG , author: Michael Hoffmeister diff --git a/src/AasxCsharpLibrary.Tests/LICENSE.txt b/src/AasxCsharpLibrary.Tests/LICENSE.txt index 2e5ee87b9..75f36a4ff 100644 --- a/src/AasxCsharpLibrary.Tests/LICENSE.txt +++ b/src/AasxCsharpLibrary.Tests/LICENSE.txt @@ -1,4 +1,4 @@ -Copyright (c) 2018-2021 Festo AG & Co. KG +Copyright (c) 2018-2023 Festo AG & Co. KG , author: Michael Hoffmeister diff --git a/src/AasxCsharpLibrary/AasxCompatibilityModels/V10/AdminShellV10.cs b/src/AasxCsharpLibrary/AasxCompatibilityModels/V10/AdminShellV10.cs index 0318d302f..09d163481 100644 --- a/src/AasxCsharpLibrary/AasxCompatibilityModels/V10/AdminShellV10.cs +++ b/src/AasxCsharpLibrary/AasxCompatibilityModels/V10/AdminShellV10.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018-2021 Festo AG & Co. KG +Copyright (c) 2018-2023 Festo AG & Co. KG Author: Michael Hoffmeister This source code is licensed under the Apache License 2.0 (see LICENSE.txt). diff --git a/src/AasxCsharpLibrary/AasxCompatibilityModels/V20/AdminShell.cs b/src/AasxCsharpLibrary/AasxCompatibilityModels/V20/AdminShell.cs index f7e190c72..805ef5cee 100644 --- a/src/AasxCsharpLibrary/AasxCompatibilityModels/V20/AdminShell.cs +++ b/src/AasxCsharpLibrary/AasxCompatibilityModels/V20/AdminShell.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018-2021 Festo AG & Co. KG +Copyright (c) 2018-2023 Festo AG & Co. KG Author: Michael Hoffmeister This source code is licensed under the Apache License 2.0 (see LICENSE.txt). diff --git a/src/AasxCsharpLibrary/AasxCompatibilityModels/V20/AdminShellConverters.cs b/src/AasxCsharpLibrary/AasxCompatibilityModels/V20/AdminShellConverters.cs index 1fc738e87..0a7906dd8 100644 --- a/src/AasxCsharpLibrary/AasxCompatibilityModels/V20/AdminShellConverters.cs +++ b/src/AasxCsharpLibrary/AasxCompatibilityModels/V20/AdminShellConverters.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018-2021 Festo AG & Co. KG +Copyright (c) 2018-2023 Festo AG & Co. KG Author: Michael Hoffmeister This source code is licensed under the Apache License 2.0 (see LICENSE.txt). diff --git a/src/AasxCsharpLibrary/AasxCompatibilityModels/V20/AdminShellUtil.cs b/src/AasxCsharpLibrary/AasxCompatibilityModels/V20/AdminShellUtil.cs index cae294406..106024766 100644 --- a/src/AasxCsharpLibrary/AasxCompatibilityModels/V20/AdminShellUtil.cs +++ b/src/AasxCsharpLibrary/AasxCompatibilityModels/V20/AdminShellUtil.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018-2021 Festo AG & Co. KG +Copyright (c) 2018-2023 Festo AG & Co. KG Author: Michael Hoffmeister This source code is licensed under the Apache License 2.0 (see LICENSE.txt). diff --git a/src/AasxCsharpLibrary/AasxCompatibilityModels/V20/AdminShellValidate.cs b/src/AasxCsharpLibrary/AasxCompatibilityModels/V20/AdminShellValidate.cs index 5870be76e..fb7c67882 100644 --- a/src/AasxCsharpLibrary/AasxCompatibilityModels/V20/AdminShellValidate.cs +++ b/src/AasxCsharpLibrary/AasxCompatibilityModels/V20/AdminShellValidate.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018-2021 Festo AG & Co. KG +Copyright (c) 2018-2023 Festo AG & Co. KG Author: Michael Hoffmeister This source code is licensed under the Apache License 2.0 (see LICENSE.txt). diff --git a/src/AasxCsharpLibrary/AdminShellCollections.cs b/src/AasxCsharpLibrary/AdminShellCollections.cs index cba83d779..774190719 100644 --- a/src/AasxCsharpLibrary/AdminShellCollections.cs +++ b/src/AasxCsharpLibrary/AdminShellCollections.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018-2021 Festo AG & Co. KG +Copyright (c) 2018-2023 Festo AG & Co. KG Author: Michael Hoffmeister This source code is licensed under the Apache License 2.0 (see LICENSE.txt). diff --git a/src/AasxCsharpLibrary/AdminShellConverters.cs b/src/AasxCsharpLibrary/AdminShellConverters.cs index 0e7f033cd..18e9ee7fd 100644 --- a/src/AasxCsharpLibrary/AdminShellConverters.cs +++ b/src/AasxCsharpLibrary/AdminShellConverters.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018-2021 Festo AG & Co. KG +Copyright (c) 2018-2023 Festo AG & Co. KG Author: Michael Hoffmeister This source code is licensed under the Apache License 2.0 (see LICENSE.txt). diff --git a/src/AasxCsharpLibrary/AdminShellPackageEnv.cs b/src/AasxCsharpLibrary/AdminShellPackageEnv.cs index db8f11931..5aadd537e 100644 --- a/src/AasxCsharpLibrary/AdminShellPackageEnv.cs +++ b/src/AasxCsharpLibrary/AdminShellPackageEnv.cs @@ -1,1536 +1,1536 @@ -/* -Copyright (c) 2018-2021 Festo AG & Co. KG -Author: Michael Hoffmeister - -This source code is licensed under the Apache License 2.0 (see LICENSE.txt). - -This source code may use other Open Source software components (see LICENSE.txt). -*/ - -using Extensions; -using Newtonsoft.Json; -using System; -using System.Collections.Generic; -using System.IO; -using System.IO.Packaging; -using System.Linq; -using System.Text.RegularExpressions; -using System.Threading.Tasks; -using System.Xml; -using System.Xml.Serialization; - -namespace AdminShellNS -{ - /// - /// This class lets an outer functionality keep track on the supplementary files, which are in or - /// are pending to be added or deleted to an Package. - /// - public class AdminShellPackageSupplementaryFile /*: IReferable*/ - { - public delegate byte[] SourceGetByteChunk(); - - public enum LocationType { InPackage, AddPending, DeletePending } - - public enum SpecialHandlingType { None, EmbedAsThumbnail } - - public readonly Uri Uri = null; - - public readonly string UseMimeType = null; - - public readonly string SourceLocalPath = null; - public readonly SourceGetByteChunk SourceGetBytesDel = null; - - public LocationType Location; - public readonly SpecialHandlingType SpecialHandling; - - public AdminShellPackageSupplementaryFile( - Uri uri, string sourceLocalPath = null, LocationType location = LocationType.InPackage, - SpecialHandlingType specialHandling = SpecialHandlingType.None, - SourceGetByteChunk sourceGetBytesDel = null, string useMimeType = null) - { - Uri = uri; - UseMimeType = useMimeType; - SourceLocalPath = sourceLocalPath; - SourceGetBytesDel = sourceGetBytesDel; - Location = location; - SpecialHandling = specialHandling; - } - - // class derives from Referable in order to provide GetElementName - public string GetElementName() - { - return "File"; - } - - } - - public class ListOfAasSupplementaryFile : List - { - public AdminShellPackageSupplementaryFile FindByUri(string path) - { - if (path == null) - return null; - - return this.FirstOrDefault( - x => x?.Uri?.ToString().Trim() == path.Trim()); - } - } - - /// - /// Provides (static?) helpers for serializing AAS.. - /// - public static class AdminShellSerializationHelper - { - - public static string TryReadXmlFirstElementNamespaceURI(Stream s) - { - string res = null; - try - { - var xr = System.Xml.XmlReader.Create(s); - int i = 0; - while (xr.Read()) - { - // limit amount of read - i++; - if (i > 99) - // obviously not found - break; - - // find element - if (xr.NodeType == System.Xml.XmlNodeType.Element) - { - res = xr.NamespaceURI; - break; - } - } - xr.Close(); - } - catch (Exception ex) - { - LogInternally.That.SilentlyIgnoredError(ex); - } - - // return to zero pos - s.Seek(0, SeekOrigin.Begin); - - // give back - return res; - } - - /// - /// Skips first few tokens of an XML content until first "real" element is encountered - /// - /// - public static void XmlSkipHeader(XmlReader xmlReader) - { - while (xmlReader.NodeType == XmlNodeType.XmlDeclaration || - xmlReader.NodeType == XmlNodeType.Whitespace || - xmlReader.NodeType == XmlNodeType.Comment || - xmlReader.NodeType == XmlNodeType.None) - xmlReader.Read(); - } - - /// - /// De-serialize an open stream into Environment. Does version/ compatibility management. - /// - /// Open for read stream - /// - public static AasCore.Aas3_0.Environment DeserializeXmlFromStreamWithCompat(Stream s) - { - // not sure - AasCore.Aas3_0.Environment res = null; - - // try get first element - var nsuri = TryReadXmlFirstElementNamespaceURI(s); - - // read V1.0? - if (nsuri != null && nsuri.Trim() == "http://www.admin-shell.io/aas/1/0") - { -#if !DoNotUseAasxCompatibilityModels - XmlSerializer serializer = new XmlSerializer( - typeof(AasxCompatibilityModels.AdminShellV10.AdministrationShellEnv), - "http://www.admin-shell.io/aas/1/0"); - var v10 = serializer.Deserialize(s) as AasxCompatibilityModels.AdminShellV10.AdministrationShellEnv; - //res = new AdministrationShellEnv(v10); - res = new AasCore.Aas3_0.Environment(new List(), new List(), new List()); - res.ConvertFromV10(v10); - return res; -#else - throw (new Exception("Cannot handle AAS file format http://www.admin-shell.io/aas/1/0 !")); -#endif - } - - // read V2.0? - if (nsuri != null && nsuri.Trim() == "http://www.admin-shell.io/aas/2/0") - { -#if !DoNotUseAasxCompatibilityModels - XmlSerializer serializer = new XmlSerializer( - typeof(AasxCompatibilityModels.AdminShellV20.AdministrationShellEnv), - "http://www.admin-shell.io/aas/2/0"); - var v20 = serializer.Deserialize(s) as AasxCompatibilityModels.AdminShellV20.AdministrationShellEnv; - //res = new AdministrationShellEnv(v20); - res = new AasCore.Aas3_0.Environment(new List(), new List(), new List()); - res.ConvertFromV20(v20); - return res; -#else - throw (new Exception("Cannot handle AAS file format http://www.admin-shell.io/aas/1/0 !")); -#endif - } - - // read V3.0? - if (nsuri != null && nsuri.Trim() == Xmlization.NS) - { - //XmlSerializer serializer = new XmlSerializer( - // typeof(AasCore.Aas3_0_RC02.Environment), "http://www.admin-shell.io/aas/3/0"); - //res = serializer.Deserialize(s) as AasCore.Aas3_0_RC02.Environment; - - using (var xmlReader = XmlReader.Create(s)) - { - // TODO (MIHO, 2022-12-26): check if could be feature of AAS core - XmlSkipHeader(xmlReader); - res = Xmlization.Deserialize.EnvironmentFrom(xmlReader); - return res; - } - } - - // nope! - return null; - } - - //public static JsonSerializer BuildDefaultAasxJsonSerializer() - //{ - // var serializer = new JsonSerializer(); - // serializer.Converters.Add( - // new AdminShellConverters.JsonAasxConverter( - // "modelType", "name")); - // return serializer; - //} - - public static T DeserializeFromJSON(string data) where T : IReferable - { - //using (var tr = new StringReader(data)) - //{ - //var serializer = BuildDefaultAasxJsonSerializer(); - //var rf = (T)serializer.Deserialize(tr, typeof(T)); - - var node = System.Text.Json.Nodes.JsonNode.Parse(data); - var rf = Jsonization.Deserialize.IReferableFrom(node); - - return (T)rf; - //} - } - - //public static T DeserializeFromJSON(JToken obj) where T : IReferable - //{ - // if (obj == null) - // return default(T); - // var serializer = BuildDefaultAasxJsonSerializer(); - // var rf = obj.ToObject(serializer); - // return rf; - //} - - ///// - ///// Use this, if DeserializeFromJSON is too tight. - ///// - //public static T DeserializePureObjectFromJSON(string data) - //{ - // using (var tr = new StringReader(data)) - // { - // //var serializer = BuildDefaultAasxJsonSerializer(); - // //var rf = (T)serializer.Deserialize(tr, typeof(T)); - // return null; - // } - //} - } - - /// - /// This class encapsulates an AdminShellEnvironment and supplementary files into an AASX Package. - /// Specifically has the capability to load, update and store .XML, .JSON and .AASX packages. - /// - public class AdminShellPackageEnv : IDisposable - { - private string _fn = "New Package"; - - private string _tempFn = null; - - private AasCore.Aas3_0.Environment _aasEnv = new AasCore.Aas3_0.Environment(new List(), new List(), new List()); - private Package _openPackage = null; - private readonly ListOfAasSupplementaryFile _pendingFilesToAdd = new ListOfAasSupplementaryFile(); - private readonly ListOfAasSupplementaryFile _pendingFilesToDelete = new ListOfAasSupplementaryFile(); - - public AdminShellPackageEnv() { } - - public AdminShellPackageEnv(AasCore.Aas3_0.Environment env) - { - if (env != null) - _aasEnv = env; - } - - public AdminShellPackageEnv(string fn, bool indirectLoadSave = false) - { - Load(fn, indirectLoadSave); - } - - public bool IsOpen - { - get - { - return _openPackage != null; - } - } - - public void SetFilename(string fileName) - { - _fn = fileName; - } - - public string Filename - { - get - { - return _fn; - } - } - - public AasCore.Aas3_0.Environment AasEnv - { - get - { - return _aasEnv; - } - } - - private static AasCore.Aas3_0.Environment LoadXml(string fn) - { - try - { - using (var reader = new StreamReader(fn)) - { - var aasEnv = AdminShellSerializationHelper.DeserializeXmlFromStreamWithCompat( - reader.BaseStream); - - if (aasEnv == null) - throw new Exception("Type error for XML file"); - - return aasEnv; - } - } - catch (Exception ex) - { - throw new Exception( - $"While reading AAS {fn} at {AdminShellUtil.ShortLocation(ex)} gave: {ex.Message}"); - } - } - - private static AasCore.Aas3_0.Environment LoadJson(string fn) - { - try - { - using (var file = System.IO.File.OpenRead(fn)) - { - //// TODO (Michael Hoffmeister, 2020-08-01): use a unified function to create a serializer - //var serializer = new JsonSerializer(); - //serializer.Converters.Add( - // new AdminShellConverters.JsonAasxConverter( - // "modelType", "name")); - - //var aasEnv = (AasCore.Aas3_0_RC02.Environment)serializer.Deserialize( - // file, typeof(AasCore.Aas3_0_RC02.Environment)); - - var node = System.Text.Json.Nodes.JsonNode.Parse(file); - var aasEnv = Jsonization.Deserialize.EnvironmentFrom(node); - - return aasEnv; - } - } - catch (Exception ex) - { - throw new Exception( - $"While reading AAS {fn} at {AdminShellUtil.ShortLocation(ex)} gave: {ex.Message}"); - } - } - - /// is unequal if indirectLoadSave is used. - private static (AasCore.Aas3_0.Environment, Package) LoadPackageAasx(string fn, string fnToLoad) - { - AasCore.Aas3_0.Environment aasEnv; - Package openPackage = null; - - Package package; - try - { - package = Package.Open(fnToLoad, FileMode.Open); - } - catch (Exception ex) - { - throw new Exception( - fn == fnToLoad - ? $"While opening the package to read AASX {fn} " + - $"at {AdminShellUtil.ShortLocation(ex)} gave: {ex.Message}" - : $"While opening the package to read AASX {fn} indirectly from {fnToLoad} " + - $"at {AdminShellUtil.ShortLocation(ex)} gave: {ex.Message}"); - } - - try - { - // get the origin from the package - PackagePart originPart = null; - var xs = package.GetRelationshipsByType( - "http://www.admin-shell.io/aasx/relationships/aasx-origin"); - foreach (var x in xs) - if (x.SourceUri.ToString() == "/") - { - originPart = package.GetPart(x.TargetUri); - break; - } - - if (originPart == null) - throw (new Exception("Unable to find AASX origin. Aborting!")); - - // get the specs from the package - PackagePart specPart = null; - xs = originPart.GetRelationshipsByType("http://www.admin-shell.io/aasx/relationships/aas-spec"); - foreach (var x in xs) - { - specPart = package.GetPart(x.TargetUri); - break; - } - - if (specPart == null) - throw (new Exception("Unable to find AASX spec(s). Aborting!")); - - // open spec part to read - try - { - if (specPart.Uri.ToString().ToLower().Trim().EndsWith("json")) - { - using (var s = specPart.GetStream(FileMode.Open)) - { - //using (var file = new StreamReader(s)) - //{ - //JsonSerializer serializer = new JsonSerializer(); - //serializer.Converters.Add( - // new AdminShellConverters.JsonAasxConverter( - // "modelType", "name")); - - //aasEnv = (AasCore.Aas3_0_RC02.Environment)serializer.Deserialize( - // file, typeof(AasCore.Aas3_0_RC02.Environment)); - - var node = System.Text.Json.Nodes.JsonNode.Parse(s); - aasEnv = Jsonization.Deserialize.EnvironmentFrom(node); - //} - } - } - else - { - using (var s = specPart.GetStream(FileMode.Open)) - { - // own catch loop to be more specific - aasEnv = AdminShellSerializationHelper.DeserializeXmlFromStreamWithCompat(s); - openPackage = package; - - if (aasEnv == null) - throw new Exception("Type error for XML file!"); - } - } - } - catch (Exception ex) - { - throw new Exception( - fn == fnToLoad - ? $"While reading spec from the AASX {fn} " + - $"at {AdminShellUtil.ShortLocation(ex)} gave: {ex.Message}" - : $"While reading spec from the {fn} (and indirectly over {fnToLoad}) " + - $"at {AdminShellUtil.ShortLocation(ex)} gave: {ex.Message}"); - } - } - catch (Exception ex) - { - throw new Exception( - fn == fnToLoad - ? $"While reading the AASX {fn} " + - $"at {AdminShellUtil.ShortLocation(ex)} gave: {ex.Message}" - : $"While reading the {fn} (and indirectly over {fnToLoad}) " + - $"at {AdminShellUtil.ShortLocation(ex)} gave: {ex.Message}"); - } - finally - { - if (openPackage == null) - { - package.Close(); - } - } - - return (aasEnv, openPackage); - } - - public void Load(string fn, bool indirectLoadSave = false) - { - _fn = fn; - _openPackage?.Close(); - _openPackage = null; - - string extension = Path.GetExtension(fn).ToLower(); - switch (extension) - { - case ".xml": - { - _aasEnv = LoadXml(fn); - break; - } - case ".json": - { - _aasEnv = LoadJson(fn); - break; - } - case ".aasx": - { - var fnToLoad = fn; - _tempFn = null; - if (indirectLoadSave) - { - try - { - _tempFn = System.IO.Path.GetTempFileName().Replace(".tmp", ".aasx"); - System.IO.File.Copy(fn, _tempFn); - fnToLoad = _tempFn; - - } - catch (Exception ex) - { - throw new Exception( - $"While copying AASX {fn} for indirect load to {fnToLoad} " + - $"at {AdminShellUtil.ShortLocation(ex)} gave: {ex.Message}"); - } - } - - // load package AASX - (_aasEnv, _openPackage) = LoadPackageAasx(fn, fnToLoad); - break; - } - default: - throw new Exception( - $"Does not know how to handle the extension {extension} of the file: {fn}"); - } - } - - public void SetTempFn(string fn) - { - try - { - _tempFn = System.IO.Path.GetTempFileName().Replace(".tmp", ".aasx"); - System.IO.File.Copy(fn, _tempFn); - - } - catch (Exception ex) - { - throw new Exception( - $"While copying AASX {fn}" + - $"at {AdminShellUtil.ShortLocation(ex)} gave: {ex.Message}"); - } - } - - public void LoadFromAasEnvString(string content) - { - try - { - //using (var file = new StringReader(content)) - //{ - // TODO (Michael Hoffmeister, 2020-08-01): use a unified function to create a serializer - //JsonSerializer serializer = new JsonSerializer(); - //serializer.Converters.Add(new AdminShellConverters.JsonAasxConverter("modelType", "name")); - //_aasEnv = (AasCore.Aas3_0_RC02.Environment)serializer.Deserialize( - // file, typeof(AasCore.Aas3_0_RC02.Environment)); - - var node = System.Text.Json.Nodes.JsonNode.Parse(content); - _aasEnv = Jsonization.Deserialize.EnvironmentFrom(node); - //} - } - catch (Exception ex) - { - throw (new Exception( - string.Format("While reading AASENV string {0} gave: {1}", - AdminShellUtil.ShortLocation(ex), ex.Message))); - } - } - - public enum SerializationFormat { None, Xml, Json }; - - //public static XmlSerializerNamespaces GetXmlDefaultNamespaces() - //{ - // var nss = new XmlSerializerNamespaces(); - // nss.Add("xsi", System.Xml.Schema.XmlSchema.InstanceNamespace); - // nss.Add("aas", "http://www.admin-shell.io/aas/2/0"); - // nss.Add("IEC", "http://www.admin-shell.io/IEC61360/2/0"); - // nss.Add("abac", "http://www.admin-shell.io/aas/abac/2/0"); - // return nss; - //} - - public bool SaveAs(string fn, bool writeFreshly = false, SerializationFormat prefFmt = SerializationFormat.None, - MemoryStream useMemoryStream = null, bool saveOnlyCopy = false) - { - // silently fix flaws - _aasEnv?.SilentFix30(); - - // ok, which format? - if (fn.ToLower().EndsWith(".xml")) - { - // save only XML - if (!saveOnlyCopy) - _fn = fn; - try - { - Stream s = (useMemoryStream != null) - ? (Stream)useMemoryStream - : System.IO.File.Open(fn, FileMode.Create, FileAccess.Write); - - try - { - // TODO (Michael Hoffmeister, 2020-08-01): use a unified function to create a serializer - //var serializer = new XmlSerializer(typeof(AasCore.Aas3_0_RC02.Environment)); - //var nss = GetXmlDefaultNamespaces(); - //serializer.Serialize(s, _aasEnv, nss); - - var writer = XmlWriter.Create(s, new XmlWriterSettings() - { - Indent = true, - OmitXmlDeclaration = true - }); - Xmlization.Serialize.To( - _aasEnv, writer); - writer.Flush(); - writer.Close(); - s.Flush(); - } - finally - { - // close? - if (useMemoryStream == null) - s.Close(); - } - } - catch (Exception ex) - { - throw (new Exception( - string.Format("While writing AAS {0} at {1} gave: {2}", - fn, AdminShellUtil.ShortLocation(ex), ex.Message))); - } - return true; - } - - if (fn.ToLower().EndsWith(".json")) - { - // save only JSON - // This functionality is an initial test. - if (!saveOnlyCopy) - _fn = fn; - try - { - Stream s = (useMemoryStream != null) ? (Stream)useMemoryStream - : System.IO.File.Open(fn, FileMode.Create, FileAccess.Write); - - try - { - //// TODO (Michael Hoffmeister, 2020-08-01): use a unified function to create a serializer - //JsonSerializer serializer = new JsonSerializer() - //{ - // NullValueHandling = NullValueHandling.Ignore, - // ReferenceLoopHandling = ReferenceLoopHandling.Serialize, - // Formatting = Newtonsoft.Json.Formatting.Indented - //}; - - //var sw = new StreamWriter(s); - //var writer = new JsonTextWriter(sw); - - //serializer.Serialize(writer, _aasEnv); - //writer.Flush(); - //sw.Flush(); - //s.Flush(); - - //if (useMemoryStream == null) - //{ - // writer.Close(); - // sw.Close(); - //} - - using (var wr = new System.Text.Json.Utf8JsonWriter(s)) - { - Jsonization.Serialize.ToJsonObject(_aasEnv).WriteTo(wr, - new System.Text.Json.JsonSerializerOptions() - { - WriteIndented = true - }); - wr.Flush(); - s.Flush(); - } - } - finally - { - // close? - if (useMemoryStream == null) - s.Close(); - } - } - catch (Exception ex) - { - throw (new Exception( - string.Format("While writing AAS {0} at {1} gave: {2}", - fn, AdminShellUtil.ShortLocation(ex), ex.Message))); - } - return true; - } - - if (fn.ToLower().EndsWith(".aasx")) - { - // save package AASX - try - { - // We want existing contents to be preserved, but do not want to allow the change of the file name. - // Therefore: copy the file to a new name, then re-open. - // fn could be changed, therefore close "old" package first - if (_openPackage != null) - { - try - { - _openPackage.Close(); - if (!writeFreshly) - { - if (_tempFn != null) - System.IO.File.Copy(_tempFn, fn); - else - { - /* TODO (MIHO, 2021-01-02): check again. - * Revisiting this code after a while, and after - * the code has undergo some changes by MR, the following copy command needed - * to be amended with a if to protect against self-copy. */ - if (_fn != fn) - System.IO.File.Copy(_fn, fn); - } - } - } - catch (Exception ex) - { - LogInternally.That.SilentlyIgnoredError(ex); - } - _openPackage = null; - } - - // approach is to utilize the existing package, if possible. If not, create from scratch - Package package = null; - if (useMemoryStream != null) - { - package = Package.Open( - useMemoryStream, (writeFreshly) ? FileMode.Create : FileMode.OpenOrCreate); - } - else - { - package = Package.Open( - (_tempFn != null) ? _tempFn : fn, - (writeFreshly) ? FileMode.Create : FileMode.OpenOrCreate); - } - _fn = fn; - - // get the origin from the package - PackagePart originPart = null; - var xs = package.GetRelationshipsByType( - "http://www.admin-shell.io/aasx/relationships/aasx-origin"); - foreach (var x in xs) - if (x.SourceUri.ToString() == "/") - { - originPart = package.GetPart(x.TargetUri); - break; - } - if (originPart == null) - { - // create, as not existing - originPart = package.CreatePart( - new Uri("/aasx/aasx-origin", UriKind.RelativeOrAbsolute), - System.Net.Mime.MediaTypeNames.Text.Plain, CompressionOption.Maximum); - using (var s = originPart.GetStream(FileMode.Create)) - { - var bytes = System.Text.Encoding.ASCII.GetBytes("Intentionally empty."); - s.Write(bytes, 0, bytes.Length); - } - package.CreateRelationship( - originPart.Uri, TargetMode.Internal, - "http://www.admin-shell.io/aasx/relationships/aasx-origin"); - } - - // get the specs from the package - PackagePart specPart = null; - PackageRelationship specRel = null; - xs = originPart.GetRelationshipsByType("http://www.admin-shell.io/aasx/relationships/aas-spec"); - foreach (var x in xs) - { - specRel = x; - specPart = package.GetPart(x.TargetUri); - break; - } - - // check, if we have to change the spec part - if (specPart != null && specRel != null) - { - var name = System.IO.Path.GetFileNameWithoutExtension( - specPart.Uri.ToString()).ToLower().Trim(); - var ext = System.IO.Path.GetExtension(specPart.Uri.ToString()).ToLower().Trim(); - if ((ext == ".json" && prefFmt == SerializationFormat.Xml) - || (ext == ".xml" && prefFmt == SerializationFormat.Json) - || (name.StartsWith("aasenv-with-no-id"))) - { - // try kill specpart - try - { - originPart.DeleteRelationship(specRel.Id); - package.DeletePart(specPart.Uri); - } - catch (Exception ex) - { - LogInternally.That.SilentlyIgnoredError(ex); - } - finally { specPart = null; specRel = null; } - } - } - - if (specPart == null) - { - // create, as not existing - var frn = "aasenv-with-no-id"; - if (_aasEnv.AssetAdministrationShells.Count > 0) - frn = _aasEnv.AssetAdministrationShells[0].GetFriendlyName() ?? frn; - var aas_spec_fn = "/aasx/#/#.aas"; - if (prefFmt == SerializationFormat.Json) - aas_spec_fn += ".json"; - else - aas_spec_fn += ".xml"; - aas_spec_fn = aas_spec_fn.Replace("#", "" + frn); - specPart = package.CreatePart( - new Uri(aas_spec_fn, UriKind.RelativeOrAbsolute), - System.Net.Mime.MediaTypeNames.Text.Xml, CompressionOption.Maximum); - originPart.CreateRelationship( - specPart.Uri, TargetMode.Internal, - "http://www.admin-shell.io/aasx/relationships/aas-spec"); - } - - // now, specPart shall be != null! - if (specPart.Uri.ToString().ToLower().Trim().EndsWith("json")) - { - using (var s = specPart.GetStream(FileMode.Create)) - { - JsonSerializer serializer = new JsonSerializer(); - serializer.NullValueHandling = NullValueHandling.Ignore; - serializer.ReferenceLoopHandling = ReferenceLoopHandling.Serialize; - serializer.Formatting = Newtonsoft.Json.Formatting.Indented; - using (var sw = new StreamWriter(s)) - { - using (JsonWriter writer = new JsonTextWriter(sw)) - { - serializer.Serialize(writer, _aasEnv); - } - } - } - } - else - { - using (var s = specPart.GetStream(FileMode.Create)) - { - //var serializer = new XmlSerializer(typeof(AasCore.Aas3_0_RC02.Environment)); - //var nss = GetXmlDefaultNamespaces(); - //serializer.Serialize(s, _aasEnv, nss); - - var writer = XmlWriter.Create(s, new XmlWriterSettings() - { - Indent = true, - OmitXmlDeclaration = true - }); - Xmlization.Serialize.To( - _aasEnv, writer); - writer.Flush(); - writer.Close(); - s.Flush(); - } - } - - // there might be pending files to be deleted (first delete, then add, - // in case of identical files in both categories) - foreach (var psfDel in _pendingFilesToDelete) - { - // try find an existing part for that file .. - var found = false; - - // normal files - xs = specPart.GetRelationshipsByType("http://www.admin-shell.io/aasx/relationships/aas-suppl"); - foreach (var x in xs) - if (x.TargetUri == psfDel.Uri) - { - // try to delete - specPart.DeleteRelationship(x.Id); - package.DeletePart(psfDel.Uri); - found = true; - break; - } - - // thumbnails - xs = package.GetRelationshipsByType( - "http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail"); - foreach (var x in xs) - if (x.TargetUri == psfDel.Uri) - { - // try to delete - package.DeleteRelationship(x.Id); - package.DeletePart(psfDel.Uri); - found = true; - break; - } - - if (!found) - throw (new Exception( - $"Not able to delete pending file {psfDel.Uri} in saving package {fn}")); - } - - // after this, there are no more pending for delete files - _pendingFilesToDelete.Clear(); - - // write pending supplementary files - foreach (var psfAdd in _pendingFilesToAdd) - { - // make sure .. - if ((psfAdd.SourceLocalPath == null && psfAdd.SourceGetBytesDel == null) || - psfAdd.Location != AdminShellPackageSupplementaryFile.LocationType.AddPending) - continue; - - // normal file? - if (psfAdd.SpecialHandling == AdminShellPackageSupplementaryFile.SpecialHandlingType.None || - psfAdd.SpecialHandling == - AdminShellPackageSupplementaryFile.SpecialHandlingType.EmbedAsThumbnail) - { - - // try find an existing part for that file .. - PackagePart filePart = null; - if (psfAdd.SpecialHandling == AdminShellPackageSupplementaryFile.SpecialHandlingType.None) - { - xs = specPart.GetRelationshipsByType( - "http://www.admin-shell.io/aasx/relationships/aas-suppl"); - foreach (var x in xs) - if (x.TargetUri == psfAdd.Uri) - { - filePart = package.GetPart(x.TargetUri); - break; - } - } - if (psfAdd.SpecialHandling == - AdminShellPackageSupplementaryFile.SpecialHandlingType.EmbedAsThumbnail) - { - xs = package.GetRelationshipsByType( - "http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail"); - foreach (var x in xs) - if (x.SourceUri.ToString() == "/" && x.TargetUri == psfAdd.Uri) - { - filePart = package.GetPart(x.TargetUri); - break; - } - } - - if (filePart == null) - { - // determine mimeType - var mimeType = psfAdd.UseMimeType; - // reconcile mime - if (mimeType == null && psfAdd.SourceLocalPath != null) - mimeType = AdminShellPackageEnv.GuessMimeType(psfAdd.SourceLocalPath); - // still null? - if (mimeType == null) - // see: https://stackoverflow.com/questions/6783921/ - // which-mime-type-to-use-for-a-binary-file-thats-specific-to-my-program - mimeType = "application/octet-stream"; - - // create new part and link - filePart = package.CreatePart(psfAdd.Uri, mimeType, CompressionOption.Maximum); - if (psfAdd.SpecialHandling == - AdminShellPackageSupplementaryFile.SpecialHandlingType.None) - specPart.CreateRelationship( - filePart.Uri, TargetMode.Internal, - "http://www.admin-shell.io/aasx/relationships/aas-suppl"); - if (psfAdd.SpecialHandling == - AdminShellPackageSupplementaryFile.SpecialHandlingType.EmbedAsThumbnail) - package.CreateRelationship( - filePart.Uri, TargetMode.Internal, - "http://schemas.openxmlformats.org/package/2006/" + - "relationships/metadata/thumbnail"); - } - - // now should be able to write - using (var s = filePart.GetStream(FileMode.Create)) - { - if (psfAdd.SourceLocalPath != null) - { - var bytes = System.IO.File.ReadAllBytes(psfAdd.SourceLocalPath); - s.Write(bytes, 0, bytes.Length); - } - - if (psfAdd.SourceGetBytesDel != null) - { - var bytes = psfAdd.SourceGetBytesDel(); - if (bytes != null) - s.Write(bytes, 0, bytes.Length); - } - } - } - } - - // after this, there are no more pending for add files - _pendingFilesToAdd.Clear(); - - // flush, but leave open - package.Flush(); - _openPackage = package; - - // if in temp fn, close the package, copy to original fn, re-open the package - if (_tempFn != null) - try - { - package.Close(); - System.IO.File.Copy(_tempFn, _fn, overwrite: true); - _openPackage = Package.Open(_tempFn, FileMode.OpenOrCreate); - } - catch (Exception ex) - { - throw (new Exception( - string.Format("While write AASX {0} indirectly at {1} gave: {2}", - fn, AdminShellUtil.ShortLocation(ex), ex.Message))); - } - } - catch (Exception ex) - { - throw (new Exception( - string.Format("While write AASX {0} at {1} gave: {2}", - fn, AdminShellUtil.ShortLocation(ex), ex.Message))); - } - return true; - } - - // Don't know to handle - throw new Exception($"Does not know how to handle the file: {fn}"); - } - - /// - /// Temporariyl saves & closes package and executes lambda. Afterwards, the package is re-opened - /// under the same file name - /// - /// Action which is to be executed while the file is CLOSED - /// Format for the saved file - public void TemporarilySaveCloseAndReOpenPackage( - Action lambda, - AdminShellPackageEnv.SerializationFormat prefFmt = AdminShellPackageEnv.SerializationFormat.None) - { - // access - if (!this.IsOpen) - throw (new Exception( - string.Format("Could not temporarily close and re-open AASX {0}, because package" + - "not open as expected!", Filename))); - - try - { - // save (it will be open, still) - SaveAs(this.Filename, prefFmt: prefFmt); - - // close - _openPackage.Flush(); - _openPackage.Close(); - - // execute lambda - lambda?.Invoke(); - } - catch (Exception ex) - { - throw (new Exception( - string.Format("While temporarily close and re-open AASX {0} at {1} gave: {2}", - Filename, AdminShellUtil.ShortLocation(ex), ex.Message))); - } - finally - { - // even after failing of the lambda, the package shall be re-opened - _openPackage = Package.Open(Filename, FileMode.OpenOrCreate); - } - } - - private int BackupIndex = 0; - - public void BackupInDir(string backupDir, int maxFiles) - { - // access - if (backupDir == null || maxFiles < 1) - return; - - // we do it not caring on any errors - try - { - // get index in form - if (BackupIndex == 0) - { - // do not always start at 0!! - var rnd = new Random(); - BackupIndex = rnd.Next(maxFiles); - } - var ndx = BackupIndex % maxFiles; - BackupIndex += 1; - - // build a filename - var bdfn = Path.Combine(backupDir, $"backup{ndx:000}.xml"); - - // raw save - using (var s = new StreamWriter(bdfn)) - { - //var serializer = new XmlSerializer(typeof(AasCore.Aas3_0_RC02.Environment)); - //var nss = new XmlSerializerNamespaces(); - //nss.Add("xsi", System.Xml.Schema.XmlSchema.InstanceNamespace); - //nss.Add("aas", "http://www.admin-shell.io/aas/2/0"); - //nss.Add("IEC61360", "http://www.admin-shell.io/IEC61360/2/0"); - //serializer.Serialize(s, _aasEnv, nss); - - var writer = XmlWriter.Create(s, new XmlWriterSettings() - { - Indent = true, - OmitXmlDeclaration = true - }); - Xmlization.Serialize.To( - _aasEnv, writer); - writer.Flush(); - writer.Close(); - s.Flush(); - } - } - catch (Exception ex) - { - LogInternally.That.SilentlyIgnoredError(ex); - } - } - - public Stream GetStreamFromUriOrLocalPackage(string uriString, - FileMode mode = FileMode.Open, - FileAccess access = FileAccess.Read) - { - // local - if (IsLocalFile(uriString)) - return GetLocalStreamFromPackage(uriString, mode, access); - - // no .. - return System.IO.File.Open(uriString, mode, access); - } - - public byte[] GetByteArrayFromUriOrLocalPackage(string uriString) - { - try - { - using (var input = GetStreamFromUriOrLocalPackage(uriString)) - { - using (MemoryStream ms = new MemoryStream()) - { - input.CopyTo(ms); - return ms.ToArray(); - } - } - } - catch (Exception ex) - { - AdminShellNS.LogInternally.That.SilentlyIgnoredError(ex); - return null; - } - } - - public bool IsLocalFile(string uriString) - { - // access - if (_openPackage == null) - return false; - if (uriString == null || uriString == "" || !uriString.StartsWith("/")) - return false; - - // check - var isLocal = _openPackage.PartExists(new Uri(uriString, UriKind.RelativeOrAbsolute)); - return isLocal; - } - - public Stream GetLocalStreamFromPackage(string uriString, FileMode mode = FileMode.Open, FileAccess access = FileAccess.Read) - { - // access - if (_openPackage == null) - throw (new Exception(string.Format($"AASX Package {_fn} not opened. Aborting!"))); - - // exist - var puri = new Uri(uriString, UriKind.RelativeOrAbsolute); - if (!_openPackage.PartExists(puri)) - throw (new Exception(string.Format($"AASX Package has no part {uriString}. Aborting!"))); - - // get part - var part = _openPackage.GetPart(puri); - if (part == null) - throw (new Exception( - string.Format($"Cannot access part {uriString} in {_fn}. Aborting!"))); - return part.GetStream(mode, access); - } - - public async Task ReplaceSupplementaryFileInPackageAsync(string sourceUri, string targetFile, string targetContentType, Stream fileContent) - { - // access - if (_openPackage == null) - throw (new Exception(string.Format($"AASX Package {_fn} not opened. Aborting!"))); - - if (!string.IsNullOrEmpty(sourceUri)) - { - _openPackage.DeletePart(new Uri(sourceUri, UriKind.RelativeOrAbsolute)); - - } - var targetUri = PackUriHelper.CreatePartUri(new Uri(targetFile, UriKind.RelativeOrAbsolute)); - PackagePart packagePart = _openPackage.CreatePart(targetUri, targetContentType); - fileContent.Position = 0; - using (Stream dest = packagePart.GetStream()) - { - fileContent.CopyTo(dest); - } - } - - public long GetStreamSizeFromPackage(string uriString) - { - long res = 0; - try - { - if (_openPackage == null) - return 0; - var part = _openPackage.GetPart(new Uri(uriString, UriKind.RelativeOrAbsolute)); - using (var s = part.GetStream(FileMode.Open)) - { - res = s.Length; - } - } - catch (Exception ex) - { - LogInternally.That.SilentlyIgnoredError(ex); - return 0; - } - return res; - } - - /// - /// Ensures: - ///
  • result == null || result.CanRead
- ///
- public Stream GetLocalThumbnailStream(ref Uri thumbUri) - { - // access - if (_openPackage == null) - throw (new Exception(string.Format($"AASX Package {_fn} not opened. Aborting!"))); - // get the thumbnail over the relationship - PackagePart thumbPart = null; - var xs = _openPackage.GetRelationshipsByType( - "http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail"); - foreach (var x in xs) - if (x.SourceUri.ToString() == "/") - { - thumbPart = _openPackage.GetPart(x.TargetUri); - thumbUri = x.TargetUri; - break; - } - if (thumbPart == null) - throw (new Exception("Unable to find AASX thumbnail. Aborting!")); - - var result = thumbPart.GetStream(FileMode.Open); - - // Post-condition - if (!(result == null || result.CanRead)) - { - throw new InvalidOperationException("Unexpected unreadable result stream"); - } - - return result; - } - - /// - /// Ensures: - ///
  • result == null || result.CanRead
- ///
- public Stream GetLocalThumbnailStream() - { - Uri dummy = null; - var result = GetLocalThumbnailStream(ref dummy); - - // Post-condition - if (!(result == null || result.CanRead)) - { - throw new InvalidOperationException("Unexpected unreadable result stream"); - } - - return result; - } - - public ListOfAasSupplementaryFile GetListOfSupplementaryFiles() - { - // new result - var result = new ListOfAasSupplementaryFile(); - - // access - if (_openPackage != null) - { - - // get the thumbnail(s) from the package - var xs = _openPackage.GetRelationshipsByType( - "http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail"); - foreach (var x in xs) - if (x.SourceUri.ToString() == "/") - { - result.Add(new AdminShellPackageSupplementaryFile( - x.TargetUri, - location: AdminShellPackageSupplementaryFile.LocationType.InPackage, - specialHandling: AdminShellPackageSupplementaryFile.SpecialHandlingType.EmbedAsThumbnail)); - } - - // get the origin from the package - PackagePart originPart = null; - xs = _openPackage.GetRelationshipsByType( - "http://www.admin-shell.io/aasx/relationships/aasx-origin"); - foreach (var x in xs) - if (x.SourceUri.ToString() == "/") - { - originPart = _openPackage.GetPart(x.TargetUri); - break; - } - - if (originPart != null) - { - // get the specs from the origin - PackagePart specPart = null; - xs = originPart.GetRelationshipsByType("http://www.admin-shell.io/aasx/relationships/aas-spec"); - foreach (var x in xs) - { - specPart = _openPackage.GetPart(x.TargetUri); - break; - } - - if (specPart != null) - { - // get the supplementaries from the package, derived from spec - xs = specPart.GetRelationshipsByType("http://www.admin-shell.io/aasx/relationships/aas-suppl"); - foreach (var x in xs) - { - result.Add( - new AdminShellPackageSupplementaryFile( - x.TargetUri, location: AdminShellPackageSupplementaryFile.LocationType.InPackage)); - } - } - } - } - - // add or modify the files to delete - foreach (var psfDel in _pendingFilesToDelete) - { - // already in - var found = result.Find(x => { return x.Uri == psfDel.Uri; }); - if (found != null) - found.Location = AdminShellPackageSupplementaryFile.LocationType.DeletePending; - else - { - psfDel.Location = AdminShellPackageSupplementaryFile.LocationType.DeletePending; - result.Add(psfDel); - } - } - - // add the files to store as well - foreach (var psfAdd in _pendingFilesToAdd) - { - // already in (should not happen ?!) - var found = result.Find(x => { return x.Uri == psfAdd.Uri; }); - if (found != null) - found.Location = AdminShellPackageSupplementaryFile.LocationType.AddPending; - else - { - psfAdd.Location = AdminShellPackageSupplementaryFile.LocationType.AddPending; - result.Add(psfAdd); - } - } - - // done - return result; - } - - public static string GuessMimeType(string fn) - { - var file_ext = System.IO.Path.GetExtension(fn).ToLower().Trim(); - var content_type = System.Net.Mime.MediaTypeNames.Text.Plain; - if (file_ext == ".pdf") content_type = System.Net.Mime.MediaTypeNames.Application.Pdf; - if (file_ext == ".xml") content_type = System.Net.Mime.MediaTypeNames.Text.Xml; - if (file_ext == ".txt") content_type = System.Net.Mime.MediaTypeNames.Text.Plain; - if (file_ext == ".igs") content_type = "application/iges"; - if (file_ext == ".iges") content_type = "application/iges"; - if (file_ext == ".stp") content_type = "application/step"; - if (file_ext == ".step") content_type = "application/step"; - if (file_ext == ".jpg") content_type = System.Net.Mime.MediaTypeNames.Image.Jpeg; - if (file_ext == ".jpeg") content_type = System.Net.Mime.MediaTypeNames.Image.Jpeg; - if (file_ext == ".png") content_type = "image/png"; - if (file_ext == ".gif") content_type = System.Net.Mime.MediaTypeNames.Image.Gif; - return content_type; - } - - public void PrepareSupplementaryFileParameters(ref string targetDir, ref string targetFn) - { - // re-work target dir - if (targetDir != null) - targetDir = targetDir.Replace(@"\", "/"); - - // rework targetFn - if (targetFn != null) - targetFn = Regex.Replace(targetFn, @"[^A-Za-z0-9-.]+", "_"); - } - - /// - /// Add a file as supplementary file to package. Operation will be pending, package needs to be saved in order - /// materialize embedding. - /// - /// Target path of file in package - public string AddSupplementaryFileToStore( - string sourcePath, string targetDir, string targetFn, bool embedAsThumb, - AdminShellPackageSupplementaryFile.SourceGetByteChunk sourceGetBytesDel = null, string useMimeType = null) - { - // beautify parameters - if ((sourcePath == null && sourceGetBytesDel == null) || targetDir == null || targetFn == null) - return null; - - // build target path - targetDir = targetDir.Trim(); - if (!targetDir.EndsWith("/")) - targetDir += "/"; - targetFn = targetFn.Trim(); - if (sourcePath == "" || targetDir == "" || targetFn == "") - throw (new Exception("Trying add supplementary file with empty name or path!")); - - var targetPath = "" + targetDir.Trim() + targetFn.Trim(); - - // base function - AddSupplementaryFileToStore(sourcePath, targetPath, embedAsThumb, sourceGetBytesDel, useMimeType); - - // return target path - return targetPath; - } - - public void AddSupplementaryFileToStore(string sourcePath, string targetPath, bool embedAsThumb, - AdminShellPackageSupplementaryFile.SourceGetByteChunk sourceGetBytesDel = null, string useMimeType = null) - { - // beautify parameters - if ((sourcePath == null && sourceGetBytesDel == null) || targetPath == null) - return; - - sourcePath = sourcePath?.Trim(); - targetPath = targetPath.Trim(); - - // add record - _pendingFilesToAdd.Add( - new AdminShellPackageSupplementaryFile( - new Uri(targetPath, UriKind.RelativeOrAbsolute), - sourcePath, - location: AdminShellPackageSupplementaryFile.LocationType.AddPending, - specialHandling: (embedAsThumb - ? AdminShellPackageSupplementaryFile.SpecialHandlingType.EmbedAsThumbnail - : AdminShellPackageSupplementaryFile.SpecialHandlingType.None), - sourceGetBytesDel: sourceGetBytesDel, - useMimeType: useMimeType) - ); - - } - - public void DeleteSupplementaryFile(AdminShellPackageSupplementaryFile psf) - { - if (psf == null) - throw (new Exception("No supplementary file given!")); - - if (psf.Location == AdminShellPackageSupplementaryFile.LocationType.AddPending) - { - // is still pending in add list -> remove - _pendingFilesToAdd.RemoveAll((x) => { return x.Uri == psf.Uri; }); - } - - if (psf.Location == AdminShellPackageSupplementaryFile.LocationType.InPackage) - { - // add to pending delete list - _pendingFilesToDelete.Add(psf); - } - } - - public void Close() - { - _openPackage?.Close(); - _openPackage = null; - _fn = ""; - _aasEnv = null; - } - - public void Flush() - { - if (_openPackage != null) - _openPackage.Flush(); - } - - public void Dispose() - { - Close(); - } - - public string MakePackageFileAvailableAsTempFile(string packageUri, bool keepFilename = false) - { - // access - if (packageUri == null) - return null; - - // get input stream - using (var input = GetLocalStreamFromPackage(packageUri)) - { - // generate tempfile name - string tempext = System.IO.Path.GetExtension(packageUri); - string temppath = System.IO.Path.GetTempFileName().Replace(".tmp", tempext); - - // maybe modify tempfile name? - if (keepFilename) - { - var masterFn = System.IO.Path.GetFileNameWithoutExtension(packageUri); - var tmpDir = System.IO.Path.GetDirectoryName(temppath); - var tmpFnExt = System.IO.Path.GetFileName(temppath); - - temppath = System.IO.Path.Combine(tmpDir, "" + masterFn + "_" + tmpFnExt); - } - - // copy to temp file - using (var temp = System.IO.File.OpenWrite(temppath)) - { - input.CopyTo(temp); - return temppath; - } - } - } - - public void EmbeddAssetInformationThumbnail(IResource defaultThumbnail, Stream fileContent) - { - // access - if (_openPackage == null) - throw (new Exception(string.Format($"AASX Package {_fn} not opened. Aborting!"))); - - if (!string.IsNullOrEmpty(defaultThumbnail.Path)) - { - var sourceUri = defaultThumbnail.Path.Replace(Path.DirectorySeparatorChar, '/'); - _openPackage.DeletePart(new Uri(sourceUri, UriKind.RelativeOrAbsolute)); - - } - var targetUri = PackUriHelper.CreatePartUri(new Uri(defaultThumbnail.Path, UriKind.RelativeOrAbsolute)); - - PackagePart packagePart = _openPackage.CreatePart(targetUri, defaultThumbnail.ContentType, compressionOption: CompressionOption.Maximum); - - _openPackage.CreateRelationship(packagePart.Uri, TargetMode.Internal, - "http://schemas.openxmlformats.org/package/2006/" + - "relationships/metadata/thumbnail"); - - //Write to the part - fileContent.Position = 0; - using (Stream dest = packagePart.GetStream()) - { - fileContent.CopyTo(dest); - } - } - } -} +/* +Copyright (c) 2018-2023 Festo AG & Co. KG +Author: Michael Hoffmeister + +This source code is licensed under the Apache License 2.0 (see LICENSE.txt). + +This source code may use other Open Source software components (see LICENSE.txt). +*/ + +using Extensions; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.IO; +using System.IO.Packaging; +using System.Linq; +using System.Text.RegularExpressions; +using System.Threading.Tasks; +using System.Xml; +using System.Xml.Serialization; + +namespace AdminShellNS +{ + /// + /// This class lets an outer functionality keep track on the supplementary files, which are in or + /// are pending to be added or deleted to an Package. + /// + public class AdminShellPackageSupplementaryFile /*: IReferable*/ + { + public delegate byte[] SourceGetByteChunk(); + + public enum LocationType { InPackage, AddPending, DeletePending } + + public enum SpecialHandlingType { None, EmbedAsThumbnail } + + public readonly Uri Uri = null; + + public readonly string UseMimeType = null; + + public readonly string SourceLocalPath = null; + public readonly SourceGetByteChunk SourceGetBytesDel = null; + + public LocationType Location; + public readonly SpecialHandlingType SpecialHandling; + + public AdminShellPackageSupplementaryFile( + Uri uri, string sourceLocalPath = null, LocationType location = LocationType.InPackage, + SpecialHandlingType specialHandling = SpecialHandlingType.None, + SourceGetByteChunk sourceGetBytesDel = null, string useMimeType = null) + { + Uri = uri; + UseMimeType = useMimeType; + SourceLocalPath = sourceLocalPath; + SourceGetBytesDel = sourceGetBytesDel; + Location = location; + SpecialHandling = specialHandling; + } + + // class derives from Referable in order to provide GetElementName + public string GetElementName() + { + return "File"; + } + + } + + public class ListOfAasSupplementaryFile : List + { + public AdminShellPackageSupplementaryFile FindByUri(string path) + { + if (path == null) + return null; + + return this.FirstOrDefault( + x => x?.Uri?.ToString().Trim() == path.Trim()); + } + } + + /// + /// Provides (static?) helpers for serializing AAS.. + /// + public static class AdminShellSerializationHelper + { + + public static string TryReadXmlFirstElementNamespaceURI(Stream s) + { + string res = null; + try + { + var xr = System.Xml.XmlReader.Create(s); + int i = 0; + while (xr.Read()) + { + // limit amount of read + i++; + if (i > 99) + // obviously not found + break; + + // find element + if (xr.NodeType == System.Xml.XmlNodeType.Element) + { + res = xr.NamespaceURI; + break; + } + } + xr.Close(); + } + catch (Exception ex) + { + LogInternally.That.SilentlyIgnoredError(ex); + } + + // return to zero pos + s.Seek(0, SeekOrigin.Begin); + + // give back + return res; + } + + /// + /// Skips first few tokens of an XML content until first "real" element is encountered + /// + /// + public static void XmlSkipHeader(XmlReader xmlReader) + { + while (xmlReader.NodeType == XmlNodeType.XmlDeclaration || + xmlReader.NodeType == XmlNodeType.Whitespace || + xmlReader.NodeType == XmlNodeType.Comment || + xmlReader.NodeType == XmlNodeType.None) + xmlReader.Read(); + } + + /// + /// De-serialize an open stream into Environment. Does version/ compatibility management. + /// + /// Open for read stream + /// + public static AasCore.Aas3_0.Environment DeserializeXmlFromStreamWithCompat(Stream s) + { + // not sure + AasCore.Aas3_0.Environment res = null; + + // try get first element + var nsuri = TryReadXmlFirstElementNamespaceURI(s); + + // read V1.0? + if (nsuri != null && nsuri.Trim() == "http://www.admin-shell.io/aas/1/0") + { +#if !DoNotUseAasxCompatibilityModels + XmlSerializer serializer = new XmlSerializer( + typeof(AasxCompatibilityModels.AdminShellV10.AdministrationShellEnv), + "http://www.admin-shell.io/aas/1/0"); + var v10 = serializer.Deserialize(s) as AasxCompatibilityModels.AdminShellV10.AdministrationShellEnv; + //res = new AdministrationShellEnv(v10); + res = new AasCore.Aas3_0.Environment(new List(), new List(), new List()); + res.ConvertFromV10(v10); + return res; +#else + throw (new Exception("Cannot handle AAS file format http://www.admin-shell.io/aas/1/0 !")); +#endif + } + + // read V2.0? + if (nsuri != null && nsuri.Trim() == "http://www.admin-shell.io/aas/2/0") + { +#if !DoNotUseAasxCompatibilityModels + XmlSerializer serializer = new XmlSerializer( + typeof(AasxCompatibilityModels.AdminShellV20.AdministrationShellEnv), + "http://www.admin-shell.io/aas/2/0"); + var v20 = serializer.Deserialize(s) as AasxCompatibilityModels.AdminShellV20.AdministrationShellEnv; + //res = new AdministrationShellEnv(v20); + res = new AasCore.Aas3_0.Environment(new List(), new List(), new List()); + res.ConvertFromV20(v20); + return res; +#else + throw (new Exception("Cannot handle AAS file format http://www.admin-shell.io/aas/1/0 !")); +#endif + } + + // read V3.0? + if (nsuri != null && nsuri.Trim() == Xmlization.NS) + { + //XmlSerializer serializer = new XmlSerializer( + // typeof(AasCore.Aas3_0_RC02.Environment), "http://www.admin-shell.io/aas/3/0"); + //res = serializer.Deserialize(s) as AasCore.Aas3_0_RC02.Environment; + + using (var xmlReader = XmlReader.Create(s)) + { + // TODO (MIHO, 2022-12-26): check if could be feature of AAS core + XmlSkipHeader(xmlReader); + res = Xmlization.Deserialize.EnvironmentFrom(xmlReader); + return res; + } + } + + // nope! + return null; + } + + //public static JsonSerializer BuildDefaultAasxJsonSerializer() + //{ + // var serializer = new JsonSerializer(); + // serializer.Converters.Add( + // new AdminShellConverters.JsonAasxConverter( + // "modelType", "name")); + // return serializer; + //} + + public static T DeserializeFromJSON(string data) where T : IReferable + { + //using (var tr = new StringReader(data)) + //{ + //var serializer = BuildDefaultAasxJsonSerializer(); + //var rf = (T)serializer.Deserialize(tr, typeof(T)); + + var node = System.Text.Json.Nodes.JsonNode.Parse(data); + var rf = Jsonization.Deserialize.IReferableFrom(node); + + return (T)rf; + //} + } + + //public static T DeserializeFromJSON(JToken obj) where T : IReferable + //{ + // if (obj == null) + // return default(T); + // var serializer = BuildDefaultAasxJsonSerializer(); + // var rf = obj.ToObject(serializer); + // return rf; + //} + + ///// + ///// Use this, if DeserializeFromJSON is too tight. + ///// + //public static T DeserializePureObjectFromJSON(string data) + //{ + // using (var tr = new StringReader(data)) + // { + // //var serializer = BuildDefaultAasxJsonSerializer(); + // //var rf = (T)serializer.Deserialize(tr, typeof(T)); + // return null; + // } + //} + } + + /// + /// This class encapsulates an AdminShellEnvironment and supplementary files into an AASX Package. + /// Specifically has the capability to load, update and store .XML, .JSON and .AASX packages. + /// + public class AdminShellPackageEnv : IDisposable + { + private string _fn = "New Package"; + + private string _tempFn = null; + + private AasCore.Aas3_0.Environment _aasEnv = new AasCore.Aas3_0.Environment(new List(), new List(), new List()); + private Package _openPackage = null; + private readonly ListOfAasSupplementaryFile _pendingFilesToAdd = new ListOfAasSupplementaryFile(); + private readonly ListOfAasSupplementaryFile _pendingFilesToDelete = new ListOfAasSupplementaryFile(); + + public AdminShellPackageEnv() { } + + public AdminShellPackageEnv(AasCore.Aas3_0.Environment env) + { + if (env != null) + _aasEnv = env; + } + + public AdminShellPackageEnv(string fn, bool indirectLoadSave = false) + { + Load(fn, indirectLoadSave); + } + + public bool IsOpen + { + get + { + return _openPackage != null; + } + } + + public void SetFilename(string fileName) + { + _fn = fileName; + } + + public string Filename + { + get + { + return _fn; + } + } + + public AasCore.Aas3_0.Environment AasEnv + { + get + { + return _aasEnv; + } + } + + private static AasCore.Aas3_0.Environment LoadXml(string fn) + { + try + { + using (var reader = new StreamReader(fn)) + { + var aasEnv = AdminShellSerializationHelper.DeserializeXmlFromStreamWithCompat( + reader.BaseStream); + + if (aasEnv == null) + throw new Exception("Type error for XML file"); + + return aasEnv; + } + } + catch (Exception ex) + { + throw new Exception( + $"While reading AAS {fn} at {AdminShellUtil.ShortLocation(ex)} gave: {ex.Message}"); + } + } + + private static AasCore.Aas3_0.Environment LoadJson(string fn) + { + try + { + using (var file = System.IO.File.OpenRead(fn)) + { + //// TODO (Michael Hoffmeister, 2020-08-01): use a unified function to create a serializer + //var serializer = new JsonSerializer(); + //serializer.Converters.Add( + // new AdminShellConverters.JsonAasxConverter( + // "modelType", "name")); + + //var aasEnv = (AasCore.Aas3_0_RC02.Environment)serializer.Deserialize( + // file, typeof(AasCore.Aas3_0_RC02.Environment)); + + var node = System.Text.Json.Nodes.JsonNode.Parse(file); + var aasEnv = Jsonization.Deserialize.EnvironmentFrom(node); + + return aasEnv; + } + } + catch (Exception ex) + { + throw new Exception( + $"While reading AAS {fn} at {AdminShellUtil.ShortLocation(ex)} gave: {ex.Message}"); + } + } + + /// is unequal if indirectLoadSave is used. + private static (AasCore.Aas3_0.Environment, Package) LoadPackageAasx(string fn, string fnToLoad) + { + AasCore.Aas3_0.Environment aasEnv; + Package openPackage = null; + + Package package; + try + { + package = Package.Open(fnToLoad, FileMode.Open); + } + catch (Exception ex) + { + throw new Exception( + fn == fnToLoad + ? $"While opening the package to read AASX {fn} " + + $"at {AdminShellUtil.ShortLocation(ex)} gave: {ex.Message}" + : $"While opening the package to read AASX {fn} indirectly from {fnToLoad} " + + $"at {AdminShellUtil.ShortLocation(ex)} gave: {ex.Message}"); + } + + try + { + // get the origin from the package + PackagePart originPart = null; + var xs = package.GetRelationshipsByType( + "http://www.admin-shell.io/aasx/relationships/aasx-origin"); + foreach (var x in xs) + if (x.SourceUri.ToString() == "/") + { + originPart = package.GetPart(x.TargetUri); + break; + } + + if (originPart == null) + throw (new Exception("Unable to find AASX origin. Aborting!")); + + // get the specs from the package + PackagePart specPart = null; + xs = originPart.GetRelationshipsByType("http://www.admin-shell.io/aasx/relationships/aas-spec"); + foreach (var x in xs) + { + specPart = package.GetPart(x.TargetUri); + break; + } + + if (specPart == null) + throw (new Exception("Unable to find AASX spec(s). Aborting!")); + + // open spec part to read + try + { + if (specPart.Uri.ToString().ToLower().Trim().EndsWith("json")) + { + using (var s = specPart.GetStream(FileMode.Open)) + { + //using (var file = new StreamReader(s)) + //{ + //JsonSerializer serializer = new JsonSerializer(); + //serializer.Converters.Add( + // new AdminShellConverters.JsonAasxConverter( + // "modelType", "name")); + + //aasEnv = (AasCore.Aas3_0_RC02.Environment)serializer.Deserialize( + // file, typeof(AasCore.Aas3_0_RC02.Environment)); + + var node = System.Text.Json.Nodes.JsonNode.Parse(s); + aasEnv = Jsonization.Deserialize.EnvironmentFrom(node); + //} + } + } + else + { + using (var s = specPart.GetStream(FileMode.Open)) + { + // own catch loop to be more specific + aasEnv = AdminShellSerializationHelper.DeserializeXmlFromStreamWithCompat(s); + openPackage = package; + + if (aasEnv == null) + throw new Exception("Type error for XML file!"); + } + } + } + catch (Exception ex) + { + throw new Exception( + fn == fnToLoad + ? $"While reading spec from the AASX {fn} " + + $"at {AdminShellUtil.ShortLocation(ex)} gave: {ex.Message}" + : $"While reading spec from the {fn} (and indirectly over {fnToLoad}) " + + $"at {AdminShellUtil.ShortLocation(ex)} gave: {ex.Message}"); + } + } + catch (Exception ex) + { + throw new Exception( + fn == fnToLoad + ? $"While reading the AASX {fn} " + + $"at {AdminShellUtil.ShortLocation(ex)} gave: {ex.Message}" + : $"While reading the {fn} (and indirectly over {fnToLoad}) " + + $"at {AdminShellUtil.ShortLocation(ex)} gave: {ex.Message}"); + } + finally + { + if (openPackage == null) + { + package.Close(); + } + } + + return (aasEnv, openPackage); + } + + public void Load(string fn, bool indirectLoadSave = false) + { + _fn = fn; + _openPackage?.Close(); + _openPackage = null; + + string extension = Path.GetExtension(fn).ToLower(); + switch (extension) + { + case ".xml": + { + _aasEnv = LoadXml(fn); + break; + } + case ".json": + { + _aasEnv = LoadJson(fn); + break; + } + case ".aasx": + { + var fnToLoad = fn; + _tempFn = null; + if (indirectLoadSave) + { + try + { + _tempFn = System.IO.Path.GetTempFileName().Replace(".tmp", ".aasx"); + System.IO.File.Copy(fn, _tempFn); + fnToLoad = _tempFn; + + } + catch (Exception ex) + { + throw new Exception( + $"While copying AASX {fn} for indirect load to {fnToLoad} " + + $"at {AdminShellUtil.ShortLocation(ex)} gave: {ex.Message}"); + } + } + + // load package AASX + (_aasEnv, _openPackage) = LoadPackageAasx(fn, fnToLoad); + break; + } + default: + throw new Exception( + $"Does not know how to handle the extension {extension} of the file: {fn}"); + } + } + + public void SetTempFn(string fn) + { + try + { + _tempFn = System.IO.Path.GetTempFileName().Replace(".tmp", ".aasx"); + System.IO.File.Copy(fn, _tempFn); + + } + catch (Exception ex) + { + throw new Exception( + $"While copying AASX {fn}" + + $"at {AdminShellUtil.ShortLocation(ex)} gave: {ex.Message}"); + } + } + + public void LoadFromAasEnvString(string content) + { + try + { + //using (var file = new StringReader(content)) + //{ + // TODO (Michael Hoffmeister, 2020-08-01): use a unified function to create a serializer + //JsonSerializer serializer = new JsonSerializer(); + //serializer.Converters.Add(new AdminShellConverters.JsonAasxConverter("modelType", "name")); + //_aasEnv = (AasCore.Aas3_0_RC02.Environment)serializer.Deserialize( + // file, typeof(AasCore.Aas3_0_RC02.Environment)); + + var node = System.Text.Json.Nodes.JsonNode.Parse(content); + _aasEnv = Jsonization.Deserialize.EnvironmentFrom(node); + //} + } + catch (Exception ex) + { + throw (new Exception( + string.Format("While reading AASENV string {0} gave: {1}", + AdminShellUtil.ShortLocation(ex), ex.Message))); + } + } + + public enum SerializationFormat { None, Xml, Json }; + + //public static XmlSerializerNamespaces GetXmlDefaultNamespaces() + //{ + // var nss = new XmlSerializerNamespaces(); + // nss.Add("xsi", System.Xml.Schema.XmlSchema.InstanceNamespace); + // nss.Add("aas", "http://www.admin-shell.io/aas/2/0"); + // nss.Add("IEC", "http://www.admin-shell.io/IEC61360/2/0"); + // nss.Add("abac", "http://www.admin-shell.io/aas/abac/2/0"); + // return nss; + //} + + public bool SaveAs(string fn, bool writeFreshly = false, SerializationFormat prefFmt = SerializationFormat.None, + MemoryStream useMemoryStream = null, bool saveOnlyCopy = false) + { + // silently fix flaws + _aasEnv?.SilentFix30(); + + // ok, which format? + if (fn.ToLower().EndsWith(".xml")) + { + // save only XML + if (!saveOnlyCopy) + _fn = fn; + try + { + Stream s = (useMemoryStream != null) + ? (Stream)useMemoryStream + : System.IO.File.Open(fn, FileMode.Create, FileAccess.Write); + + try + { + // TODO (Michael Hoffmeister, 2020-08-01): use a unified function to create a serializer + //var serializer = new XmlSerializer(typeof(AasCore.Aas3_0_RC02.Environment)); + //var nss = GetXmlDefaultNamespaces(); + //serializer.Serialize(s, _aasEnv, nss); + + var writer = XmlWriter.Create(s, new XmlWriterSettings() + { + Indent = true, + OmitXmlDeclaration = true + }); + Xmlization.Serialize.To( + _aasEnv, writer); + writer.Flush(); + writer.Close(); + s.Flush(); + } + finally + { + // close? + if (useMemoryStream == null) + s.Close(); + } + } + catch (Exception ex) + { + throw (new Exception( + string.Format("While writing AAS {0} at {1} gave: {2}", + fn, AdminShellUtil.ShortLocation(ex), ex.Message))); + } + return true; + } + + if (fn.ToLower().EndsWith(".json")) + { + // save only JSON + // This functionality is an initial test. + if (!saveOnlyCopy) + _fn = fn; + try + { + Stream s = (useMemoryStream != null) ? (Stream)useMemoryStream + : System.IO.File.Open(fn, FileMode.Create, FileAccess.Write); + + try + { + //// TODO (Michael Hoffmeister, 2020-08-01): use a unified function to create a serializer + //JsonSerializer serializer = new JsonSerializer() + //{ + // NullValueHandling = NullValueHandling.Ignore, + // ReferenceLoopHandling = ReferenceLoopHandling.Serialize, + // Formatting = Newtonsoft.Json.Formatting.Indented + //}; + + //var sw = new StreamWriter(s); + //var writer = new JsonTextWriter(sw); + + //serializer.Serialize(writer, _aasEnv); + //writer.Flush(); + //sw.Flush(); + //s.Flush(); + + //if (useMemoryStream == null) + //{ + // writer.Close(); + // sw.Close(); + //} + + using (var wr = new System.Text.Json.Utf8JsonWriter(s)) + { + Jsonization.Serialize.ToJsonObject(_aasEnv).WriteTo(wr, + new System.Text.Json.JsonSerializerOptions() + { + WriteIndented = true + }); + wr.Flush(); + s.Flush(); + } + } + finally + { + // close? + if (useMemoryStream == null) + s.Close(); + } + } + catch (Exception ex) + { + throw (new Exception( + string.Format("While writing AAS {0} at {1} gave: {2}", + fn, AdminShellUtil.ShortLocation(ex), ex.Message))); + } + return true; + } + + if (fn.ToLower().EndsWith(".aasx")) + { + // save package AASX + try + { + // We want existing contents to be preserved, but do not want to allow the change of the file name. + // Therefore: copy the file to a new name, then re-open. + // fn could be changed, therefore close "old" package first + if (_openPackage != null) + { + try + { + _openPackage.Close(); + if (!writeFreshly) + { + if (_tempFn != null) + System.IO.File.Copy(_tempFn, fn); + else + { + /* TODO (MIHO, 2021-01-02): check again. + * Revisiting this code after a while, and after + * the code has undergo some changes by MR, the following copy command needed + * to be amended with a if to protect against self-copy. */ + if (_fn != fn) + System.IO.File.Copy(_fn, fn); + } + } + } + catch (Exception ex) + { + LogInternally.That.SilentlyIgnoredError(ex); + } + _openPackage = null; + } + + // approach is to utilize the existing package, if possible. If not, create from scratch + Package package = null; + if (useMemoryStream != null) + { + package = Package.Open( + useMemoryStream, (writeFreshly) ? FileMode.Create : FileMode.OpenOrCreate); + } + else + { + package = Package.Open( + (_tempFn != null) ? _tempFn : fn, + (writeFreshly) ? FileMode.Create : FileMode.OpenOrCreate); + } + _fn = fn; + + // get the origin from the package + PackagePart originPart = null; + var xs = package.GetRelationshipsByType( + "http://www.admin-shell.io/aasx/relationships/aasx-origin"); + foreach (var x in xs) + if (x.SourceUri.ToString() == "/") + { + originPart = package.GetPart(x.TargetUri); + break; + } + if (originPart == null) + { + // create, as not existing + originPart = package.CreatePart( + new Uri("/aasx/aasx-origin", UriKind.RelativeOrAbsolute), + System.Net.Mime.MediaTypeNames.Text.Plain, CompressionOption.Maximum); + using (var s = originPart.GetStream(FileMode.Create)) + { + var bytes = System.Text.Encoding.ASCII.GetBytes("Intentionally empty."); + s.Write(bytes, 0, bytes.Length); + } + package.CreateRelationship( + originPart.Uri, TargetMode.Internal, + "http://www.admin-shell.io/aasx/relationships/aasx-origin"); + } + + // get the specs from the package + PackagePart specPart = null; + PackageRelationship specRel = null; + xs = originPart.GetRelationshipsByType("http://www.admin-shell.io/aasx/relationships/aas-spec"); + foreach (var x in xs) + { + specRel = x; + specPart = package.GetPart(x.TargetUri); + break; + } + + // check, if we have to change the spec part + if (specPart != null && specRel != null) + { + var name = System.IO.Path.GetFileNameWithoutExtension( + specPart.Uri.ToString()).ToLower().Trim(); + var ext = System.IO.Path.GetExtension(specPart.Uri.ToString()).ToLower().Trim(); + if ((ext == ".json" && prefFmt == SerializationFormat.Xml) + || (ext == ".xml" && prefFmt == SerializationFormat.Json) + || (name.StartsWith("aasenv-with-no-id"))) + { + // try kill specpart + try + { + originPart.DeleteRelationship(specRel.Id); + package.DeletePart(specPart.Uri); + } + catch (Exception ex) + { + LogInternally.That.SilentlyIgnoredError(ex); + } + finally { specPart = null; specRel = null; } + } + } + + if (specPart == null) + { + // create, as not existing + var frn = "aasenv-with-no-id"; + if (_aasEnv.AssetAdministrationShells.Count > 0) + frn = _aasEnv.AssetAdministrationShells[0].GetFriendlyName() ?? frn; + var aas_spec_fn = "/aasx/#/#.aas"; + if (prefFmt == SerializationFormat.Json) + aas_spec_fn += ".json"; + else + aas_spec_fn += ".xml"; + aas_spec_fn = aas_spec_fn.Replace("#", "" + frn); + specPart = package.CreatePart( + new Uri(aas_spec_fn, UriKind.RelativeOrAbsolute), + System.Net.Mime.MediaTypeNames.Text.Xml, CompressionOption.Maximum); + originPart.CreateRelationship( + specPart.Uri, TargetMode.Internal, + "http://www.admin-shell.io/aasx/relationships/aas-spec"); + } + + // now, specPart shall be != null! + if (specPart.Uri.ToString().ToLower().Trim().EndsWith("json")) + { + using (var s = specPart.GetStream(FileMode.Create)) + { + JsonSerializer serializer = new JsonSerializer(); + serializer.NullValueHandling = NullValueHandling.Ignore; + serializer.ReferenceLoopHandling = ReferenceLoopHandling.Serialize; + serializer.Formatting = Newtonsoft.Json.Formatting.Indented; + using (var sw = new StreamWriter(s)) + { + using (JsonWriter writer = new JsonTextWriter(sw)) + { + serializer.Serialize(writer, _aasEnv); + } + } + } + } + else + { + using (var s = specPart.GetStream(FileMode.Create)) + { + //var serializer = new XmlSerializer(typeof(AasCore.Aas3_0_RC02.Environment)); + //var nss = GetXmlDefaultNamespaces(); + //serializer.Serialize(s, _aasEnv, nss); + + var writer = XmlWriter.Create(s, new XmlWriterSettings() + { + Indent = true, + OmitXmlDeclaration = true + }); + Xmlization.Serialize.To( + _aasEnv, writer); + writer.Flush(); + writer.Close(); + s.Flush(); + } + } + + // there might be pending files to be deleted (first delete, then add, + // in case of identical files in both categories) + foreach (var psfDel in _pendingFilesToDelete) + { + // try find an existing part for that file .. + var found = false; + + // normal files + xs = specPart.GetRelationshipsByType("http://www.admin-shell.io/aasx/relationships/aas-suppl"); + foreach (var x in xs) + if (x.TargetUri == psfDel.Uri) + { + // try to delete + specPart.DeleteRelationship(x.Id); + package.DeletePart(psfDel.Uri); + found = true; + break; + } + + // thumbnails + xs = package.GetRelationshipsByType( + "http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail"); + foreach (var x in xs) + if (x.TargetUri == psfDel.Uri) + { + // try to delete + package.DeleteRelationship(x.Id); + package.DeletePart(psfDel.Uri); + found = true; + break; + } + + if (!found) + throw (new Exception( + $"Not able to delete pending file {psfDel.Uri} in saving package {fn}")); + } + + // after this, there are no more pending for delete files + _pendingFilesToDelete.Clear(); + + // write pending supplementary files + foreach (var psfAdd in _pendingFilesToAdd) + { + // make sure .. + if ((psfAdd.SourceLocalPath == null && psfAdd.SourceGetBytesDel == null) || + psfAdd.Location != AdminShellPackageSupplementaryFile.LocationType.AddPending) + continue; + + // normal file? + if (psfAdd.SpecialHandling == AdminShellPackageSupplementaryFile.SpecialHandlingType.None || + psfAdd.SpecialHandling == + AdminShellPackageSupplementaryFile.SpecialHandlingType.EmbedAsThumbnail) + { + + // try find an existing part for that file .. + PackagePart filePart = null; + if (psfAdd.SpecialHandling == AdminShellPackageSupplementaryFile.SpecialHandlingType.None) + { + xs = specPart.GetRelationshipsByType( + "http://www.admin-shell.io/aasx/relationships/aas-suppl"); + foreach (var x in xs) + if (x.TargetUri == psfAdd.Uri) + { + filePart = package.GetPart(x.TargetUri); + break; + } + } + if (psfAdd.SpecialHandling == + AdminShellPackageSupplementaryFile.SpecialHandlingType.EmbedAsThumbnail) + { + xs = package.GetRelationshipsByType( + "http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail"); + foreach (var x in xs) + if (x.SourceUri.ToString() == "/" && x.TargetUri == psfAdd.Uri) + { + filePart = package.GetPart(x.TargetUri); + break; + } + } + + if (filePart == null) + { + // determine mimeType + var mimeType = psfAdd.UseMimeType; + // reconcile mime + if (mimeType == null && psfAdd.SourceLocalPath != null) + mimeType = AdminShellPackageEnv.GuessMimeType(psfAdd.SourceLocalPath); + // still null? + if (mimeType == null) + // see: https://stackoverflow.com/questions/6783921/ + // which-mime-type-to-use-for-a-binary-file-thats-specific-to-my-program + mimeType = "application/octet-stream"; + + // create new part and link + filePart = package.CreatePart(psfAdd.Uri, mimeType, CompressionOption.Maximum); + if (psfAdd.SpecialHandling == + AdminShellPackageSupplementaryFile.SpecialHandlingType.None) + specPart.CreateRelationship( + filePart.Uri, TargetMode.Internal, + "http://www.admin-shell.io/aasx/relationships/aas-suppl"); + if (psfAdd.SpecialHandling == + AdminShellPackageSupplementaryFile.SpecialHandlingType.EmbedAsThumbnail) + package.CreateRelationship( + filePart.Uri, TargetMode.Internal, + "http://schemas.openxmlformats.org/package/2006/" + + "relationships/metadata/thumbnail"); + } + + // now should be able to write + using (var s = filePart.GetStream(FileMode.Create)) + { + if (psfAdd.SourceLocalPath != null) + { + var bytes = System.IO.File.ReadAllBytes(psfAdd.SourceLocalPath); + s.Write(bytes, 0, bytes.Length); + } + + if (psfAdd.SourceGetBytesDel != null) + { + var bytes = psfAdd.SourceGetBytesDel(); + if (bytes != null) + s.Write(bytes, 0, bytes.Length); + } + } + } + } + + // after this, there are no more pending for add files + _pendingFilesToAdd.Clear(); + + // flush, but leave open + package.Flush(); + _openPackage = package; + + // if in temp fn, close the package, copy to original fn, re-open the package + if (_tempFn != null) + try + { + package.Close(); + System.IO.File.Copy(_tempFn, _fn, overwrite: true); + _openPackage = Package.Open(_tempFn, FileMode.OpenOrCreate); + } + catch (Exception ex) + { + throw (new Exception( + string.Format("While write AASX {0} indirectly at {1} gave: {2}", + fn, AdminShellUtil.ShortLocation(ex), ex.Message))); + } + } + catch (Exception ex) + { + throw (new Exception( + string.Format("While write AASX {0} at {1} gave: {2}", + fn, AdminShellUtil.ShortLocation(ex), ex.Message))); + } + return true; + } + + // Don't know to handle + throw new Exception($"Does not know how to handle the file: {fn}"); + } + + /// + /// Temporariyl saves & closes package and executes lambda. Afterwards, the package is re-opened + /// under the same file name + /// + /// Action which is to be executed while the file is CLOSED + /// Format for the saved file + public void TemporarilySaveCloseAndReOpenPackage( + Action lambda, + AdminShellPackageEnv.SerializationFormat prefFmt = AdminShellPackageEnv.SerializationFormat.None) + { + // access + if (!this.IsOpen) + throw (new Exception( + string.Format("Could not temporarily close and re-open AASX {0}, because package" + + "not open as expected!", Filename))); + + try + { + // save (it will be open, still) + SaveAs(this.Filename, prefFmt: prefFmt); + + // close + _openPackage.Flush(); + _openPackage.Close(); + + // execute lambda + lambda?.Invoke(); + } + catch (Exception ex) + { + throw (new Exception( + string.Format("While temporarily close and re-open AASX {0} at {1} gave: {2}", + Filename, AdminShellUtil.ShortLocation(ex), ex.Message))); + } + finally + { + // even after failing of the lambda, the package shall be re-opened + _openPackage = Package.Open(Filename, FileMode.OpenOrCreate); + } + } + + private int BackupIndex = 0; + + public void BackupInDir(string backupDir, int maxFiles) + { + // access + if (backupDir == null || maxFiles < 1) + return; + + // we do it not caring on any errors + try + { + // get index in form + if (BackupIndex == 0) + { + // do not always start at 0!! + var rnd = new Random(); + BackupIndex = rnd.Next(maxFiles); + } + var ndx = BackupIndex % maxFiles; + BackupIndex += 1; + + // build a filename + var bdfn = Path.Combine(backupDir, $"backup{ndx:000}.xml"); + + // raw save + using (var s = new StreamWriter(bdfn)) + { + //var serializer = new XmlSerializer(typeof(AasCore.Aas3_0_RC02.Environment)); + //var nss = new XmlSerializerNamespaces(); + //nss.Add("xsi", System.Xml.Schema.XmlSchema.InstanceNamespace); + //nss.Add("aas", "http://www.admin-shell.io/aas/2/0"); + //nss.Add("IEC61360", "http://www.admin-shell.io/IEC61360/2/0"); + //serializer.Serialize(s, _aasEnv, nss); + + var writer = XmlWriter.Create(s, new XmlWriterSettings() + { + Indent = true, + OmitXmlDeclaration = true + }); + Xmlization.Serialize.To( + _aasEnv, writer); + writer.Flush(); + writer.Close(); + s.Flush(); + } + } + catch (Exception ex) + { + LogInternally.That.SilentlyIgnoredError(ex); + } + } + + public Stream GetStreamFromUriOrLocalPackage(string uriString, + FileMode mode = FileMode.Open, + FileAccess access = FileAccess.Read) + { + // local + if (IsLocalFile(uriString)) + return GetLocalStreamFromPackage(uriString, mode, access); + + // no .. + return System.IO.File.Open(uriString, mode, access); + } + + public byte[] GetByteArrayFromUriOrLocalPackage(string uriString) + { + try + { + using (var input = GetStreamFromUriOrLocalPackage(uriString)) + { + using (MemoryStream ms = new MemoryStream()) + { + input.CopyTo(ms); + return ms.ToArray(); + } + } + } + catch (Exception ex) + { + AdminShellNS.LogInternally.That.SilentlyIgnoredError(ex); + return null; + } + } + + public bool IsLocalFile(string uriString) + { + // access + if (_openPackage == null) + return false; + if (uriString == null || uriString == "" || !uriString.StartsWith("/")) + return false; + + // check + var isLocal = _openPackage.PartExists(new Uri(uriString, UriKind.RelativeOrAbsolute)); + return isLocal; + } + + public Stream GetLocalStreamFromPackage(string uriString, FileMode mode = FileMode.Open, FileAccess access = FileAccess.Read) + { + // access + if (_openPackage == null) + throw (new Exception(string.Format($"AASX Package {_fn} not opened. Aborting!"))); + + // exist + var puri = new Uri(uriString, UriKind.RelativeOrAbsolute); + if (!_openPackage.PartExists(puri)) + throw (new Exception(string.Format($"AASX Package has no part {uriString}. Aborting!"))); + + // get part + var part = _openPackage.GetPart(puri); + if (part == null) + throw (new Exception( + string.Format($"Cannot access part {uriString} in {_fn}. Aborting!"))); + return part.GetStream(mode, access); + } + + public async Task ReplaceSupplementaryFileInPackageAsync(string sourceUri, string targetFile, string targetContentType, Stream fileContent) + { + // access + if (_openPackage == null) + throw (new Exception(string.Format($"AASX Package {_fn} not opened. Aborting!"))); + + if (!string.IsNullOrEmpty(sourceUri)) + { + _openPackage.DeletePart(new Uri(sourceUri, UriKind.RelativeOrAbsolute)); + + } + var targetUri = PackUriHelper.CreatePartUri(new Uri(targetFile, UriKind.RelativeOrAbsolute)); + PackagePart packagePart = _openPackage.CreatePart(targetUri, targetContentType); + fileContent.Position = 0; + using (Stream dest = packagePart.GetStream()) + { + fileContent.CopyTo(dest); + } + } + + public long GetStreamSizeFromPackage(string uriString) + { + long res = 0; + try + { + if (_openPackage == null) + return 0; + var part = _openPackage.GetPart(new Uri(uriString, UriKind.RelativeOrAbsolute)); + using (var s = part.GetStream(FileMode.Open)) + { + res = s.Length; + } + } + catch (Exception ex) + { + LogInternally.That.SilentlyIgnoredError(ex); + return 0; + } + return res; + } + + /// + /// Ensures: + ///
  • result == null || result.CanRead
+ ///
+ public Stream GetLocalThumbnailStream(ref Uri thumbUri) + { + // access + if (_openPackage == null) + throw (new Exception(string.Format($"AASX Package {_fn} not opened. Aborting!"))); + // get the thumbnail over the relationship + PackagePart thumbPart = null; + var xs = _openPackage.GetRelationshipsByType( + "http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail"); + foreach (var x in xs) + if (x.SourceUri.ToString() == "/") + { + thumbPart = _openPackage.GetPart(x.TargetUri); + thumbUri = x.TargetUri; + break; + } + if (thumbPart == null) + throw (new Exception("Unable to find AASX thumbnail. Aborting!")); + + var result = thumbPart.GetStream(FileMode.Open); + + // Post-condition + if (!(result == null || result.CanRead)) + { + throw new InvalidOperationException("Unexpected unreadable result stream"); + } + + return result; + } + + /// + /// Ensures: + ///
  • result == null || result.CanRead
+ ///
+ public Stream GetLocalThumbnailStream() + { + Uri dummy = null; + var result = GetLocalThumbnailStream(ref dummy); + + // Post-condition + if (!(result == null || result.CanRead)) + { + throw new InvalidOperationException("Unexpected unreadable result stream"); + } + + return result; + } + + public ListOfAasSupplementaryFile GetListOfSupplementaryFiles() + { + // new result + var result = new ListOfAasSupplementaryFile(); + + // access + if (_openPackage != null) + { + + // get the thumbnail(s) from the package + var xs = _openPackage.GetRelationshipsByType( + "http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail"); + foreach (var x in xs) + if (x.SourceUri.ToString() == "/") + { + result.Add(new AdminShellPackageSupplementaryFile( + x.TargetUri, + location: AdminShellPackageSupplementaryFile.LocationType.InPackage, + specialHandling: AdminShellPackageSupplementaryFile.SpecialHandlingType.EmbedAsThumbnail)); + } + + // get the origin from the package + PackagePart originPart = null; + xs = _openPackage.GetRelationshipsByType( + "http://www.admin-shell.io/aasx/relationships/aasx-origin"); + foreach (var x in xs) + if (x.SourceUri.ToString() == "/") + { + originPart = _openPackage.GetPart(x.TargetUri); + break; + } + + if (originPart != null) + { + // get the specs from the origin + PackagePart specPart = null; + xs = originPart.GetRelationshipsByType("http://www.admin-shell.io/aasx/relationships/aas-spec"); + foreach (var x in xs) + { + specPart = _openPackage.GetPart(x.TargetUri); + break; + } + + if (specPart != null) + { + // get the supplementaries from the package, derived from spec + xs = specPart.GetRelationshipsByType("http://www.admin-shell.io/aasx/relationships/aas-suppl"); + foreach (var x in xs) + { + result.Add( + new AdminShellPackageSupplementaryFile( + x.TargetUri, location: AdminShellPackageSupplementaryFile.LocationType.InPackage)); + } + } + } + } + + // add or modify the files to delete + foreach (var psfDel in _pendingFilesToDelete) + { + // already in + var found = result.Find(x => { return x.Uri == psfDel.Uri; }); + if (found != null) + found.Location = AdminShellPackageSupplementaryFile.LocationType.DeletePending; + else + { + psfDel.Location = AdminShellPackageSupplementaryFile.LocationType.DeletePending; + result.Add(psfDel); + } + } + + // add the files to store as well + foreach (var psfAdd in _pendingFilesToAdd) + { + // already in (should not happen ?!) + var found = result.Find(x => { return x.Uri == psfAdd.Uri; }); + if (found != null) + found.Location = AdminShellPackageSupplementaryFile.LocationType.AddPending; + else + { + psfAdd.Location = AdminShellPackageSupplementaryFile.LocationType.AddPending; + result.Add(psfAdd); + } + } + + // done + return result; + } + + public static string GuessMimeType(string fn) + { + var file_ext = System.IO.Path.GetExtension(fn).ToLower().Trim(); + var content_type = System.Net.Mime.MediaTypeNames.Text.Plain; + if (file_ext == ".pdf") content_type = System.Net.Mime.MediaTypeNames.Application.Pdf; + if (file_ext == ".xml") content_type = System.Net.Mime.MediaTypeNames.Text.Xml; + if (file_ext == ".txt") content_type = System.Net.Mime.MediaTypeNames.Text.Plain; + if (file_ext == ".igs") content_type = "application/iges"; + if (file_ext == ".iges") content_type = "application/iges"; + if (file_ext == ".stp") content_type = "application/step"; + if (file_ext == ".step") content_type = "application/step"; + if (file_ext == ".jpg") content_type = System.Net.Mime.MediaTypeNames.Image.Jpeg; + if (file_ext == ".jpeg") content_type = System.Net.Mime.MediaTypeNames.Image.Jpeg; + if (file_ext == ".png") content_type = "image/png"; + if (file_ext == ".gif") content_type = System.Net.Mime.MediaTypeNames.Image.Gif; + return content_type; + } + + public void PrepareSupplementaryFileParameters(ref string targetDir, ref string targetFn) + { + // re-work target dir + if (targetDir != null) + targetDir = targetDir.Replace(@"\", "/"); + + // rework targetFn + if (targetFn != null) + targetFn = Regex.Replace(targetFn, @"[^A-Za-z0-9-.]+", "_"); + } + + /// + /// Add a file as supplementary file to package. Operation will be pending, package needs to be saved in order + /// materialize embedding. + /// + /// Target path of file in package + public string AddSupplementaryFileToStore( + string sourcePath, string targetDir, string targetFn, bool embedAsThumb, + AdminShellPackageSupplementaryFile.SourceGetByteChunk sourceGetBytesDel = null, string useMimeType = null) + { + // beautify parameters + if ((sourcePath == null && sourceGetBytesDel == null) || targetDir == null || targetFn == null) + return null; + + // build target path + targetDir = targetDir.Trim(); + if (!targetDir.EndsWith("/")) + targetDir += "/"; + targetFn = targetFn.Trim(); + if (sourcePath == "" || targetDir == "" || targetFn == "") + throw (new Exception("Trying add supplementary file with empty name or path!")); + + var targetPath = "" + targetDir.Trim() + targetFn.Trim(); + + // base function + AddSupplementaryFileToStore(sourcePath, targetPath, embedAsThumb, sourceGetBytesDel, useMimeType); + + // return target path + return targetPath; + } + + public void AddSupplementaryFileToStore(string sourcePath, string targetPath, bool embedAsThumb, + AdminShellPackageSupplementaryFile.SourceGetByteChunk sourceGetBytesDel = null, string useMimeType = null) + { + // beautify parameters + if ((sourcePath == null && sourceGetBytesDel == null) || targetPath == null) + return; + + sourcePath = sourcePath?.Trim(); + targetPath = targetPath.Trim(); + + // add record + _pendingFilesToAdd.Add( + new AdminShellPackageSupplementaryFile( + new Uri(targetPath, UriKind.RelativeOrAbsolute), + sourcePath, + location: AdminShellPackageSupplementaryFile.LocationType.AddPending, + specialHandling: (embedAsThumb + ? AdminShellPackageSupplementaryFile.SpecialHandlingType.EmbedAsThumbnail + : AdminShellPackageSupplementaryFile.SpecialHandlingType.None), + sourceGetBytesDel: sourceGetBytesDel, + useMimeType: useMimeType) + ); + + } + + public void DeleteSupplementaryFile(AdminShellPackageSupplementaryFile psf) + { + if (psf == null) + throw (new Exception("No supplementary file given!")); + + if (psf.Location == AdminShellPackageSupplementaryFile.LocationType.AddPending) + { + // is still pending in add list -> remove + _pendingFilesToAdd.RemoveAll((x) => { return x.Uri == psf.Uri; }); + } + + if (psf.Location == AdminShellPackageSupplementaryFile.LocationType.InPackage) + { + // add to pending delete list + _pendingFilesToDelete.Add(psf); + } + } + + public void Close() + { + _openPackage?.Close(); + _openPackage = null; + _fn = ""; + _aasEnv = null; + } + + public void Flush() + { + if (_openPackage != null) + _openPackage.Flush(); + } + + public void Dispose() + { + Close(); + } + + public string MakePackageFileAvailableAsTempFile(string packageUri, bool keepFilename = false) + { + // access + if (packageUri == null) + return null; + + // get input stream + using (var input = GetLocalStreamFromPackage(packageUri)) + { + // generate tempfile name + string tempext = System.IO.Path.GetExtension(packageUri); + string temppath = System.IO.Path.GetTempFileName().Replace(".tmp", tempext); + + // maybe modify tempfile name? + if (keepFilename) + { + var masterFn = System.IO.Path.GetFileNameWithoutExtension(packageUri); + var tmpDir = System.IO.Path.GetDirectoryName(temppath); + var tmpFnExt = System.IO.Path.GetFileName(temppath); + + temppath = System.IO.Path.Combine(tmpDir, "" + masterFn + "_" + tmpFnExt); + } + + // copy to temp file + using (var temp = System.IO.File.OpenWrite(temppath)) + { + input.CopyTo(temp); + return temppath; + } + } + } + + public void EmbeddAssetInformationThumbnail(IResource defaultThumbnail, Stream fileContent) + { + // access + if (_openPackage == null) + throw (new Exception(string.Format($"AASX Package {_fn} not opened. Aborting!"))); + + if (!string.IsNullOrEmpty(defaultThumbnail.Path)) + { + var sourceUri = defaultThumbnail.Path.Replace(Path.DirectorySeparatorChar, '/'); + _openPackage.DeletePart(new Uri(sourceUri, UriKind.RelativeOrAbsolute)); + + } + var targetUri = PackUriHelper.CreatePartUri(new Uri(defaultThumbnail.Path, UriKind.RelativeOrAbsolute)); + + PackagePart packagePart = _openPackage.CreatePart(targetUri, defaultThumbnail.ContentType, compressionOption: CompressionOption.Maximum); + + _openPackage.CreateRelationship(packagePart.Uri, TargetMode.Internal, + "http://schemas.openxmlformats.org/package/2006/" + + "relationships/metadata/thumbnail"); + + //Write to the part + fileContent.Position = 0; + using (Stream dest = packagePart.GetStream()) + { + fileContent.CopyTo(dest); + } + } + } +} diff --git a/src/AasxCsharpLibrary/AdminShellUtil.cs b/src/AasxCsharpLibrary/AdminShellUtil.cs index 5e3d82e4a..572e2299c 100644 --- a/src/AasxCsharpLibrary/AdminShellUtil.cs +++ b/src/AasxCsharpLibrary/AdminShellUtil.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018-2021 Festo AG & Co. KG +Copyright (c) 2018-2023 Festo AG & Co. KG Author: Michael Hoffmeister This source code is licensed under the Apache License 2.0 (see LICENSE.txt). @@ -864,7 +864,7 @@ public static string GetTemporaryDirectory() // see: https://stackoverflow.com/questions/6386113/using-system-io-packaging-to-generate-a-zip-file public static void AddFileToZip( - string zipFilename, string fileToAdd, + string zipFilename, string fileToAdd, CompressionOption compression = CompressionOption.Normal, FileMode fileMode = FileMode.OpenOrCreate) { @@ -933,8 +933,8 @@ public static string Base64Decode(string base64EncodedData) public static bool CheckIfAsciiOnly(byte[] data, int bytesToCheck = int.MaxValue) { if (data == null) - return true; - + return true; + var ascii = true; for (int i = 0; i < Math.Min(data.Length, bytesToCheck); i++) if (data[i] >= 128) diff --git a/src/AasxCsharpLibrary/AdminShellValidate.cs b/src/AasxCsharpLibrary/AdminShellValidate.cs index 475477b4f..61368a5d8 100644 --- a/src/AasxCsharpLibrary/AdminShellValidate.cs +++ b/src/AasxCsharpLibrary/AdminShellValidate.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018-2021 Festo AG & Co. KG +Copyright (c) 2018-2023 Festo AG & Co. KG Author: Michael Hoffmeister This source code is licensed under the Apache License 2.0 (see LICENSE.txt). diff --git a/src/AasxCsharpLibrary/Display/EnumerationPlacmentBase.cs b/src/AasxCsharpLibrary/Display/EnumerationPlacmentBase.cs index 52f09f025..30efc4cad 100644 --- a/src/AasxCsharpLibrary/Display/EnumerationPlacmentBase.cs +++ b/src/AasxCsharpLibrary/Display/EnumerationPlacmentBase.cs @@ -1,4 +1,12 @@ -namespace AdminShellNS.Display +/* +Copyright (c) 2018-2023 Festo AG & Co. KG +Author: Michael Hoffmeister + +This source code is licensed under the Apache License 2.0 (see LICENSE.txt). + +This source code may use other Open Source software components (see LICENSE.txt). +*/ +namespace AdminShellNS.Display { public class EnumerationPlacmentBase { diff --git a/src/AasxCsharpLibrary/Display/EnumerationPlacmentOperationVariable.cs b/src/AasxCsharpLibrary/Display/EnumerationPlacmentOperationVariable.cs index a5b1723f1..ebd9e3def 100644 --- a/src/AasxCsharpLibrary/Display/EnumerationPlacmentOperationVariable.cs +++ b/src/AasxCsharpLibrary/Display/EnumerationPlacmentOperationVariable.cs @@ -1,4 +1,12 @@ -namespace AdminShellNS.Display +/* +Copyright (c) 2018-2023 Festo AG & Co. KG +Author: Michael Hoffmeister + +This source code is licensed under the Apache License 2.0 (see LICENSE.txt). + +This source code may use other Open Source software components (see LICENSE.txt). +*/ +namespace AdminShellNS.Display { public class EnumerationPlacmentOperationVariable : EnumerationPlacmentBase { diff --git a/src/AasxCsharpLibrary/Display/OperationVariableDirection.cs b/src/AasxCsharpLibrary/Display/OperationVariableDirection.cs index f9bf1af30..b94d1555c 100644 --- a/src/AasxCsharpLibrary/Display/OperationVariableDirection.cs +++ b/src/AasxCsharpLibrary/Display/OperationVariableDirection.cs @@ -1,4 +1,12 @@ -namespace AdminShellNS.Display +/* +Copyright (c) 2018-2023 Festo AG & Co. KG +Author: Michael Hoffmeister + +This source code is licensed under the Apache License 2.0 (see LICENSE.txt). + +This source code may use other Open Source software components (see LICENSE.txt). +*/ +namespace AdminShellNS.Display { public enum OperationVariableDirection { diff --git a/src/AasxCsharpLibrary/Exceptions/MetamodelVerificationException.cs b/src/AasxCsharpLibrary/Exceptions/MetamodelVerificationException.cs index 712e8fb67..e82a140d8 100644 --- a/src/AasxCsharpLibrary/Exceptions/MetamodelVerificationException.cs +++ b/src/AasxCsharpLibrary/Exceptions/MetamodelVerificationException.cs @@ -1,4 +1,12 @@ -using System; +/* +Copyright (c) 2018-2023 Festo AG & Co. KG +Author: Michael Hoffmeister + +This source code is licensed under the Apache License 2.0 (see LICENSE.txt). + +This source code may use other Open Source software components (see LICENSE.txt). +*/ +using System; using System.Collections.Generic; using static AasCore.Aas3_0.Reporting; diff --git a/src/AasxCsharpLibrary/Exceptions/NullValueException.cs b/src/AasxCsharpLibrary/Exceptions/NullValueException.cs index e6f64e125..285ad9976 100644 --- a/src/AasxCsharpLibrary/Exceptions/NullValueException.cs +++ b/src/AasxCsharpLibrary/Exceptions/NullValueException.cs @@ -1,4 +1,12 @@ -using System; +/* +Copyright (c) 2018-2023 Festo AG & Co. KG +Author: Michael Hoffmeister + +This source code is licensed under the Apache License 2.0 (see LICENSE.txt). + +This source code may use other Open Source software components (see LICENSE.txt). +*/ +using System; namespace AdminShellNS.Exceptions { diff --git a/src/AasxCsharpLibrary/Extensions/AasElementSelfDescription.cs b/src/AasxCsharpLibrary/Extensions/AasElementSelfDescription.cs index 3f584ac0e..b619c40c3 100644 --- a/src/AasxCsharpLibrary/Extensions/AasElementSelfDescription.cs +++ b/src/AasxCsharpLibrary/Extensions/AasElementSelfDescription.cs @@ -1,4 +1,11 @@ - +/* +Copyright (c) 2018-2023 Festo AG & Co. KG +Author: Michael Hoffmeister + +This source code is licensed under the Apache License 2.0 (see LICENSE.txt). + +This source code may use other Open Source software components (see LICENSE.txt). +*/ namespace Extensions { public class AasElementSelfDescription diff --git a/src/AasxCsharpLibrary/Extensions/ComparerUtils.cs b/src/AasxCsharpLibrary/Extensions/ComparerUtils.cs index 8305ade1d..feb6f349a 100644 --- a/src/AasxCsharpLibrary/Extensions/ComparerUtils.cs +++ b/src/AasxCsharpLibrary/Extensions/ComparerUtils.cs @@ -1,4 +1,12 @@ -using System.Collections.Generic; +/* +Copyright (c) 2018-2023 Festo AG & Co. KG +Author: Michael Hoffmeister + +This source code is licensed under the Apache License 2.0 (see LICENSE.txt). + +This source code may use other Open Source software components (see LICENSE.txt). +*/ +using System.Collections.Generic; using System.Globalization; namespace Extensions diff --git a/src/AasxCsharpLibrary/Extensions/ExtendAnnotatedRelationshipElement.cs b/src/AasxCsharpLibrary/Extensions/ExtendAnnotatedRelationshipElement.cs index 460ea0fe4..2f6fc880a 100644 --- a/src/AasxCsharpLibrary/Extensions/ExtendAnnotatedRelationshipElement.cs +++ b/src/AasxCsharpLibrary/Extensions/ExtendAnnotatedRelationshipElement.cs @@ -1,4 +1,12 @@ -using AdminShellNS.Display; +/* +Copyright (c) 2018-2023 Festo AG & Co. KG +Author: Michael Hoffmeister + +This source code is licensed under the Apache License 2.0 (see LICENSE.txt). + +This source code may use other Open Source software components (see LICENSE.txt). +*/ +using AdminShellNS.Display; using System; using System.Collections.Generic; using System.Linq; diff --git a/src/AasxCsharpLibrary/Extensions/ExtendAssetAdministrationShell.cs b/src/AasxCsharpLibrary/Extensions/ExtendAssetAdministrationShell.cs index de80ed138..ae3f0c1cc 100644 --- a/src/AasxCsharpLibrary/Extensions/ExtendAssetAdministrationShell.cs +++ b/src/AasxCsharpLibrary/Extensions/ExtendAssetAdministrationShell.cs @@ -1,4 +1,12 @@ -using AdminShellNS; +/* +Copyright (c) 2018-2023 Festo AG & Co. KG +Author: Michael Hoffmeister + +This source code is licensed under the Apache License 2.0 (see LICENSE.txt). + +This source code may use other Open Source software components (see LICENSE.txt). +*/ +using AdminShellNS; using System; using System.Collections.Generic; using System.Text.RegularExpressions; diff --git a/src/AasxCsharpLibrary/Extensions/ExtendAssetInformation.cs b/src/AasxCsharpLibrary/Extensions/ExtendAssetInformation.cs index fd0a9e460..3c9a3a938 100644 --- a/src/AasxCsharpLibrary/Extensions/ExtendAssetInformation.cs +++ b/src/AasxCsharpLibrary/Extensions/ExtendAssetInformation.cs @@ -1,4 +1,12 @@ -using System; +/* +Copyright (c) 2018-2023 Festo AG & Co. KG +Author: Michael Hoffmeister + +This source code is licensed under the Apache License 2.0 (see LICENSE.txt). + +This source code may use other Open Source software components (see LICENSE.txt). +*/ +using System; namespace Extensions { diff --git a/src/AasxCsharpLibrary/Extensions/ExtendBlob.cs b/src/AasxCsharpLibrary/Extensions/ExtendBlob.cs index 31983384b..004023c72 100644 --- a/src/AasxCsharpLibrary/Extensions/ExtendBlob.cs +++ b/src/AasxCsharpLibrary/Extensions/ExtendBlob.cs @@ -1,4 +1,12 @@ -using System.Text; +/* +Copyright (c) 2018-2023 Festo AG & Co. KG +Author: Michael Hoffmeister + +This source code is licensed under the Apache License 2.0 (see LICENSE.txt). + +This source code may use other Open Source software components (see LICENSE.txt). +*/ +using System.Text; namespace Extensions { diff --git a/src/AasxCsharpLibrary/Extensions/ExtendConceptDescription.cs b/src/AasxCsharpLibrary/Extensions/ExtendConceptDescription.cs index 29510ea73..527803a3b 100644 --- a/src/AasxCsharpLibrary/Extensions/ExtendConceptDescription.cs +++ b/src/AasxCsharpLibrary/Extensions/ExtendConceptDescription.cs @@ -1,4 +1,12 @@ -using AdminShellNS; +/* +Copyright (c) 2018-2023 Festo AG & Co. KG +Author: Michael Hoffmeister + +This source code is licensed under the Apache License 2.0 (see LICENSE.txt). + +This source code may use other Open Source software components (see LICENSE.txt). +*/ +using AdminShellNS; using System; using System.Collections.Generic; using System.Linq; diff --git a/src/AasxCsharpLibrary/Extensions/ExtendDataElement.cs b/src/AasxCsharpLibrary/Extensions/ExtendDataElement.cs index a36fe71d5..c8bba8c3e 100644 --- a/src/AasxCsharpLibrary/Extensions/ExtendDataElement.cs +++ b/src/AasxCsharpLibrary/Extensions/ExtendDataElement.cs @@ -1,4 +1,12 @@ -namespace Extensions +/* +Copyright (c) 2018-2023 Festo AG & Co. KG +Author: Michael Hoffmeister + +This source code is licensed under the Apache License 2.0 (see LICENSE.txt). + +This source code may use other Open Source software components (see LICENSE.txt). +*/ +namespace Extensions { public static class ExtendDataElement { diff --git a/src/AasxCsharpLibrary/Extensions/ExtendDataSpecificationIEC61360.cs b/src/AasxCsharpLibrary/Extensions/ExtendDataSpecificationIEC61360.cs index 8ffd2f3ca..b1a600060 100644 --- a/src/AasxCsharpLibrary/Extensions/ExtendDataSpecificationIEC61360.cs +++ b/src/AasxCsharpLibrary/Extensions/ExtendDataSpecificationIEC61360.cs @@ -1,4 +1,12 @@ -using System.Collections.Generic; +/* +Copyright (c) 2018-2023 Festo AG & Co. KG +Author: Michael Hoffmeister + +This source code is licensed under the Apache License 2.0 (see LICENSE.txt). + +This source code may use other Open Source software components (see LICENSE.txt). +*/ +using System.Collections.Generic; namespace Extensions { diff --git a/src/AasxCsharpLibrary/Extensions/ExtendEmbeddedDataSpecification.cs b/src/AasxCsharpLibrary/Extensions/ExtendEmbeddedDataSpecification.cs index e290d6d7d..f2996502a 100644 --- a/src/AasxCsharpLibrary/Extensions/ExtendEmbeddedDataSpecification.cs +++ b/src/AasxCsharpLibrary/Extensions/ExtendEmbeddedDataSpecification.cs @@ -1,4 +1,12 @@ -using System.Collections.Generic; +/* +Copyright (c) 2018-2023 Festo AG & Co. KG +Author: Michael Hoffmeister + +This source code is licensed under the Apache License 2.0 (see LICENSE.txt). + +This source code may use other Open Source software components (see LICENSE.txt). +*/ +using System.Collections.Generic; // using DataSpecificationContent = HasDataSpecification.DataSpecificationContent; namespace Extensions diff --git a/src/AasxCsharpLibrary/Extensions/ExtendEntity.cs b/src/AasxCsharpLibrary/Extensions/ExtendEntity.cs index a23c82e91..3a34d8ec4 100644 --- a/src/AasxCsharpLibrary/Extensions/ExtendEntity.cs +++ b/src/AasxCsharpLibrary/Extensions/ExtendEntity.cs @@ -1,4 +1,12 @@ -using AdminShellNS.Display; +/* +Copyright (c) 2018-2023 Festo AG & Co. KG +Author: Michael Hoffmeister + +This source code is licensed under the Apache License 2.0 (see LICENSE.txt). + +This source code may use other Open Source software components (see LICENSE.txt). +*/ +using AdminShellNS.Display; using System; using System.Collections.Generic; using System.Linq; diff --git a/src/AasxCsharpLibrary/Extensions/ExtendEnvironment.cs b/src/AasxCsharpLibrary/Extensions/ExtendEnvironment.cs index 0e913c6bf..ee3febf94 100644 --- a/src/AasxCsharpLibrary/Extensions/ExtendEnvironment.cs +++ b/src/AasxCsharpLibrary/Extensions/ExtendEnvironment.cs @@ -1,4 +1,12 @@ -using AdminShellNS; +/* +Copyright (c) 2018-2023 Festo AG & Co. KG +Author: Michael Hoffmeister + +This source code is licensed under the Apache License 2.0 (see LICENSE.txt). + +This source code may use other Open Source software components (see LICENSE.txt). +*/ +using AdminShellNS; using Newtonsoft.Json; using System; using System.Collections.Generic; diff --git a/src/AasxCsharpLibrary/Extensions/ExtendFile.cs b/src/AasxCsharpLibrary/Extensions/ExtendFile.cs index a838911cd..4538b3679 100644 --- a/src/AasxCsharpLibrary/Extensions/ExtendFile.cs +++ b/src/AasxCsharpLibrary/Extensions/ExtendFile.cs @@ -1,4 +1,12 @@ -namespace Extensions +/* +Copyright (c) 2018-2023 Festo AG & Co. KG +Author: Michael Hoffmeister + +This source code is licensed under the Apache License 2.0 (see LICENSE.txt). + +This source code may use other Open Source software components (see LICENSE.txt). +*/ +namespace Extensions { public static class ExtendFile { diff --git a/src/AasxCsharpLibrary/Extensions/ExtendHasDataSpecification.cs b/src/AasxCsharpLibrary/Extensions/ExtendHasDataSpecification.cs index 4f2c51692..7ac12e1a9 100644 --- a/src/AasxCsharpLibrary/Extensions/ExtendHasDataSpecification.cs +++ b/src/AasxCsharpLibrary/Extensions/ExtendHasDataSpecification.cs @@ -1,4 +1,12 @@ -namespace Extensions +/* +Copyright (c) 2018-2023 Festo AG & Co. KG +Author: Michael Hoffmeister + +This source code is licensed under the Apache License 2.0 (see LICENSE.txt). + +This source code may use other Open Source software components (see LICENSE.txt). +*/ +namespace Extensions { public static class ExtendHasDataSpecification { diff --git a/src/AasxCsharpLibrary/Extensions/ExtendIAdministrativeInformation.cs b/src/AasxCsharpLibrary/Extensions/ExtendIAdministrativeInformation.cs index 8dd8afeb7..d872d13b3 100644 --- a/src/AasxCsharpLibrary/Extensions/ExtendIAdministrativeInformation.cs +++ b/src/AasxCsharpLibrary/Extensions/ExtendIAdministrativeInformation.cs @@ -1,4 +1,12 @@ -using System; +/* +Copyright (c) 2018-2023 Festo AG & Co. KG +Author: Michael Hoffmeister + +This source code is licensed under the Apache License 2.0 (see LICENSE.txt). + +This source code may use other Open Source software components (see LICENSE.txt). +*/ +using System; using System.Collections.Generic; using System.Linq; @@ -10,7 +18,7 @@ public static string ToStringExtended(this IAdministrativeInformation ls, int fm { if (fmt == 2) return String.Format("/{0}/{1}", ls.Version, ls.Revision); - return String.Format("[ver={0}, rev={1}, tmpl={2}, crea={3}]", + return String.Format("[ver={0}, rev={1}, tmpl={2}, crea={3}]", ls.Version, ls.Revision, ls.TemplateId, ls.Creator?.ToStringExtended(fmt)); } } diff --git a/src/AasxCsharpLibrary/Extensions/ExtendIClass.cs b/src/AasxCsharpLibrary/Extensions/ExtendIClass.cs index d8a7aaeff..bfc166b54 100644 --- a/src/AasxCsharpLibrary/Extensions/ExtendIClass.cs +++ b/src/AasxCsharpLibrary/Extensions/ExtendIClass.cs @@ -1,4 +1,12 @@ -using System.Collections.Generic; +/* +Copyright (c) 2018-2023 Festo AG & Co. KG +Author: Michael Hoffmeister + +This source code is licensed under the Apache License 2.0 (see LICENSE.txt). + +This source code may use other Open Source software components (see LICENSE.txt). +*/ +using System.Collections.Generic; using System.Linq; namespace Extensions diff --git a/src/AasxCsharpLibrary/Extensions/ExtendIDataSpecificationContent.cs b/src/AasxCsharpLibrary/Extensions/ExtendIDataSpecificationContent.cs index cb699f87f..6247e2f7b 100644 --- a/src/AasxCsharpLibrary/Extensions/ExtendIDataSpecificationContent.cs +++ b/src/AasxCsharpLibrary/Extensions/ExtendIDataSpecificationContent.cs @@ -1,4 +1,12 @@ -using AdminShellNS; +/* +Copyright (c) 2018-2023 Festo AG & Co. KG +Author: Michael Hoffmeister + +This source code is licensed under the Apache License 2.0 (see LICENSE.txt). + +This source code may use other Open Source software components (see LICENSE.txt). +*/ +using AdminShellNS; using System.Collections.Generic; namespace Extensions diff --git a/src/AasxCsharpLibrary/Extensions/ExtendIIdentifiable.cs b/src/AasxCsharpLibrary/Extensions/ExtendIIdentifiable.cs index dec471483..2d66bb81a 100644 --- a/src/AasxCsharpLibrary/Extensions/ExtendIIdentifiable.cs +++ b/src/AasxCsharpLibrary/Extensions/ExtendIIdentifiable.cs @@ -1,4 +1,12 @@ -using System.Collections.Generic; +/* +Copyright (c) 2018-2023 Festo AG & Co. KG +Author: Michael Hoffmeister + +This source code is licensed under the Apache License 2.0 (see LICENSE.txt). + +This source code may use other Open Source software components (see LICENSE.txt). +*/ +using System.Collections.Generic; using System.Linq; namespace Extensions diff --git a/src/AasxCsharpLibrary/Extensions/ExtendILangStringDefinitionTypeIec61360.cs b/src/AasxCsharpLibrary/Extensions/ExtendILangStringDefinitionTypeIec61360.cs index 5d527d27f..7cfe9fbb6 100644 --- a/src/AasxCsharpLibrary/Extensions/ExtendILangStringDefinitionTypeIec61360.cs +++ b/src/AasxCsharpLibrary/Extensions/ExtendILangStringDefinitionTypeIec61360.cs @@ -1,4 +1,12 @@ -using System; +/* +Copyright (c) 2018-2023 Festo AG & Co. KG +Author: Michael Hoffmeister + +This source code is licensed under the Apache License 2.0 (see LICENSE.txt). + +This source code may use other Open Source software components (see LICENSE.txt). +*/ +using System; using System.Collections.Generic; namespace Extensions diff --git a/src/AasxCsharpLibrary/Extensions/ExtendILangStringNameType.cs b/src/AasxCsharpLibrary/Extensions/ExtendILangStringNameType.cs index 8a0eb8374..73528cc82 100644 --- a/src/AasxCsharpLibrary/Extensions/ExtendILangStringNameType.cs +++ b/src/AasxCsharpLibrary/Extensions/ExtendILangStringNameType.cs @@ -1,4 +1,12 @@ -using System; +/* +Copyright (c) 2018-2023 Festo AG & Co. KG +Author: Michael Hoffmeister + +This source code is licensed under the Apache License 2.0 (see LICENSE.txt). + +This source code may use other Open Source software components (see LICENSE.txt). +*/ +using System; using System.Collections.Generic; using System.Linq; @@ -13,7 +21,7 @@ public static string ToStringExtended(this ILangStringNameType ls, int fmt) return String.Format("[{0},{1}]", ls.Language, ls.Text); } - public static string ToStringExtended(this List elems, + public static string ToStringExtended(this List elems, int format = 1, string delimiter = ",") { return string.Join(delimiter, elems.Select((k) => k.ToStringExtended(format))); diff --git a/src/AasxCsharpLibrary/Extensions/ExtendILangStringPreferredNameTypeIec61360.cs b/src/AasxCsharpLibrary/Extensions/ExtendILangStringPreferredNameTypeIec61360.cs index e1faa8efe..6dce9cd40 100644 --- a/src/AasxCsharpLibrary/Extensions/ExtendILangStringPreferredNameTypeIec61360.cs +++ b/src/AasxCsharpLibrary/Extensions/ExtendILangStringPreferredNameTypeIec61360.cs @@ -1,4 +1,12 @@ -using System; +/* +Copyright (c) 2018-2023 Festo AG & Co. KG +Author: Michael Hoffmeister + +This source code is licensed under the Apache License 2.0 (see LICENSE.txt). + +This source code may use other Open Source software components (see LICENSE.txt). +*/ +using System; using System.Collections.Generic; namespace Extensions @@ -29,8 +37,8 @@ public static string GetDefaultString(this List ConvertFromV20( this List lss, AasxCompatibilityModels.AdminShellV20.LangStringSetIEC61360 src) diff --git a/src/AasxCsharpLibrary/Extensions/ExtendILangStringShortNameTypeIec61360.cs b/src/AasxCsharpLibrary/Extensions/ExtendILangStringShortNameTypeIec61360.cs index 4ed41aece..5bb312ce1 100644 --- a/src/AasxCsharpLibrary/Extensions/ExtendILangStringShortNameTypeIec61360.cs +++ b/src/AasxCsharpLibrary/Extensions/ExtendILangStringShortNameTypeIec61360.cs @@ -1,4 +1,12 @@ -using System; +/* +Copyright (c) 2018-2023 Festo AG & Co. KG +Author: Michael Hoffmeister + +This source code is licensed under the Apache License 2.0 (see LICENSE.txt). + +This source code may use other Open Source software components (see LICENSE.txt). +*/ +using System; using System.Collections.Generic; namespace Extensions @@ -8,8 +16,8 @@ public static class ExtendILangStringShortNameTypeIec61360 public static List CreateLangStringShortNameType(string language, string text) { return new List { new LangStringShortNameTypeIec61360(language, text) }; - } - + } + public static string GetDefaultString(this List langStringSet, string defaultLang = null) { return ExtendLangString.GetDefaultStringGen(langStringSet, defaultLang); diff --git a/src/AasxCsharpLibrary/Extensions/ExtendILangStringTextType.cs b/src/AasxCsharpLibrary/Extensions/ExtendILangStringTextType.cs index 45f07d68f..d30a5d83d 100644 --- a/src/AasxCsharpLibrary/Extensions/ExtendILangStringTextType.cs +++ b/src/AasxCsharpLibrary/Extensions/ExtendILangStringTextType.cs @@ -1,4 +1,12 @@ -using System; +/* +Copyright (c) 2018-2023 Festo AG & Co. KG +Author: Michael Hoffmeister + +This source code is licensed under the Apache License 2.0 (see LICENSE.txt). + +This source code may use other Open Source software components (see LICENSE.txt). +*/ +using System; using System.Collections.Generic; using System.Linq; @@ -18,7 +26,7 @@ public static string ToStringExtended(this ILangStringTextType ls, int fmt) return String.Format("[{0},{1}]", ls.Language, ls.Text); } - public static string ToStringExtended(this List elems, + public static string ToStringExtended(this List elems, int format = 1, string delimiter = ",") { return string.Join(delimiter, elems.Select((k) => k.ToStringExtended(format))); diff --git a/src/AasxCsharpLibrary/Extensions/ExtendIReferable.cs b/src/AasxCsharpLibrary/Extensions/ExtendIReferable.cs index c11504043..45a6cee8b 100644 --- a/src/AasxCsharpLibrary/Extensions/ExtendIReferable.cs +++ b/src/AasxCsharpLibrary/Extensions/ExtendIReferable.cs @@ -1,4 +1,12 @@ -using AdminShellNS; +/* +Copyright (c) 2018-2023 Festo AG & Co. KG +Author: Michael Hoffmeister + +This source code is licensed under the Apache License 2.0 (see LICENSE.txt). + +This source code may use other Open Source software components (see LICENSE.txt). +*/ +using AdminShellNS; using AdminShellNS.Display; using System; using System.Collections.Generic; diff --git a/src/AasxCsharpLibrary/Extensions/ExtendISubmodelElement.cs b/src/AasxCsharpLibrary/Extensions/ExtendISubmodelElement.cs index 6faa74108..e55eb4060 100644 --- a/src/AasxCsharpLibrary/Extensions/ExtendISubmodelElement.cs +++ b/src/AasxCsharpLibrary/Extensions/ExtendISubmodelElement.cs @@ -1,4 +1,12 @@ -using AasxCompatibilityModels; +/* +Copyright (c) 2018-2023 Festo AG & Co. KG +Author: Michael Hoffmeister + +This source code is licensed under the Apache License 2.0 (see LICENSE.txt). + +This source code may use other Open Source software components (see LICENSE.txt). +*/ +using AasxCompatibilityModels; using AdminShellNS; using AdminShellNS.Display; using System; diff --git a/src/AasxCsharpLibrary/Extensions/ExtendKey.cs b/src/AasxCsharpLibrary/Extensions/ExtendKey.cs index 9042c9ebb..1c1468dbd 100644 --- a/src/AasxCsharpLibrary/Extensions/ExtendKey.cs +++ b/src/AasxCsharpLibrary/Extensions/ExtendKey.cs @@ -1,4 +1,12 @@ -using AdminShellNS; +/* +Copyright (c) 2018-2023 Festo AG & Co. KG +Author: Michael Hoffmeister + +This source code is licensed under the Apache License 2.0 (see LICENSE.txt). + +This source code may use other Open Source software components (see LICENSE.txt). +*/ +using AdminShellNS; using System; using System.Collections.Generic; using System.Text.RegularExpressions; diff --git a/src/AasxCsharpLibrary/Extensions/ExtendKeyList.cs b/src/AasxCsharpLibrary/Extensions/ExtendKeyList.cs index 1c7dd5c2c..f31af2106 100644 --- a/src/AasxCsharpLibrary/Extensions/ExtendKeyList.cs +++ b/src/AasxCsharpLibrary/Extensions/ExtendKeyList.cs @@ -1,4 +1,12 @@ -using AdminShellNS; +/* +Copyright (c) 2018-2023 Festo AG & Co. KG +Author: Michael Hoffmeister + +This source code is licensed under the Apache License 2.0 (see LICENSE.txt). + +This source code may use other Open Source software components (see LICENSE.txt). +*/ +using AdminShellNS; using Extensions; using System.Collections.Generic; using System.Linq; diff --git a/src/AasxCsharpLibrary/Extensions/ExtendKeyTypes.cs b/src/AasxCsharpLibrary/Extensions/ExtendKeyTypes.cs index 060933a55..9165c7f6f 100644 --- a/src/AasxCsharpLibrary/Extensions/ExtendKeyTypes.cs +++ b/src/AasxCsharpLibrary/Extensions/ExtendKeyTypes.cs @@ -1,4 +1,12 @@ -namespace Extensions +/* +Copyright (c) 2018-2023 Festo AG & Co. KG +Author: Michael Hoffmeister + +This source code is licensed under the Apache License 2.0 (see LICENSE.txt). + +This source code may use other Open Source software components (see LICENSE.txt). +*/ +namespace Extensions { public static class ExtendKeyTypes { diff --git a/src/AasxCsharpLibrary/Extensions/ExtendLangString.cs b/src/AasxCsharpLibrary/Extensions/ExtendLangString.cs index 02ffca805..7ebdf4878 100644 --- a/src/AasxCsharpLibrary/Extensions/ExtendLangString.cs +++ b/src/AasxCsharpLibrary/Extensions/ExtendLangString.cs @@ -1,4 +1,12 @@ -using System.Collections.Generic; +/* +Copyright (c) 2018-2023 Festo AG & Co. KG +Author: Michael Hoffmeister + +This source code is licensed under the Apache License 2.0 (see LICENSE.txt). + +This source code may use other Open Source software components (see LICENSE.txt). +*/ +using System.Collections.Generic; namespace Extensions { diff --git a/src/AasxCsharpLibrary/Extensions/ExtendLangStringSet.cs b/src/AasxCsharpLibrary/Extensions/ExtendLangStringSet.cs index 5adf083f1..03a09070b 100644 --- a/src/AasxCsharpLibrary/Extensions/ExtendLangStringSet.cs +++ b/src/AasxCsharpLibrary/Extensions/ExtendLangStringSet.cs @@ -1,4 +1,12 @@ -using System; +/* +Copyright (c) 2018-2023 Festo AG & Co. KG +Author: Michael Hoffmeister + +This source code is licensed under the Apache License 2.0 (see LICENSE.txt). + +This source code may use other Open Source software components (see LICENSE.txt). +*/ +using System; using System.Collections.Generic; using System.Text.RegularExpressions; diff --git a/src/AasxCsharpLibrary/Extensions/ExtendModelKind.cs b/src/AasxCsharpLibrary/Extensions/ExtendModelKind.cs index dc1d50bb2..da437cc36 100644 --- a/src/AasxCsharpLibrary/Extensions/ExtendModelKind.cs +++ b/src/AasxCsharpLibrary/Extensions/ExtendModelKind.cs @@ -1,4 +1,12 @@ -using AdminShellNS; +/* +Copyright (c) 2018-2023 Festo AG & Co. KG +Author: Michael Hoffmeister + +This source code is licensed under the Apache License 2.0 (see LICENSE.txt). + +This source code may use other Open Source software components (see LICENSE.txt). +*/ +using AdminShellNS; namespace Extensions { diff --git a/src/AasxCsharpLibrary/Extensions/ExtendMultiLanguageProperty.cs b/src/AasxCsharpLibrary/Extensions/ExtendMultiLanguageProperty.cs index 99c45f5ca..7d5ae0a10 100644 --- a/src/AasxCsharpLibrary/Extensions/ExtendMultiLanguageProperty.cs +++ b/src/AasxCsharpLibrary/Extensions/ExtendMultiLanguageProperty.cs @@ -1,4 +1,12 @@ -using AdminShellNS; +/* +Copyright (c) 2018-2023 Festo AG & Co. KG +Author: Michael Hoffmeister + +This source code is licensed under the Apache License 2.0 (see LICENSE.txt). + +This source code may use other Open Source software components (see LICENSE.txt). +*/ +using AdminShellNS; using System; using System.Collections.Generic; diff --git a/src/AasxCsharpLibrary/Extensions/ExtendObject.cs b/src/AasxCsharpLibrary/Extensions/ExtendObject.cs index 6a9b426ed..e1b93208d 100644 --- a/src/AasxCsharpLibrary/Extensions/ExtendObject.cs +++ b/src/AasxCsharpLibrary/Extensions/ExtendObject.cs @@ -1,4 +1,12 @@ -using System; +/* +Copyright (c) 2018-2023 Festo AG & Co. KG +Author: Michael Hoffmeister + +This source code is licensed under the Apache License 2.0 (see LICENSE.txt). + +This source code may use other Open Source software components (see LICENSE.txt). +*/ +using System; using System.Collections.Generic; using System.Reflection; using Extensions.ArrayExtensions; diff --git a/src/AasxCsharpLibrary/Extensions/ExtendOperation.cs b/src/AasxCsharpLibrary/Extensions/ExtendOperation.cs index 9e68c0f7f..e80f7c006 100644 --- a/src/AasxCsharpLibrary/Extensions/ExtendOperation.cs +++ b/src/AasxCsharpLibrary/Extensions/ExtendOperation.cs @@ -1,4 +1,12 @@ -using AdminShellNS.Display; +/* +Copyright (c) 2018-2023 Festo AG & Co. KG +Author: Michael Hoffmeister + +This source code is licensed under the Apache License 2.0 (see LICENSE.txt). + +This source code may use other Open Source software components (see LICENSE.txt). +*/ +using AdminShellNS.Display; using System.Collections.Generic; using System.Linq; diff --git a/src/AasxCsharpLibrary/Extensions/ExtendProperty.cs b/src/AasxCsharpLibrary/Extensions/ExtendProperty.cs index 79acdd5a0..4518005f5 100644 --- a/src/AasxCsharpLibrary/Extensions/ExtendProperty.cs +++ b/src/AasxCsharpLibrary/Extensions/ExtendProperty.cs @@ -1,4 +1,12 @@ -using System; +/* +Copyright (c) 2018-2023 Festo AG & Co. KG +Author: Michael Hoffmeister + +This source code is licensed under the Apache License 2.0 (see LICENSE.txt). + +This source code may use other Open Source software components (see LICENSE.txt). +*/ +using System; using System.Collections.Generic; using System.Globalization; using System.Linq; diff --git a/src/AasxCsharpLibrary/Extensions/ExtendQualifier.cs b/src/AasxCsharpLibrary/Extensions/ExtendQualifier.cs index 2f75beb8b..5914661d4 100644 --- a/src/AasxCsharpLibrary/Extensions/ExtendQualifier.cs +++ b/src/AasxCsharpLibrary/Extensions/ExtendQualifier.cs @@ -1,4 +1,12 @@ -using System; +/* +Copyright (c) 2018-2023 Festo AG & Co. KG +Author: Michael Hoffmeister + +This source code is licensed under the Apache License 2.0 (see LICENSE.txt). + +This source code may use other Open Source software components (see LICENSE.txt). +*/ +using System; using System.Collections.Generic; using System.Text.RegularExpressions; diff --git a/src/AasxCsharpLibrary/Extensions/ExtendRange.cs b/src/AasxCsharpLibrary/Extensions/ExtendRange.cs index f77fa7da6..706148f3a 100644 --- a/src/AasxCsharpLibrary/Extensions/ExtendRange.cs +++ b/src/AasxCsharpLibrary/Extensions/ExtendRange.cs @@ -1,4 +1,12 @@ -using System; +/* +Copyright (c) 2018-2023 Festo AG & Co. KG +Author: Michael Hoffmeister + +This source code is licensed under the Apache License 2.0 (see LICENSE.txt). + +This source code may use other Open Source software components (see LICENSE.txt). +*/ +using System; using AAS = AasCore.Aas3_0; namespace Extensions diff --git a/src/AasxCsharpLibrary/Extensions/ExtendReference.cs b/src/AasxCsharpLibrary/Extensions/ExtendReference.cs index 88ef553f5..34a6c5061 100644 --- a/src/AasxCsharpLibrary/Extensions/ExtendReference.cs +++ b/src/AasxCsharpLibrary/Extensions/ExtendReference.cs @@ -1,4 +1,12 @@ -using AdminShellNS.Exceptions; +/* +Copyright (c) 2018-2023 Festo AG & Co. KG +Author: Michael Hoffmeister + +This source code is licensed under the Apache License 2.0 (see LICENSE.txt). + +This source code may use other Open Source software components (see LICENSE.txt). +*/ +using AdminShellNS.Exceptions; using System.Collections.Generic; using System.Linq; diff --git a/src/AasxCsharpLibrary/Extensions/ExtendReferenceElement.cs b/src/AasxCsharpLibrary/Extensions/ExtendReferenceElement.cs index e20c08216..3660c53c9 100644 --- a/src/AasxCsharpLibrary/Extensions/ExtendReferenceElement.cs +++ b/src/AasxCsharpLibrary/Extensions/ExtendReferenceElement.cs @@ -1,4 +1,12 @@ -using AAS = AasCore.Aas3_0; +/* +Copyright (c) 2018-2023 Festo AG & Co. KG +Author: Michael Hoffmeister + +This source code is licensed under the Apache License 2.0 (see LICENSE.txt). + +This source code may use other Open Source software components (see LICENSE.txt). +*/ +using AAS = AasCore.Aas3_0; namespace Extensions { diff --git a/src/AasxCsharpLibrary/Extensions/ExtendRelationshipElement.cs b/src/AasxCsharpLibrary/Extensions/ExtendRelationshipElement.cs index 3cface08f..f57b8a0e8 100644 --- a/src/AasxCsharpLibrary/Extensions/ExtendRelationshipElement.cs +++ b/src/AasxCsharpLibrary/Extensions/ExtendRelationshipElement.cs @@ -1,4 +1,12 @@ -using AAS = AasCore.Aas3_0; +/* +Copyright (c) 2018-2023 Festo AG & Co. KG +Author: Michael Hoffmeister + +This source code is licensed under the Apache License 2.0 (see LICENSE.txt). + +This source code may use other Open Source software components (see LICENSE.txt). +*/ +using AAS = AasCore.Aas3_0; namespace Extensions { diff --git a/src/AasxCsharpLibrary/Extensions/ExtendSpecificAssetId.cs b/src/AasxCsharpLibrary/Extensions/ExtendSpecificAssetId.cs index 33375d862..d020bab4a 100644 --- a/src/AasxCsharpLibrary/Extensions/ExtendSpecificAssetId.cs +++ b/src/AasxCsharpLibrary/Extensions/ExtendSpecificAssetId.cs @@ -1,4 +1,12 @@ -using Extensions; +/* +Copyright (c) 2018-2023 Festo AG & Co. KG +Author: Michael Hoffmeister + +This source code is licensed under the Apache License 2.0 (see LICENSE.txt). + +This source code may use other Open Source software components (see LICENSE.txt). +*/ +using Extensions; using System.Collections.Generic; using System.Linq; diff --git a/src/AasxCsharpLibrary/Extensions/ExtendStream.cs b/src/AasxCsharpLibrary/Extensions/ExtendStream.cs index 2e0ea17c5..98fcdd6ae 100644 --- a/src/AasxCsharpLibrary/Extensions/ExtendStream.cs +++ b/src/AasxCsharpLibrary/Extensions/ExtendStream.cs @@ -1,4 +1,12 @@ -using System.IO; +/* +Copyright (c) 2018-2023 Festo AG & Co. KG +Author: Michael Hoffmeister + +This source code is licensed under the Apache License 2.0 (see LICENSE.txt). + +This source code may use other Open Source software components (see LICENSE.txt). +*/ +using System.IO; namespace Extensions { diff --git a/src/AasxCsharpLibrary/Extensions/ExtendStringification.cs b/src/AasxCsharpLibrary/Extensions/ExtendStringification.cs index 56be60109..68a598392 100644 --- a/src/AasxCsharpLibrary/Extensions/ExtendStringification.cs +++ b/src/AasxCsharpLibrary/Extensions/ExtendStringification.cs @@ -1,4 +1,12 @@ -using System; +/* +Copyright (c) 2018-2023 Festo AG & Co. KG +Author: Michael Hoffmeister + +This source code is licensed under the Apache License 2.0 (see LICENSE.txt). + +This source code may use other Open Source software components (see LICENSE.txt). +*/ +using System; using System.Collections.Generic; using System.Linq; diff --git a/src/AasxCsharpLibrary/Extensions/ExtendSubmodel.cs b/src/AasxCsharpLibrary/Extensions/ExtendSubmodel.cs index 11fcc39e0..978f85bf0 100644 --- a/src/AasxCsharpLibrary/Extensions/ExtendSubmodel.cs +++ b/src/AasxCsharpLibrary/Extensions/ExtendSubmodel.cs @@ -1,4 +1,12 @@ -using AdminShellNS; +/* +Copyright (c) 2018-2023 Festo AG & Co. KG +Author: Michael Hoffmeister + +This source code is licensed under the Apache License 2.0 (see LICENSE.txt). + +This source code may use other Open Source software components (see LICENSE.txt). +*/ +using AdminShellNS; using AdminShellNS.Display; using System; using System.Collections.Generic; diff --git a/src/AasxCsharpLibrary/Extensions/ExtendSubmodelElementCollection.cs b/src/AasxCsharpLibrary/Extensions/ExtendSubmodelElementCollection.cs index 170248d56..84200657d 100644 --- a/src/AasxCsharpLibrary/Extensions/ExtendSubmodelElementCollection.cs +++ b/src/AasxCsharpLibrary/Extensions/ExtendSubmodelElementCollection.cs @@ -1,4 +1,12 @@ -using AdminShellNS.Display; +/* +Copyright (c) 2018-2023 Festo AG & Co. KG +Author: Michael Hoffmeister + +This source code is licensed under the Apache License 2.0 (see LICENSE.txt). + +This source code may use other Open Source software components (see LICENSE.txt). +*/ +using AdminShellNS.Display; using System; using System.Collections.Generic; using System.Linq; diff --git a/src/AasxCsharpLibrary/Extensions/ExtendSubmodelElementList.cs b/src/AasxCsharpLibrary/Extensions/ExtendSubmodelElementList.cs index d79fd39d8..1b930be64 100644 --- a/src/AasxCsharpLibrary/Extensions/ExtendSubmodelElementList.cs +++ b/src/AasxCsharpLibrary/Extensions/ExtendSubmodelElementList.cs @@ -1,4 +1,12 @@ -using AdminShellNS.Display; +/* +Copyright (c) 2018-2023 Festo AG & Co. KG +Author: Michael Hoffmeister + +This source code is licensed under the Apache License 2.0 (see LICENSE.txt). + +This source code may use other Open Source software components (see LICENSE.txt). +*/ +using AdminShellNS.Display; using System; using System.Collections.Generic; using System.Linq; diff --git a/src/AasxCsharpLibrary/Extensions/ExtensionsUtil.cs b/src/AasxCsharpLibrary/Extensions/ExtensionsUtil.cs index fc710ef79..ece2bbd9d 100644 --- a/src/AasxCsharpLibrary/Extensions/ExtensionsUtil.cs +++ b/src/AasxCsharpLibrary/Extensions/ExtensionsUtil.cs @@ -1,4 +1,12 @@ -using AasxCompatibilityModels; +/* +Copyright (c) 2018-2023 Festo AG & Co. KG +Author: Michael Hoffmeister + +This source code is licensed under the Apache License 2.0 (see LICENSE.txt). + +This source code may use other Open Source software components (see LICENSE.txt). +*/ +using AasxCompatibilityModels; using System; using System.Collections.Generic; diff --git a/src/AasxCsharpLibrary/Extensions/LocatedReference.cs b/src/AasxCsharpLibrary/Extensions/LocatedReference.cs index a99558b3e..38abd4565 100644 --- a/src/AasxCsharpLibrary/Extensions/LocatedReference.cs +++ b/src/AasxCsharpLibrary/Extensions/LocatedReference.cs @@ -1,4 +1,12 @@ -namespace Extensions +/* +Copyright (c) 2018-2023 Festo AG & Co. KG +Author: Michael Hoffmeister + +This source code is licensed under the Apache License 2.0 (see LICENSE.txt). + +This source code may use other Open Source software components (see LICENSE.txt). +*/ +namespace Extensions { public class LocatedReference { diff --git a/src/AasxCsharpLibrary/Extensions/MatchMode.cs b/src/AasxCsharpLibrary/Extensions/MatchMode.cs index d67579028..4b54d5eed 100644 --- a/src/AasxCsharpLibrary/Extensions/MatchMode.cs +++ b/src/AasxCsharpLibrary/Extensions/MatchMode.cs @@ -1,4 +1,12 @@ -namespace Extensions +/* +Copyright (c) 2018-2023 Festo AG & Co. KG +Author: Michael Hoffmeister + +This source code is licensed under the Apache License 2.0 (see LICENSE.txt). + +This source code may use other Open Source software components (see LICENSE.txt). +*/ +namespace Extensions { public enum MatchMode { diff --git a/src/AasxCsharpLibrary/IAasxOnlineConnection.cs b/src/AasxCsharpLibrary/IAasxOnlineConnection.cs index 8f2ca66cf..d580a86ab 100644 --- a/src/AasxCsharpLibrary/IAasxOnlineConnection.cs +++ b/src/AasxCsharpLibrary/IAasxOnlineConnection.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018-2021 Festo AG & Co. KG +Copyright (c) 2018-2023 Festo AG & Co. KG Author: Michael Hoffmeister This source code is licensed under the Apache License 2.0 (see LICENSE.txt). diff --git a/src/AasxCsharpLibrary/LICENSE.txt b/src/AasxCsharpLibrary/LICENSE.txt index 2e5ee87b9..75f36a4ff 100644 --- a/src/AasxCsharpLibrary/LICENSE.txt +++ b/src/AasxCsharpLibrary/LICENSE.txt @@ -1,4 +1,4 @@ -Copyright (c) 2018-2021 Festo AG & Co. KG +Copyright (c) 2018-2023 Festo AG & Co. KG , author: Michael Hoffmeister diff --git a/src/AasxDictionaryImport.Tests/LICENSE.txt b/src/AasxDictionaryImport.Tests/LICENSE.txt index 2e5ee87b9..75f36a4ff 100644 --- a/src/AasxDictionaryImport.Tests/LICENSE.txt +++ b/src/AasxDictionaryImport.Tests/LICENSE.txt @@ -1,4 +1,4 @@ -Copyright (c) 2018-2021 Festo AG & Co. KG +Copyright (c) 2018-2023 Festo AG & Co. KG , author: Michael Hoffmeister diff --git a/src/AasxDictionaryImport/LICENSE.txt b/src/AasxDictionaryImport/LICENSE.txt index 2e5ee87b9..75f36a4ff 100644 --- a/src/AasxDictionaryImport/LICENSE.txt +++ b/src/AasxDictionaryImport/LICENSE.txt @@ -1,4 +1,4 @@ -Copyright (c) 2018-2021 Festo AG & Co. KG +Copyright (c) 2018-2023 Festo AG & Co. KG , author: Michael Hoffmeister diff --git a/src/AasxFileServerRestLibrary/LICENSE.txt b/src/AasxFileServerRestLibrary/LICENSE.txt index 2e5ee87b9..75f36a4ff 100644 --- a/src/AasxFileServerRestLibrary/LICENSE.txt +++ b/src/AasxFileServerRestLibrary/LICENSE.txt @@ -1,4 +1,4 @@ -Copyright (c) 2018-2021 Festo AG & Co. KG +Copyright (c) 2018-2023 Festo AG & Co. KG , author: Michael Hoffmeister diff --git a/src/AasxFileServerRestLibrary/Model/AssetAdministrationShellAndAsset.cs b/src/AasxFileServerRestLibrary/Model/AssetAdministrationShellAndAsset.cs index 3d4410ba3..14ad79175 100644 --- a/src/AasxFileServerRestLibrary/Model/AssetAdministrationShellAndAsset.cs +++ b/src/AasxFileServerRestLibrary/Model/AssetAdministrationShellAndAsset.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018-2022 +Copyright (c) 2018-2023 This source code is licensed under the Apache License 2.0 (see LICENSE.txt). diff --git a/src/AasxFormatCst/AasxCstUtils.cs b/src/AasxFormatCst/AasxCstUtils.cs index 2f342208f..d0cff4e43 100644 --- a/src/AasxFormatCst/AasxCstUtils.cs +++ b/src/AasxFormatCst/AasxCstUtils.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018-2021 Festo AG & Co. KG +Copyright (c) 2018-2023 Festo AG & Co. KG Author: Michael Hoffmeister This source code is licensed under the Apache License 2.0 (see LICENSE.txt). diff --git a/src/AasxFormatCst/AasxToCst.cs b/src/AasxFormatCst/AasxToCst.cs index 8632f944c..7073187b5 100644 --- a/src/AasxFormatCst/AasxToCst.cs +++ b/src/AasxFormatCst/AasxToCst.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018-2021 Festo AG & Co. KG +Copyright (c) 2018-2023 Festo AG & Co. KG Author: Michael Hoffmeister This source code is licensed under the Apache License 2.0 (see LICENSE.txt). diff --git a/src/AasxFormatCst/CstClassDef.cs b/src/AasxFormatCst/CstClassDef.cs index d4bf1392c..8b93cb4c4 100644 --- a/src/AasxFormatCst/CstClassDef.cs +++ b/src/AasxFormatCst/CstClassDef.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018-2021 Festo AG & Co. KG +Copyright (c) 2018-2023 Festo AG & Co. KG Author: Michael Hoffmeister This source code is licensed under the Apache License 2.0 (see LICENSE.txt). diff --git a/src/AasxFormatCst/CstIdObjectBase.cs b/src/AasxFormatCst/CstIdObjectBase.cs index a9fbb5659..30f598e43 100644 --- a/src/AasxFormatCst/CstIdObjectBase.cs +++ b/src/AasxFormatCst/CstIdObjectBase.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018-2021 Festo AG & Co. KG +Copyright (c) 2018-2023 Festo AG & Co. KG Author: Michael Hoffmeister This source code is licensed under the Apache License 2.0 (see LICENSE.txt). diff --git a/src/AasxFormatCst/CstIdStore.cs b/src/AasxFormatCst/CstIdStore.cs index 275c0f29e..94d284db2 100644 --- a/src/AasxFormatCst/CstIdStore.cs +++ b/src/AasxFormatCst/CstIdStore.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018-2021 Festo AG & Co. KG +Copyright (c) 2018-2023 Festo AG & Co. KG Author: Michael Hoffmeister This source code is licensed under the Apache License 2.0 (see LICENSE.txt). diff --git a/src/AasxFormatCst/CstListOfValues.cs b/src/AasxFormatCst/CstListOfValues.cs index eeb5560b4..d245af678 100644 --- a/src/AasxFormatCst/CstListOfValues.cs +++ b/src/AasxFormatCst/CstListOfValues.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018-2021 Festo AG & Co. KG +Copyright (c) 2018-2023 Festo AG & Co. KG Author: Michael Hoffmeister This source code is licensed under the Apache License 2.0 (see LICENSE.txt). diff --git a/src/AasxFormatCst/CstNodeDef.cs b/src/AasxFormatCst/CstNodeDef.cs index 0d4a13417..2f3576510 100644 --- a/src/AasxFormatCst/CstNodeDef.cs +++ b/src/AasxFormatCst/CstNodeDef.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018-2021 Festo AG & Co. KG +Copyright (c) 2018-2023 Festo AG & Co. KG Author: Michael Hoffmeister This source code is licensed under the Apache License 2.0 (see LICENSE.txt). diff --git a/src/AasxFormatCst/CstPropertyDef.cs b/src/AasxFormatCst/CstPropertyDef.cs index 59e12eeaa..2e131698a 100644 --- a/src/AasxFormatCst/CstPropertyDef.cs +++ b/src/AasxFormatCst/CstPropertyDef.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018-2021 Festo AG & Co. KG +Copyright (c) 2018-2023 Festo AG & Co. KG Author: Michael Hoffmeister This source code is licensed under the Apache License 2.0 (see LICENSE.txt). diff --git a/src/AasxFormatCst/CstPropertyRecord.cs b/src/AasxFormatCst/CstPropertyRecord.cs index 3560a7624..24f7f6563 100644 --- a/src/AasxFormatCst/CstPropertyRecord.cs +++ b/src/AasxFormatCst/CstPropertyRecord.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018-2021 Festo AG & Co. KG +Copyright (c) 2018-2023 Festo AG & Co. KG Author: Michael Hoffmeister This source code is licensed under the Apache License 2.0 (see LICENSE.txt). diff --git a/src/AasxFormatCst/CstRootBase.cs b/src/AasxFormatCst/CstRootBase.cs index af5d7b5e6..7bb02a953 100644 --- a/src/AasxFormatCst/CstRootBase.cs +++ b/src/AasxFormatCst/CstRootBase.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018-2021 Festo AG & Co. KG +Copyright (c) 2018-2023 Festo AG & Co. KG Author: Michael Hoffmeister This source code is licensed under the Apache License 2.0 (see LICENSE.txt). diff --git a/src/AasxFormatCst/LICENSE.txt b/src/AasxFormatCst/LICENSE.txt index 2e5ee87b9..75f36a4ff 100644 --- a/src/AasxFormatCst/LICENSE.txt +++ b/src/AasxFormatCst/LICENSE.txt @@ -1,4 +1,4 @@ -Copyright (c) 2018-2021 Festo AG & Co. KG +Copyright (c) 2018-2023 Festo AG & Co. KG , author: Michael Hoffmeister diff --git a/src/AasxFormatCst/ListOfUnique.cs b/src/AasxFormatCst/ListOfUnique.cs index 194f9a9f6..e3f92f3b7 100644 --- a/src/AasxFormatCst/ListOfUnique.cs +++ b/src/AasxFormatCst/ListOfUnique.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018-2021 Festo AG & Co. KG +Copyright (c) 2018-2023 Festo AG & Co. KG Author: Michael Hoffmeister This source code is licensed under the Apache License 2.0 (see LICENSE.txt). diff --git a/src/AasxIntegrationBase/AasForms/AasFormUtils.cs b/src/AasxIntegrationBase/AasForms/AasFormUtils.cs index 45baba595..90962df0c 100644 --- a/src/AasxIntegrationBase/AasForms/AasFormUtils.cs +++ b/src/AasxIntegrationBase/AasForms/AasFormUtils.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018-2021 Festo AG & Co. KG +Copyright (c) 2018-2023 Festo AG & Co. KG Author: Michael Hoffmeister This source code is licensed under the Apache License 2.0 (see LICENSE.txt). diff --git a/src/AasxIntegrationBase/AasForms/AnyUiRenderForm.cs b/src/AasxIntegrationBase/AasForms/AnyUiRenderForm.cs index fe0dc8240..efe0f9f4e 100644 --- a/src/AasxIntegrationBase/AasForms/AnyUiRenderForm.cs +++ b/src/AasxIntegrationBase/AasForms/AnyUiRenderForm.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018-2022 Festo AG & Co. KG +Copyright (c) 2018-2023 Festo AG & Co. KG Author: Michael Hoffmeister This source code is licensed under the Apache License 2.0 (see LICENSE.txt). diff --git a/src/AasxIntegrationBase/AasForms/FormDescription.cs b/src/AasxIntegrationBase/AasForms/FormDescription.cs index 3da4707f1..d1abf732c 100644 --- a/src/AasxIntegrationBase/AasForms/FormDescription.cs +++ b/src/AasxIntegrationBase/AasForms/FormDescription.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018-2021 Festo AG & Co. KG +Copyright (c) 2018-2023 Festo AG & Co. KG Author: Michael Hoffmeister This source code is licensed under the Apache License 2.0 (see LICENSE.txt). diff --git a/src/AasxIntegrationBase/AasForms/FormInstance.cs b/src/AasxIntegrationBase/AasForms/FormInstance.cs index 1c8096c19..9566e5b01 100644 --- a/src/AasxIntegrationBase/AasForms/FormInstance.cs +++ b/src/AasxIntegrationBase/AasForms/FormInstance.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018-2021 Festo AG & Co. KG +Copyright (c) 2018-2023 Festo AG & Co. KG Author: Michael Hoffmeister This source code is licensed under the Apache License 2.0 (see LICENSE.txt). diff --git a/src/AasxIntegrationBase/AasxCompatibilityModels/AasForms/FormDescriptionV20.cs b/src/AasxIntegrationBase/AasxCompatibilityModels/AasForms/FormDescriptionV20.cs index 5b8a41834..ed5b9ddd8 100644 --- a/src/AasxIntegrationBase/AasxCompatibilityModels/AasForms/FormDescriptionV20.cs +++ b/src/AasxIntegrationBase/AasxCompatibilityModels/AasForms/FormDescriptionV20.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018-2021 Festo AG & Co. KG +Copyright (c) 2018-2023 Festo AG & Co. KG Author: Michael Hoffmeister This source code is licensed under the Apache License 2.0 (see LICENSE.txt). @@ -232,6 +232,6 @@ public class FormDescReferenceElementV20 : FormDescSubmodelElementV20 public FormDescReferenceElementV20() { } } -} - +} + #endif \ No newline at end of file diff --git a/src/AasxIntegrationBase/AasxCompatibilityModels/AasxPluginOptionsBaseV20.cs b/src/AasxIntegrationBase/AasxCompatibilityModels/AasxPluginOptionsBaseV20.cs index c735d58f6..b35c4666d 100644 --- a/src/AasxIntegrationBase/AasxCompatibilityModels/AasxPluginOptionsBaseV20.cs +++ b/src/AasxIntegrationBase/AasxCompatibilityModels/AasxPluginOptionsBaseV20.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018-2021 Festo AG & Co. KG +Copyright (c) 2018-2023 Festo AG & Co. KG Author: Michael Hoffmeister This source code is licensed under the Apache License 2.0 (see LICENSE.txt). @@ -61,6 +61,6 @@ public class AasxPluginOptionsLookupRecordBaseV20 : AasxPluginOptionsRecordBaseV public class AasxPluginLookupOptionsBaseV20 : AasxPluginOptionsBaseV20 { } -} - +} + #endif \ No newline at end of file diff --git a/src/AasxIntegrationBase/AasxLanguageHelper.cs b/src/AasxIntegrationBase/AasxLanguageHelper.cs index bf84774de..651eb2494 100644 --- a/src/AasxIntegrationBase/AasxLanguageHelper.cs +++ b/src/AasxIntegrationBase/AasxLanguageHelper.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018-2021 Festo AG & Co. KG +Copyright (c) 2018-2023 Festo AG & Co. KG Author: Michael Hoffmeister This source code is licensed under the Apache License 2.0 (see LICENSE.txt). diff --git a/src/AasxIntegrationBase/AasxMenu.cs b/src/AasxIntegrationBase/AasxMenu.cs index f59a2404e..2834e9a1f 100644 --- a/src/AasxIntegrationBase/AasxMenu.cs +++ b/src/AasxIntegrationBase/AasxMenu.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018-2021 Festo AG & Co. KG +Copyright (c) 2018-2023 Festo AG & Co. KG Author: Michael Hoffmeister This source code is licensed under the Apache License 2.0 (see LICENSE.txt). diff --git a/src/AasxIntegrationBase/AasxPluginHelper.cs b/src/AasxIntegrationBase/AasxPluginHelper.cs index beeb33ad9..dd4ad598e 100644 --- a/src/AasxIntegrationBase/AasxPluginHelper.cs +++ b/src/AasxIntegrationBase/AasxPluginHelper.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018-2021 Festo AG & Co. KG +Copyright (c) 2018-2023 Festo AG & Co. KG Author: Michael Hoffmeister This source code is licensed under the Apache License 2.0 (see LICENSE.txt). diff --git a/src/AasxIntegrationBase/AasxPluginInterface.cs b/src/AasxIntegrationBase/AasxPluginInterface.cs index e3543ed03..cbb8bba7b 100644 --- a/src/AasxIntegrationBase/AasxPluginInterface.cs +++ b/src/AasxIntegrationBase/AasxPluginInterface.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018-2021 Festo AG & Co. KG +Copyright (c) 2018-2023 Festo AG & Co. KG Author: Michael Hoffmeister This source code is licensed under the Apache License 2.0 (see LICENSE.txt). @@ -367,9 +367,9 @@ public AasxPluginListOfActionDescription ListActionsBasicHelper( bool enablePanelAnyUi = false, bool enableNewSubmodel = false) { - var res = new AasxPluginListOfActionDescription(); - - // for speed reasons, have the most often used at top! + var res = new AasxPluginListOfActionDescription(); + + // for speed reasons, have the most often used at top! if (enableCheckVisualExt) res.Add(new AasxPluginActionDescriptionBase( "call-check-visual-extension", @@ -388,7 +388,7 @@ public AasxPluginListOfActionDescription ListActionsBasicHelper( if (enableEventsGet) res.Add(new AasxPluginActionDescriptionBase( "get-events", "Pops and returns the earliest event from the event stack.")); - if (enableEventReturn) + if (enableEventReturn) res.Add(new AasxPluginActionDescriptionBase( "event-return", "Called to return a result evaluated by the host for a certain event.")); if (enableCheckVisualExt) @@ -419,8 +419,8 @@ public AasxPluginListOfActionDescription ListActionsBasicHelper( res.Add(new AasxPluginActionDescriptionBase( "generate-submodel", "Returns a generated default Submodel based on the name provided as string argument.")); - } - + } + return res; } diff --git a/src/AasxIntegrationBase/AasxPluginOptionSerialization.cs b/src/AasxIntegrationBase/AasxPluginOptionSerialization.cs index 01a571186..9686096fb 100644 --- a/src/AasxIntegrationBase/AasxPluginOptionSerialization.cs +++ b/src/AasxIntegrationBase/AasxPluginOptionSerialization.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018-2021 Festo AG & Co. KG +Copyright (c) 2018-2023 Festo AG & Co. KG Author: Michael Hoffmeister This source code is licensed under the Apache License 2.0 (see LICENSE.txt). @@ -60,11 +60,11 @@ public DisplayNameSerializationBinder(Type[] startingTypes) foreach (var startingType in startingTypes) { - var customDisplayNameTypes = - // this.GetType() + var customDisplayNameTypes = + // this.GetType() startingType - .Assembly - //concat with references if desired + .Assembly + //concat with references if desired .GetTypes() .Where(x => x .GetCustomAttributes(false) diff --git a/src/AasxIntegrationBase/AasxPluginOptionsBase.cs b/src/AasxIntegrationBase/AasxPluginOptionsBase.cs index 229ca2d08..fd0003bf1 100644 --- a/src/AasxIntegrationBase/AasxPluginOptionsBase.cs +++ b/src/AasxIntegrationBase/AasxPluginOptionsBase.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018-2021 Festo AG & Co. KG +Copyright (c) 2018-2023 Festo AG & Co. KG Author: Michael Hoffmeister This source code is licensed under the Apache License 2.0 (see LICENSE.txt). diff --git a/src/AasxIntegrationBase/AasxSearchUtil.cs b/src/AasxIntegrationBase/AasxSearchUtil.cs index a960076e8..ab50a34ae 100644 --- a/src/AasxIntegrationBase/AasxSearchUtil.cs +++ b/src/AasxIntegrationBase/AasxSearchUtil.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018-2021 Festo AG & Co. KG +Copyright (c) 2018-2023 Festo AG & Co. KG Author: Michael Hoffmeister This source code is licensed under the Apache License 2.0 (see LICENSE.txt). diff --git a/src/AasxIntegrationBase/AdminShellEvents/AasEventMsgEnvelope.cs b/src/AasxIntegrationBase/AdminShellEvents/AasEventMsgEnvelope.cs index 6dc7c9a66..0d31449d2 100644 --- a/src/AasxIntegrationBase/AdminShellEvents/AasEventMsgEnvelope.cs +++ b/src/AasxIntegrationBase/AdminShellEvents/AasEventMsgEnvelope.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018-2021 Festo AG & Co. KG +Copyright (c) 2018-2023 Festo AG & Co. KG Author: Michael Hoffmeister This source code is licensed under the Apache License 2.0 (see LICENSE.txt). diff --git a/src/AasxIntegrationBase/AdminShellEvents/AasEventMsgStack.cs b/src/AasxIntegrationBase/AdminShellEvents/AasEventMsgStack.cs index 6117ed676..3f0e66b44 100644 --- a/src/AasxIntegrationBase/AdminShellEvents/AasEventMsgStack.cs +++ b/src/AasxIntegrationBase/AdminShellEvents/AasEventMsgStack.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018-2021 Festo AG & Co. KG +Copyright (c) 2018-2023 Festo AG & Co. KG Author: Michael Hoffmeister This source code is licensed under the Apache License 2.0 (see LICENSE.txt). diff --git a/src/AasxIntegrationBase/AdminShellEvents/AasPayloadBase.cs b/src/AasxIntegrationBase/AdminShellEvents/AasPayloadBase.cs index 8ff1bc2bc..76f245380 100644 --- a/src/AasxIntegrationBase/AdminShellEvents/AasPayloadBase.cs +++ b/src/AasxIntegrationBase/AdminShellEvents/AasPayloadBase.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018-2021 Festo AG & Co. KG +Copyright (c) 2018-2023 Festo AG & Co. KG Author: Michael Hoffmeister This source code is licensed under the Apache License 2.0 (see LICENSE.txt). diff --git a/src/AasxIntegrationBase/AdminShellEvents/AasPayloadStructuralChange.cs b/src/AasxIntegrationBase/AdminShellEvents/AasPayloadStructuralChange.cs index 569ae9e54..c3d3102fc 100644 --- a/src/AasxIntegrationBase/AdminShellEvents/AasPayloadStructuralChange.cs +++ b/src/AasxIntegrationBase/AdminShellEvents/AasPayloadStructuralChange.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018-2021 Festo AG & Co. KG +Copyright (c) 2018-2023 Festo AG & Co. KG Author: Michael Hoffmeister This source code is licensed under the Apache License 2.0 (see LICENSE.txt). diff --git a/src/AasxIntegrationBase/AdminShellEvents/AasPayloadUpdateValue.cs b/src/AasxIntegrationBase/AdminShellEvents/AasPayloadUpdateValue.cs index 8160f5678..d0973a620 100644 --- a/src/AasxIntegrationBase/AdminShellEvents/AasPayloadUpdateValue.cs +++ b/src/AasxIntegrationBase/AdminShellEvents/AasPayloadUpdateValue.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018-2021 Festo AG & Co. KG +Copyright (c) 2018-2023 Festo AG & Co. KG Author: Michael Hoffmeister This source code is licensed under the Apache License 2.0 (see LICENSE.txt). diff --git a/src/AasxIntegrationBase/AnyUI/AnyUiContextPlusDialogs.cs b/src/AasxIntegrationBase/AnyUI/AnyUiContextPlusDialogs.cs index 7d6b22c03..3315ec754 100644 --- a/src/AasxIntegrationBase/AnyUI/AnyUiContextPlusDialogs.cs +++ b/src/AasxIntegrationBase/AnyUI/AnyUiContextPlusDialogs.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018-2021 Festo AG & Co. KG +Copyright (c) 2018-2023 Festo AG & Co. KG Author: Michael Hoffmeister This source code is licensed under the Apache License 2.0 (see LICENSE.txt). @@ -175,8 +175,8 @@ public virtual async Task MenuSelectSaveFilenameAsync { await Task.Yield(); return null; - } - + } + /// /// If ticket does not contain the filename named by argName, /// read it by the user. @@ -194,8 +194,8 @@ public virtual async Task MenuSelectSaveFilenameToTicketAsync( { await Task.Yield(); return false; - } - + } + /// /// Selects a text either from user or from ticket. /// @@ -285,11 +285,11 @@ public async Task CheckIfDownloadAndStart( string contentType = "application/octet-stream") { // access - if (ticket == null + if (ticket == null || !(ticket[argFileName] is string fn) || !(ticket[argLocation] is string location)) - return; - + return; + await CheckIfDownloadAndStart(log, location, fn, contentType); } diff --git a/src/AasxIntegrationBase/Extensions.cs b/src/AasxIntegrationBase/Extensions.cs index 42df79b70..44cfb4753 100644 --- a/src/AasxIntegrationBase/Extensions.cs +++ b/src/AasxIntegrationBase/Extensions.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018-2021 Festo AG & Co. KG +Copyright (c) 2018-2023 Festo AG & Co. KG Author: Michael Hoffmeister This source code is licensed under the Apache License 2.0 (see LICENSE.txt). diff --git a/src/AasxIntegrationBase/LICENSE.txt b/src/AasxIntegrationBase/LICENSE.txt index 2e5ee87b9..75f36a4ff 100644 --- a/src/AasxIntegrationBase/LICENSE.txt +++ b/src/AasxIntegrationBase/LICENSE.txt @@ -1,4 +1,4 @@ -Copyright (c) 2018-2021 Festo AG & Co. KG +Copyright (c) 2018-2023 Festo AG & Co. KG , author: Michael Hoffmeister diff --git a/src/AasxIntegrationBase/LogInstance.cs b/src/AasxIntegrationBase/LogInstance.cs index 0213f94ac..bac4bb329 100644 --- a/src/AasxIntegrationBase/LogInstance.cs +++ b/src/AasxIntegrationBase/LogInstance.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018-2021 Festo AG & Co. KG +Copyright (c) 2018-2023 Festo AG & Co. KG Author: Michael Hoffmeister This source code is licensed under the Apache License 2.0 (see LICENSE.txt). diff --git a/src/AasxIntegrationBase/MiniMarkup/MiniMarkupBase.cs b/src/AasxIntegrationBase/MiniMarkup/MiniMarkupBase.cs index eed143864..01916e2d9 100644 --- a/src/AasxIntegrationBase/MiniMarkup/MiniMarkupBase.cs +++ b/src/AasxIntegrationBase/MiniMarkup/MiniMarkupBase.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018-2021 Festo AG & Co. KG +Copyright (c) 2018-2023 Festo AG & Co. KG Author: Michael Hoffmeister This source code is licensed under the Apache License 2.0 (see LICENSE.txt). diff --git a/src/AasxIntegrationBase/MinimalLogger.cs b/src/AasxIntegrationBase/MinimalLogger.cs index bd5d185ea..2308fe338 100644 --- a/src/AasxIntegrationBase/MinimalLogger.cs +++ b/src/AasxIntegrationBase/MinimalLogger.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018-2021 Festo AG & Co. KG +Copyright (c) 2018-2023 Festo AG & Co. KG Author: Michael Hoffmeister This source code is licensed under the Apache License 2.0 (see LICENSE.txt). diff --git a/src/AasxIntegrationBase/PluginEventStack.cs b/src/AasxIntegrationBase/PluginEventStack.cs index 04a440097..aec636119 100644 --- a/src/AasxIntegrationBase/PluginEventStack.cs +++ b/src/AasxIntegrationBase/PluginEventStack.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018-2021 Festo AG & Co. KG +Copyright (c) 2018-2023 Festo AG & Co. KG Author: Michael Hoffmeister This source code is licensed under the Apache License 2.0 (see LICENSE.txt). diff --git a/src/AasxIntegrationBase/PluginInterop/AasxPluginExportTableInterop.cs b/src/AasxIntegrationBase/PluginInterop/AasxPluginExportTableInterop.cs index b2218700b..0d0e985d1 100644 --- a/src/AasxIntegrationBase/PluginInterop/AasxPluginExportTableInterop.cs +++ b/src/AasxIntegrationBase/PluginInterop/AasxPluginExportTableInterop.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018-2021 Festo AG & Co. KG +Copyright (c) 2018-2023 Festo AG & Co. KG Author: Michael Hoffmeister This source code is licensed under the Apache License 2.0 (see LICENSE.txt). diff --git a/src/AasxIntegrationBaseGdi/AnyUI/AnyUiGdiHelper.cs b/src/AasxIntegrationBaseGdi/AnyUI/AnyUiGdiHelper.cs index 473717018..2132bb504 100644 --- a/src/AasxIntegrationBaseGdi/AnyUI/AnyUiGdiHelper.cs +++ b/src/AasxIntegrationBaseGdi/AnyUI/AnyUiGdiHelper.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018-2019 Festo AG & Co. KG +Copyright (c) 2018-2023 Festo AG & Co. KG Author: Michael Hoffmeister This source code is licensed under the Apache License 2.0 (see LICENSE.txt). diff --git a/src/AasxIntegrationBaseGdi/AnyUI/AnyUiMagickHelper.cs b/src/AasxIntegrationBaseGdi/AnyUI/AnyUiMagickHelper.cs index e31836d37..95cb8cc62 100644 --- a/src/AasxIntegrationBaseGdi/AnyUI/AnyUiMagickHelper.cs +++ b/src/AasxIntegrationBaseGdi/AnyUI/AnyUiMagickHelper.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018-2019 Festo AG & Co. KG +Copyright (c) 2018-2023 Festo AG & Co. KG Author: Michael Hoffmeister This source code is licensed under the Apache License 2.0 (see LICENSE.txt). diff --git a/src/AasxIntegrationBaseGdi/AnyUI/AnyUiTimerHelper.cs b/src/AasxIntegrationBaseGdi/AnyUI/AnyUiTimerHelper.cs index c3a807b42..b542fddc0 100644 --- a/src/AasxIntegrationBaseGdi/AnyUI/AnyUiTimerHelper.cs +++ b/src/AasxIntegrationBaseGdi/AnyUI/AnyUiTimerHelper.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018-2019 Festo AG & Co. KG +Copyright (c) 2018-2023 Festo AG & Co. KG Author: Michael Hoffmeister This source code is licensed under the Apache License 2.0 (see LICENSE.txt). diff --git a/src/AasxIntegrationBaseGdi/LICENSE.txt b/src/AasxIntegrationBaseGdi/LICENSE.txt index 2e5ee87b9..75f36a4ff 100644 --- a/src/AasxIntegrationBaseGdi/LICENSE.txt +++ b/src/AasxIntegrationBaseGdi/LICENSE.txt @@ -1,4 +1,4 @@ -Copyright (c) 2018-2021 Festo AG & Co. KG +Copyright (c) 2018-2023 Festo AG & Co. KG , author: Michael Hoffmeister diff --git a/src/AasxIntegrationBaseGdi/OperatingSystemHelper.cs b/src/AasxIntegrationBaseGdi/OperatingSystemHelper.cs index 78bd313c9..aa1d5e76a 100644 --- a/src/AasxIntegrationBaseGdi/OperatingSystemHelper.cs +++ b/src/AasxIntegrationBaseGdi/OperatingSystemHelper.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018-2019 Festo AG & Co. KG +Copyright (c) 2018-2023 Festo AG & Co. KG Author: Michael Hoffmeister This source code is licensed under the Apache License 2.0 (see LICENSE.txt). diff --git a/src/AasxIntegrationBaseWpf/AasxWpfBaseUtils.cs b/src/AasxIntegrationBaseWpf/AasxWpfBaseUtils.cs index 8db53f1f1..21a5e4a8b 100644 --- a/src/AasxIntegrationBaseWpf/AasxWpfBaseUtils.cs +++ b/src/AasxIntegrationBaseWpf/AasxWpfBaseUtils.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018-2021 Festo AG & Co. KG +Copyright (c) 2018-2023 Festo AG & Co. KG Author: Michael Hoffmeister This source code is licensed under the Apache License 2.0 (see LICENSE.txt). diff --git a/src/AasxIntegrationBaseWpf/AnyUI/AnyUiHelper.cs b/src/AasxIntegrationBaseWpf/AnyUI/AnyUiHelper.cs index 30a57e5c3..06f890e29 100644 --- a/src/AasxIntegrationBaseWpf/AnyUI/AnyUiHelper.cs +++ b/src/AasxIntegrationBaseWpf/AnyUI/AnyUiHelper.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018-2019 Festo AG & Co. KG +Copyright (c) 2018-2023 Festo AG & Co. KG Author: Michael Hoffmeister This source code is licensed under the Apache License 2.0 (see LICENSE.txt). diff --git a/src/AasxIntegrationBaseWpf/DynamicContextMenu.cs b/src/AasxIntegrationBaseWpf/DynamicContextMenu.cs index 8cf93c96b..541f80670 100644 --- a/src/AasxIntegrationBaseWpf/DynamicContextMenu.cs +++ b/src/AasxIntegrationBaseWpf/DynamicContextMenu.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018-2021 Festo AG & Co. KG +Copyright (c) 2018-2023 Festo AG & Co. KG Author: Michael Hoffmeister This source code is licensed under the Apache License 2.0 (see LICENSE.txt). diff --git a/src/AasxIntegrationBaseWpf/EmptyFlyout.xaml b/src/AasxIntegrationBaseWpf/EmptyFlyout.xaml index d0cf45598..a459086dd 100644 --- a/src/AasxIntegrationBaseWpf/EmptyFlyout.xaml +++ b/src/AasxIntegrationBaseWpf/EmptyFlyout.xaml @@ -7,7 +7,7 @@ mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="900" Loaded="UserControl_Loaded">