diff --git a/mocha-dotnet.sln b/mocha-dotnet.sln new file mode 100644 index 0000000..3585483 --- /dev/null +++ b/mocha-dotnet.sln @@ -0,0 +1,54 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.002.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "mocha-dotnet", "mocha-dotnet", "{2A2B84F1-FA6B-4D67-ACB8-E277D50C98F2}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{66EB3261-A473-41C7-8D40-E1B4DC8ED4B3}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "lib", "lib", "{A2C401E9-FED4-43BA-A928-566239894CEE}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mocha.Core", "mocha-dotnet\src\lib\Mocha.Core\Mocha.Core.csproj", "{2A9C53A8-F078-4858-B737-A315F097F6A5}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "framework-dotnet", "framework-dotnet", "{C5186076-0020-47F5-B4FE-07E19AADC9EE}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "framework-dotnet", "framework-dotnet", "{D014ADBA-7B4D-4AA2-8223-C49F7052E6A6}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{5D15CF7D-69F7-4F78-AD47-93B332F65982}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "lib", "lib", "{7D0A3F8A-502F-469E-BB79-DB4D5212E395}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MBS.Core", "framework-dotnet\framework-dotnet\src\lib\MBS.Core\MBS.Core.csproj", "{91F156ED-2825-4EE2-A051-2A46DB6B0CAD}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {2A9C53A8-F078-4858-B737-A315F097F6A5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2A9C53A8-F078-4858-B737-A315F097F6A5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2A9C53A8-F078-4858-B737-A315F097F6A5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2A9C53A8-F078-4858-B737-A315F097F6A5}.Release|Any CPU.Build.0 = Release|Any CPU + {91F156ED-2825-4EE2-A051-2A46DB6B0CAD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {91F156ED-2825-4EE2-A051-2A46DB6B0CAD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {91F156ED-2825-4EE2-A051-2A46DB6B0CAD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {91F156ED-2825-4EE2-A051-2A46DB6B0CAD}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {66EB3261-A473-41C7-8D40-E1B4DC8ED4B3} = {2A2B84F1-FA6B-4D67-ACB8-E277D50C98F2} + {A2C401E9-FED4-43BA-A928-566239894CEE} = {66EB3261-A473-41C7-8D40-E1B4DC8ED4B3} + {2A9C53A8-F078-4858-B737-A315F097F6A5} = {A2C401E9-FED4-43BA-A928-566239894CEE} + {D014ADBA-7B4D-4AA2-8223-C49F7052E6A6} = {C5186076-0020-47F5-B4FE-07E19AADC9EE} + {5D15CF7D-69F7-4F78-AD47-93B332F65982} = {D014ADBA-7B4D-4AA2-8223-C49F7052E6A6} + {7D0A3F8A-502F-469E-BB79-DB4D5212E395} = {5D15CF7D-69F7-4F78-AD47-93B332F65982} + {91F156ED-2825-4EE2-A051-2A46DB6B0CAD} = {7D0A3F8A-502F-469E-BB79-DB4D5212E395} + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {D28A9CF8-0235-4F8F-865F-C460BDCAE16D} + EndGlobalSection +EndGlobal diff --git a/mocha-dotnet/src/lib/Mocha.Core/ExportEntitiesAttribute.cs b/mocha-dotnet/src/lib/Mocha.Core/ExportEntitiesAttribute.cs new file mode 100755 index 0000000..58a67e1 --- /dev/null +++ b/mocha-dotnet/src/lib/Mocha.Core/ExportEntitiesAttribute.cs @@ -0,0 +1,33 @@ +// +// ExportEntitiesAttribute.cs +// +// Author: +// beckermj <> +// +// Copyright (c) 2022 ${CopyrightHolder} +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +using System; +namespace Mocha.Core +{ + /// + /// Tells the MCX compiler to treat all public static properties in this + /// class as XML entities. + /// + public class ExportEntitiesAttribute : System.Attribute + { + public string Prefix { get; set; } = null; + public string Suffix { get; set; } = null; + } +} diff --git a/mocha-dotnet/src/lib/Mocha.Core/InstanceKey.cs b/mocha-dotnet/src/lib/Mocha.Core/InstanceKey.cs new file mode 100755 index 0000000..894feb1 --- /dev/null +++ b/mocha-dotnet/src/lib/Mocha.Core/InstanceKey.cs @@ -0,0 +1,91 @@ +// +// InstanceKey.cs +// +// Author: +// Michael Becker +// +// Copyright (c) 2020 Mike Becker's Software +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +using System; +namespace Mocha.Core +{ + public struct InstanceKey + { + public int ClassIndex { get; } + public int InstanceIndex { get; } + + private bool _isNotEmpty; + public bool IsEmpty { get { return !_isNotEmpty; } } + + public static readonly InstanceKey Empty = new InstanceKey(); + + public static InstanceKey Parse(string instanceKey) + { + return new InstanceKey(instanceKey); + } + + public InstanceKey(string instanceKey) + { + if (instanceKey == null) + { + ClassIndex = 0; + InstanceIndex = 0; + _isNotEmpty = false; + } + else + { + if (instanceKey.Contains("$")) + { + string[] split = instanceKey.Split(new char[] { '$' }); + if (split.Length == 2) + { + if (Int32.TryParse(split[0], out int ci) && Int32.TryParse(split[1], out int ii)) + { + ClassIndex = ci; + InstanceIndex = ii; + _isNotEmpty = true; + return; + } + } + } + } + throw new ArgumentException("must be a string containing two integers separated by a '$'"); + } + public InstanceKey(int classIndex, int instanceIndex) + { + ClassIndex = classIndex; + InstanceIndex = instanceIndex; + _isNotEmpty = true; + } + + public override bool Equals(object obj) + { + return (obj is InstanceKey) && ((InstanceKey)obj).ClassIndex == ClassIndex && ((InstanceKey)obj).InstanceIndex == InstanceIndex && ((InstanceKey)obj).IsEmpty == IsEmpty; + } + public static bool operator ==(InstanceKey left, InstanceKey right) + { + return left.Equals(right); + } + public static bool operator !=(InstanceKey left, InstanceKey right) + { + return !left.Equals(right); + } + + public override string ToString() + { + return String.Format("{0}${1}", ClassIndex, InstanceIndex); + } + } +} diff --git a/mocha-dotnet/src/lib/Mocha.Core/InstanceReference.cs b/mocha-dotnet/src/lib/Mocha.Core/InstanceReference.cs new file mode 100755 index 0000000..80f4518 --- /dev/null +++ b/mocha-dotnet/src/lib/Mocha.Core/InstanceReference.cs @@ -0,0 +1,115 @@ +// +// InstanceReference.cs +// +// Author: +// Michael Becker +// +// Copyright (c) 2022 Mike Becker's Software +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +using System; + +using MBS.Core; + +namespace Mocha.Core +{ + public struct InstanceReference : IEquatable + { + private NanoId _ID; + private bool isNotEmpty; + + public static InstanceReference Create() + { + InstanceReference handle = new InstanceReference(); + handle._ID = NanoId.Generate(); + handle.isNotEmpty = true; + return handle; + } + + public byte[] ToByteArray() + { + return System.Text.Encoding.ASCII.GetBytes(_ID.ToString()); + } + + public static readonly InstanceReference Empty = new InstanceReference(); + + public bool IsEmpty { get { return !isNotEmpty; } } + + public bool Equals(InstanceReference other) + { + if (IsEmpty && other.IsEmpty) + return true; + + return _ID == other._ID && !IsEmpty; + } + + public static bool operator ==(InstanceReference left, InstanceReference right) + { + return left.Equals(right); + } + public static bool operator !=(InstanceReference left, InstanceReference right) + { + return !left.Equals(right); + } + + public override string ToString() + { + if (IsEmpty) + return "(empty) "; + + return _ID.ToString(); + } + + + public static string IntToString(int value, char[] baseChars) + { + string result = string.Empty; + int targetBase = baseChars.Length; + + do + { + result = baseChars[value % targetBase] + result; + value = value / targetBase; + } + while (value > 0); + + return result; + } + + /// + /// An optimized method using an array as buffer instead of + /// string concatenation. This is faster for return values having + /// a length > 1. + /// + public static string IntToStringFast(int value, char[] baseChars) + { + // 32 is the worst cast buffer size for base 2 and int.MaxValue + int i = 32; + char[] buffer = new char[i]; + int targetBase = baseChars.Length; + + do + { + buffer[--i] = baseChars[value % targetBase]; + value = value / targetBase; + } + while (value > 0); + + char[] result = new char[32 - i]; + Array.Copy(buffer, i, result, 0, 32 - i); + + return new string(result); + } + } +} diff --git a/mocha-dotnet/src/lib/Mocha.Core/KnownAttributeGuids.cs b/mocha-dotnet/src/lib/Mocha.Core/KnownAttributeGuids.cs new file mode 100755 index 0000000..897c7b0 --- /dev/null +++ b/mocha-dotnet/src/lib/Mocha.Core/KnownAttributeGuids.cs @@ -0,0 +1,50 @@ +using System; +namespace Mocha.Core +{ + public static class KnownAttributeGuids + { + public static class Text + { + public static Guid Name { get; } = new Guid("{9153A637-992E-4712-ADF2-B03F0D9EDEA6}"); + public static Guid Verb { get; } = new Guid("{61345a5d-3397-4a96-8797-8863f03a476c}"); + public static Guid Value { get; } = new Guid("{041DD7FD-2D9C-412B-8B9D-D7125C166FE0}"); + public static Guid CSSValue { get; } = new Guid("{C0DD4A42-F503-4EB3-8034-7C428B1B8803}"); + public static Guid RelationshipType { get; } = new Guid("{71106B12-1934-4834-B0F6-D894637BAEED}"); + + public static Guid TargetURL { get; } = new Guid("{970F79A0-9EFE-4E7D-9286-9908C6F06A67}"); + + public static Guid UserName { get; } = new Guid("{960FAF02-5C59-40F7-91A7-20012A99D9ED}"); + public static Guid PasswordHash { get; } = new Guid("{F377FC29-4DF1-4AFB-9643-4191F37A00A9}"); + public static Guid PasswordSalt { get; } = new Guid("{8C5A99BC-40ED-4FA2-B23F-F373C1F3F4BE}"); + + public static Guid ContentType { get; } = new Guid("{34142FCB-172C-490A-AF03-FF8451D00CAF}"); + + public static Guid BackgroundColor { get; } = new Guid("{B817BE3B-D0AC-4A60-A98A-97F99E96CC89}"); + public static Guid ForegroundColor { get; } = new Guid("{BB4B6E0D-D9BA-403D-9E81-93E8F7FB31C8}"); + public static Guid IPAddress { get; } = new Guid("{ADE5A3C3-A84E-4798-BC5B-E08F21380208}"); + public static Guid Token { get; } = new Guid("{da7686b6-3803-4f15-97f6-7f8f3ae16668}"); + + public static Guid DebugDefinitionFileName { get; } = new Guid("{03bf47c7-dc97-43c8-a8c9-c6147bee4e1f}"); + } + public static class Boolean + { + public static Guid DisplayVersionInBadge { get; } = new Guid("{BE5966A4-C4CA-49A6-B504-B6E8759F392D}"); + public static Guid Editable { get; } = new Guid("{957fd8b3-fdc4-4f35-87d6-db1c0682f53c}"); + public static Guid Static { get; } = new Guid("{9A3A0719-64C2-484F-A55E-22CD4597D9FD}"); + public static Guid Singular { get; } = new Guid("{F1A06573-C447-4D85-B4E7-54A438C4A960}"); + public static Guid Required { get; } = new Guid("{4061c1c4-7ec3-439b-b72d-59c7df344a76}"); + public static Guid Null { get; } = new Guid("{745c6c38-594e-4528-82c9-e25b023705e4}"); + public static Guid Visible { get; } = new Guid("{ff73c8f6-f706-4944-b562-43a0acb7eade}"); + public static Guid RenderAsText { get; } = new Guid("{15dd9e49-ab6d-44f0-9039-27af81736406}"); + public static Guid UseAnyCondition { get; } = new Guid("{31a8a2c2-1f55-4dfe-b177-427a2219ef8c}"); + public static Guid ValidateOnlyOnSubmit { get; } = new Guid("{400fcd8e-823b-4f4a-aa38-b444f763259b}"); + } + public static class Numeric + { + public static Guid Index { get; } = new Guid("{0f31b9ca-e3e2-4c62-8c9e-b55f16eafbf9}"); + public static Guid Level { get; } = new Guid("{8C528FB0-4063-47B0-BC56-85E387A41BD2}"); + public static Guid DebugDefinitionLineNumber { get; } = new Guid("{822be9b7-531d-4aa1-818a-6e4de1609057}"); + public static Guid DebugDefinitionColumnNumber { get; } = new Guid("{0f75c750-e738-4410-9b4e-deb422efc7aa}"); + } + } +} diff --git a/mocha-dotnet/src/lib/Mocha.Core/KnownInstanceGuids.cs b/mocha-dotnet/src/lib/Mocha.Core/KnownInstanceGuids.cs new file mode 100755 index 0000000..ecae6f0 --- /dev/null +++ b/mocha-dotnet/src/lib/Mocha.Core/KnownInstanceGuids.cs @@ -0,0 +1,299 @@ +using System; +namespace Mocha.Core +{ + public static class KnownInstanceGuids + { + [ExportEntities(Prefix = "IDC_", Suffix = null)] + public static class Classes + { + public static Guid Class { get; } = new Guid("{B9C9B9B7-AD8A-4CBD-AA6B-E05784630B6B}"); + public static Guid Attribute { get; } = new Guid("{F9CD7751-EF62-4F7C-8A28-EBE90B8F46AA}"); + public static Guid Relationship { get; } = new Guid("{9B0A80F9-C325-4D36-997C-FB4106204648}"); + + public static Guid InstanceDefinition { get; } = new Guid("{ee26f146-0b89-4cfe-a1af-ae6ac3533eae}"); + + public static Guid Enumeration { get; } = new Guid("{70c3ee17-4d54-4342-9e7b-527cf73c93dd}"); + + // Attribute subclasses + public static Guid TextAttribute { get; } = new Guid("{C2F36542-60C3-4B9E-9A96-CA9B309C43AF}"); + public static Guid BooleanAttribute { get; } = new Guid("{EA830448-A403-4ED9-A3D3-048D5D5C3A03}"); + public static Guid NumericAttribute { get; } = new Guid("{9DE86AF1-EFD6-4B71-9DCC-202F247C94CB}"); + public static Guid DateAttribute { get; } = new Guid("{0B7B1812-DFB4-4F25-BF6D-CEB0E1DF8744}"); + + public static Guid Element { get; } = new Guid("{91929595-3dbd-4eae-8add-6120a49797c7}"); + public static Guid ElementContent { get; } = new Guid("{f85d4f5e-c69f-4498-9913-7a8554e233a4}"); + + public static Guid Translation { get; } = new Guid("{04A53CC8-3206-4A97-99C5-464DB8CAA6E6}"); + public static Guid TranslationValue { get; } = new Guid("{6D38E757-EC18-43AD-9C35-D15BB446C0E1}"); + + public static Guid String { get; } = new Guid("{5AECB489-DBC2-432E-86AF-6BE349317238}"); + public static Guid StringComponent { get; } = new Guid("{F9E2B671-13F5-4172-A568-725ACD8BBFAB}"); + public static Guid ExtractSingleInstanceStringComponent { get; } = new Guid("{FCECCE4E-8D05-485A-AE34-B1B45E766661}"); + public static Guid InstanceAttributeStringComponent { get; } = new Guid("{623565D5-5AEE-49ED-A5A9-0CFE670507BC}"); + + public static Guid Prompt { get; } = new Guid("{EC889225-416A-4F73-B8D1-2A42B37AF43E}"); + public static Guid TextPrompt { get; } = new Guid("{195DDDD7-0B74-4498-BF61-B0549FE05CF3}"); + public static Guid ChoicePrompt { get; } = new Guid("{5597AEEB-922D-48AF-AE67-DF7D951C71DB}"); + public static Guid InstancePrompt { get; } = new Guid("{F3ECBF1E-E732-4370-BE05-8FA7CC520F50}"); + public static Guid BooleanPrompt { get; } = new Guid("{a7b49c03-c9ce-4a79-a4b2-e94fc8cd8b29}"); + + public static Guid Method { get; } = new Guid("{D2813913-80B6-4DD6-9AD6-56D989169734}"); + + // public static Guid MethodCall { get; } = new Guid("{084A6D58-32C9-4A5F-9D2B-86C46F74E522}"); + + public static Guid ConditionalEvaluationCase { get; } = new Guid("{ba18abdc-11ae-46af-850a-eb30280b0ffa}"); + public static Guid ConditionalSelectAttributeCase { get; } = new Guid("{a1115690-c400-4e3e-9c8f-24e2a9477e8f}"); + + public static Guid AccessModifier { get; } = new Guid("{ca4fcc11-16c8-4872-a712-82e589d382ce}"); + + public static Guid MethodBinding { get; } = new Guid("{CB36098E-B9BF-4D22-87FA-4186EC632C89}"); + public static Guid ReturnAttributeMethodBinding { get; } = new Guid("{30FB6BA6-2BBB-41D2-B91A-709C00A07790}"); + public static Guid ReturnInstanceSetMethodBinding { get; } = new Guid("{AADC20F9-7559-429B-AEF0-97E059295C76}"); + + public static Guid Executable { get; } = new Guid("{6A1F66F7-8EA6-43D1-B2AF-198F63B84710}"); + public static Guid ExecutableReturningAttribute { get; } = new Guid("{50b2db7a-3623-4be4-b40d-98fab89d3ff5}"); + public static Guid ExecutableReturningInstanceSet { get; } = new Guid("{d5fbc5cb-13fb-4e68-b3ad-46b4ab8909f7}"); + public static Guid ExecutableReturningElement { get; } = new Guid("{a15a4f52-1f1a-4ef3-80a7-033d45cc0548}"); + public static Guid ExecutableReturningWorkData { get; } = new Guid("{a0365b76-ad1f-462e-84da-d6a1d5b9c88c}"); + + public static Guid Event { get; set; } = new Guid("{ca727ecd-8536-4aeb-9e75-352dbb958767}"); + + public static Guid WorkData { get; set; } = new Guid("{05e8f023-88cb-416b-913e-75299e665eb2}"); + public static Guid WorkSet { get; set; } = new Guid("{c4c171d8-994b-485b-b0ac-053d11b963ab}"); + + public static Guid Parameter { get; } = new Guid("{1ab99be0-43f1-495a-b85e-ec38ea606713}"); + public static Guid ParameterAssignment { get; } = new Guid("{c7aa0c7c-50d8-44fd-9b05-a558a38a6954}"); // 28 + public static Guid ElementContentDisplayOption { get; } = new Guid("{bd68052a-daa4-43b9-8965-d38095473170}"); + + public static Guid ReportObject { get; } = new Guid("{ff7d5757-d9d9-48ab-ab04-5932e7341a90}"); + + public static Guid Validation { get; } = new Guid("{3E45AA17-6E8E-41DB-9C94-E84B4B4176E8}"); + public static Guid ValidationClassification { get; } = new Guid("{8f43d578-a671-436b-afdc-c8689a5bd9b6}"); + + public static Guid PrimaryObjectReportField { get; } = new Guid("{59EA0C72-4800-48BA-84A4-DDFE10E5F4D0}"); + public static Guid RelationshipReportField { get; } = new Guid("{FC4E3BB5-1EA7-44FF-B828-2EA54CDD4ABB}"); + + public static Guid ReportField { get; } = new Guid("{655A04D9-FE35-4F89-9AAB-B8FA34989D03}"); + public static Guid AttributeReportField { get; } = new Guid("{C06E0461-A956-4599-9708-012C8FE04D94}"); + + public static Guid Module { get; } = new Guid("{e009631d-6b9d-445c-95df-79f4ef8c8fff}"); + + public static Guid Report { get; } = new Guid("{19D947B6-CE82-4EEE-92EC-A4E01E27F2DB}"); + public static Guid ReportColumn { get; } = new Guid("{BEFE99A1-B2EB-4365-A2C9-061C6609037B}"); + public static Guid StandardReport { get; } = new Guid("{FDF4A498-DE83-417D-BA01-707372125C8D}"); + + public static Guid TaskCategory { get; } = new Guid("{e8d8060f-a20c-442f-8384-03488b63247f}"); + public static Guid Task { get; } = new Guid("{D4F2564B-2D11-4A5C-8AA9-AF52D4EACC13}"); + public static Guid UITask { get; } = new Guid("{BFD07772-178C-4885-A6CE-C85076C8461C}"); + + public static Guid Tenant { get; } = new Guid("{703F9D65-C584-4D9F-A656-D0E3C247FF1F}"); + + public static Guid User { get; } = new Guid("{9C6871C1-9A7F-4A3A-900E-69D1D9E24486}"); + public static Guid UserLogin { get; } = new Guid("{64F4BCDB-38D0-4373-BA30-8AE99AF1A5F7}"); + + public static Guid MenuItemCommand { get; } = new Guid("{9D3EDE23-6DB9-4664-9145-ABCBD3A0A2C2}"); + public static Guid MenuItemSeparator { get; } = new Guid("{798DECAB-5119-49D7-B0AD-D4BF45807188}"); + public static Guid MenuItemHeader { get; } = new Guid("{1F148873-8A97-4409-A79B-C19D5D380CA4}"); + public static Guid MenuItemInstance { get; } = new Guid("{6E3AA9AF-96B9-4208-BEA9-291A72C68418}"); + + public static Guid Style { get; } = new Guid("{A48C843A-B24B-4BC3-BE6F-E2D069229B0A}"); + public static Guid StyleRule { get; } = new Guid("{C269A1F3-E014-4230-B78D-38EAF6EA8A81}"); + public static Guid StyleClass { get; } = new Guid("{a725f089-7763-4887-af37-da52358c378c}"); + + public static Guid Page { get; } = new Guid("{D9626359-48E3-4840-A089-CD8DA6731690}"); + public static Guid ContainerPageComponent { get; } = new Guid("{6AD6BD1C-7D1C-4AC9-9642-FEBC61E9D6FF}"); + public static Guid ButtonPageComponent { get; } = new Guid("{F480787D-F51E-498A-8972-72128D808AEB}"); + public static Guid HeadingPageComponent { get; } = new Guid("{FD86551E-E4CE-4B8B-95CB-BEC1E6A0EE2B}"); + public static Guid ImagePageComponent { get; } = new Guid("{798B67FA-D4BE-42B9-B4BD-6F8E02C953C0}"); + public static Guid PanelPageComponent { get; } = new Guid("{D349C489-9684-4A5A-9843-B906A7F803BC}"); + public static Guid ParagraphPageComponent { get; } = new Guid("{ADFF93CE-9E85-4168-A7D4-5239B99BE36D}"); + public static Guid SequentialContainerPageComponent { get; } = new Guid("{A66D9AE2-3BEC-4083-A5CB-7DE3B03A9CC7}"); + public static Guid SummaryPageComponent { get; } = new Guid("{5EBA7BD6-BA0A-45B2-835C-C92489FD7E74}"); + public static Guid TabContainerPageComponent { get; } = new Guid("{E52B02D7-895C-4642-9B03-EB0232868190}"); + public static Guid DetailPageComponent { get; } = new Guid("{41F9508E-6CF0-4F3D-8762-FF17CD52C466}"); + public static Guid ElementPageComponent { get; } = new Guid("{122d5565-9df9-4656-b6af-ba5df6630d32}"); + + public static Guid IntegrationID { get; } = new Guid("{49a5ebda-baaa-4ede-bba5-decc250ce1a3}"); + public static Guid IntegrationIDUsage { get; } = new Guid("{86084b9f-3860-4857-a41f-2f8b6877aff1}"); + + public static Guid Dashboard { get; } = new Guid("{896B529C-452D-42AC-98C5-170ED4F826C6}"); + public static Guid DashboardContent { get; } = new Guid("{2720ea77-cb09-4099-9f74-ccdacdd146e8}"); + public static Guid Instance { get; } = new Guid("{263C4882-945F-4DE9-AED8-E0D6516D4903}"); + public static Guid InstanceSet { get; } = new Guid("{53aac86e-ce60-4509-a869-417c38c305e0}"); + + public static Guid AuditLine { get; } = new Guid("{a4124a76-02f6-406a-9583-a197675b493b}"); + + public static Guid Theme { get; } = new Guid("{7c2cc4b5-8323-4478-863b-1759d7adf62e}"); + + public static Guid CommonBoolean { get; } = new Guid("{5b025da3-b7bd-45a9-b084-48c4a922bf72}"); + public static Guid CommonInstanceSet { get; } = new Guid("{3382da21-4fc5-45dc-bbd1-f7ba3ece1a1b}"); + } + public static class Methods + { + public static class ControlTransaction + { + public static Guid CreateInstance { get; } = new Guid("{4E92D64E-AC91-4ABF-8052-96366DF93996}"); + } + public static class GetInstanceSetBySystemRoutine + { + public static Guid Tenant__get__Current_Tenant { get; } = new Guid("{22ec44d5-bede-48bb-96ca-03481611422c}"); + public static Guid Instance__get__This_Instance { get; } = new Guid("{d78fe3ca-3c15-41a0-bccf-0a701b4712a4}"); + } + } + + [ExportEntities(Prefix = "IDC_", Suffix = null)] + public static class MethodClasses + { + public static Guid ControlTransactionMethod { get; } = new Guid("{BF73CEAC-F972-46E8-BFA1-7807F39F1B91}"); // 8 + // PU - Process Updates Method - 11 + public static Guid GetAttributeMethod { get; } = new Guid("{c3ecf8c9-597f-417b-ad65-fae0401719c6}"); // 12 + // Perform System Routine Method - 13 + public static Guid GetReferencedAttributeMethod { get; } = new Guid("{9205c54e-921a-484c-9be2-3d3deb877474}"); // 18 + public static Guid SelectFromInstanceSetMethod { get; } = new Guid("{130637B4-17A7-4394-8F4D-E83A79114E6C}"); // 19 + public static Guid EvaluateBooleanExpressionMethod { get; } = new Guid("{e1529108-2f84-4a4c-89b3-a647bc3e41d7}"); // 24 + // AR - Assign Relationship Method - 25 + public static Guid GetReferencedInstanceSetMethod { get; } = new Guid("{bcfd0d64-3eba-4a97-9622-f3a960877d24}"); // 26 + // BEM - Build Element Method - 29 + public static Guid BuildAttributeMethod { get; } = new Guid("{e5879955-0093-48c8-8042-813168578af2}"); // 30 + // CN - Calculate Numeric Method - 35 + /// + /// GSI - Get Specified Instances Method + /// Equivalent to YP: `static function $verb$name() : $returnType = $inst` + /// + /// The get specified instances method. + public static Guid GetSpecifiedInstancesMethod { get; } = new Guid("{7794c7d0-b15d-4b23-aa40-63bb3d1f53ac}"); // 40 + + // GSP - Get Instance Set from Parameters Method - 51 + // SA - Select Attribute Method - 52 + // PRU - Process Related Updates Method - 54 + // BUIR - Build UI Response Method - 62 + // GEP - Get Element from Parameters Method - 63 + // GAP - Get Attribute from Parameters Method - 64 + public static Guid GetInstanceSetBySystemRoutineMethod { get; } = new Guid("{7bdc53a1-81f0-458d-96f4-5637e6e1cf49}"); // 65 + // GAS - Get Attribute by System Routine Method - 66 + // GES - Get Element by System Routine Method - 67 + // US - Update by System Routine Method - 68 + // CS - Compare Instance Sets Method - 91 + public static Guid CalculateDateMethod { get; } = new Guid("{1e58e284-56eb-42b4-88b9-e0a691559fa6}"); // 92 + // EC - Evaluate Conditions Method - 94 + // SIM - Spawn Internal Message Method - 169 + // BWSR - Build Web Service Response Method - 171 + // GRE - Get Referenced Element Method - 197 + public static Guid GetRelationshipMethod { get; } = new Guid("{d53c9232-89ef-4cca-8520-261da6787450}"); // 207 + // IWS - Invoke Web Service Method - 208 + public static Guid InstanceOpMethod { get; } = new Guid("{4c814982-938f-4116-bdc1-827bae6a5f71}"); + public static Guid ConditionalSelectAttributeMethod { get; } = new Guid("{d534a369-321e-4c32-bd7f-8ff2017f191e}"); // 13038 + // SSC - Conditional Select from Instance Set Method - 13039 + } + public static class PromptValueClasses + { + public static Guid InstancePromptValue { get; } = new Guid("{0A6E2CF2-97B6-4339-B1DA-1DBBFE9806C6}"); + + /// + /// Return Instance Set Method Binding: `Instance@get This Instance (GSS)*P*S [rsmb]` + /// + public static Guid This_Instance { get; } = new Guid("{a476372a-24e7-41d1-9a21-ba241b1a5067}"); + /// + /// Return Instance Set Method Binding: `Instance@get Related Instance (GSS)*P*S [rsmb]` + /// + public static Guid Related_Instance { get; } = new Guid("{01e09f71-0bf6-4e33-a9f5-d45d5fb375c7}"); + + public static Guid Report_Field_Instance { get; } = new Guid("{236d54d3-3f69-477d-bafa-ae84ea0e7d6d}"); + + /// + /// Parameter: Class [CL] + /// + public static Guid Class_Instance_for_SS_Method { get; } = new Guid("{53675af2-67e1-425f-b121-6f1d4459179a}"); + } + public static class Users + { + public static Guid XQEnvironments { get; } = new Guid("{B066A54B-B160-4510-A805-436D3F90C2E6}"); + } + + [ExportEntities(Prefix = "IDI_ObjectSource_", Suffix = null)] + public static class ObjectSources + { + public static Guid System { get; } = new Guid("{9547EB35-07FB-4B64-B82C-6DA1989B9165}"); + public static Guid Delivered { get; } = new Guid("{062B57B5-D728-4DF8-903A-AD79D843B5CA}"); + public static Guid Custom { get; } = new Guid("{63D91CCD-D196-4C3A-8609-6DF371E2406F}"); + } + public static class ReportColumnOptions + { + public static Guid DisplayAsCount { get; } = new Guid("{5C9B4C79-995B-4E6A-81C0-39C174BF9F6D}"); + } + + [ExportEntities(Prefix = "IDI_Page_", Suffix = null)] + public static class Pages + { + public static Guid LoginPage { get; } = new Guid("{9E272BC3-0358-4EB7-8B3B-581964A59634}"); + } + + [ExportEntities(Prefix = "IDI_Style_", Suffix = null)] + public static class Styles + { + public static Guid BlockElementHorizontallyCentered { get; } = new Guid("{2ccfdd1b-74ab-4a35-885b-667d21465704}"); + } + + [ExportEntities(Prefix = "IDI_StyleProperty_", Suffix = null)] + public static class StyleProperties + { + public static Guid BackgroundAttachment { get; } = new Guid("{0b4bcb85-d3c1-4c96-a203-23b29dec0b0c}"); + public static Guid Display { get; } = new Guid("{10a121b6-6d91-4a99-9c51-42168fd14065}"); + + public static Guid Padding { get; } = new Guid("{354D0A44-6816-4E65-BC84-4910CE0CE6F5}"); + public static Guid PaddingLeft { get; } = new Guid("{dffd0a45-ce3c-44da-bfdb-9b77df6e16a7}"); + public static Guid PaddingRight { get; } = new Guid("{b63f804f-e7e8-4401-a893-54448452ed89}"); + public static Guid PaddingTop { get; } = new Guid("{1ab15d91-d124-4d49-8c53-088dfead5866}"); + public static Guid PaddingBottom { get; } = new Guid("{67db661d-10e8-4475-8cb1-983e65893766}"); + + public static Guid Margin { get; } = new Guid("{6d503800-6454-43c4-9940-82bea7e62a8f}"); + public static Guid MarginLeft { get; } = new Guid("{fd8f58fc-8234-4b33-a7ab-2d60aedad5a5}"); + public static Guid MarginRight { get; } = new Guid("{207bb86c-f604-4700-8174-c771c59e864f}"); + public static Guid MarginTop { get; } = new Guid("{c250f1de-afec-4422-b29d-59ec9f533fdb}"); + public static Guid MarginBottom { get; } = new Guid("{059d7330-18ed-4716-a721-9c5a28c8ee84}"); + + public static Guid Width { get; } = new Guid("{7a84cf37-c445-4e75-ab1a-075bb99067f2}"); + } + + [ExportEntities(Prefix = "IDI_Orientation_", Suffix = null)] + public static class Orientation + { + public static Guid Horizontal { get; } = new Guid("{9B7B7F14-0925-456D-98E6-E3FFEFDC272C}"); + public static Guid Vertical { get; } = new Guid("{96423CAA-260E-453A-B609-E8090897EDDF}"); + } + + [ExportEntities(Prefix = "IDI_SecurityDomain_", Suffix = null)] + public static class SecurityDomains + { + public static Guid Anyone { get; } = new Guid("{7c420ec0-988b-4987-89f6-004df29d7e6b}"); + public static Guid AuthenticatedUsers { get; } = new Guid("{f9d4f21d-2b2b-4002-b99d-7b30d4e67c6d}"); + } + + [ExportEntities(Prefix = "IDI_Task_", Suffix = null)] + public static class Tasks + { + public static Guid OpenDefinitionInCodeEditor { get; } = new Guid("{4f8a0e8e-e139-4cc6-b8cf-a32e67bd192d}"); + } + + [ExportEntities(Prefix = "IDI_DisplayOption_", Suffix = null)] + public static class ElementContentDisplayOptions + { + public static Guid DisplayAsPageTitle { get; } = new Guid("{369335cf-4a3d-4349-9300-62bd72dafeb6}"); + public static Guid NotEnterable { get; } = new Guid("{831e921b-5132-4b37-9303-da0994a0f828}"); + public static Guid SubmitNotEnterable { get; } = new Guid("{f480a1d6-cc9b-4606-bce1-d6757fa99bad}"); + public static Guid ShowSubelementsVertically { get; } = new Guid("{8bfd1ae2-1474-413d-b4dd-6cd4993080d1}"); + public static Guid Singular { get; } = new Guid("{683b3cdb-2e69-468e-bb36-4bd62716542c}"); + public static Guid DoNotShow { get; } = new Guid("{cc278872-4454-49fe-821a-ae657bffe062}"); + public static Guid InitializeForEntry { get; } = new Guid("{59410ca4-8214-4b59-ba49-1565d0cf16c7}"); + public static Guid DoNotShowLabel { get; } = new Guid("{a9fe1e02-0785-4363-b4dd-8b7ca989d4fd}"); + public static Guid WideText { get; } = new Guid("{dc0570c5-cfd5-4f87-9ba7-51fab4ccf551}"); + public static Guid Required { get; } = new Guid("{7e508c54-0507-4ae7-8ea2-7c9f197051c7}"); + public static Guid DoNotShowIfEmpty { get; } = new Guid("{055b9a42-caf5-42ad-bd2e-9a4c3527947d}"); + /// + /// Obscured Text - displays text in a text box element as obscured (system-dependent, e.g. asterisk (*) or dot) + /// + /// The GUID of the `Obscured Text` EC Display Option. + public static Guid ObscuredText { get; } = new Guid("{e42fb627-6559-42e7-a8fe-59c9d674eec4}"); + } + } +} diff --git a/mocha-dotnet/src/lib/Mocha.Core/KnownRelationshipGuids.cs b/mocha-dotnet/src/lib/Mocha.Core/KnownRelationshipGuids.cs new file mode 100755 index 0000000..8e2f4d0 --- /dev/null +++ b/mocha-dotnet/src/lib/Mocha.Core/KnownRelationshipGuids.cs @@ -0,0 +1,285 @@ +// +// KnownRelationshipGuids.cs +// +// Author: +// Michael Becker +// +// Copyright (c) 2020 Mike Becker's Software +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +using System; +namespace Mocha.Core +{ + [ExportEntities(Prefix = "IDR_", Suffix = null)] + public static class KnownRelationshipGuids + { + public static Guid Class__has_super__Class { get; } = new Guid("{100F0308-855D-4EC5-99FA-D8976CA20053}"); + public static Guid Class__has_sub__Class { get; } = new Guid("{C14BC80D-879C-4E6F-9123-E8DFB13F4666}"); + + public static Guid Class__has__Method { get; } = new Guid("{2DA28271-5E46-4472-A6F5-910B5DD6F608}"); + public static Guid Method__for__Class { get; } = new Guid("{76D2CE0D-AA4D-460B-B844-2BD76EF9902B}"); + + public static Guid Class__has__Instance { get; } = new Guid("{7EB41D3C-2AE9-4884-83A4-E59441BCAEFB}"); + public static Guid Instance__for__Class { get; } = new Guid("{494D5A6D-04BE-477B-8763-E3F57D0DD8C8}"); + + public static Guid Class__has__Relationship { get; } = new Guid("{3997CAAD-3BFA-4EA6-9CFA-2AA63E20F08D}"); + public static Guid Relationship__for__Class { get; } = new Guid("{C00BD63F-10DA-4751-B8EA-0905436EA098}"); + + public static Guid Class__has_title__Translation { get; } = new Guid("{B8BDB905-69DD-49CD-B557-0781F7EF2C50}"); + + public static Guid Class__has__Attribute { get; } = new Guid("{DECBB61A-2C6C-4BC8-9042-0B5B701E08DE}"); + public static Guid Attribute__for__Class { get; } = new Guid("{FFC8E435-B9F8-4495-8C85-4DDA67F7E2A8}"); + + public static Guid Class__has_default__Task { get; } = new Guid("{CF396DAA-75EA-4148-8468-C66A71F2262D}"); + + public static Guid Class__has_owner__User { get; } = new Guid("{D1A25625-C90F-4A73-A6F2-AFB530687705}"); + public static Guid User__owner_for__Class { get; } = new Guid("{04DD2E6B-EA57-4840-8DD5-F0AA943C37BB}"); + + public static Guid Instance__for__Module { get; } = new Guid("{c60fda3c-2c0a-4229-80e8-f644e4471d28}"); + public static Guid Module__has__Instance { get; } = new Guid("{c3e5d7e3-5e11-4f8d-a212-b175327b2648}"); + + public static Guid Class__has__Object_Source { get; } = new Guid("{B62F9B81-799B-4ABE-A4AF-29B45347DE54}"); + public static Guid Object_Source__for__Class { get; } = new Guid("{FBB9391D-C4A2-4326-9F85-7801F377253C}"); + + public static Guid Relationship__has_source__Class { get; } = new Guid("{7FB5D234-042E-45CB-B11D-AD72F8D45BD3}"); + public static Guid Relationship__has_destination__Class { get; } = new Guid("{F220F1C2-0499-4E87-A32E-BDBF80C1F8A4}"); + public static Guid Relationship__has_sibling__Relationship { get; } = new Guid("{656110FF-4502-48B8-A7F3-D07F017AEA3F}"); + + public static Guid Translation__has__Translation_Value { get; } = new Guid("{F9B60C00-FF1D-438F-AC74-6EDFA8DD7324}"); + public static Guid Translation_Value__has__Language { get; } = new Guid("{3655AEC2-E2C9-4DDE-8D98-0C4D3CE1E569}"); + + public static Guid String__has__String_Component { get; } = new Guid("{3B6C4C25-B7BC-4242-8ED1-BA6D01B834BA}"); + public static Guid Extract_Single_Instance_String_Component__has__Relationship { get; } = new Guid("{5E499753-F50F-4A9E-BF53-DC013820499C}"); + public static Guid Instance_Attribute_String_Component__has__Attribute { get; } = new Guid("{E15D4277-69FB-4F19-92DB-8D087F361484}"); + public static Guid String_Component__has_source__Method { get; } = new Guid("{1ef1c965-e120-48be-b682-aa040573b5fb}"); + + public static Guid Class__instance_labeled_by__String { get; } = new Guid("{F52FC851-D655-48A9-B526-C5FE0D7A29D2}"); + public static Guid Class__has_summary__Report_Field { get; } = new Guid("{D11050AD-7376-4AB7-84DE-E8D0336B74D2}"); + public static Guid Class__has_related__Task { get; } = new Guid("{4D8670E1-2AF1-4E7C-9C87-C910BD7B319B}"); + + public static Guid Report_Object__has__Report_Field { get; } = new Guid("{0af62656-42bc-40a5-b0bc-dbba67c347f6}"); + public static Guid Report_Field__for__Report_Object { get; } = new Guid("{b46c8caa-3f46-465f-ba11-7d6f385425a2}"); + + public static Guid Task__has_title__Translation { get; } = new Guid("{D97AE03C-261F-4060-A06D-985E26FA662C}"); + public static Guid Task__has_instructions__Translation { get; } = new Guid("{A9387898-9DC0-4006-94F1-1FB02EB3ECD7}"); + public static Guid Task__has__Prompt { get; } = new Guid("{929B106F-7E3E-4D30-BB84-E450A4FED063}"); + public static Guid Task__has__Task_Category { get; } = new Guid("{84048159-430d-4f6c-9361-115c8629c517}"); + public static Guid Task__executes__Method_Call { get; } = new Guid("{D8C0D4D4-F8C6-4B92-A2C1-8BF16B16203D}"); + public static Guid Task__has_preview_action_title__Translation { get; } = new Guid("{3f65ce02-11dd-4829-a46b-b9ea1b43e56a}"); + + public static Guid Prompt__has__Report_Field { get; } = new Guid("{922CCB05-61EA-441D-96E0-63D58231D202}"); // 3de784b9-4561-42f0-946f-b1e90d80029e + public static Guid Report_Field__for__Prompt { get; } = new Guid("{5DED3DB4-6864-45A9-A5FF-8E5A35AD6E6F}"); // b5f59216-a1f1-4979-8642-a4845e59daa8 + + public static Guid Instance_Prompt__has_valid__Class { get; } = new Guid("{D5BD754B-F401-4FD8-A707-82684E7E25F0}"); + + public static Guid Instance_Prompt_Value__has__Instance { get; } = new Guid("{512B518E-A892-44AB-AC35-4E9DBCABFF0B}"); + + public static Guid Method__has__Method_Binding { get; } = new Guid("{D52500F1-1421-4B73-9987-223163BC9C04}"); + public static Guid Method_Binding__for__Method { get; } = new Guid("{B782A592-8AF5-4228-8296-E3D0B24C70A8}"); + + public static Guid Method__has_return_type__Class { get; } = new Guid("{1241c599-e55d-4dcf-9200-d0e48c217ef8}"); + + public static Guid Method_Binding__has__Parameter_Assignment { get; } = new Guid("{24938109-94f1-463a-9314-c49e667cf45b}"); + public static Guid Parameter_Assignment__for__Method_Binding { get; } = new Guid("{19c4a5db-fd26-44b8-b431-e081e6ffff8a}"); + + public static Guid Parameter__has_data_type__Instance { get; } = new Guid("{ccb5200c-5faf-4a3a-9e8e-2edf5c2e0785}"); + public static Guid Instance__data_type_for__Parameter { get; } = new Guid("{ea1e6305-b2e4-4ba5-91b4-1ecfbebfa490}"); + + public static Guid Instance_Set__has__Instance { get; } = new Guid("{7c9010a2-69f1-4029-99c8-72e05c78c41e}"); + + public static Guid Parameter_Assignment__assigns_to__Parameter { get; } = new Guid("{a6d30e78-7bff-4fcc-b109-ee96681b0a9e}"); + public static Guid Parameter__assigned_from__Parameter_Assignment { get; } = new Guid("{2085341e-5e7e-4a7f-bb8d-dfa58f6030d9}"); + + public static Guid Method_Binding__assigned_to__Parameter_Assignment { get; } = new Guid("{cbcb23b7-10c4-49eb-a1ca-b9da73fe8b83}"); + public static Guid Parameter_Assignment__assigns_from__Method_Binding { get; } = new Guid("{1e055d30-a968-49d8-93fe-541994fc0c51}"); + + public static Guid Method_Call__has__Method { get; } = new Guid("{3D3B601B-4EF0-49F3-AF05-86CEA0F00619}"); + public static Guid Method_Call__has__Prompt_Value { get; } = new Guid("{765BD0C9-117D-4D0E-88C9-2CEBD4898135}"); + + public static Guid Validation__has__Validation_Classification { get; } = new Guid("{BCDB6FFD-D2F2-4B63-BD7E-9C2CCD9547E0}"); + public static Guid Validation__has_true_condition__Executable { get; } = new Guid("{AA2D3B51-4153-4599-A983-6B4A13ADCBCB}"); + public static Guid Validation__has_false_condition__Executable { get; } = new Guid("{419047F8-852B-4A4D-B161-A8BD022FD8EB}"); + + public static Guid Validation__has_failure_message__Translation { get; } = new Guid("{E15A97DD-2A1D-4DC0-BD6B-A957B63D9802}"); + public static Guid Translation__failure_message_for__Validation { get; } = new Guid("{46a7dfcb-8848-47d5-9ad3-d27fbd8b423f}"); + + public static Guid Get_Attribute_Method__has__Attribute { get; } = new Guid("{5eca9b3f-be75-4f6e-8495-781480774833}"); + + public static Guid Get_Referenced_Instance_Set_Method__loop_on__Instance_Set { get; } = new Guid("{2978238f-7cb0-4ba3-8c6f-473df782cfef}"); + public static Guid Get_Referenced_Instance_Set_Method__has_relationship__Method { get; } = new Guid("{6a65819e-c8cb-4575-9af8-ee221364049b}"); + + public static Guid Get_Referenced_Attribute_Method__has__Attribute { get; } = new Guid("{87f90fe9-5ec6-4b09-8f51-b8a4d1544cae}"); + public static Guid Get_Referenced_Attribute_Method__loop_on__Instance_Set { get; } = new Guid("{c7ecd498-6d05-4e07-b1bc-f7127d0d6666}"); + + public static Guid Get_Specific_Instances_Method__has__Instance { get; } = new Guid("{dea1aa0b-2bef-4bac-b4f9-0ce8cf7006fc}"); + + public static Guid Evaluate_Boolean_Expression_Method__has_source_attribute__Method { get; } = new Guid("{45d76d56-01ed-4641-9f68-cfe0c7d0d265}"); + public static Guid Evaluate_Boolean_Expression_Method__equal_to_attribute__Method { get; } = new Guid("{0646df91-7e3e-4d59-be71-b978a22ced8e}"); + + public static Guid Prompt_Value__has__Prompt { get; } = new Guid("{7CD62362-DDCE-4BFC-87B9-B5499B0BC141}"); + + public static Guid User__has_display_name__Translatable_Text_Constant { get; } = new Guid("{6C29856C-3B10-4F5B-A291-DD3CA4C04A2F}"); + public static Guid User_Login__has__User { get; } = new Guid("{85B40E4B-849B-4006-A9C0-4E201B25975F}"); + + public static Guid User__has_default__Page { get; } = new Guid("{f00cda6f-eded-4e0f-b6c5-9675ed664a75}"); + + public static Guid Dashboard__has__Dashboard_Content { get; } = new Guid("{d26acf18-afa5-4ccd-8629-e1d9dac394ed}"); + public static Guid Dashboard_Content__for__Dashboard { get; } = new Guid("{9f236d2d-1f45-4096-a69c-42f37abbeebc}"); + public static Guid Dashboard_Content__has__Instance { get; } = new Guid("{1f0c4075-2b7d-42c2-8488-c7db06e91f5a}"); + public static Guid Instance__for__Dashboard_Content { get; } = new Guid("{376951c9-252b-4843-8e1d-ca89c94ddfa6}"); + + public static Guid Return_Instance_Set_Method_Binding__has_source__Class { get; } = new Guid("{EE7A3049-8E09-410C-84CB-C2C0D652CF40}"); + + public static Guid Report__has__Report_Column { get; } = new Guid("{7A8F57F1-A4F3-4BAF-84A5-E893FD79447D}"); + public static Guid Report__has__Report_Data_Source { get; } = new Guid("{1DE7B484-F9E3-476A-A9D3-7D2A86B55845}"); + public static Guid Report__has__Prompt { get; } = new Guid("{5D112697-303F-419F-886F-3F09F0670B07}"); + + public static Guid Report_Column__has__Report_Field { get; } = new Guid("{B9026910-7E91-4EE1-B5F2-D7B740614831}"); + public static Guid Report_Column__has__Report_Column_Option { get; } = new Guid("{41FFF5F0-B467-4986-A6FD-46FAF4A479E9}"); + + public static Guid Report_Data_Source__has_source__Method { get; } = new Guid("{2D5CB496-5839-46A0-9B94-30D4E2227B56}"); + + public static Guid Report_Field__has_source__Method { get; } = new Guid("{5db86b76-69bf-421f-96e7-4c49452db82e}"); + public static Guid Attribute_Report_Field__has_target__Attribute { get; } = new Guid("{37964301-26FD-41D8-8661-1F73684C0E0A}"); + public static Guid Relationship_Report_Field__has_target__Relationship { get; } = new Guid("{134B2790-F6DF-4F97-9AB5-9878C4A715E5}"); + + + public static Guid Tenant__has__Application { get; } = new Guid("{22936f51-2629-4503-a30b-a02d61a6c0e0}"); + public static Guid Tenant__has_sidebar__Menu_Item { get; } = new Guid("{D62DFB9F-48D5-4697-AAAD-1CAD0EA7ECFA}"); + public static Guid Tenant__has__Tenant_Type { get; } = new Guid("{E94B6C9D-3307-4858-9726-F24B7DB21E2D}"); + + public static Guid Tenant__has_company_logo_image__File { get; } = new Guid("{3540c81c-b229-4eac-b9b5-9d4b4c6ad1eb}"); + + public static Guid Menu__has__Menu_Section { get; } = new Guid("{a22d949f-f8d1-4dcc-a3eb-d9f910228dfd}"); + public static Guid Menu_Item__has_title__Translatable_Text_Constant { get; } = new Guid("{65E3C87E-A2F7-4A33-9FA7-781EFA801E02}"); + public static Guid Menu_Section__has__Menu_Item { get; } = new Guid("{5b659d7c-58f9-453c-9826-dd3205c3c97f}"); + + public static Guid Command_Menu_Item__has__Icon { get; } = new Guid("{8859DAEF-01F7-46FA-8F3E-7B2F28E0A520}"); + + public static Guid Instance_Menu_Item__has_target__Instance { get; } = new Guid("{C599C20E-F01A-4B12-A919-5DC3B0F545C2}"); + + public static Guid Page__has_title__Translation { get; } = new Guid("{7BE6522A-4BE8-4CD3-8701-C8353F7DF630}"); + public static Guid Page__has__Style { get; } = new Guid("{6E6E1A85-3EA9-4939-B13E-CBF645CB8B59}"); + public static Guid Page__has__Page_Component { get; } = new Guid("{24F6C596-D77D-4754-B023-00321DEBA924}"); + + public static Guid Style__has__Style_Rule { get; } = new Guid("{4CC8A654-B2DF-4B17-A956-24939530790E}"); + public static Guid Style_Rule__has__Style_Property { get; } = new Guid("{B69C2708-E78D-413A-B491-ABB6F1D2A6E0}"); + + public static Guid Page__has_master__Page { get; } = new Guid("{9bdbfd64-0915-419f-83fd-e8cf8bcc74ae}"); + public static Guid Page__master_for__Page { get; } = new Guid("{7fe8f2a2-c94d-4010-83aa-9300cc99d71d}"); + + public static Guid Page_Component__has__Style { get; } = new Guid("{818CFF50-7D42-43B2-B6A7-92C3C54D450D}"); + public static Guid Style__for__Page_Component { get; } = new Guid("{007563E7-7277-4436-8C82-06D5F156D8E1}"); + + public static Guid Button_Page_Component__has_text__Translatable_Text_Constant { get; } = new Guid("{C25230B1-4D23-4CFE-8B75-56C33E8293AF}"); + public static Guid Image_Page_Component__has_source__Method { get; } = new Guid("{481E3FBE-B82A-4C76-9DDF-D66C6BA8C590}"); + + public static Guid Sequential_Container_Page_Component__has__Sequential_Container_Orientation { get; } = new Guid("{DD55F506-8718-4240-A894-21346656E804}"); + public static Guid Container_Page_Component__has__Page_Component { get; } = new Guid("{CB7B8162-1C9E-4E72-BBB8-C1C37CA69CD5}"); + + public static Guid Panel_Page_Component__has_header__Page_Component { get; } = new Guid("{223B4073-F417-49CD-BCA1-0E0749144B9D}"); + public static Guid Panel_Page_Component__has_content__Page_Component { get; } = new Guid("{AD8C5FAE-2444-4700-896E-C5F968C0F85B}"); + public static Guid Panel_Page_Component__has_footer__Page_Component { get; } = new Guid("{56E339BD-6189-4BAC-AB83-999543FB8060}"); + + public static Guid Element_Page_Component__has__Element { get; } = new Guid("{fe833426-e25d-4cde-8939-2a6c9baac20c}"); + public static Guid Element_Page_Component__has__Element_Content_Display_Option { get; } = new Guid("{74e3c13a-04fd-4f49-be70-05a32cdcdfe7}"); + public static Guid Element_Content_Display_Option__for__Element_Page_Component { get; } = new Guid("{7d3a7045-0925-49db-9b7d-24863c9848a6}"); + + public static Guid Element__for__Element_Page_Component { get; } = new Guid("{963c5c60-3979-47fa-b201-a26839b9ded9}"); + + public static Guid Tenant__has_logo_image__File { get; } = new Guid("{4C399E80-ECA2-4A68-BFB4-26A5E6E97047}"); + public static Guid Tenant__has_background_image__File { get; } = new Guid("{39B0D963-4BE0-49C8-BFA2-607051CB0101}"); + public static Guid Tenant__has_icon_image__File { get; } = new Guid("{CC4E65BD-7AAA-40DA-AECA-C607D7042CE3}"); + public static Guid Tenant__has_login_header__Translatable_Text_Constant { get; } = new Guid("{41D66ACB-AFDE-4B6F-892D-E66255F10DEB}"); + public static Guid Tenant__has_login_footer__Translatable_Text_Constant { get; } = new Guid("{A6203B6B-5BEB-4008-AE49-DB5E7DDBA45B}"); + public static Guid Tenant__has_application_title__Translation { get; } = new Guid("{76683437-67ba-46d9-a5e7-2945be635345}"); + public static Guid Tenant__has_mega__Menu { get; } = new Guid("{cdd743cb-c74a-4671-9922-652c7db9f2d8}"); + + public static Guid Tenant_Type__has_title__Translatable_Text_Constant { get; } = new Guid("{79AAE09C-5690-471C-8442-1B230610456C}"); + + public static Guid Prompt__has_title__Translatable_Text_Constant { get; } = new Guid("{081ee211-7534-43c4-99b5-24bd9537babc}"); + + public static Guid Report__has_title__Translatable_Text_Constant { get; } = new Guid("{DF93EFB0-8B5E-49E7-8BC0-553F9E7602F9}"); + public static Guid Report__has_description__Translatable_Text_Constant { get; } = new Guid("{D5AA18A7-7ACD-4792-B039-6C620A151BAD}"); + public static Guid Report_Field__has_title__Translatable_Text_Constant { get; } = new Guid("{6780BFC2-DBC0-40AE-83EE-BFEF979F0054}"); + + public static Guid Content_Page_Component__gets_content_from__Method { get; } = new Guid("{0E002E6F-AA79-457C-93B8-2CCE1AEF5F7E}"); + public static Guid Method__provides_content_for__Content_Page_Component { get; } = new Guid("{5E75000D-2421-4AD4-9E5F-B9FDD9CB4744}"); + + public static Guid Securable_Item__secured_by__Method { get; } = new Guid("{15199c49-9595-4288-846d-13b0ad5dcd4b}"); + public static Guid Get_Relationship_Method__has__Relationship { get; } = new Guid("{321581d6-60c1-4547-8344-9d5bda027adc}"); + + public static Guid Integration_ID__has__Integration_ID_Usage { get; } = new Guid("{6cd30735-df83-4253-aabe-360d6e1a3701}"); + public static Guid Integration_ID_Usage__for__Integration_ID { get; } = new Guid("{d8d981ec-7686-40da-b89f-006c85042444}"); + + public static Guid Conditional_Method__has__Conditional_Method_Case { get; } = new Guid("{df2059e6-650c-49a8-8188-570ccbe4fd2d}"); + public static Guid Conditional_Method_Case__for__Conditional_Method { get; } = new Guid("{be7a6285-d700-40f3-868e-c0878a3e94a6}"); + + public static Guid Conditional_Method_Case__has_return_attribute__Method_Binding { get; } = new Guid("{b6715132-b438-4073-b81d-3ecf19584b7d}"); + public static Guid Method_Binding__returns_attribute_for__Conditional_Method_Case { get; } = new Guid("{1c868a06-8fb7-432d-839b-7a5a02a50eb6}"); + + public static Guid Conditional_Method_Case__has_true_condition__Method_Binding { get; } = new Guid("{d955da3f-7ef4-4374-8b86-167c73434f75}"); + public static Guid Method_Binding__true_condition_for__Conditional_Method_Case { get; } = new Guid("{1acdefd1-e1b4-45bb-99e1-bf73dea71da5}"); + + public static Guid Conditional_Method_Case__has_false_condition__Method_Binding { get; } = new Guid("{e46dbc4f-ae8d-4ad8-b9e6-10cedfa68b73}"); + public static Guid Method_Binding__false_condition_for__Conditional_Method_Case { get; } = new Guid("{633af008-bf7f-4da1-94d6-67a9a80586d6}"); + + public static Guid Audit_Line__has__Instance { get; } = new Guid("{c91807ed-0d73-4729-990b-d90750764fb5}"); + public static Guid Audit_Line__has__User { get; } = new Guid("{7c1e048d-3dcb-4473-9f2e-e21014a76aa5}"); + + public static Guid Method__has__Method_Parameter { get; } = new Guid("{c455dc79-ba9b-4a7c-af8e-9ca59dbe511f}"); + public static Guid Method_Parameter__for__Method { get; } = new Guid("{0bcb6e5b-5885-4747-843c-ed4c3d3dc234}"); + public static Guid Method__returns__Attribute { get; } = new Guid("{eb015d32-0d4f-4647-b9b8-715097f4434b}"); + + public static Guid Detail_Page_Component__has_caption__Translation { get; } = new Guid("{4a15fa44-fb7b-4e26-8ce2-f36652792b48}"); + + public static Guid Element__has__Element_Content { get; } = new Guid("{c1d32481-02f9-48c6-baf8-37d93fa8da23}"); + public static Guid Element_Content__for__Element { get; } = new Guid("{2eff7f58-0edd-40b7-9c06-00774257649e}"); + + public static Guid Element__has_label__Translation { get; } = new Guid("{7147ea90-9f45-4bb9-b151-025b6e2bd834}"); + + public static Guid Element_Content__has__Instance { get; } = new Guid("{315b71ba-953d-45fc-87e5-4f0a268242a9}"); + public static Guid Instance__for__Element_Content { get; } = new Guid("{c3959f84-248d-4ede-a3f2-f262917c7b56}"); + + public static Guid Element_Content__has__Element_Content_Display_Option { get; } = new Guid("{f070dfa7-6260-4488-a779-fae291903f2d}"); + + public static Guid Element_Content__has__Parameter_Assignment { get; } = new Guid("{51214ef0-458a-44fa-8b9d-f3d9d2309388}"); + public static Guid Parameter__assigned_from__Element_Content { get; } = new Guid("{dcef180b-a2ca-4d87-bb05-b946c319b562}"); + + public static Guid Element_Content__has__Validation { get; } = new Guid("{265637cd-2099-416b-88fa-4f5ed88a87e3}"); + public static Guid Validation__for__Element_Content { get; } = new Guid("{3a4677e8-9c78-4149-80ad-46e5ac3b12f5}"); + + public static Guid Instance__has__Instance_Definition { get; } = new Guid("{329c54ee-17b8-4550-ae80-be5dee9ac53c}"); + + public static Guid Task__has_initiating__Element { get; } = new Guid("{78726736-f5b7-4466-b114-29cbaf6c9329}"); + public static Guid Element__initiates_for__Task { get; } = new Guid("{36964c5d-348e-4f88-8a62-0a795b43bc14}"); + + public static Guid Detail_Page_Component__has_row_source__Method_Binding { get; } = new Guid("{54FBD056-0BD4-44F4-921C-11FB0C77996E}"); + public static Guid Detail_Page_Component__has_column_source__Method_Binding { get; } = new Guid("{ddabeeda-aa26-4d87-a457-4e7da921a293}"); + + public static Guid Work_Set__has_valid__Class { get; } = new Guid("{08087462-41a5-4271-84bc-a9bcd31a2c21}"); + public static Guid Class__valid_for__Work_Set { get; } = new Guid("{73c65dcf-7810-47d4-98c0-898ca1b17a68}"); + + public static Guid Conditional_Select_Attribute_Case__invokes__Executable_returning_Attribute { get; } = new Guid("{dbd97430-9c55-430d-815c-77fce9887ba7}"); + public static Guid Executable_returning_Attribute__invoked_by__Conditional_Select_Attribute_Case { get; } = new Guid("{f4b04072-abe8-452a-b8f8-e0369dde24d4}"); + + public static Guid Style__gets_background_image_File_from__Return_Instance_Set_Method_Binding { get; } = new Guid("{4b4a0a3e-426c-4f70-bc15-b6efeb338486}"); + + public static Guid Style__has__Style_Class { get; } = new Guid("{2cebd830-52aa-44ff-818d-b2d6ee273a1f}"); + public static Guid Style_Class__for__Style { get; } = new Guid("{b2fbce51-455a-42b5-9fd1-c28bb0cbe613}"); + + public static Guid Style__implements__Style { get; } = new Guid("{99b1c16a-f2cb-4cc5-a3bb-82a96335aa39}"); + public static Guid Style__implemented_for__Style { get; } = new Guid("{271ef816-1e94-4f02-a805-4f9536c28dca}"); + } +} diff --git a/mocha-dotnet/src/lib/Mocha.Core/Mocha.Core.csproj b/mocha-dotnet/src/lib/Mocha.Core/Mocha.Core.csproj new file mode 100644 index 0000000..192a048 --- /dev/null +++ b/mocha-dotnet/src/lib/Mocha.Core/Mocha.Core.csproj @@ -0,0 +1,10 @@ + + + + + + net8.0 + enable + enable + + \ No newline at end of file diff --git a/mocha-dotnet/src/lib/Mocha.Core/OmsException.cs b/mocha-dotnet/src/lib/Mocha.Core/OmsException.cs new file mode 100755 index 0000000..8244a1e --- /dev/null +++ b/mocha-dotnet/src/lib/Mocha.Core/OmsException.cs @@ -0,0 +1,39 @@ +// +// OmsException.cs +// +// Author: +// Michael Becker +// +// Copyright (c) 2021 Mike Becker's Software +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +using System; +namespace Mocha.Core +{ + public class OmsException : Exception + { + public OmsException() + { + } + public OmsException(string message) : base(message) + { + } + public OmsException(string message, Exception innerException) : base(message, innerException) + { + } + public OmsException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) : base(info, context) + { + } + } +} diff --git a/mocha-dotnet/src/lib/Mocha.Core/Relationship.cs b/mocha-dotnet/src/lib/Mocha.Core/Relationship.cs new file mode 100755 index 0000000..87ed921 --- /dev/null +++ b/mocha-dotnet/src/lib/Mocha.Core/Relationship.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; + +namespace Mocha.Core +{ + public class Relationship + { + public Relationship(InstanceReference sourceInstance, InstanceReference relationshipInstance) + { + SourceInstance = sourceInstance; + RelationshipInstance = relationshipInstance; + } + + public InstanceReference SourceInstance { get; } + public InstanceReference RelationshipInstance { get; } + } +} diff --git a/mocha-dotnet/src/lib/Mocha.Core/RelationshipKey.cs b/mocha-dotnet/src/lib/Mocha.Core/RelationshipKey.cs new file mode 100755 index 0000000..9b5ebc8 --- /dev/null +++ b/mocha-dotnet/src/lib/Mocha.Core/RelationshipKey.cs @@ -0,0 +1,56 @@ +// +// RelationshipKey.cs +// +// Author: +// Michael Becker +// +// Copyright (c) 2021 Mike Becker's Software +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +using System; +namespace Mocha.Core +{ + public struct RelationshipKey + { + public Guid SourceInstanceID { get; } + public Guid RelationshipID { get; } + + public RelationshipKey(Guid sourceInstanceId, Guid relationshipId) + { + SourceInstanceID = sourceInstanceId; + RelationshipID = relationshipId; + } + + public override bool Equals(object obj) + { + return (obj is RelationshipKey) && ((RelationshipKey)obj).SourceInstanceID == SourceInstanceID && ((RelationshipKey)obj).RelationshipID == RelationshipID; + } + public static bool operator ==(RelationshipKey left, RelationshipKey right) + { + return left.Equals(right); + } + public static bool operator !=(RelationshipKey left, RelationshipKey right) + { + return !left.Equals(right); + } + + public override int GetHashCode() + { + int hashcode = 0x51ed270b; + hashcode += (SourceInstanceID.GetHashCode() * -1521134295); + hashcode += (RelationshipID.GetHashCode() * -1521134295); + return hashcode; + } + } +} diff --git a/mocha-dotnet/src/lib/Mocha.Core/Tenant.cs b/mocha-dotnet/src/lib/Mocha.Core/Tenant.cs new file mode 100755 index 0000000..a79ccee --- /dev/null +++ b/mocha-dotnet/src/lib/Mocha.Core/Tenant.cs @@ -0,0 +1,37 @@ +// +// Tenant.cs +// +// Author: +// Michael Becker +// +// Copyright (c) 2020 Mike Becker's Software +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +using System; + +namespace Mocha.Core +{ + public class Tenant + { + public string Name { get; } = null; + public Guid ID { get; } = Guid.Empty; + + public Tenant(string name, Guid id) + { + Name = name; + ID = id; + } + } +} diff --git a/mocha-dotnet/src/lib/Mocha.Core/TenantHandle.cs b/mocha-dotnet/src/lib/Mocha.Core/TenantHandle.cs new file mode 100755 index 0000000..04262b5 --- /dev/null +++ b/mocha-dotnet/src/lib/Mocha.Core/TenantHandle.cs @@ -0,0 +1,121 @@ +// +// InstanceHandle.cs +// +// Author: +// Michael Becker +// +// Copyright (c) 2022 Mike Becker's Software +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +using System; +namespace Mocha.Core +{ + public struct TenantHandle : IEquatable + { + private Guid _ID1; + private Guid _ID2; + + private DateTime _date; + private bool isNotEmpty; + + public static TenantHandle Create() + { + TenantHandle handle = new TenantHandle(); + handle._ID1 = Guid.NewGuid(); + handle._ID2 = Guid.NewGuid(); + handle._date = DateTime.Now; + handle.isNotEmpty = true; + return handle; + } + + public byte[] ToByteArray() + { + byte[] data = new byte[32]; + Array.Copy(_ID1.ToByteArray(), 0, data, 0, 16); + Array.Copy(_ID2.ToByteArray(), 0, data, 16, 16); + return data; + } + + public static readonly TenantHandle Empty = new TenantHandle(); + + public bool IsEmpty { get { return !isNotEmpty; } } + + public bool Equals(TenantHandle other) + { + if (IsEmpty && other.IsEmpty) + return true; + + return _ID1 == other._ID1 && _ID2 == other._ID2 && _date == other._date; + } + + public static bool operator ==(TenantHandle left, TenantHandle right) + { + return left.Equals(right); + } + public static bool operator !=(TenantHandle left, TenantHandle right) + { + return !left.Equals(right); + } + + public override string ToString() + { + if (IsEmpty) + return null; + + byte[] data = ToByteArray(); + return Convert.ToBase64String(data); + } + + + public static string IntToString(int value, char[] baseChars) + { + string result = string.Empty; + int targetBase = baseChars.Length; + + do + { + result = baseChars[value % targetBase] + result; + value = value / targetBase; + } + while (value > 0); + + return result; + } + + /// + /// An optimized method using an array as buffer instead of + /// string concatenation. This is faster for return values having + /// a length > 1. + /// + public static string IntToStringFast(int value, char[] baseChars) + { + // 32 is the worst cast buffer size for base 2 and int.MaxValue + int i = 32; + char[] buffer = new char[i]; + int targetBase = baseChars.Length; + + do + { + buffer[--i] = baseChars[value % targetBase]; + value = value / targetBase; + } + while (value > 0); + + char[] result = new char[32 - i]; + Array.Copy(buffer, i, result, 0, 32 - i); + + return new string(result); + } + } +} diff --git a/mocha-dotnet/src/lib/Mocha.Core/Transaction.cs b/mocha-dotnet/src/lib/Mocha.Core/Transaction.cs new file mode 100755 index 0000000..a32527d --- /dev/null +++ b/mocha-dotnet/src/lib/Mocha.Core/Transaction.cs @@ -0,0 +1,127 @@ +// +// Transaction.cs +// +// Author: +// Michael Becker +// +// Copyright (c) 2021 Mike Becker's Software +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +using System; +using System.Collections; +using System.Collections.Generic; + +using MBS.Core; +using MBS.Core.Collections.Generic; + +namespace Mocha.Core +{ + // FIXME: this should be extrapolated into a Collections.Generic.Blockchain implementation + public class Transaction + { + private Transaction _next = null; + private Transaction _prev = null; + + private byte[] hash = null; + public string Hashstr { get { return ToHexstring(hash); } } + + private string ToHexstring(byte[] data) + { + // 00 AA CC DD + // data.len == 4, str.len == 8 + char[] cc = new char[data.Length * 2]; + for (int i = 0; i < data.Length; i++) + { + string t = data[i].ToString("x").PadLeft(2, '0'); + cc[(i * 2)] = t[0]; + cc[(i * 2) + 1] = t[1]; + } + + // 0 1 2 3 + // 0 1 2 3 4 5 6 7 + return new string(cc); + } + + private byte[] GetData() + { + System.IO.MemoryStream ms = new System.IO.MemoryStream(); + System.IO.BinaryWriter bw = new System.IO.BinaryWriter(ms); + bw.Write(Operations.Count); + foreach (TransactionOperation op in Operations) + { + bw.Write(op.GetData()); + } + bw.Close(); + return ms.ToArray(); + } + + public class TransactionCollection : AppendOnlyLinkedList + { + protected virtual System.Security.Cryptography.HashAlgorithm CreateHashAlgorithm() + { + return new System.Security.Cryptography.SHA512Managed(); + } + + protected override void InsertItem(Transaction item) + { + System.Security.Cryptography.HashAlgorithm sha = CreateHashAlgorithm(); + + LinkedListNode prev = Last; + + System.IO.MemoryStream ms = new System.IO.MemoryStream(); + System.IO.BinaryWriter bw = new System.IO.BinaryWriter(ms); + bw.Write(item.GetData()); + while (prev != null) + { + bw.Write(prev.Value.GetData()); + + prev = prev.Previous; + } + bw.Close(); + + item.hash = sha.ComputeHash(ms.ToArray()); + + base.InsertItem(item); + } + + public bool Verify() + { + System.Security.Cryptography.HashAlgorithm sha = CreateHashAlgorithm(); + LinkedListNode prev = Last; + + System.IO.MemoryStream ms = new System.IO.MemoryStream(); + System.IO.BinaryWriter bw = new System.IO.BinaryWriter(ms); + while (prev != null) + { + bw.Write(prev.Value.GetData()); + + prev = prev.Previous; + } + bw.Close(); + + if (Last.Value.hash.Matches(sha.ComputeHash(ms.ToArray()))) + return true; + return false; + } + } + + public TenantHandle Tenant { get; } = TenantHandle.Empty; + public Transaction(TenantHandle tenant) + { + Tenant = tenant; + } + + public TransactionOperation.TransactionOperationCollection Operations { get; } = new TransactionOperation.TransactionOperationCollection(); + } +} diff --git a/mocha-dotnet/src/lib/Mocha.Core/TransactionOperation.cs b/mocha-dotnet/src/lib/Mocha.Core/TransactionOperation.cs new file mode 100755 index 0000000..4971d2c --- /dev/null +++ b/mocha-dotnet/src/lib/Mocha.Core/TransactionOperation.cs @@ -0,0 +1,38 @@ +// +// TransactionOperation.cs +// +// Author: +// Michael Becker +// +// Copyright (c) 2021 Mike Becker's Software +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +using System; +namespace Mocha.Core +{ + public abstract class TransactionOperation + { + public class TransactionOperationCollection + : System.Collections.ObjectModel.Collection + { + + } + + protected abstract byte[] GetDataInternal(); + public byte[] GetData() + { + return GetDataInternal(); + } + } +}