Beispiel #1
0
 internal WorkspaceRepositoryConfiguration(string type, string hostName, string accountName, string projectName, string repositoryName, string collaborationBranch, string rootFolder, string lastCommitId, Guid?tenantId, string clientId, GitHubClientSecret clientSecret)
 {
     Type                = type;
     HostName            = hostName;
     AccountName         = accountName;
     ProjectName         = projectName;
     RepositoryName      = repositoryName;
     CollaborationBranch = collaborationBranch;
     RootFolder          = rootFolder;
     LastCommitId        = lastCommitId;
     TenantId            = tenantId;
     ClientId            = clientId;
     ClientSecret        = clientSecret;
 }
        internal static WorkspaceRepositoryConfiguration DeserializeWorkspaceRepositoryConfiguration(JsonElement element)
        {
            Optional <string>             type                = default;
            Optional <string>             hostName            = default;
            Optional <string>             accountName         = default;
            Optional <string>             projectName         = default;
            Optional <string>             repositoryName      = default;
            Optional <string>             collaborationBranch = default;
            Optional <string>             rootFolder          = default;
            Optional <string>             lastCommitId        = default;
            Optional <Guid>               tenantId            = default;
            Optional <string>             clientId            = default;
            Optional <GitHubClientSecret> clientSecret        = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("type"))
                {
                    type = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("hostName"))
                {
                    hostName = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("accountName"))
                {
                    accountName = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("projectName"))
                {
                    projectName = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("repositoryName"))
                {
                    repositoryName = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("collaborationBranch"))
                {
                    collaborationBranch = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("rootFolder"))
                {
                    rootFolder = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("lastCommitId"))
                {
                    lastCommitId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("tenantId"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    tenantId = property.Value.GetGuid();
                    continue;
                }
                if (property.NameEquals("clientId"))
                {
                    clientId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("clientSecret"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    clientSecret = GitHubClientSecret.DeserializeGitHubClientSecret(property.Value);
                    continue;
                }
            }
            return(new WorkspaceRepositoryConfiguration(type.Value, hostName.Value, accountName.Value, projectName.Value, repositoryName.Value, collaborationBranch.Value, rootFolder.Value, lastCommitId.Value, Optional.ToNullable(tenantId), clientId.Value, clientSecret.Value));
        }