示例#1
0
 internal CustomPersistentDiskProperties(UnderlyingResourceType underlyingResourceType, string mountPath, bool?readOnly, IList <string> mountOptions)
 {
     UnderlyingResourceType = underlyingResourceType;
     MountPath    = mountPath;
     ReadOnly     = readOnly;
     MountOptions = mountOptions;
 }
示例#2
0
 void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
 {
     writer.WriteStartObject();
     writer.WritePropertyName("shareName");
     writer.WriteStringValue(ShareName);
     writer.WritePropertyName("type");
     writer.WriteStringValue(UnderlyingResourceType.ToString());
     writer.WritePropertyName("mountPath");
     writer.WriteStringValue(MountPath);
     if (Optional.IsDefined(ReadOnly))
     {
         writer.WritePropertyName("readOnly");
         writer.WriteBooleanValue(ReadOnly.Value);
     }
     if (Optional.IsCollectionDefined(MountOptions))
     {
         writer.WritePropertyName("mountOptions");
         writer.WriteStartArray();
         foreach (var item in MountOptions)
         {
             writer.WriteStringValue(item);
         }
         writer.WriteEndArray();
     }
     writer.WriteEndObject();
 }
示例#3
0
        internal static CustomPersistentDiskProperties DeserializeCustomPersistentDiskProperties(JsonElement element)
        {
            if (element.TryGetProperty("type", out JsonElement discriminator))
            {
                switch (discriminator.GetString())
                {
                case "AzureFileVolume": return(AzureFileVolume.DeserializeAzureFileVolume(element));
                }
            }
            UnderlyingResourceType type             = default;
            string                     mountPath    = default;
            Optional <bool>            readOnly     = default;
            Optional <IList <string> > mountOptions = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("type"))
                {
                    type = new UnderlyingResourceType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("mountPath"))
                {
                    mountPath = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("readOnly"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    readOnly = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("mountOptions"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <string> array = new List <string>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(item.GetString());
                    }
                    mountOptions = array;
                    continue;
                }
            }
            return(new CustomPersistentDiskProperties(type, mountPath, Optional.ToNullable(readOnly), Optional.ToList(mountOptions)));
        }
示例#4
0
        internal static AzureFileVolume DeserializeAzureFileVolume(JsonElement element)
        {
            string shareName                        = default;
            UnderlyingResourceType type             = default;
            string                     mountPath    = default;
            Optional <bool>            readOnly     = default;
            Optional <IList <string> > mountOptions = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("shareName"))
                {
                    shareName = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("type"))
                {
                    type = new UnderlyingResourceType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("mountPath"))
                {
                    mountPath = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("readOnly"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    readOnly = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("mountOptions"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <string> array = new List <string>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(item.GetString());
                    }
                    mountOptions = array;
                    continue;
                }
            }
            return(new AzureFileVolume(type, mountPath, Optional.ToNullable(readOnly), Optional.ToList(mountOptions), shareName));
        }
示例#5
0
 internal AzureFileVolume(UnderlyingResourceType underlyingResourceType, string mountPath, bool?readOnly, IList <string> mountOptions, string shareName) : base(underlyingResourceType, mountPath, readOnly, mountOptions)
 {
     ShareName = shareName;
     UnderlyingResourceType = underlyingResourceType;
 }