Exemplo n.º 1
0
        public string rootOption(Token <GroupTestToken> a, ValueOption <Group <GroupTestToken, string> > option)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("R(");
            builder.Append(a.Value);
            var gg = option.Match(
                (Group <GroupTestToken, string> group) =>
            {
                var aToken = group.Token(0).Value;
                builder.Append($";{aToken}");
                return(group);
            },
                () =>
            {
                builder.Append(";");
                builder.Append("a");
                var g = new Group <GroupTestToken, string>();
                g.Add("<none>", "<none>");
                return(g);
            });

            builder.Append(")");
            return(builder.ToString());
        }
Exemplo n.º 2
0
        public DateExpression DateExpression(
            Token <IndexOutOfRangeToken> yearToken,
            Token <IndexOutOfRangeToken> monthToken,
            Token <IndexOutOfRangeToken> dayToken,
            Token <IndexOutOfRangeToken> hoursToken,
            Token <IndexOutOfRangeToken> minutesToken,
            Token <IndexOutOfRangeToken> secondsToken,
            ValueOption <Group <IndexOutOfRangeToken, Expression> > offsetGroup,
            ValueOption <Group <IndexOutOfRangeToken, Expression> > roundGroup
            )
        {
            var(dateOffsetMagnitude, dateOffsetKind) = ExtractDateOffset(offsetGroup);

            var dateRoundKind = DateRoundKind.NONE;

            roundGroup.Match(
                g =>
            {
                dateRoundKind = Enum.Parse <DateRoundKind>(g.Token(0).Value, true);
                return(g);
            },
                () => null);

            return(new DateExpression(
                       $"{yearToken.IntValue:D4}-{monthToken.IntValue:D2}-{dayToken.IntValue:D2}T{hoursToken.IntValue:D2}:{minutesToken.IntValue:D2}:{secondsToken.IntValue:D2}Z",
                       dateOffsetMagnitude,
                       dateOffsetKind,
                       dateRoundKind));
        }
Exemplo n.º 3
0
        public ValueItem(object value, ValueOption option = ValueOption.Include)
        {
            Option = option;
            switch (value)
            {
            case string svalue:
                SValue = svalue;
                Type   = ValueType.Text;
                break;

            case bool bvalue:
                BValue = bvalue;
                Type   = ValueType.Bool;
                break;

            case int ivalue:
                IValue = ivalue;
                Type   = ValueType.Integer;
                break;

            case float fvalue:
                FValue = fvalue;
                Type   = ValueType.Float;
                break;

            case decimal dvalue:
                DValue = dvalue;
                Type   = ValueType.Decimal;
                break;

            default:
                Type = ValueType.Unknown;
                break;
            }
        }
Exemplo n.º 4
0
        private ValueOption <FindResult> FindBranch([NotNull] string s)
        {
            DebugCode.AssertState(s.Length > 0, "The string length should be positive");
            var currentNode = Root;
            var offset      = 0;

            for (;;)
            {
                var edgeIndex = FindEdge(currentNode, s[offset], out var edge);
                if (edgeIndex == -1)
                {
                    return(ValueOption.None <FindResult>());
                }
                var edgeLength    = edge.Length;
                var compareLength = Math.Min(s.Length - offset, edgeLength);
                if (compareLength > 1 &&
                    string.Compare(s, offset + 1, InternalData, edge.Begin + 1, compareLength - 1) != 0)
                {
                    return(ValueOption.None <FindResult>());
                }
                offset += compareLength;
                if (offset == s.Length)
                {
                    return(ValueOption.Some(new FindResult {
                        Node = edge, Length = compareLength
                    }));
                }
                DebugCode.AssertState(compareLength == edgeLength, "Invalid compare length. Check logic");
                currentNode = edge;
                // continue search from the next level
            }
        }
Exemplo n.º 5
0
        public void NoneTest()
        {
            var none = ValueOption.None <int>();

            Assert.IsFalse(none.HasValue);
            Assert.AreEqual(none.GetValueOrDefault(2), 2);
            Assert.AreEqual(none.GetValueOrDefault(value => 10, () => 20), 20);
        }
Exemplo n.º 6
0
    public void Init(ValueOption value)
    {
        toggle = GetComponent <Toggle>();

        toggle.isOn = (bool)value.value;

        toggle.onValueChanged.AddListener((v) => value.setAction(v));
    }
