protected override IEnumerable <string> GetImplementedInterfaces()
        {
            var name = new CsArguments(Cfg.CounterUnit.Unit.GetTypename(), Cfg.DenominatorUnit.Unit.GetTypename())
                       .MakeGenericType(nameof(IFractionalUnit));

            return(new[] { name });
        }
        private void Add_StaticFields()
        {
            foreach (var i in _relatedUnit.Units)
            {
                var unitTypeName = Cfg.TargetUnitTypename;
                var f1Name       = i.FieldName + unitTypeName;
                var f1Type       = unitTypeName;

                var v = Cfg.Source.Container.GetTypename() + "." + i.FieldName + Cfg.Source.Unit.GetTypename();
                v = new CsArguments(v).Create(f1Type);
                var field = Target.AddField(f1Name, f1Type)
                            .WithStatic()
                            .WithIsReadOnly()
                            .WithVisibility(Visibilities.Internal)
                            .WithConstValue(v)
                            .Description = $"unit 1/{i.UnitShortCode.EffectiveValue}";


                var unitDefinitionType = new CsArguments(unitTypeName)
                                         .MakeGenericType("UnitDefinition");

                var value = new CsArguments(f1Name, Inverse(i.ScaleFactor)).Create(unitDefinitionType);
                field = Target.AddField(i.FieldName, unitDefinitionType)
                        .WithIsReadOnly()
                        .WithStatic()
                        .WithConstValue(value)
                        .Description = $"unit 1/{i.UnitShortCode.EffectiveValue} with factor";
            }
        }
        public void AddVariable <T>(string name, params string[] a)
        {
            a = a.Select(Replace).ToArray();
            var code = new CsArguments(a).Create <T>();

            AddVariable(name, code);
        }
Ejemplo n.º 4
0
        public string MakeGenericTypeMethodCall(string methodName, params string [] args)
        {
            var call1 = MakeGenericType(methodName);
            var a     = new CsArguments(args);

            return(a.CallMethod(call1));
        }
Ejemplo n.º 5
0
        public static void Throw <T>(this CsCodeWriter cs, params string[] arguments)
        {
            var exception = new CsArguments(arguments).Create <T>();
            var code      = $"throw {exception};";

            cs.WriteLine(code);
        }
Ejemplo n.º 6
0
        public static void Add_FromMethods(Type t, XValueTypeName valueTypeName,
                                           TypesGroup types, CsClass target, IRelatedUnitDefinition u)
        {
#if DEBUG
            if (target.Name == "Power")
            {
                System.Diagnostics.Debug.Write("");
            }
#endif
            foreach (var inputType in "decimal,double,int,long".Split(','))
            {
                var arg = "value";
                if (inputType == OtherValuePropertyType)
                {
                    arg = $"({ValuePropertyType}){arg}";
                }

                var args = new CsArguments(arg, types.Container + "." + u.FieldName)
                           .Create(target.Name);
                var valueIn           = $" value in {u.UnitShortCode.EffectiveValue}";
                var methodName        = "From" + u.FromMethodNameSufix.CoalesceNullOrWhiteSpace(u.FieldName);
                var methodDescription = $"creates {types.Value.FirstLower()} from{valueIn}";

                var cw = Ext.Create(t);
                cw.WriteReturn(args);
                var m = target.AddMethod(methodName, target.Name, methodDescription)
                        .WithStatic()
                        .WithBody(cw);
                m.AddParam("value", inputType).Description = string.Format("{0}{1}", valueTypeName, valueIn);
            }
        }
        private void Add_ConvertOtherPower()
        {
            var infos = RelatedUnitGeneratorDefs.All;

            var tmp = infos.GetPowers(Cfg);

            if (tmp?.MyInfo is null || tmp.Other.Count == 0)
            {
                return;
            }
            foreach (var i in tmp.Other.Values)
            {
                var targetUnit = new TypesGroup(i.Name);
                if (Cfg == targetUnit.Unit)
                {
                    continue;
                }
                var cw   = Ext.Create <BasicUnitGenerator>();
                var code = new CsArguments(Target.Name, targetUnit.Unit.GetTypename())
                           .MakeGenericTypeMethodCall("GlobalUnitRegistry.Relations.GetOrThrow", "this");
                cw.WriteReturn(code);
                var m = Target.AddMethod("Get" + targetUnit.Unit.TypeName, targetUnit.Unit.GetTypename()).WithBody(cw);
                m.WithAggressiveInlining(Target);

                m.AddRelatedUnitSourceAttribute(Target, RelatedUnitSourceUsage.ProvidesRelatedUnit, 10);
            }
        }
