Exemplo n.º 1
0
        internal static VirtualApplicationData DeserializeVirtualApplicationData(JsonElement element)
        {
            ResourceIdentifier id                            = default;
            string             name                          = default;
            ResourceType       type                          = default;
            SystemData         systemData                    = default;
            Optional <string>  objectId                      = default;
            Optional <string>  description                   = default;
            Optional <string>  friendlyName                  = default;
            Optional <string>  filePath                      = default;
            Optional <string>  msixPackageFamilyName         = default;
            Optional <string>  msixPackageApplicationId      = default;
            Optional <RemoteApplicationType> applicationType = default;
            CommandLineSetting commandLineSetting            = default;
            Optional <string>  commandLineArguments          = default;
            Optional <bool>    showInPortal                  = default;
            Optional <string>  iconPath                      = default;
            Optional <int>     iconIndex                     = default;
            Optional <string>  iconHash                      = default;
            Optional <byte[]>  iconContent                   = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("id"))
                {
                    id = new ResourceIdentifier(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("type"))
                {
                    type = new ResourceType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("systemData"))
                {
                    systemData = JsonSerializer.Deserialize <SystemData>(property.Value.ToString());
                    continue;
                }
                if (property.NameEquals("properties"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        if (property0.NameEquals("objectId"))
                        {
                            objectId = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("description"))
                        {
                            description = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("friendlyName"))
                        {
                            friendlyName = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("filePath"))
                        {
                            filePath = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("msixPackageFamilyName"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                msixPackageFamilyName = null;
                                continue;
                            }
                            msixPackageFamilyName = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("msixPackageApplicationId"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                msixPackageApplicationId = null;
                                continue;
                            }
                            msixPackageApplicationId = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("applicationType"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            applicationType = new RemoteApplicationType(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("commandLineSetting"))
                        {
                            commandLineSetting = new CommandLineSetting(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("commandLineArguments"))
                        {
                            commandLineArguments = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("showInPortal"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            showInPortal = property0.Value.GetBoolean();
                            continue;
                        }
                        if (property0.NameEquals("iconPath"))
                        {
                            iconPath = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("iconIndex"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            iconIndex = property0.Value.GetInt32();
                            continue;
                        }
                        if (property0.NameEquals("iconHash"))
                        {
                            iconHash = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("iconContent"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            iconContent = property0.Value.GetBytesFromBase64("D");
                            continue;
                        }
                    }
                    continue;
                }
            }
            return(new VirtualApplicationData(id, name, type, systemData, objectId.Value, description.Value, friendlyName.Value, filePath.Value, msixPackageFamilyName.Value, msixPackageApplicationId.Value, Optional.ToNullable(applicationType), commandLineSetting, commandLineArguments.Value, Optional.ToNullable(showInPortal), iconPath.Value, Optional.ToNullable(iconIndex), iconHash.Value, iconContent.Value));
        }
 /// <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="RemoteApplicationType" />, 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) => RemoteApplicationType.CreateFrom(sourceValue);