示例#1
0
        public List <TProviderResource> GetAll()
        {
            var providerDefinitions = _providerFactory.All().OrderBy(p => p.ImplementationName);

            var result = new List <TProviderResource>(providerDefinitions.Count());

            foreach (var definition in providerDefinitions)
            {
                _providerFactory.SetProviderCharacteristics(definition);

                result.Add(_resourceMapper.ToResource(definition));
            }

            return(result.OrderBy(p => p.Name).ToList());
        }
示例#2
0
        protected ProviderControllerBase(IProviderFactory <TProvider, TProviderDefinition> providerFactory, string resource, ProviderResourceMapper <TProviderResource, TProviderDefinition> resourceMapper)
        {
            _providerFactory = providerFactory;
            _resourceMapper  = resourceMapper;

            SharedValidator.RuleFor(c => c.Name).NotEmpty();
            SharedValidator.RuleFor(c => c.Name).Must((v, c) => !_providerFactory.All().Any(p => p.Name == c && p.Id != v.Id)).WithMessage("Should be unique");
            SharedValidator.RuleFor(c => c.Implementation).NotEmpty();
            SharedValidator.RuleFor(c => c.ConfigContract).NotEmpty();

            PostValidator.RuleFor(c => c.Fields).NotNull();
        }
示例#3
0
        private List <TProviderResource> GetAll()
        {
            var providerDefinitions = _providerFactory.All();

            var result = new List <TProviderResource>(providerDefinitions.Count);

            foreach (var definition in providerDefinitions)
            {
                var providerResource = new TProviderResource();
                providerResource.InjectFrom(definition);
                providerResource.Fields = SchemaBuilder.ToSchema(definition.Settings);

                result.Add(providerResource);
            }

            return(result);
        }
示例#4
0
        private List <TProviderResource> GetAll()
        {
            var providerDefinitions = _providerFactory.All().OrderBy(p => p.ImplementationName);

            var result = new List <TProviderResource>(providerDefinitions.Count());

            foreach (var definition in providerDefinitions)
            {
                var providerResource = new TProviderResource();
                providerResource.InjectFrom(definition);
                providerResource.InjectFrom(_providerFactory.GetProviderCharacteristics(_providerFactory.GetInstance(definition), definition));
                providerResource.Fields = SchemaBuilder.ToSchema(definition.Settings);

                result.Add(providerResource);
            }

            return(result.OrderBy(p => p.Name).ToList());
        }
示例#5
0
        protected ProviderModuleBase(IProviderFactory <TProvider, TProviderDefinition> providerFactory, string resource)
            : base(resource)
        {
            _providerFactory = providerFactory;

            Get["schema"] = x => GetTemplates();
            Post["test"]  = x => Test(ReadResourceFromRequest());

            GetResourceAll  = GetAll;
            GetResourceById = GetProviderById;
            CreateResource  = CreateProvider;
            UpdateResource  = UpdateProvider;
            DeleteResource  = DeleteProvider;

            SharedValidator.RuleFor(c => c.Name).NotEmpty();
            SharedValidator.RuleFor(c => c.Name).Must((v, c) => !_providerFactory.All().Any(p => p.Name == c && p.Id != v.Id)).WithMessage("Should be unique");
            SharedValidator.RuleFor(c => c.Implementation).NotEmpty();
            SharedValidator.RuleFor(c => c.ConfigContract).NotEmpty();

            PostValidator.RuleFor(c => c.Fields).NotNull();
        }