Ejemplo n.º 8
0
        public static CsMethod AddOperator(this CsClass cl, string operatorName, CsArguments csArgument, string resultType = null)
        {
            resultType = resultType.CoalesceNullOrWhiteSpace(cl.Name);
            var code = csArgument.Create(resultType);

            return(cl.AddMethod(operatorName, resultType, "implements " + operatorName + " operator")
                   .WithBodyFromExpression(code));
        }
Ejemplo n.º 9
0
        public override string ToString()
        {
            var l          = Left.Value + " " + LeftMethodArgumentName;
            var r          = Right.Value + " " + RightMethodArgumentName;
            var args       = new CsArguments(l, r);
            var methodName = $"{Result.Value} operator {Oper}";

            return(args.CallMethod(methodName));
        }
Ejemplo n.º 10
0
        private void Add_WithSecond()
        {
            var cw = Ext.Create(GetType());
            var e  = new CsArguments("newUnit", _info.SecondPropertyName).Create(Target.Name);

            cw.WriteLine($"return {e};");
            Target.AddMethod($"With{_info.FirstPropertyName}", Cfg.UnitTypes.Unit.TypeName)
            .WithBody(cw)
            .AddParam("newUnit", _info.First.Unit.TypeName);
        }
        private void Add_Properties()
        {
            foreach (var i in Cfg.Units)
            {
                var unitTypeName = Cfg.Name.ToUnitTypeName().GetTypename();

                var n2 = i.FieldName + unitTypeName;
                {
                    var constValue = i.UnitConstructor;
                    if (string.IsNullOrEmpty(constValue))
                    {
                        var args = i.UnitShortCode.GetCreationArgs(Related);
                        constValue = args.Create(unitTypeName);
                    }

                    Target.AddField(n2, unitTypeName)
                    .WithIsReadOnly()
                    .WithVisibility(Visibilities.Internal)
                    .WithConstValue(constValue)
                    .WithStatic();
                }
                {
                    var args = new[]
                    {
                        n2,
                        i.ScaleFactor
                    };

                    if (i.Aliases != null)
                    {
                        args = i.Aliases.Plus(args);
                    }

                    var unitDefinitionType = new CsArguments(unitTypeName)
                                             .MakeGenericType("UnitDefinition");

                    // public static readonly UnitDefinition<LengthUnit> Km
                    // = new UnitDefinition<LengthUnit>("km", 1000m);
                    var value = new CsArguments(args).Create(unitDefinitionType);
                    Target.AddField(i.FieldName, unitDefinitionType)
                    .WithIsReadOnly()
                    .WithStatic()
                    .WithConstValue(value);
                }
                if (i.AddFromMethod)
                {
                    var c = Get(Cfg.Name.ValueTypeName, out var file);
                    CsFilesManager.AddGeneratorName(file, GetType().Name);
                    var value = new CsArguments("value", Target.Name + "." + i.FieldName + ".Unit").Create(c.Name);
                    c.AddMethod("From" + i.FieldName, c.Name).WithBody($"return {value};")
                    .WithParameter(new CsMethodParameter("value", "decimal"));
                }
            }
        }
        private void Add_StaticConstructor()
        {
            var cw    = Ext.Create(GetType());
            var array = new CsArguments(_relatedUnit.Units.Select(q => q.FieldName).ToArray());

            array.CreateArray(cw, "All = ");
            var c = Target.AddConstructor().WithStatic().WithBody(cw);

            Target.AddField("All", AllPropertyTypeName).WithStatic().WithIsReadOnly()
            .Description = $"All known {Cfg.TargetUnitTypename.FirstLower()} units";
        }
        private void Add_AllProperty()
        {
            var cw    = new CsCodeWriter();
            var array = new CsArguments(Cfg.Units.Select(q => q.FieldName).ToArray());

            array.CreateArray(cw, "return ");
            Target.AddProperty("All", "IReadOnlyList<UnitDefinition<" + Cfg.Name + "Unit>>")
            .WithIsPropertyReadOnly()
            .WithNoEmitField()
            .WithStatic()
            .WithOwnGetter(cw.Code)
            .Description = $"All known {Cfg.Name.FirstLower()} units";
        }
        public void WriteCode(CsCodeWriter cw)
        {
            if (!string.IsNullOrEmpty(_input.Comment))
            {
                var lines = _input.Comment.Split('\r', '\n').Where(a => !string.IsNullOrWhiteSpace(a));
                foreach (var i in lines)
                {
                    cw.WriteLine("// " + i);
                }
            }

            if (_input.Throw)
            {
                cw.WriteLine("// " + _input.OperatorParameters.DebugIs);
                cw.WriteLine("throw new " + nameof(NotImplementedException) + "();");
                return;
            }

            var right = OperatorParameters.RightMethodArgumentName;
            var left  = OperatorParameters.LeftMethodArgumentName;

            foreach (var i in _input.Vars)
            {
                cw.WriteAssign(i.Name, i.Code, true);
            }
            if (!string.IsNullOrEmpty(RightValue))
            {
                right += "Converted";
                cw.WriteAssign(right, RightValue, true);
            }

            if (string.IsNullOrEmpty(_input.UseReturnExpression))
            {
                var value = string.IsNullOrEmpty(_input.UseValueExpression)
                    ? $"{left}.Value {OperatorParameters.Oper} {right}.Value"
                    : _input.UseValueExpression;
                if (!string.IsNullOrEmpty(_input.ResultMultiplication))
                {
                    value += " * " + _input.ResultMultiplication;
                }
                cw.WriteAssign("value", value, true);

                var code = new CsArguments("value", ResultUnit).Create(OperatorParameters.Result.Value.ValueTypeName);
                cw.WriteReturn(code);
            }
            else
            {
                cw.WriteReturn(_input.UseReturnExpression);
            }
        }
        private void Add_AlternateConstructor()
        {
            var f    = GenInfo.FirstPropertyName.FirstLower();
            var s    = GenInfo.SecondPropertyName.FirstLower();
            var cw   = new CsCodeWriter();
            var code = new CsArguments(f, s).Create(GenInfo.Result.Unit);

            cw.WriteLine("{0} = {1};", ValuePropName, ValuePropName.FirstLower());
            cw.WriteLine("{0} = {1};", UnitPropName, code);

            var m = Target.AddConstructor()
                    .WithBody(cw);

            m.AddParam(ValuePropName.FirstLower(), ValuePropertyType);
            m.AddParam(f, GenInfo.First.Unit.GetTypename());
            m.AddParam(s, GenInfo.Second.Unit.GetTypename());
        }
        private static CsCodeWriter CreateCodeForFractionalResult(OperatorParams p)
        {
            var cw = Ext.Create <MultiplyAlgebraGenerator>();

            cw.WriteLine("// scenario E");
            var args = new CsArguments(
                $"{p.LeftMethodArgumentName}.Value {p.Oper} {p.RightMethodArgumentName}.Value",
                $"{p.LeftMethodArgumentName}.Unit",
                $"{p.RightMethodArgumentName}.Unit"
                );
            var tResult = p.Result.Value;

            var expression = args.Create(tResult.ValueTypeName);

            cw.WriteLine($"return {expression};");
            return(cw);
        }
        private void Add_Decompose()
        {
            var basicUnit  = Cfg.Source.Unit;
            var resultType = Target.GetTypeName <DecomposableUnitItem>();
            var cs         = Ext.Create(GetType());

            cs.WriteAssign("tmp", "Get" + basicUnit.TypeName + "()", true);
            var args = new CsArguments("tmp", "-1").Create(resultType);

            cs.WriteReturn(args);

            var m = Target.AddMethod(nameof(IDerivedDecomposableUnit.GetBasicUnit), resultType);

            m.WithBody(cs);

            Target.ImplementedInterfaces.Add(nameof(IDerivedDecomposableUnit));
        }
        private void Add_Decompose()
        {
            if (Related is null || !Related.IsPower2OrHigher)
            {
                return;
            }
            var basicUnit = BaseUnit;

            {
                var type = new CsArguments(Target.GetTypeName <DecomposableUnitItem>())
                           .MakeGenericType(Target.GetTypeName <IReadOnlyList <int> >(), true);

                var cs = Ext.Create(GetType());
                if (basicUnit is null)
                {
                    throw new NotSupportedException();

                    /*cs.WriteLine("var decomposer = new UnitDecomposer();");
                     * cs.WriteLine("decomposer.Add(this, 1);");
                     * cs.WriteReturn("decomposer.Items");*/
                }
                else
                {
                    cs.WriteReturn("new[] { " + nameof(IDerivedDecomposableUnit.GetBasicUnit) + "() }");
                }

                var m = Target.AddMethod(nameof(IDecomposableUnit.Decompose), type);
                m.WithBody(cs);

                Target.ImplementedInterfaces.Add(nameof(IDecomposableUnit));
            }
            // if (basicUnit != null)
            {
                var resultType = Target.GetTypeName <DecomposableUnitItem>();
                var cs         = Ext.Create(GetType());
                cs.WriteAssign("tmp", "Get" + basicUnit.Name + "Unit()", true);
                var args = new CsArguments("tmp", Related.MyInfo.Power.CsEncode()).Create(resultType);
                cs.WriteReturn(args);

                var m = Target.AddMethod(nameof(IDerivedDecomposableUnit.GetBasicUnit), resultType);
                m.WithBody(cs);

                Target.ImplementedInterfaces.Add(nameof(IDerivedDecomposableUnit));
            }
        }
