示例#1
0
 internal AccessPolicyEntry(Guid tenantId, string objectId, Guid?applicationId, AccessPermissions permissions)
 {
     TenantId      = tenantId;
     ObjectId      = objectId;
     ApplicationId = applicationId;
     Permissions   = permissions;
 }
示例#2
0
        public AccessPolicyEntry(Guid tenantId, string objectId, AccessPermissions permissions)
        {
            if (objectId == null)
            {
                throw new ArgumentNullException(nameof(objectId));
            }
            if (permissions == null)
            {
                throw new ArgumentNullException(nameof(permissions));
            }

            TenantId    = tenantId;
            ObjectId    = objectId;
            Permissions = permissions;
        }
        internal static AccessPolicyEntry DeserializeAccessPolicyEntry(JsonElement element)
        {
            Guid              tenantId      = default;
            string            objectId      = default;
            Optional <Guid>   applicationId = default;
            AccessPermissions permissions   = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("tenantId"))
                {
                    tenantId = property.Value.GetGuid();
                    continue;
                }
                if (property.NameEquals("objectId"))
                {
                    objectId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("applicationId"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    applicationId = property.Value.GetGuid();
                    continue;
                }
                if (property.NameEquals("permissions"))
                {
                    permissions = AccessPermissions.DeserializeAccessPermissions(property.Value);
                    continue;
                }
            }
            return(new AccessPolicyEntry(tenantId, objectId, Optional.ToNullable(applicationId), permissions));
        }