Example #1
0
 void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
 {
     writer.WriteStartObject();
     writer.WritePropertyName("sasExpirationPeriod");
     writer.WriteStringValue(SasExpirationPeriod);
     writer.WritePropertyName("expirationAction");
     writer.WriteStringValue(ExpirationAction.ToString());
     writer.WriteEndObject();
 }
Example #2
0
        public SasPolicy(string sasExpirationPeriod, ExpirationAction expirationAction)
        {
            if (sasExpirationPeriod == null)
            {
                throw new ArgumentNullException(nameof(sasExpirationPeriod));
            }

            SasExpirationPeriod = sasExpirationPeriod;
            ExpirationAction    = expirationAction;
        }
Example #3
0
        internal static SasPolicy DeserializeSasPolicy(JsonElement element)
        {
            string           sasExpirationPeriod = default;
            ExpirationAction expirationAction    = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("sasExpirationPeriod"))
                {
                    sasExpirationPeriod = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("expirationAction"))
                {
                    expirationAction = new ExpirationAction(property.Value.GetString());
                    continue;
                }
            }
            return(new SasPolicy(sasExpirationPeriod, expirationAction));
        }