Ejemplo n.º 19
0
        private void Add_Decompose()
        {
            var items = _info2?.Items;

            if (items is null || items.Length == 0)
            {
                return;
            }
            var type = new CsArguments(Target.GetTypeName <DecomposableUnitItem>())
                       .MakeGenericType(Target.GetTypeName <IReadOnlyList <int> >(), true);

            var cs = Ext.Create(GetType());

            {
                // creates code
                var codeItems = new DecomposeExpressionFinder(typeof(Length).Assembly).GetCodeItems(items, Target.Name);
                if (codeItems != null)
                {
                    var initCodes = codeItems.Select(a => a.Init).Where(a => !string.IsNullOrWhiteSpace(a));
                    foreach (var i in initCodes)
                    {
                        cs.WriteLine(i);
                    }
                    cs.WriteLine(new CsArguments(codeItems.Select(a => a.Expression).ToArray()).ReturnArray().Code);
                    cs.WriteLine("/*");
                }

                cs.WriteLine("var decomposer = new UnitDecomposer();");
                foreach (var item in items)
                {
                    cs.WriteLine("decomposer.Add({0}, {1});", item.Propertyname, item.Power.CsEncode());
                }
                cs.WriteReturn("decomposer.Items");

                if (codeItems != null)
                {
                    cs.WriteLine("*/");
                }
                var m = Target.AddMethod(nameof(IDecomposableUnit.Decompose), type);
                m.WithBody(cs);
            }

            Target.ImplementedInterfaces.Add(nameof(IDecomposableUnit));
        }
