#pragma warning disable CS0472 // The result of the expression is always the same since a value of this type is never equal to 'null'
    /// <summary>
    /// {{#description}}{{.}}{{/description}}{{^description}}{{classname}}{{/description}}
    /// </summary>
    [DataContract]
    {{#generatePropertyChanged}}
    [ImplementPropertyChanged]
    {{/generatePropertyChanged}}
    {{>visibility}} partial class {{classname}} : {{#vendorExtensions.x-inheritsName}} {{vendorExtensions.x-inheritsName}}, {{/vendorExtensions.x-inheritsName}} {{#parent}}{{{parent}}}, {{/parent}} IEquatable<{{classname}}>, IValidatableObject //Mark 555
    {
        {{#vars}}
        {{/vars}}
        {{#vars}}
{{^vendorExtensions.x-isinherited}}
        {{#isEnum}}
{{>modelInnerEnum}}
        {{/isEnum}}
        {{#items.isEnum}}
        {{#items}}
{{>modelInnerEnum}}
        {{/items}}
        {{/items.isEnum}}
{{/vendorExtensions.x-isinherited}}
        {{/vars}}
        {{#vars}}
{{^vendorExtensions.x-isinherited}}
        {{#isEnum}}
        /// <summary>
        /// Is Enum: Gets or Sets
        /// vendorExtensions
        /// {{^description}}{{{name}}}{{/description}}{{#description}}{{{description}}}{{/description}}
        /// </summary>{{#description}}
        /// <value>{{{description}}}</value>{{/description}}
        [DataMember(Name="{{baseName}}")]
        public 
    {{#isEnum}}
        {{#isContainer}}
        {{#isListContainer}}
        List<{{{vendorExtensions.x-enumTypeName}}}>
        {{/isListContainer}}
        {{#isMapContainer}}
        {{{datatype}}}
        {{/isMapContainer}}
        {{/isContainer}}
        {{^isContainer}}
{{{vendorExtensions.x-enumTypeName}}}?
        {{/isContainer}}
    {{/isEnum}} 
        {{name}} { get; set; } // Mark 2 vendorExtensions: {{{vendorExtensions}}}
    {{/isEnum}}
{{/vendorExtensions.x-isinherited}}
        {{/vars}}
    {{#hasRequired}}
    {{^hasOnlyReadOnly}}
        /// <summary>
        /// 2. Initializes a new instance of the <see cref="{{classname}}" /> class.
        /// </summary>
        [JsonConstructorAttribute]
        public {{classname}}() { }
    {{/hasOnlyReadOnly}}
    {{/hasRequired}}

    
        {{#vars}}
        {{^isEnum}}
        {{^vendorExtensions.x-isinherited}}
        /// <summary>
        /// Not Enum: Gets or Sets 
        /// {{^description}}{{{name}}}{{/description}}{{#description}}{{description}}{{/description}}
        /// </summary>{{#description}}
        /// <value>{{description}}</value>{{/description}}
        [DataMember(Name="{{baseName}}"{{#required}}, IsRequired = true{{/required}})] 
        public {{{datatype}}} {{name}} { get; {{#isReadOnly}}private {{/isReadOnly}}set; } // Mark 1 vendorExtensions: {{{vendorExtensions}}}
        {{/vendorExtensions.x-isinherited}}
        {{/isEnum}}
        {{/vars}}
        /// <summary>
        /// Returns the string presentation of the object
        /// </summary>
        /// <returns>String presentation of the object</returns>
        public override string ToString()
        {
            var sb = new StringBuilder();
            sb.Append("class {{classname}} {\n");
            {{#vars}}
            sb.Append("  {{name}}: ").Append({{name}}).Append("\n");
            {{/vars}}
            sb.Append("}\n");
            return sb.ToString();
        }
  
        /// <summary>
        /// Returns the JSON string presentation of the object
        /// </summary>
        /// <returns>JSON string presentation of the object</returns>
        public {{#parent}} new {{/parent}}string ToJson()
        {
            return JsonConvert.SerializeObject(this, Formatting.Indented);
        }

        /// <summary>
        /// Returns true if objects are equal
        /// </summary>
        /// <param name="obj">Object to be compared</param>
        /// <returns>Boolean</returns>
        public override bool Equals(object obj)
        {
            // credit: http://stackoverflow.com/a/10454552/677735
            return this.Equals(obj as {{classname}});
        }

        /// <summary>
        /// Returns true if {{classname}} instances are equal
        /// </summary>
        /// <param name="other">Instance of {{classname}} to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals({{classname}} other)
        {
            // credit: http://stackoverflow.com/a/10454552/677735
            if (other == null)
                return false;

            return {{#vars}}{{#isNotContainer}}
                (
                    this.{{name}} == other.{{name}} ||
                    this.{{name}} != null &&
                    this.{{name}}.Equals(other.{{name}})
                ){{#hasMore}} && {{/hasMore}}{{/isNotContainer}}{{^isNotContainer}}
                (
                    this.{{name}} == other.{{name}} ||
                    this.{{name}} != null &&
                    this.{{name}}.SequenceEqual(other.{{name}})
                ){{#hasMore}} && {{/hasMore}}{{/isNotContainer}}{{/vars}}{{^vars}}false{{/vars}};
        }

        /// <summary>
        /// Gets the hash code
        /// </summary>
        /// <returns>Hash code</returns>
        public override int GetHashCode()
        {
            // credit: http://stackoverflow.com/a/263416/677735
            unchecked // Overflow is fine, just wrap
            {
                int hash = 41;
                // Suitable nullity checks etc, of course :)
                {{#vars}}
                if (this.{{name}} != null)
                    hash = hash * 59 + this.{{name}}.GetHashCode();
                {{/vars}}
                return hash;
            }
        }

{{#generatePropertyChanged}}
        public event PropertyChangedEventHandler PropertyChanged;

        public virtual void OnPropertyChanged(string propertyName)
        {
            // NOTE: property changed is handled via "code weaving" using Fody.
            // Properties with setters are modified at compile time to notify of changes.
            var propertyChanged = PropertyChanged;
            if (propertyChanged != null)
            {
                propertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }

{{/generatePropertyChanged}}
        public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
        { {{#vars}}{{#hasValidation}}{{#maxLength}}
            // {{{name}}} ({{{datatype}}}) maxLength
            if(this.{{{name}}} != null && this.{{{name}}}.Length > {{maxLength}})
            {
                yield return new ValidationResult("Invalid value for {{{name}}}, length must be less than {{maxLength}}.", new [] { "{{{name}}}" });
            }
{{/maxLength}}{{#minLength}}
            // {{{name}}} ({{{datatype}}}) minLength
            if(this.{{{name}}} != null && this.{{{name}}}.Length < {{minLength}})
            {
                yield return new ValidationResult("Invalid value for {{{name}}}, length must be greater than {{minLength}}.", new [] { "{{{name}}}" });
            }
{{/minLength}}{{#maximum}}
            // {{{name}}} ({{{datatype}}}) maximum
            if(this.{{{name}}} > ({{{datatype}}}){{maximum}})
            {
                yield return new ValidationResult("Invalid value for {{{name}}}, must be a value less than or equal to {{maximum}}.", new [] { "{{{name}}}" });
            }
{{/maximum}}{{#minimum}}
            // {{{name}}} ({{{datatype}}}) minimum
            if(this.{{{name}}} < ({{{datatype}}}){{minimum}})
            {
                yield return new ValidationResult("Invalid value for {{{name}}}, must be a value greater than or equal to {{minimum}}.", new [] { "{{{name}}}" });
            }
{{/minimum}}{{#pattern}}
            // {{{name}}} ({{{datatype}}}) pattern
            Regex regex{{{name}}} = new Regex(@"{{vendorExtensions.x-regex}}"{{#vendorExtensions.x-modifiers}}{{#-first}}, {{/-first}}RegexOptions.{{.}}{{^-last}} | {{/-last}}{{/vendorExtensions.x-modifiers}});
            if (false == regex{{{name}}}.Match(this.{{{name}}}).Success)
            {
                yield return new ValidationResult(@"Invalid value for {{{name}}}, must match a pattern of {{pattern}}.", new [] { "{{{name}}}" });
            }
{{/pattern}}{{/hasValidation}}{{/vars}}
            yield break;
        }
    }

#pragma warning restore CS0472 // The result of the expression is always the same since a value of this type is never equal to 'null'
