Ejemplo n.º 1
0
        public IKoraliumBuilder AddTableResolver <Resolver, T>(Action <ITableResolverBuilder <T> > options = null)
            where Resolver : TableResolver <T>
        {
            TableResolverBuilder <T> opt = new TableResolverBuilder <T>();

            options?.Invoke(opt);

            CircularDependencyHelper.CheckCircularDependency(typeof(T));
            var columns = MetadataHelper.CollectMetadata(typeof(T), typeLookup, opt.PropertyNamingPolicy);

            if (opt.TableName == null)
            {
                opt.TableName = MetadataHelper.CreateTableName(typeof(T));
            }

            var securityPolicy = MetadataHelper.GetSecurityPolicy <Resolver, T>();

            Services.AddScoped <Resolver>();

            PartitionResolver partitionResolver = null;

            if (opt.PartitionResolver != null)
            {
                partitionResolver = opt.PartitionResolver;
            }
            else
            {
                partitionResolver = new DefaultPartitionResolver();
            }

            tables.Add(new KoraliumTable(
                           opt.TableName,
                           typeof(Resolver),
                           typeof(T),
                           columns,
                           securityPolicy,
                           opt.Indicies,
                           opt.OperationsProvider,
                           partitionResolver));

            return(this);
        }