Freigeben über


Beispiel für von C# generierten Code

/*
 * HCN API
 *
 * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
 *
 * OpenAPI spec version: 2.1
 *
 * Generated by: https://github.com/swagger-api/swagger-codegen.git
 */
using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System.ComponentModel.DataAnnotations;
using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter;
namespace IO.Swagger.Model
{
    /// <summary>
    /// Ipam
    /// </summary>
    [DataContract]
    public partial class Ipam :  IEquatable<Ipam>, IValidatableObject
    {
        /// <summary>
        ///  Type : dhcp
        /// </summary>
        /// <value> Type : dhcp</value>
        [JsonConverter(typeof(StringEnumConverter))]
        public enum TypeEnum
        {
            /// <summary>
            /// Enum Static for value: Static
            /// </summary>
            [EnumMember(Value = "Static")]
            Static = 1,
            /// <summary>
            /// Enum Dhcp for value: Dhcp
            /// </summary>
            [EnumMember(Value = "Dhcp")]
            Dhcp = 2
        }
        /// <summary>
        ///  Type : dhcp
        /// </summary>
        /// <value> Type : dhcp</value>
        [DataMember(Name="Type", EmitDefaultValue=false)]
        public TypeEnum? Type { get; set; }
        /// <summary>
        /// Initializes a new instance of the <see cref="Ipam" /> class.
        /// </summary>
        /// <param name="Type"> Type : dhcp.</param>
        /// <param name="Subnets">Subnets.</param>
        public Ipam(TypeEnum? Type = default(TypeEnum?), List<Subnet> Subnets = default(List<Subnet>))
        {
            this.Type = Type;
            this.Subnets = Subnets;
        }
        /// <summary>
        /// Gets or Sets Subnets
        /// </summary>
        [DataMember(Name="Subnets", EmitDefaultValue=false)]
        public List<Subnet> Subnets { get; set; }
        /// <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 Ipam {\n");
            sb.Append("  Type: ").Append(Type).Append("\n");
            sb.Append("  Subnets: ").Append(Subnets).Append("\n");
            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 string ToJson()
        {
            return JsonConvert.SerializeObject(this, Formatting.Indented);
        }
        /// <summary>
        /// Returns true if objects are equal
        /// </summary>
        /// <param name="input">Object to be compared</param>
        /// <returns>Boolean</returns>
        public override bool Equals(object input)
        {
            return this.Equals(input as Ipam);
        }
        /// <summary>
        /// Returns true if Ipam instances are equal
        /// </summary>
        /// <param name="input">Instance of Ipam to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(Ipam input)
        {
            if (input == null)
                return false;
            return
                (
                    this.Type == input.Type ||
                    (this.Type != null &&
                    this.Type.Equals(input.Type))
                ) &&
                (
                    this.Subnets == input.Subnets ||
                    this.Subnets != null &&
                    this.Subnets.SequenceEqual(input.Subnets)
                );
        }
        /// <summary>
        /// Gets the hash code
        /// </summary>
        /// <returns>Hash code</returns>
        public override int GetHashCode()
        {
            unchecked // Overflow is fine, just wrap
            {
                int hashCode = 41;
                if (this.Type != null)
                    hashCode = hashCode * 59 + this.Type.GetHashCode();
                if (this.Subnets != null)
                    hashCode = hashCode * 59 + this.Subnets.GetHashCode();
                return hashCode;
            }
        }
        /// <summary>
        /// To validate all properties of the instance
        /// </summary>
        /// <param name="validationContext">Validation context</param>
        /// <returns>Validation Result</returns>
        IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
        {
            yield break;
        }
    }
}
/*
 * HCN API
 *
 * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
 *
 * OpenAPI spec version: 2.1
 *
 * Generated by: https://github.com/swagger-api/swagger-codegen.git
 */