Ejemplo n.º 20
0
        protected override void GenerateOne()
        {
            _info           = GetInfo();
            _info2          = GetInfo2();
            Target.Kind     = CsNamespaceMemberKind.Class;
            Target.IsSealed = true;

            foreach (var i in GetImplementedInterfaces())
            {
                Target.ImplementedInterfaces.Add(i);
            }

            var name = new CsArguments(Cfg.UnitTypes.Unit.TypeName).MakeGenericType("IEquatable");

            Target.ImplementedInterfaces.Add(name);

            var pi = new[]
            {
                new ConstructorParameterInfo(_info.FirstPropertyName, _info.First.Unit.TypeName, null,
                                             _info.FirstPropertyName.Decamelize().ToLower()),
                new ConstructorParameterInfo(_info.SecondPropertyName, _info.Second.Unit.TypeName, null,
                                             _info.SecondPropertyName.Decamelize().ToLower())
            };
            var col1 = new Col1(pi);

            Add_Constructor(col1);
            Add_Properties(col1);
            Add_UnitNameProperty();
            Add_Equals();
            Add_GetHashCode(
                $"({_info.FirstPropertyName}.GetHashCode() * 397) ^ {_info.SecondPropertyName}.GetHashCode()");
            AddCommon_EqualityOperators();
            Add_ToString(PropertyName);

            Add_WithFirst();
            Add_WithSecond();

            Add_Decompose();
        }
Ejemplo n.º 21
0
        public void Generate(CommonFractionalUnitsCollection collection)
        {
            foreach (var item in collection.Items)
            {
                var cl = GetClass(item.Type.Container.GetTypename());
                cl.AddComment(item.ToString());

                FractionUnit fuDefinition = null;

                var description = string.Format("represents {0} unit '{1}'",
                                                item.Type.Value.FirstLower(), item.GetUnitName(ref fuDefinition));
                var p1 = fuDefinition.CounterUnit.Container + "." + item.CounterUnit;
                var p2 = fuDefinition.DenominatorUnit.Container + "." + item.DenominatorUnit;

                var x = new CsArguments(p1, p2).Create(item.Type.Unit);
                var f = cl.AddField(item.TargetPropertyName, item.Type.Unit.GetTypename())
                        .WithStatic()
                        .WithIsReadOnly()
                        .WithConstValue(x);

                f.Description = description;
            }
        }
        public void ConvertRight <T>(params string[] a)
        {
            var type = new CsArguments(a).Create <T>();

            ConvertRight(type);
        }
