Exemplo n.º 1
0
        internal static UserSourceInfo DeserializeUserSourceInfo(JsonElement element)
        {
            if (element.TryGetProperty("type", out JsonElement discriminator))
            {
                switch (discriminator.GetString())
                {
                case "BuildResult": return(BuildResultUserSourceInfo.DeserializeBuildResultUserSourceInfo(element));

                case "Container": return(CustomContainerUserSourceInfo.DeserializeCustomContainerUserSourceInfo(element));

                case "Jar": return(JarUploadedUserSourceInfo.DeserializeJarUploadedUserSourceInfo(element));

                case "NetCoreZip": return(NetCoreZipUploadedUserSourceInfo.DeserializeNetCoreZipUploadedUserSourceInfo(element));

                case "Source": return(SourceUploadedUserSourceInfo.DeserializeSourceUploadedUserSourceInfo(element));

                case "UploadedUserSourceInfo": return(UploadedUserSourceInfo.DeserializeUploadedUserSourceInfo(element));
                }
            }
            string            type    = default;
            Optional <string> version = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("type"))
                {
                    type = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("version"))
                {
                    version = property.Value.GetString();
                    continue;
                }
            }
            return(new UserSourceInfo(type, version.Value));
        }
Exemplo n.º 2
0
        internal static UploadedUserSourceInfo DeserializeUploadedUserSourceInfo(JsonElement element)
        {
            if (element.TryGetProperty("type", out JsonElement discriminator))
            {
                switch (discriminator.GetString())
                {
                case "Jar": return(JarUploadedUserSourceInfo.DeserializeJarUploadedUserSourceInfo(element));

                case "NetCoreZip": return(NetCoreZipUploadedUserSourceInfo.DeserializeNetCoreZipUploadedUserSourceInfo(element));

                case "Source": return(SourceUploadedUserSourceInfo.DeserializeSourceUploadedUserSourceInfo(element));
                }
            }
            Optional <string> relativePath = default;
            string            type         = default;
            Optional <string> version      = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("relativePath"))
                {
                    relativePath = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("type"))
                {
                    type = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("version"))
                {
                    version = property.Value.GetString();
                    continue;
                }
            }
            return(new UploadedUserSourceInfo(type, version.Value, relativePath.Value));
        }