Example #1
0
        private object GetTemplates()
        {
            var defaultDefinitions = _providerFactory.GetDefaultDefinitions().OrderBy(p => p.ImplementationName).ToList();

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

            foreach (var providerDefinition in defaultDefinitions)
            {
                var providerResource = new TProviderResource();
                MapToResource(providerResource, providerDefinition);

                var presetDefinitions = _providerFactory.GetPresetDefinitions(providerDefinition);

                providerResource.Presets = presetDefinitions.Select(v =>
                {
                    var presetResource = new TProviderResource();
                    MapToResource(presetResource, v);

                    return(presetResource as ProviderResource);
                }).ToList();

                result.Add(providerResource);
            }

            return(result);
        }
Example #2
0
        private TProviderDefinition GetDefinition(TProviderResource providerResource)
        {
            var definition = new TProviderDefinition();

            definition.InjectFrom(providerResource);

            var preset = _providerFactory.GetPresetDefinitions(definition)
                         .Where(v => v.Name == definition.Name)
                         .Select(v => v.Settings)
                         .FirstOrDefault();

            var configContract = ReflectionExtensions.CoreAssembly.FindTypeByName(definition.ConfigContract);

            definition.Settings = (IProviderConfig)SchemaBuilder.ReadFormSchema(providerResource.Fields, configContract, preset);

            Validate(definition);

            return(definition);
        }
Example #3
0
        public List <TProviderResource> GetTemplates()
        {
            var defaultDefinitions = _providerFactory.GetDefaultDefinitions().OrderBy(p => p.ImplementationName).ToList();

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

            foreach (var providerDefinition in defaultDefinitions)
            {
                var providerResource  = _resourceMapper.ToResource(providerDefinition);
                var presetDefinitions = _providerFactory.GetPresetDefinitions(providerDefinition);

                providerResource.Presets = presetDefinitions
                                           .Select(v => _resourceMapper.ToResource(v))
                                           .ToList();

                result.Add(providerResource);
            }

            return(result);
        }