Exemplo n.º 7
0
        private string CalculateValue(dynamic element, ValueOption option)
        {
            var elementNode = element as HtmlNode;

            if (elementNode != null)
            {
                switch (option)
                {
                case ValueOption.OuterHtml:
                {
                    return(elementNode.OuterHtml);
                }

                case ValueOption.InnerHtml:
                {
                    return(elementNode.InnerHtml);
                }

                case ValueOption.InnerText:
                {
                    return(elementNode.InnerText);
                }

                default:
                {
                    return(elementNode.InnerHtml);
                }
                }
            }
            else
            {
                switch (option)
                {
                case ValueOption.OuterHtml:
                {
                    throw new NotSupportedException();
                }

                case ValueOption.InnerHtml:
                {
                    throw new NotSupportedException();
                }

                case ValueOption.InnerText:
                {
                    // Cost too much, need re-implement
                    var document = new HtmlDocument();
                    document.LoadHtml(element.ToString());
                    return(document.DocumentNode.InnerText);
                }

                default:
                {
                    return(element.ToString());
                }
                }
            }
        }
Exemplo n.º 8
0
        private string CalculateValue(dynamic element, ValueOption option)
        {
            if (element is HtmlNode elementNode)
            {
                switch (option)
                {
                case ValueOption.OuterHtml:
                {
                    return(elementNode.OuterHtml);
                }

                case ValueOption.InnerHtml:
                {
                    return(elementNode.InnerHtml);
                }

                case ValueOption.InnerText:
                {
                    return(elementNode.InnerText);
                }

                default:
                {
                    return(elementNode.InnerHtml);
                }
                }
            }

            var document = new HtmlDocument();

            document.LoadHtml(element.ToString());

            switch (option)
            {
            case ValueOption.OuterHtml:
            {
                return(document.DocumentNode.OuterHtml);
            }

            case ValueOption.InnerHtml:
            {
                return(document.DocumentNode.InnerHtml);
            }

            case ValueOption.InnerText:
            {
                // Cost too much, need re-implement

                return(document.DocumentNode.InnerText);
            }

            default:
            {
                return(element.ToString());
            }
            }
        }
Exemplo n.º 9
0
        public void SomeTest()
        {
            var some = ValueOption.Some(1);

            Assert.IsTrue(some.HasValue);
            Assert.AreEqual(some.Value, 1);
            Assert.AreEqual(some.GetValueOrDefault(2), 1);
            Assert.AreEqual(some.GetValueOrDefault(value => 10, () => 20), 10);
        }
Exemplo n.º 10
0
        public void ParseNullableValueOption_ReturnsSuccessfulResult()
        {
            // arrange
            ValueOption <uint?> valueOption = ValueOption <uint?> .Create("value option", "value");

            // act
            uint?parsedResult = valueOption.Parse("").Result;

            // assert
            Assert.False(parsedResult.HasValue);
        }
Exemplo n.º 11
0
        public string Root2(Token <OptionTestToken> a, ValueOption <string> b, Token <OptionTestToken> c)
        {
            var r = new StringBuilder();

            r.Append("R(");
            r.Append(a.Value);
            r.Append(b.Match(v => $",{v}", () => ",<none>"));
            r.Append($",{c.Value}");
            r.Append(")");
            return(r.ToString());
        }
Exemplo n.º 12
0
        /// <summary>
        /// 获得当前查询器的文本结果, 如果查询结果为多个, 则返回第一个结果的值
        /// </summary>
        /// <param name="option">元素取值方式</param>
        /// <returns>查询到的文本结果</returns>
        public string GetValue(ValueOption option = ValueOption.None)
        {
            if (Elements == null || Elements.Count == 0)
            {
                return(null);
            }

            var element = Elements[0];

            return(CalculateValue(element, option));
        }
Exemplo n.º 13
0
        public void ConstructorTest_Success()
        {
            var valueOption = new ValueOption(value: "Test", description: "Description",
                                              valueOptionSetting: ValueOptionSettings.UserInput);

            Assert.Multiple(() =>
            {
                Assert.That(valueOption.Value.ToString(), Is.EqualTo("Test"));
                Assert.That(valueOption.Description, Is.EqualTo("Description"));
                Assert.That(valueOption.ValueOptionSetting, Is.EqualTo(ValueOptionSettings.UserInput));
            });
        }
