示例#1
0
 internal SyncGroup(string id, string name, string type, int?interval, DateTimeOffset?lastSyncTime, SyncConflictResolutionPolicy?conflictResolutionPolicy, string syncDatabaseId, string hubDatabaseUserName, string hubDatabasePassword, SyncGroupState?syncState, SyncGroupSchema schema, bool?usePrivateLinkConnection) : base(id, name, type)
 {
     Interval                 = interval;
     LastSyncTime             = lastSyncTime;
     ConflictResolutionPolicy = conflictResolutionPolicy;
     SyncDatabaseId           = syncDatabaseId;
     HubDatabaseUserName      = hubDatabaseUserName;
     HubDatabasePassword      = hubDatabasePassword;
     SyncState                = syncState;
     Schema = schema;
     UsePrivateLinkConnection = usePrivateLinkConnection;
 }
        internal static SyncGroup DeserializeSyncGroup(JsonElement element)
        {
            Optional <string>         id           = default;
            Optional <string>         name         = default;
            Optional <string>         type         = default;
            Optional <int>            interval     = default;
            Optional <DateTimeOffset> lastSyncTime = default;
            Optional <SyncConflictResolutionPolicy> conflictResolutionPolicy = default;
            Optional <string>          syncDatabaseId      = default;
            Optional <string>          hubDatabaseUserName = default;
            Optional <string>          hubDatabasePassword = default;
            Optional <SyncGroupState>  syncState           = default;
            Optional <SyncGroupSchema> schema = default;
            Optional <bool>            usePrivateLinkConnection = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("id"))
                {
                    id = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("type"))
                {
                    type = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("properties"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        if (property0.NameEquals("interval"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            interval = property0.Value.GetInt32();
                            continue;
                        }
                        if (property0.NameEquals("lastSyncTime"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            lastSyncTime = property0.Value.GetDateTimeOffset("O");
                            continue;
                        }
                        if (property0.NameEquals("conflictResolutionPolicy"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            conflictResolutionPolicy = new SyncConflictResolutionPolicy(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("syncDatabaseId"))
                        {
                            syncDatabaseId = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("hubDatabaseUserName"))
                        {
                            hubDatabaseUserName = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("hubDatabasePassword"))
                        {
                            hubDatabasePassword = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("syncState"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            syncState = new SyncGroupState(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("schema"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            schema = SyncGroupSchema.DeserializeSyncGroupSchema(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("usePrivateLinkConnection"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            usePrivateLinkConnection = property0.Value.GetBoolean();
                            continue;
                        }
                    }
                    continue;
                }
            }
            return(new SyncGroup(id.Value, name.Value, type.Value, Optional.ToNullable(interval), Optional.ToNullable(lastSyncTime), Optional.ToNullable(conflictResolutionPolicy), syncDatabaseId.Value, hubDatabaseUserName.Value, hubDatabasePassword.Value, Optional.ToNullable(syncState), schema.Value, Optional.ToNullable(usePrivateLinkConnection)));
        }