Example #1
0
 public override string Visit(MemberGuid memberGuid)
 {
     return("uniqueidentifier");
 }
Example #2
0
 public abstract TResult Visit(MemberGuid memberGuid);
Example #3
0
        public override string Visit(MemberGuid memberGuid)
        {
            string typeName = StringExt.ToTitleCase(_member.Name);

            var template = $@"
[Serializable]
[JsonConverter(typeof(GuidStrongTypeConverter<{typeName}>))]
public partial struct {typeName} : ITypedGuid, IStrongTypeFactory<Guid, {typeName}>, IEquatable<{typeName}>
{{
    private readonly Guid _value;

    private {typeName}(Guid guid)
    {{
        _value = guid;
    }}

    public static explicit operator {typeName}(Guid value)
    {{
        return new {typeName}(value);
    }}

    public static implicit operator Guid({typeName} value)
    {{
        return value._value;
    }}

    public override string ToString()
    {{
        return _value.ToString();
    }}

    private Guid UnderlyingValue()
    {{
        return _value;
    }}

    public Guid Value {{ get {{ return _value; }} }}

    {typeName} IStrongTypeFactory<Guid, {typeName}>.NewWithValue(Guid value)
    {{
        return new {typeName}(value);
    }}

    public TResult Accept<TResult>(IStrongTypeVistor<TResult> visitor)
    {{
        return visitor.Visit(this);
    }}

    public Guid ToGuid()
    {{
        return _value;
    }}

    public string ToString(string format)
    {{
        return _value.ToString(format);
    }}

    public string ToString(string format, IFormatProvider provider)
    {{
        return _value.ToString(format, provider);
    }}

    public override bool Equals(object other)
    {{
        if (other is {typeName})
        {{
            return Equals(({typeName})other);
        }}
        return false;
    }}

    public override int GetHashCode()
    {{
        return _value.GetHashCode();
    }}

    public bool Equals({typeName} other)
    {{
        return _value.Equals(other._value);
    }}

    public static bool operator ==({typeName} left, {typeName} right)
    {{
        return left.Equals(right);
    }}

    public static bool operator !=({typeName} left, {typeName} right)
    {{
        return !left.Equals(right);
    }}
}}";

            return(template);
        }
Example #4
0
 public override TResult Visit(MemberGuid memberGuid)
 {
     return(DefaultVisit(memberGuid));
 }
 public override bool Visit(MemberGuid memberGuid)
 {
     return(true);
 }
Example #6
0
 public override string Visit(MemberGuid memberGuid)
 {
     return("System.Guid" + Optionality());
 }