Exemplo n.º 14
0
        /// <summary>
        /// 获得当前查询器的文本结果, 如果查询结果为多个, 则返回第一个结果的值
        /// </summary>
        /// <param name="option">元素取值方式</param>
        /// <returns>查询到的文本结果</returns>
        public IEnumerable <string> GetValues(ValueOption option = ValueOption.None)
        {
            List <string> result = new List <string>();

            foreach (var el in Elements)
            {
                var value = CalculateValue(el, option);
                if (!string.IsNullOrEmpty(value))
                {
                    result.Add(value);
                }
            }
            return(result);
        }
Exemplo n.º 15
0
        public void ParseValueOption_ReturnsSuccessfulResult()
        {
            // arrange
            uint inputArgument             = 100;
            ValueOption <uint> valueOption = ValueOption <uint> .Create("value option", "value");

            string[] stringInputArgument =
            {
                "--value", inputArgument.ToString()
            };
            // act
            uint parsedResult = valueOption.Parse(stringInputArgument).Result;

            // assert
            Assert.Equal(inputArgument, parsedResult);
        }
Exemplo n.º 16
0
        public DateExpression DateExpression(
            Token <IndexOutOfRangeToken> nowToken,
            ValueOption <Group <IndexOutOfRangeToken, Expression> > offsetGroup,
            ValueOption <Group <IndexOutOfRangeToken, Expression> > roundGroup
            )
        {
            var(dateOffsetMagnitude, dateOffsetKind) = ExtractDateOffset(offsetGroup);

            var dateRoundKind = DateRoundKind.NONE;

            roundGroup.Match(
                g =>
            {
                dateRoundKind = Enum.Parse <DateRoundKind>(g.Token(0).Value, true);
                return(g);
            },
                () => null);

            return(new DateExpression(nowToken.Value, dateOffsetMagnitude, dateOffsetKind, dateRoundKind));
        }
Exemplo n.º 17
0
        public string rootOption(Token <GroupTestToken> a, ValueOption <Group <GroupTestToken, string> > option)
        {
            var builder = new StringBuilder();

            builder.Append("R(");
            builder.Append(a.Value);
            option.Match(
                group =>
            {
                var aToken = group.Token(0).Value;
                builder.Append($";{aToken}");
                return(null);
            },
                () =>
            {
                builder.Append($";<none>");
                return(null);
            });
            builder.Append(")");
            return(builder.ToString());
        }
Exemplo n.º 18
0
        public void Add(string arg)
        {
            if (arg.startsWith("/", "-"))
            {
                #region オプションのパース
                string option = arg.TrimStart('/', '-');


                // ■ xxx=xxx aaa:bbb 形式の場合はプロパティオプション
                string[] token = { null, null };
                if (option.slice(out token[0], out token[1], '=', ':'))
                {
                    PropertyOption prop = new PropertyOption(token[0], token[1]);

                    if (!this.properties.ContainsKey(prop.Name))
                    {
                        this.properties.Add(prop.Name, prop);
                        this.options.Add(prop);
                    }
                }
                // ■プロパティ形式でない場合は単なるスイッチオプション。
                else
                {
                    ValueOption value = new ValueOption(option);
                    if (!this.values.ContainsKey(value.Name))
                    {
                        this.values.Add(value.Name, value);
                        this.options.Add(value);
                    }
                }

                #endregion
            }
            else
            {
                #region パラメータ
                this.parameters.Add(arg);
                #endregion
            }
        }
Exemplo n.º 19
0
    public void Init(ValueOption value)
    {
        slider      = GetComponent <Slider>();
        valueOption = value;
        if (value.value is RangeValue <float> )
        {
            RangeValue <float> rv = (RangeValue <float>)value.value;
            slider.minValue = rv.minValue;
            slider.maxValue = rv.maxValue;

            slider.onValueChanged.AddListener(SetFloat);
            slider.value = rv.value;
        }
        else
        {
            RangeValue <int> rv = (RangeValue <int>)value.value;
            slider.minValue = rv.minValue;
            slider.maxValue = rv.maxValue;

            slider.onValueChanged.AddListener(SetInt);
            slider.value = rv.value;
        }
    }
Exemplo n.º 20
0
 public object FirstRecurse2(ValueOption <object> optSecond, object third)
 {
     return(null);
 }
Exemplo n.º 21
0
 public SubBadVisitor BadOptionArg(BadVisitor a, ValueOption <Token <BadVisitorTokens> > b, Group <BadVisitor, BadVisitorTokens> c, string d)
 {
     return(null);
 }