Ejemplo n.º 23
0
        private void Add_Algebra_PlusMinus()
        {
            const string right = "right";
            const string left  = "left";

            var delta = BasicUnitDefs.All.GetDeltaByUnit(Cfg.UnitTypes.Unit);

            if (delta != null)
            {
                if (delta.UnitTypes.Value == Cfg.UnitTypes.Value)
                {
                    delta = null;
                }
            }

            void AddPlusOrMinus(string op, XValueTypeName lt, XValueTypeName rt)
            {
                var resultType = Cfg.UnitTypes.Value;

                if (delta != null && op == "-")
                {
                    resultType = delta.UnitTypes.Value;
                }

                string CreateResultFromVariable(string varName, XValueTypeName srcType, bool addMinus = false)
                {
                    var result = addMinus ? "-" + varName : varName;

                    if (delta is null || srcType == resultType)
                    {
                        return(result);
                    }

                    var unitSource = varName;

                    if (lt != rt)
                    {
                        if (lt == resultType)
                        {
                            unitSource = left;
                        }
                        else if (rt == resultType)
                        {
                            unitSource = right;
                        }
                        else
                        {
                            throw new NotSupportedException();
                        }
                    }

                    result = new CsArguments(result + ".Value", unitSource + ".Unit").Create(resultType.ValueTypeName);
                    return(result);
                }

                var cw = Ext.Create <BasicUnitValuesGenerator>();

                var result1   = CreateResultFromVariable(right, rt, op == "-");
                var condition =
                    $"{left}.Value.Equals({ValuePropertyType}.Zero) && string.IsNullOrEmpty({left}.Unit?.UnitName)";

                cw.SingleLineIf(condition, ReturnValue(result1));

                result1   = CreateResultFromVariable(left, lt);
                condition =
                    $"{right}.Value.Equals({ValuePropertyType}.Zero) && string.IsNullOrEmpty({right}.Unit?.UnitName)";
                cw.SingleLineIf(condition, ReturnValue(result1));

                cw.WriteLine($"{right} = {right}.ConvertTo({left}.Unit);");
                var returnExpression = new CsArguments($"{left}.Value {op} {right}.Value", $"{left}.Unit")
                                       .Create(resultType.ValueTypeName);

                cw.WriteLine(ReturnValue(returnExpression));
                Target.AddMethod(op, resultType.ValueTypeName)
                .WithLeftRightArguments(lt.ValueTypeName, rt.ValueTypeName)
                .WithBody(cw);
            }

            var targetName = new XValueTypeName(Target.Name);

            AddPlusOrMinus("-", targetName, targetName);
            if (delta != null)
            {
                AddPlusOrMinus("+", targetName, delta.UnitTypes.Value);
                AddPlusOrMinus("+", delta.UnitTypes.Value, targetName);
            }
            else
            {
                AddPlusOrMinus("+", targetName, targetName);
            }
        }
        protected void Add_Parse(string splitMethodName)
        {
            string ArrayItemCode(ref int columnIndex)
            {
                return($"units[{(columnIndex++).CsEncode()}]");
            }

            CsArguments GetConstructorArguments(TypesGroup tg, ref int columnIndex)
            {
                var aa        = ProductUnitDefs.All;
                var a4        = aa.ByValueTypeName(tg.Value);
                var arguments = ArrayItemCode(ref columnIndex);

                if (a4 is null)
                {
                    return(new CsArguments(arguments));
                }

                return(new CsArguments(
                           new CsArguments(arguments).Create(a4.CounterUnit.Unit.TypeName),
                           new CsArguments(ArrayItemCode(ref columnIndex)).Create(a4.DenominatorUnit.Unit.TypeName)
                           ));
            }

            CsArguments licznik, mianownik;
            {
                var columnIndex = 0;
                if (Cfg is FractionUnit fu)
                {
                    licznik   = GetConstructorArguments(fu.CounterUnit, ref columnIndex);
                    mianownik = GetConstructorArguments(fu.DenominatorUnit, ref columnIndex);
                }
                else
                {
                    licznik   = new CsArguments(ArrayItemCode(ref columnIndex));
                    mianownik = new CsArguments(ArrayItemCode(ref columnIndex));
                }
            }

            var cw = Ext.Create(GetType());

            if (string.IsNullOrEmpty(splitMethodName))
            {
                cw.WithThrowNotImplementedException("Not implemented due to unknown split method name.");
            }
            else
            {
                cw.SingleLineIf("string.IsNullOrEmpty(value)",
                                "throw new ArgumentNullException(nameof(value));");

                cw.WriteLine("var r = CommonParse.Parse(value, typeof(" + Target.Name + "));");

                cw.WriteLine("var units = " + splitMethodName + "(r.UnitName);");
                var sum = mianownik.Arguments.Length + licznik.Arguments.Length;
                cw.SingleLineIf("units.Length != " + sum.CsEncode(),
                                "throw new Exception($\"{r.UnitName} is not valid " + Target.Name + " unit\");");

                cw.WriteAssign("counterUnit", new CsArguments("units[0]").Create(GenInfo.First.Unit), true);
                //cw.WriteLine("var counterUnit = new " + GenInfo.First.Unit + "(units[0]);");
                cw.WriteAssign("denominatorUnit", mianownik.Create(GenInfo.Second.Unit), true);
                // cw.WriteLine("var denominatorUnit = new " + GenInfo.Second.Unit + "(units[1]);");
                cw.WriteLine(ReturnValue($"new {Target.Name}(r.Value, counterUnit, denominatorUnit)"));
            }

            var m = Target.AddMethod("Parse", GenInfo.Result.Value.ValueTypeName)
                    .WithStatic()
                    .WithBody(cw);

            m.AddParam("value", "string");
        }