using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System.ComponentModel.DataAnnotations;
using SwaggerDateConverter = IO.Swagger.Client.SwaggerDateConverter;
namespace IO.Swagger.Model
{
    /// <summary>
    /// Subnet
    /// </summary>
    [DataContract]
    public partial class Subnet :  IEquatable<Subnet>, IValidatableObject
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="Subnet" /> class.
        /// </summary>
        /// <param name="ID">ID.</param>
        /// <param name="IpAddressPrefix">IpAddressPrefix.</param>
        /// <param name="Policies">Policies.</param>
        /// <param name="Routes">Routes.</param>
        public Subnet(string ID = default(string), string IpAddressPrefix = default(string), List<SubnetPolicy> Policies = default(List<SubnetPolicy>), List<Route> Routes = default(List<Route>))
        {
            this.ID = ID;
            this.IpAddressPrefix = IpAddressPrefix;
            this.Policies = Policies;
            this.Routes = Routes;
        }
        /// <summary>
        /// Gets or Sets ID
        /// </summary>
        [DataMember(Name="ID", EmitDefaultValue=false)]
        public string ID { get; set; }
        /// <summary>
        /// Gets or Sets IpAddressPrefix
        /// </summary>
        [DataMember(Name="IpAddressPrefix", EmitDefaultValue=false)]
        public string IpAddressPrefix { get; set; }
        /// <summary>
        /// Gets or Sets Policies
        /// </summary>
        [DataMember(Name="Policies", EmitDefaultValue=false)]
        public List<SubnetPolicy> Policies { get; set; }
        /// <summary>
        /// Gets or Sets Routes
        /// </summary>
        [DataMember(Name="Routes", EmitDefaultValue=false)]
        public List<Route> Routes { get; set; }
        /// <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 Subnet {\n");
            sb.Append("  ID: ").Append(ID).Append("\n");
            sb.Append("  IpAddressPrefix: ").Append(IpAddressPrefix).Append("\n");
            sb.Append("  Policies: ").Append(Policies).Append("\n");
            sb.Append("  Routes: ").Append(Routes).Append("\n");
            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 string ToJson()
        {
            return JsonConvert.SerializeObject(this, Formatting.Indented);
        }
        /// <summary>
        /// Returns true if objects are equal
        /// </summary>
        /// <param name="input">Object to be compared</param>
        /// <returns>Boolean</returns>
        public override bool Equals(object input)
        {
            return this.Equals(input as Subnet);
        }
        /// <summary>
        /// Returns true if Subnet instances are equal
        /// </summary>
        /// <param name="input">Instance of Subnet to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(Subnet input)
        {
            if (input == null)
                return false;
            return
                (
                    this.ID == input.ID ||
                    (this.ID != null &&
                    this.ID.Equals(input.ID))
                ) &&
                (
                    this.IpAddressPrefix == input.IpAddressPrefix ||
                    (this.IpAddressPrefix != null &&
                    this.IpAddressPrefix.Equals(input.IpAddressPrefix))
                ) &&
                (
                    this.Policies == input.Policies ||
                    this.Policies != null &&
                    this.Policies.SequenceEqual(input.Policies)
                ) &&
                (
                    this.Routes == input.Routes ||
                    this.Routes != null &&
                    this.Routes.SequenceEqual(input.Routes)
                );
        }
        /// <summary>
        /// Gets the hash code
        /// </summary>
        /// <returns>Hash code</returns>
        public override int GetHashCode()
        {
            unchecked // Overflow is fine, just wrap
            {
                int hashCode = 41;
                if (this.ID != null)
                    hashCode = hashCode * 59 + this.ID.GetHashCode();
                if (this.IpAddressPrefix != null)
                    hashCode = hashCode * 59 + this.IpAddressPrefix.GetHashCode();
                if (this.Policies != null)
                    hashCode = hashCode * 59 + this.Policies.GetHashCode();
                if (this.Routes != null)
                    hashCode = hashCode * 59 + this.Routes.GetHashCode();
                return hashCode;
            }
        }
        /// <summary>
        /// To validate all properties of the instance
        /// </summary>
        /// <param name="validationContext">Validation context</param>
        /// <returns>Validation Result</returns>
        IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
        {
            // ID (string) pattern
            Regex regexID = new Regex(@"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$", RegexOptions.CultureInvariant);
            if (false == regexID.Match(this.ID).Success)
            {
                yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for ID, must match a pattern of " + regexID, new [] { "ID" });
            }
            yield break;
        }
    }
}