示例#1
0
 void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
 {
     writer.WriteStartObject();
     writer.WritePropertyName("osType");
     writer.WriteStringValue(OSType.ToSerialString());
     writer.WritePropertyName("osState");
     writer.WriteStringValue(OSState.ToSerialString());
     if (Optional.IsDefined(Snapshot))
     {
         writer.WritePropertyName("snapshot");
         JsonSerializer.Serialize(writer, Snapshot);
     }
     if (Optional.IsDefined(ManagedDisk))
     {
         writer.WritePropertyName("managedDisk");
         JsonSerializer.Serialize(writer, ManagedDisk);
     }
     if (Optional.IsDefined(BlobUri))
     {
         writer.WritePropertyName("blobUri");
         writer.WriteStringValue(BlobUri.AbsoluteUri);
     }
     if (Optional.IsDefined(Caching))
     {
         writer.WritePropertyName("caching");
         writer.WriteStringValue(Caching.Value.ToSerialString());
     }
     if (Optional.IsDefined(DiskSizeGB))
     {
         writer.WritePropertyName("diskSizeGB");
         writer.WriteNumberValue(DiskSizeGB.Value);
     }
     if (Optional.IsDefined(StorageAccountType))
     {
         writer.WritePropertyName("storageAccountType");
         writer.WriteStringValue(StorageAccountType.Value.ToString());
     }
     if (Optional.IsDefined(DiskEncryptionSet))
     {
         writer.WritePropertyName("diskEncryptionSet");
         JsonSerializer.Serialize(writer, DiskEncryptionSet);
     }
     writer.WriteEndObject();
 }
示例#2
0
 /// <summary>
 /// Converts the <see cref="sourceValue" /> parameter to the <see cref="destinationType" /> parameter using <see cref="formatProvider"
 /// /> and <see cref="ignoreCase" />
 /// </summary>
 /// <param name="sourceValue">the <see cref="System.Object"/> to convert from</param>
 /// <param name="destinationType">the <see cref="System.Type" /> to convert to</param>
 /// <param name="formatProvider">not used by this TypeConverter.</param>
 /// <param name="ignoreCase">when set to <c>true</c>, will ignore the case when converting.</param>
 /// <returns>
 /// an instance of <see cref="OSState" />, or <c>null</c> if there is no suitable conversion.
 /// </returns>
 public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => OSState.CreateFrom(sourceValue);