Exemplo n.º 22
0
 public ValueItem(decimal value, ValueOption option = ValueOption.Include)
 {
     DValue = value;
     Option = option;
     Type   = ValueType.Decimal;
 }
Exemplo n.º 23
0
 public ValueItem(ValueOption option)
 {
     Option = option;
 }
Exemplo n.º 24
0
    protected override void OnSetModel(ref object model)
    {
        value = (ValueOption)model;

        SetField();
    }
 public PluginEncryptedTextOptionViewModel(ValueOption <PasswordString?> valueOption, ILocalizationProvider localizationProvider)
     : base(valueOption.Value, valueOption.NameTextId)
 {
     _pluginOptionViewModelImplementation = new PluginOptionViewModelImplementation <PasswordString?>(valueOption, localizationProvider, this);
 }
Exemplo n.º 26
0
 public void Init(ValueOption value)
 {
     this.value = value;
     SetModel(value.value);
 }
Exemplo n.º 27
0
    public void Init(ValueOption value)
    {
        this.value = (PlayerShip)value.value;

        onValueChanged += p => value.setAction(p);
    }
Exemplo n.º 28
0
        /// <summary>
        /// Outputs this object to a string using the delimeter.
        /// </summary>
        /// <returns>string representation of this object</returns>

        public override string ToString()
        {
            return(string.Format("{1}{0}{2}{0}{3}{0}{4}{0}{5}{0}{6}", DELIMETER, FilterType.ToString(), Value, ValueOption.ToString(), ValueIgnoreCase.ToString(), ValueSizeOption, Enabled));
        }
