diff --git a/uml4net.CodeGenerator/Extensions/GenericExtensions.cs b/uml4net.CodeGenerator/Extensions/GenericExtensions.cs deleted file mode 100644 index 893e0056..00000000 --- a/uml4net.CodeGenerator/Extensions/GenericExtensions.cs +++ /dev/null @@ -1,128 +0,0 @@ -// ------------------------------------------------------------------------------------------------- -// -// -// Copyright 2019-2024 Starion Group S.A. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, softwareUseCases -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// -// ------------------------------------------------------------------------------------------------ - -namespace uml4net.CodeGenerator.Extensions -{ - using System; - using System.Linq; - - /// - /// DotLiquid filter for generic Code Generation Features - /// - public static class GenericExtensions - { - /// - /// Capitalize the first letter of a string - /// - /// - /// The subject input string - /// - /// - /// Returns a string - /// - public static string CapitalizeFirstLetter(this string input) - { - if (string.IsNullOrEmpty(input)) - { - throw new ArgumentException("string can't be empty!"); - } - - return string.Concat(input.First().ToString().ToUpper(), input.AsSpan(1)); - } - - /// - /// Lower ccase the first letter of a string - /// - /// - /// The subject input string - /// - /// - /// Returns a string - /// - public static string LowerCaseFirstLetter(this string input) - { - if (string.IsNullOrEmpty(input)) - { - throw new ArgumentException("string can't be empty!"); - } - - return string.Concat(input.First().ToString().ToLower(), input.AsSpan(1)); - } - - /// - /// Prefixes the input string with another - /// - /// - /// the string that is to be prefixed - /// - /// - /// the subject prefix - /// - /// - public static string Prefix(this string input, string prefix) - { - return $"{prefix}{input}"; - } - - /// - /// Returns the opposite value of a boolean - /// - /// - /// the subject boolean - /// - /// - /// true or false - /// - public static bool FlipIt(bool value) - { - return !value; - } - - /// - /// Increments the value with 1 - /// - /// - /// the value that is to be incremented - /// - /// - /// the value incremented with 1 - /// - public static int Increment(int value) - { - var result = value + 1; - return result; - } - - /// - /// Increments the value with 1 - /// - /// - /// the value that is to be incremented - /// - /// - /// the value incremented with 1 - /// - public static int Decrement(int value) - { - var result = value - 1; - return result; - } - } -} \ No newline at end of file diff --git a/uml4net.CodeGenerator/Generators/CorePocoGenerator.cs b/uml4net.CodeGenerator/Generators/CorePocoGenerator.cs index c28c7c43..b137d3bd 100644 --- a/uml4net.CodeGenerator/Generators/CorePocoGenerator.cs +++ b/uml4net.CodeGenerator/Generators/CorePocoGenerator.cs @@ -26,7 +26,7 @@ namespace uml4net.CodeGenerator.Generators using System.IO; - using uml4net.CodeGenerator.Extensions; + using uml4net.Extensions; using uml4net.POCO.Packages; using uml4net.POCO.StructuredClassifiers; @@ -179,10 +179,10 @@ public async Task GenerateClass(IPackage package, DirectoryInfo outputDi /// protected override void RegisterHelpers() { - //ECoreNetto.HandleBars.BooleanHelper.RegisterBooleanHelper(this.Handlebars); - //ECoreNetto.HandleBars.StringHelper.RegisterStringHelper(this.Handlebars); - //ECoreNetto.HandleBars.StructuralFeatureHelper.RegisterStructuralFeatureHelper(this.Handlebars); - //ECoreNetto.HandleBars.GeneralizationHelper.RegisterGeneralizationHelper(this.Handlebars); + uml4net.HandleBars.BooleanHelper.RegisterBooleanHelper(this.Handlebars); + uml4net.HandleBars.StringHelper.RegisterStringHelper(this.Handlebars); + uml4net.HandleBars.PropertyHelper.RegisterStructuralFeatureHelper(this.Handlebars); + uml4net.HandleBars.GeneralizationHelper.RegisterGeneralizationHelper(this.Handlebars); //this.Handlebars.RegisteredDocumentationHelper(); //this.Handlebars.RegisterTypeNameHelper(); diff --git a/uml4net.CodeGenerator/uml4net.CodeGenerator.csproj b/uml4net.CodeGenerator/uml4net.CodeGenerator.csproj index 932c2a13..c26ebd42 100644 --- a/uml4net.CodeGenerator/uml4net.CodeGenerator.csproj +++ b/uml4net.CodeGenerator/uml4net.CodeGenerator.csproj @@ -32,7 +32,6 @@ - diff --git a/uml4net.Extensions/ElementExtensions.cs b/uml4net.Extensions/ElementExtensions.cs index 7c67960f..a8d63c49 100644 --- a/uml4net.Extensions/ElementExtensions.cs +++ b/uml4net.Extensions/ElementExtensions.cs @@ -18,8 +18,6 @@ // // ------------------------------------------------------------------------------------------------ -using uml4net.POCO.CommonStructure; - namespace uml4net.Extensions { using System; @@ -28,6 +26,8 @@ namespace uml4net.Extensions using HtmlAgilityPack; + using uml4net.POCO.CommonStructure; + /// /// Extension methods for interface /// diff --git a/uml4net.Extensions/StringExtensions.cs b/uml4net.Extensions/StringExtensions.cs index f7fa2b2a..4806cc10 100644 --- a/uml4net.Extensions/StringExtensions.cs +++ b/uml4net.Extensions/StringExtensions.cs @@ -118,5 +118,49 @@ public static string Prefix(this string input, string prefix) { return $"{prefix}{input}"; } + + /// + /// Returns the opposite value of a boolean + /// + /// + /// the subject boolean + /// + /// + /// true or false + /// + public static bool FlipIt(bool value) + { + return !value; + } + + /// + /// Increments the value with 1 + /// + /// + /// the value that is to be incremented + /// + /// + /// the value incremented with 1 + /// + public static int Increment(int value) + { + var result = value + 1; + return result; + } + + /// + /// Increments the value with 1 + /// + /// + /// the value that is to be incremented + /// + /// + /// the value incremented with 1 + /// + public static int Decrement(int value) + { + var result = value - 1; + return result; + } } } \ No newline at end of file diff --git a/uml4net.HandleBars/GeneralizationHelper.cs b/uml4net.HandleBars/GeneralizationHelper.cs index e52be85b..dc6e871e 100644 --- a/uml4net.HandleBars/GeneralizationHelper.cs +++ b/uml4net.HandleBars/GeneralizationHelper.cs @@ -22,6 +22,7 @@ namespace uml4net.HandleBars { using System; using System.Linq; + using HandlebarsDotNet; using uml4net.POCO; diff --git a/uml4net.HandleBars/PropertyHelper.cs b/uml4net.HandleBars/PropertyHelper.cs index 11408c04..ce2a4b11 100644 --- a/uml4net.HandleBars/PropertyHelper.cs +++ b/uml4net.HandleBars/PropertyHelper.cs @@ -25,7 +25,6 @@ namespace uml4net.HandleBars using HandlebarsDotNet; - using uml4net; using uml4net.Extensions; using uml4net.POCO.Classification;