Esempio n. 1
0
 internal WhatIfPropertyChange(string path, WhatIfPropertyChangeType propertyChangeType, BinaryData before, BinaryData after, IReadOnlyList <WhatIfPropertyChange> children)
 {
     Path = path;
     PropertyChangeType = propertyChangeType;
     Before             = before;
     After    = after;
     Children = children;
 }
Esempio n. 2
0
        internal static WhatIfPropertyChange DeserializeWhatIfPropertyChange(JsonElement element)
        {
            string path = default;
            WhatIfPropertyChangeType propertyChangeType = default;
            Optional <BinaryData>    before             = default;
            Optional <BinaryData>    after = default;
            Optional <IReadOnlyList <WhatIfPropertyChange> > children = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("path"))
                {
                    path = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("propertyChangeType"))
                {
                    propertyChangeType = property.Value.GetString().ToWhatIfPropertyChangeType();
                    continue;
                }
                if (property.NameEquals("before"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    before = BinaryData.FromString(property.Value.GetRawText());
                    continue;
                }
                if (property.NameEquals("after"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    after = BinaryData.FromString(property.Value.GetRawText());
                    continue;
                }
                if (property.NameEquals("children"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <WhatIfPropertyChange> array = new List <WhatIfPropertyChange>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(DeserializeWhatIfPropertyChange(item));
                    }
                    children = array;
                    continue;
                }
            }
            return(new WhatIfPropertyChange(path, propertyChangeType, before.Value, after.Value, Optional.ToList(children)));
        }
Esempio n. 3
0
        internal WhatIfPropertyChange(string path, WhatIfPropertyChangeType propertyChangeType)
        {
            if (path == null)
            {
                throw new ArgumentNullException(nameof(path));
            }

            Path = path;
            PropertyChangeType = propertyChangeType;
            Children           = new ChangeTrackingList <WhatIfPropertyChange>();
        }
 public static string ToSerialString(this WhatIfPropertyChangeType value) => value switch
 {