Exemplo n.º 29
0
 public int TestNonTerminal(int sub, ValueOption <Group <GroupTestToken, int> > group)
 {
     return(1);
 }
        /// <summary>
        /// Create the template output
        /// </summary>
        public virtual string TransformText()
        {
            this.Write("//\n// Generated by ValueObjectGenerator\n// DO NOT EDIT THIS FILE\n//\nusing System;\nusing System.Diagnostics.CodeAnalysis;\nusing System.Linq;\n\n");

            ValueName = ValueName.Replace("\"", "");
            var declarationType = DeclarationSyntax.Keyword;

            var requireNotEmpty       = NotEmpty;
            var requireNonNegative    = NotNegative;
            var requireMinMax         = !string.IsNullOrEmpty(Min) && !string.IsNullOrEmpty(Max);
            var requireValidateMethod =
                !ValueOption.HasFlag(ValueOption.NonValidating) &&
                !requireNotEmpty &&
                !requireNonNegative &&
                !requireMinMax;

            var isClass  = DeclarationSyntax is ClassDeclarationSyntax;
            var isStruct = DeclarationSyntax is StructDeclarationSyntax;



            #line default
            #line hidden
            if (!string.IsNullOrEmpty(Namespace))
            {
            #line default
            #line hidden
                this.Write("namespace ");
                this.Write(this.ToStringHelper.ToStringWithCulture(Namespace));

            #line default
            #line hidden
                this.Write("\n{\n");
            }

            #line default
            #line hidden
            this.Write("    public partial ");
            this.Write(this.ToStringHelper.ToStringWithCulture(declarationType));

            #line default
            #line hidden
            this.Write(" ");
            this.Write(this.ToStringHelper.ToStringWithCulture(Name));

            #line default
            #line hidden
            this.Write(" : IEquatable<");
            this.Write(this.ToStringHelper.ToStringWithCulture(Name));

            #line default
            #line hidden
            this.Write(">");
            this.Write(this.ToStringHelper.ToStringWithCulture(ValueOption.HasFlag(ValueOption.Comparable) ? $", IComparable<{Name}>" : ""));

            #line default
            #line hidden
            this.Write("\n    {\n        public ");
            this.Write(this.ToStringHelper.ToStringWithCulture(BaseTypeName));

            #line default
            #line hidden
            this.Write(" ");
            this.Write(this.ToStringHelper.ToStringWithCulture(ValueName));

            #line default
            #line hidden
            this.Write(" { get; }\n");
            /* Min-Max Variable */

            #line default
            #line hidden
            if (requireMinMax)
            {
            #line default
            #line hidden
                this.Write("        public static readonly ");
                this.Write(this.ToStringHelper.ToStringWithCulture(Name));

            #line default
            #line hidden
                this.Write(" Min = new ");
                this.Write(this.ToStringHelper.ToStringWithCulture(Name));

            #line default
            #line hidden
                this.Write("( ");
                this.Write(this.ToStringHelper.ToStringWithCulture(Min));

            #line default
            #line hidden
                this.Write(" );\n        public static readonly ");
                this.Write(this.ToStringHelper.ToStringWithCulture(Name));

            #line default
            #line hidden
                this.Write(" Max = new ");
                this.Write(this.ToStringHelper.ToStringWithCulture(Name));

            #line default
            #line hidden
                this.Write("( ");
                this.Write(this.ToStringHelper.ToStringWithCulture(Max));

            #line default
            #line hidden
                this.Write(" );\n");
            }

            #line default
            #line hidden
            this.Write("\n        public ");
            this.Write(this.ToStringHelper.ToStringWithCulture(Name));

            #line default
            #line hidden
            this.Write("( ");
            this.Write(this.ToStringHelper.ToStringWithCulture(BaseTypeName));

            #line default
            #line hidden
            this.Write(" value )\n        {\n");
            /* Non-Empty */

            #line default
            #line hidden
            if (requireNotEmpty)
            {
            #line default
            #line hidden
                if (BaseTypeName == "string")
                {
            #line default
            #line hidden
                    this.Write("            if( string.IsNullOrEmpty( value )");
                    this.Write(this.ToStringHelper.ToStringWithCulture(!ExcludeWhiteSpace ? " || value.Trim().Length == 0" : ""));

            #line default
            #line hidden
                    this.Write(" )\n            {\n                throw new ArgumentException( $\"(");
                    this.Write(this.ToStringHelper.ToStringWithCulture(Name));

            #line default
            #line hidden
                    this.Write(") value is empty\" );\n            }\n");
                }
                else
                {
            #line default
            #line hidden
                    this.Write("            if( !value.Any() )\n            {\n                throw new ArgumentException( $\"(");
                    this.Write(this.ToStringHelper.ToStringWithCulture(Name));

            #line default
            #line hidden
                    this.Write(") value is empty\" );\n            }\n");
                }

            #line default
            #line hidden
                this.Write("            ");
                this.Write(this.ToStringHelper.ToStringWithCulture(ValueName));

            #line default
            #line hidden
                this.Write(" = value;\n");
                /* Non-Negative */

            #line default
            #line hidden
            }
            else if (requireNonNegative)
            {
            #line default
            #line hidden
                this.Write("            if( value < 0 )\n            {\n                throw new ArgumentException( $\"(");
                this.Write(this.ToStringHelper.ToStringWithCulture(Name));

            #line default
            #line hidden
                this.Write(") value is negative {value}\" );\n            }\n            ");
                this.Write(this.ToStringHelper.ToStringWithCulture(ValueName));

            #line default
            #line hidden
                this.Write(" = value;\n");
                /* Min, Max */

            #line default
            #line hidden
            }
            else if (requireMinMax)
            {
            #line default
            #line hidden
                this.Write("            if( value < (");
                this.Write(this.ToStringHelper.ToStringWithCulture(Min));

            #line default
            #line hidden
                this.Write(") || value > (");
                this.Write(this.ToStringHelper.ToStringWithCulture(Max));

            #line default
            #line hidden
                this.Write(") )\n            {\n                throw new ArgumentOutOfRangeException( $\"");
                this.Write(this.ToStringHelper.ToStringWithCulture(Name));

            #line default
            #line hidden
                this.Write(" Out of range : {value} (range:");
                this.Write(this.ToStringHelper.ToStringWithCulture(Min));

            #line default
            #line hidden
                this.Write(" < ");
                this.Write(this.ToStringHelper.ToStringWithCulture(Max));

            #line default
            #line hidden
                this.Write(")\" );\n            }\n            ");
                this.Write(this.ToStringHelper.ToStringWithCulture(ValueName));

            #line default
            #line hidden
                this.Write(" = value;\n");
                /* No Validation */

            #line default
            #line hidden
            }
            else if (!requireValidateMethod)
            {
            #line default
            #line hidden
                this.Write("            ");
                this.Write(this.ToStringHelper.ToStringWithCulture(ValueName));

            #line default
            #line hidden
                this.Write(" = value;\n");
            }
            else
            {
            #line default
            #line hidden
                this.Write("            ");
                this.Write(this.ToStringHelper.ToStringWithCulture(ValueName));

            #line default
            #line hidden
                this.Write(" = Validate( value );\n");
            }

            #line default
            #line hidden
            this.Write("        }\n\n");
            /* Validate method */

            #line default
            #line hidden
            if (requireValidateMethod)
            {
            #line default
            #line hidden
                this.Write("        private static partial ");
                this.Write(this.ToStringHelper.ToStringWithCulture(BaseTypeName));

            #line default
            #line hidden
                this.Write(" Validate( ");
                this.Write(this.ToStringHelper.ToStringWithCulture(BaseTypeName));

            #line default
            #line hidden
                this.Write(" value );\n");
            }

            #line default
            #line hidden
            this.Write("\n");
            /* ToString */

            #line default
            #line hidden
            if (!ValueOption.HasFlag(ValueOption.ToString))
            {
            #line default
            #line hidden
                this.Write("        //\n        // Default ToString()\n        //\n        public override string ToString()\n        {\n            return ");
                this.Write(this.ToStringHelper.ToStringWithCulture(ValueName));

            #line default
            #line hidden
                this.Write(".ToString() ?? \"\";\n        }\n");
            }
            else
            {
            #line default
            #line hidden
                this.Write("        //\n        // Custom ToString()\n        //\n        private partial string ToStringImpl();\n\n        public override string ToString()\n        {\n            return ToStringImpl();\n        }\n");
            }

            #line default
            #line hidden
            this.Write("\n        //----------------------------------------------------------------------\n        // Equality\n        //----------------------------------------------------------------------\n        public bool Equals( ");
            this.Write(this.ToStringHelper.ToStringWithCulture(isClass ? "[AllowNull] " : ""));

            #line default
            #line hidden
            this.Write(this.ToStringHelper.ToStringWithCulture(Name));

            #line default
            #line hidden
            this.Write(" other )\n        {\n");
            if (isClass)
            {
            #line default
            #line hidden
                this.Write("            if( ReferenceEquals( null, other ) )\n            {\n                return false;\n            }\n\n            if( ReferenceEquals( this, other ) )\n            {\n                return true;\n            }\n            return ");
                this.Write(this.ToStringHelper.ToStringWithCulture(ValueName));

            #line default
            #line hidden
                this.Write(" == other.");
                this.Write(this.ToStringHelper.ToStringWithCulture(ValueName));

            #line default
            #line hidden
                this.Write(";\n");
            }
            else if (isStruct)
            {
            #line default
            #line hidden
                this.Write("            return Equals( ");
                this.Write(this.ToStringHelper.ToStringWithCulture(ValueName));

            #line default
            #line hidden
                this.Write(", other.");
                this.Write(this.ToStringHelper.ToStringWithCulture(ValueName));

            #line default
            #line hidden
                this.Write(" );\n");
            }

            #line default
            #line hidden
            this.Write("        }\n\n        public override bool Equals( [AllowNull] object obj )\n        {\n");
            if (isClass)
            {
            #line default
            #line hidden
                this.Write("            if( ReferenceEquals( null, obj ) )\n            {\n                return false;\n            }\n\n            if( ReferenceEquals( this, obj ) )\n            {\n                return true;\n            }\n\n            if( obj.GetType() != this.GetType() )\n            {\n                return false;\n            }\n\n            return Equals( (");
                this.Write(this.ToStringHelper.ToStringWithCulture(Name));

            #line default
            #line hidden
                this.Write(")obj );\n");
            }
            else if (isStruct)
            {
            #line default
            #line hidden
                this.Write("            return obj is ");
                this.Write(this.ToStringHelper.ToStringWithCulture(Name));

            #line default
            #line hidden
                this.Write(" other && Equals( other );\n");
            }

            #line default
            #line hidden
            this.Write("        }\n\n        // HashCode\n        public override int GetHashCode() => ");
            this.Write(this.ToStringHelper.ToStringWithCulture(ValueName));

            #line default
            #line hidden
            this.Write(".GetHashCode();\n\n        // Operator ==, !=\n        public static bool operator ==( ");
            this.Write(this.ToStringHelper.ToStringWithCulture(Name));

            #line default
            #line hidden
            this.Write(" a, ");
            this.Write(this.ToStringHelper.ToStringWithCulture(Name));

            #line default
            #line hidden
            this.Write(" b )\n        {\n");
            if (isClass)
            {
            #line default
            #line hidden
                this.Write("            if( ReferenceEquals( a, b ) )\n            {\n                return true;\n            }\n\n            return a?.Equals( b ) ?? ReferenceEquals( null, b );\n");
            }
            else if (isStruct)
            {
            #line default
            #line hidden
                this.Write("            return a.Equals( b );\n");
            }

            #line default
            #line hidden
            this.Write("        }\n\n        public static bool operator !=( ");
            this.Write(this.ToStringHelper.ToStringWithCulture(Name));

            #line default
            #line hidden
            this.Write(" a, ");
            this.Write(this.ToStringHelper.ToStringWithCulture(Name));

            #line default
            #line hidden
            this.Write(" b )\n        {\n            return !( a == b );\n        }\n\n");
            if (ValueOption.HasFlag(ValueOption.Explicit))
            {
            #line default
            #line hidden
                this.Write("        //----------------------------------------------------------------------\n        // Explicit\n        //----------------------------------------------------------------------\n        public static explicit operator ");
                this.Write(this.ToStringHelper.ToStringWithCulture(BaseTypeName));

            #line default
            #line hidden
                this.Write("( ");
                this.Write(this.ToStringHelper.ToStringWithCulture(Name));

            #line default
            #line hidden
                this.Write(" x )\n        {\n            return x.");
                this.Write(this.ToStringHelper.ToStringWithCulture(ValueName));

            #line default
            #line hidden
                this.Write(";\n        }\n\n        public static explicit operator ");
                this.Write(this.ToStringHelper.ToStringWithCulture(Name));

            #line default
            #line hidden
                this.Write("( ");
                this.Write(this.ToStringHelper.ToStringWithCulture(BaseTypeName));

            #line default
            #line hidden
                this.Write(" value )\n        {\n            return new ");
                this.Write(this.ToStringHelper.ToStringWithCulture(Name));

            #line default
            #line hidden
                this.Write("( value );\n        }\n");
            }
            else if (ValueOption.HasFlag(ValueOption.Implicit))
            {
            #line default
            #line hidden
                this.Write("        //----------------------------------------------------------------------\n        // Implicit\n        //----------------------------------------------------------------------\n        public static implicit operator ");
                this.Write(this.ToStringHelper.ToStringWithCulture(BaseTypeName));

            #line default
            #line hidden
                this.Write("( ");
                this.Write(this.ToStringHelper.ToStringWithCulture(Name));

            #line default
            #line hidden
                this.Write(" x )\n        {\n            return x.");
                this.Write(this.ToStringHelper.ToStringWithCulture(ValueName));

            #line default
            #line hidden
                this.Write(";\n        }\n\n        public static implicit operator ");
                this.Write(this.ToStringHelper.ToStringWithCulture(Name));

            #line default
            #line hidden
                this.Write("( ");
                this.Write(this.ToStringHelper.ToStringWithCulture(BaseTypeName));

            #line default
            #line hidden
                this.Write(" value )\n        {\n            return new ");
                this.Write(this.ToStringHelper.ToStringWithCulture(Name));

            #line default
            #line hidden
                this.Write("( value );\n        }\n");
            }

            #line default
            #line hidden
            this.Write("\n");
            if (ValueOption.HasFlag(ValueOption.Comparable))
            {
            #line default
            #line hidden
                this.Write("        //----------------------------------------------------------------------\n        // Comparable\n        //----------------------------------------------------------------------\n        public int CompareTo( ");
                this.Write(this.ToStringHelper.ToStringWithCulture(Name));

            #line default
            #line hidden
                this.Write(" other )\n        {\n            if( ReferenceEquals( this, other ) )\n            {\n                return 0;\n            }\n\n            if( ReferenceEquals( null, other ) )\n            {\n                return 1;\n            }\n\n            return ");
                this.Write(this.ToStringHelper.ToStringWithCulture(ValueName));

            #line default
            #line hidden
                this.Write(".CompareTo( other.");
                this.Write(this.ToStringHelper.ToStringWithCulture(ValueName));

            #line default
            #line hidden
                this.Write(" );\n        }\n");
            }

            #line default
            #line hidden
            this.Write("\n    }\n\n");
            if (!string.IsNullOrEmpty(Namespace))
            {
            #line default
            #line hidden
                this.Write("}\n");
            }

            #line default
            #line hidden
            return(this.GenerationEnvironment.ToString());
        }