Ejemplo n.º 1
0
 internal EventData(SenderAuthorization authorization, IReadOnlyDictionary <string, string> claims, string caller, string description, string id, string eventDataId, string correlationId, LocalizableString eventName, LocalizableString category, HttpRequestInfo httpRequest, EventLevel?level, string resourceGroupName, LocalizableString resourceProviderName, string resourceId, LocalizableString resourceType, string operationId, LocalizableString operationName, IReadOnlyDictionary <string, string> properties, LocalizableString status, LocalizableString subStatus, DateTimeOffset?eventTimestamp, DateTimeOffset?submissionTimestamp, string subscriptionId, string tenantId)
 {
     Authorization        = authorization;
     Claims               = claims;
     Caller               = caller;
     Description          = description;
     Id                   = id;
     EventDataId          = eventDataId;
     CorrelationId        = correlationId;
     EventName            = eventName;
     Category             = category;
     HttpRequest          = httpRequest;
     Level                = level;
     ResourceGroupName    = resourceGroupName;
     ResourceProviderName = resourceProviderName;
     ResourceId           = resourceId;
     ResourceType         = resourceType;
     OperationId          = operationId;
     OperationName        = operationName;
     Properties           = properties;
     Status               = status;
     SubStatus            = subStatus;
     EventTimestamp       = eventTimestamp;
     SubmissionTimestamp  = submissionTimestamp;
     SubscriptionId       = subscriptionId;
     TenantId             = tenantId;
 }
Ejemplo n.º 2
0
        internal static EventData DeserializeEventData(JsonElement element)
        {
            Optional <SenderAuthorization> authorization            = default;
            Optional <IReadOnlyDictionary <string, string> > claims = default;
            Optional <string>            caller                         = default;
            Optional <string>            description                    = default;
            Optional <string>            id                             = default;
            Optional <string>            eventDataId                    = default;
            Optional <string>            correlationId                  = default;
            Optional <LocalizableString> eventName                      = default;
            Optional <LocalizableString> category                       = default;
            Optional <HttpRequestInfo>   httpRequest                    = default;
            Optional <EventLevel>        level                          = default;
            Optional <string>            resourceGroupName              = default;
            Optional <LocalizableString> resourceProviderName           = default;
            Optional <string>            resourceId                     = default;
            Optional <LocalizableString> resourceType                   = default;
            Optional <string>            operationId                    = default;
            Optional <LocalizableString> operationName                  = default;
            Optional <IReadOnlyDictionary <string, string> > properties = default;
            Optional <LocalizableString> status                         = default;
            Optional <LocalizableString> subStatus                      = default;
            Optional <DateTimeOffset>    eventTimestamp                 = default;
            Optional <DateTimeOffset>    submissionTimestamp            = default;
            Optional <string>            subscriptionId                 = default;
            Optional <string>            tenantId                       = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("authorization"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    authorization = SenderAuthorization.DeserializeSenderAuthorization(property.Value);
                    continue;
                }
                if (property.NameEquals("claims"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    Dictionary <string, string> dictionary = new Dictionary <string, string>();
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        dictionary.Add(property0.Name, property0.Value.GetString());
                    }
                    claims = dictionary;
                    continue;
                }
                if (property.NameEquals("caller"))
                {
                    caller = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("description"))
                {
                    description = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("id"))
                {
                    id = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("eventDataId"))
                {
                    eventDataId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("correlationId"))
                {
                    correlationId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("eventName"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    eventName = LocalizableString.DeserializeLocalizableString(property.Value);
                    continue;
                }
                if (property.NameEquals("category"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    category = LocalizableString.DeserializeLocalizableString(property.Value);
                    continue;
                }
                if (property.NameEquals("httpRequest"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    httpRequest = HttpRequestInfo.DeserializeHttpRequestInfo(property.Value);
                    continue;
                }
                if (property.NameEquals("level"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    level = property.Value.GetString().ToEventLevel();
                    continue;
                }
                if (property.NameEquals("resourceGroupName"))
                {
                    resourceGroupName = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("resourceProviderName"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    resourceProviderName = LocalizableString.DeserializeLocalizableString(property.Value);
                    continue;
                }
                if (property.NameEquals("resourceId"))
                {
                    resourceId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("resourceType"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    resourceType = LocalizableString.DeserializeLocalizableString(property.Value);
                    continue;
                }
                if (property.NameEquals("operationId"))
                {
                    operationId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("operationName"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    operationName = LocalizableString.DeserializeLocalizableString(property.Value);
                    continue;
                }
                if (property.NameEquals("properties"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    Dictionary <string, string> dictionary = new Dictionary <string, string>();
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        dictionary.Add(property0.Name, property0.Value.GetString());
                    }
                    properties = dictionary;
                    continue;
                }
                if (property.NameEquals("status"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    status = LocalizableString.DeserializeLocalizableString(property.Value);
                    continue;
                }
                if (property.NameEquals("subStatus"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    subStatus = LocalizableString.DeserializeLocalizableString(property.Value);
                    continue;
                }
                if (property.NameEquals("eventTimestamp"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    eventTimestamp = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property.NameEquals("submissionTimestamp"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    submissionTimestamp = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property.NameEquals("subscriptionId"))
                {
                    subscriptionId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("tenantId"))
                {
                    tenantId = property.Value.GetString();
                    continue;
                }
            }
            return(new EventData(authorization.Value, Optional.ToDictionary(claims), caller.Value, description.Value, id.Value, eventDataId.Value, correlationId.Value, eventName.Value, category.Value, httpRequest.Value, Optional.ToNullable(level), resourceGroupName.Value, resourceProviderName.Value, resourceId.Value, resourceType.Value, operationId.Value, operationName.Value, Optional.ToDictionary(properties), status.Value, subStatus.Value, Optional.ToNullable(eventTimestamp), Optional.ToNullable(submissionTimestamp), subscriptionId.Value, tenantId.Value));
        }