Exemple #1
0
        public override async Task OnWritingAsync(DomainGroup group, OperationKind operationKind, CancellationToken cancellationToken)
        {
            _hitCounter.TrackInvocation <DomainGroup>(ResourceDefinitionHitCounter.ExtensibilityPoint.OnWritingAsync);

            if (operationKind == OperationKind.DeleteResource)
            {
                _groupToDelete = await base.GetGroupToDeleteAsync(group.Id, cancellationToken);
            }
        }
        public override void OnDeserialize(RecordCompany resource)
        {
            _hitCounter.TrackInvocation <RecordCompany>(ResourceDefinitionHitCounter.ExtensibilityPoint.OnDeserialize);

            if (!string.IsNullOrEmpty(resource.Name))
            {
                resource.Name = resource.Name.ToUpperInvariant();
            }
        }
Exemple #3
0
        public override void OnDeserialize(Student resource)
        {
            _hitCounter.TrackInvocation <Student>(ResourceDefinitionHitCounter.ExtensibilityPoint.OnDeserialize);

            if (!string.IsNullOrEmpty(resource.SocialSecurityNumber))
            {
                resource.SocialSecurityNumber = _encryptionService.Decrypt(resource.SocialSecurityNumber);
            }
        }
Exemple #4
0
        public override IReadOnlyCollection <IncludeElementExpression> OnApplyIncludes(IReadOnlyCollection <IncludeElementExpression> existingIncludes)
        {
            _hitCounter.TrackInvocation <Planet>(ResourceDefinitionHitCounter.ExtensibilityPoint.OnApplyIncludes);

            if (_clientSettingsProvider.IsIncludePlanetMoonsBlocked &&
                existingIncludes.Any(include => include.Relationship.Property.Name == nameof(Planet.Moons)))
            {
                throw new JsonApiException(new Error(HttpStatusCode.BadRequest)
                {
                    Title = "Including moons is not permitted."
                });
            }

            return(existingIncludes);
        }
        public override Task OnPrepareWriteAsync(DomainGroup group, OperationKind operationKind, CancellationToken cancellationToken)
        {
            _hitCounter.TrackInvocation <DomainGroup>(ResourceDefinitionHitCounter.ExtensibilityPoint.OnPrepareWriteAsync);

            if (operationKind == OperationKind.CreateResource)
            {
                group.Id = Guid.NewGuid();
            }
            else if (operationKind == OperationKind.UpdateResource)
            {
                _beforeGroupName = group.Name;
            }

            return(Task.CompletedTask);
        }
Exemple #6
0
        public override Task OnPrepareWriteAsync(DomainUser user, OperationKind operationKind, CancellationToken cancellationToken)
        {
            _hitCounter.TrackInvocation <DomainUser>(ResourceDefinitionHitCounter.ExtensibilityPoint.OnPrepareWriteAsync);

            if (operationKind == OperationKind.CreateResource)
            {
                user.Id = Guid.NewGuid();
            }
            else if (operationKind == OperationKind.UpdateResource)
            {
                _beforeLoginName   = user.LoginName;
                _beforeDisplayName = user.DisplayName;
            }

            return(Task.CompletedTask);
        }
        public override SparseFieldSetExpression OnApplySparseFieldSet(SparseFieldSetExpression existingSparseFieldSet)
        {
            _hitCounter.TrackInvocation <Lyric>(ResourceDefinitionHitCounter.ExtensibilityPoint.OnApplySparseFieldSet);

            return(_lyricPermissionProvider.CanViewText
                ? base.OnApplySparseFieldSet(existingSparseFieldSet)
                : existingSparseFieldSet.Excluding <Lyric>(lyric => lyric.Text, ResourceGraph));
        }
Exemple #8
0
        public override IDictionary <string, object> GetMeta(TextLanguage resource)
        {
            _hitCounter.TrackInvocation <TextLanguage>(ResourceDefinitionHitCounter.ExtensibilityPoint.GetMeta);

            return(new Dictionary <string, object>
            {
                ["Notice"] = NoticeText
            });
        }
        public override IReadOnlyCollection <IncludeElementExpression> OnApplyIncludes(IReadOnlyCollection <IncludeElementExpression> existingIncludes)
        {
            _hitCounter.TrackInvocation <Moon>(ResourceDefinitionHitCounter.ExtensibilityPoint.OnApplyIncludes);

            if (!_clientSettingsProvider.IsMoonOrbitingPlanetAutoIncluded ||
                existingIncludes.Any(include => include.Relationship.Property.Name == nameof(Moon.OrbitsAround)))
            {
                return(existingIncludes);
            }

            RelationshipAttribute orbitsAroundRelationship =
                ResourceContext.Relationships.Single(relationship => relationship.Property.Name == nameof(Moon.OrbitsAround));

            return(new List <IncludeElementExpression>(existingIncludes)
            {
                new IncludeElementExpression(orbitsAroundRelationship)
            });
        }
        public override IDictionary <string, object> GetMeta(MusicTrack resource)
        {
            _hitCounter.TrackInvocation <MusicTrack>(ResourceDefinitionHitCounter.ExtensibilityPoint.GetMeta);

            return(new Dictionary <string, object>
            {
                ["Copyright"] = $"(C) {resource.ReleasedAt.Year}. All rights reserved."
            });
        }
Exemple #11
0
        public override IDictionary <string, object> GetMeta(SupportTicket resource)
        {
            _hitCounter.TrackInvocation <SupportTicket>(ResourceDefinitionHitCounter.ExtensibilityPoint.GetMeta);

            if (resource.Description != null && resource.Description.StartsWith("Critical:", StringComparison.Ordinal))
            {
                return(new Dictionary <string, object>
                {
                    ["hasHighPriority"] = true
                });
            }

            return(base.GetMeta(resource));
        }
Exemple #12
0
    public override IImmutableSet <IncludeElementExpression> OnApplyIncludes(IImmutableSet <IncludeElementExpression> existingIncludes)
    {
        if (ExtensibilityPointsToTrack.HasFlag(ResourceDefinitionExtensibilityPoints.OnApplyIncludes))
        {
            _hitCounter.TrackInvocation <TResource>(ResourceDefinitionExtensibilityPoints.OnApplyIncludes);
        }

        return(base.OnApplyIncludes(existingIncludes));
    }
Exemple #13
0
        public override SortExpression OnApplySort(SortExpression existingSort)
        {
            _hitCounter.TrackInvocation <Star>(ResourceDefinitionHitCounter.ExtensibilityPoint.OnApplySort);

            return(existingSort ?? GetDefaultSortOrder());
        }
        public override Task OnWritingAsync(DomainGroup group, OperationKind operationKind, CancellationToken cancellationToken)
        {
            _hitCounter.TrackInvocation <DomainGroup>(ResourceDefinitionHitCounter.ExtensibilityPoint.OnWritingAsync);

            return(FinishWriteAsync(group, operationKind, cancellationToken));
        }