Example #1
0
        void BuildFormatter(ISchemaBuilder <TSchema> builder)
        {
            try
            {
                var formatterBuilder = new DynamicEntityFormatterBuilder <TEntity, TSchema>(builder);

                if (FormatterFactory != null)
                {
                    formatterBuilder.Factory = FormatterFactory;
                }

                foreach (var specification in _specifications.Values)
                {
                    specification.Apply(formatterBuilder);
                }

                var formatter = formatterBuilder.Build();

                builder.Add(formatter);
            }
            catch (Exception exception)
            {
                throw new SchemaConfigurationException($"Failed to build entity formatter: {TypeCache<TEntity>.ShortName}", exception);
            }
        }
Example #2
0
        void BuildConverter(ISchemaBuilder <TSchema> builder)
        {
            try
            {
                var converterBuilder = new DynamicEntityConverterBuilder <TEntity, TSchema>(builder, EntitySelector);

                foreach (var specification in _specifications.Values)
                {
                    specification.Apply(converterBuilder);
                }

                var converter = converterBuilder.Build();

                builder.Add(converter);
            }
            catch (Exception exception)
            {
                throw new SchemaConfigurationException($"Failed to build entity map: {TypeCache<TEntity>.ShortName}", exception);
            }
        }
Example #3
0
        public void Apply(ISchemaBuilder <TSchema> builder)
        {
            try
            {
                var entityMapBuilder = new DynamicEntityMapBuilder <TEntity, TSchema>(builder, EntityTypeSelector);

                foreach (var specification in _specifications.Values)
                {
                    specification.Apply(entityMapBuilder);
                }

                var map = entityMapBuilder.Build();

                builder.Add(map);
            }
            catch (Exception exception)
            {
                throw new SchemaConfigurationException($"Failed to build entity map: {TypeCache<TEntity>.ShortName}", exception);
            }
        }