Ejemplo n.º 25
0
        public static void CheckArgument(this CsCodeWriter code, string argName, ArgChecking flags,
                                         ITypeNameResolver resolver)
        {
            if (flags == ArgChecking.None)
            {
                return;
            }

            var canBeNull     = true;
            var argNameToRead = argName + "?";

            if ((flags & ArgChecking.NotNull) != 0)
            {
                var throwCode = new CsArguments($"nameof({argName})")
                                .Throw <NullReferenceException>(resolver);
                code.SingleLineIf($"{argName} is null", throwCode);
                canBeNull     = false;
                argNameToRead = argName;
            }

            if ((flags & ArgChecking.TrimValue) != 0)
            {
                code.WriteLine("{0} = {1}.Trim();", argName, argNameToRead);
                flags &= ~ArgChecking.TrimValue;

                if ((flags & ArgChecking.NotWhitespace) != 0)
                {
                    flags &= ~ArgChecking.NotWhitespace;
                    flags |= ArgChecking.NotEmpty;
                }
            }

            if ((flags & ArgChecking.NotNull) != 0 && canBeNull)
            {
                flags &= ~ArgChecking.NotNull;
                //p.Attributes.Add(CsAttribute.Make<NotNullAttribute>(target));
                var throwCode = new CsArguments($"nameof({argName})")
                                .Throw <NullReferenceException>(resolver);
                code.SingleLineIf($"{argName} is null", throwCode);
            }

            if ((flags & ArgChecking.NotWhitespace) != 0)
            {
                flags &= ~(ArgChecking.NotEmpty | ArgChecking.NotWhitespace);
                // var m = nameof(string.IsNullOrWhiteSpace);
                var throwCode = new CsArguments($"nameof({argName})")
                                .Throw <ArgumentException>(resolver);
                code.SingleLineIf($"string.IsNullOrWhiteSpace({argName})", throwCode);

                flags &= ~(ArgChecking.NotNullOrWhitespace | ArgChecking.NotNullOrEmpty);
            }

            if ((flags & ArgChecking.NotEmpty) != 0)
            {
                flags &= ~ArgChecking.NotEmpty;
                var throwCode = new CsArguments($"nameof({argName})")
                                .Throw <ArgumentException>(resolver);
                var condition =
                    canBeNull
                        ? $"string.IsNullOrEmpty({argName})"
                        : $"{argName}.Length == 0";

                code.SingleLineIf(condition, throwCode);
            }
        }
 public void WithResultUnit <T>(params string[] a)
 {
     a          = a.Select(Replace).ToArray();
     ResultUnit = new CsArguments(a).Create <T>();
 }