Beispiel #1
0
 public static NestedResourceConfig <TModel, TParenModel> CreateConfig <TModel, TParenModel>(
     this NestedResourceStrategy <TModel, TParenModel> strategy,
     IEntityConfig <TParenModel> parent,
     string name,
     Func <TModel> createModel)
     where TModel : class
     where TParenModel : class
 => new NestedResourceConfig <TModel, TParenModel>(strategy, parent, name, createModel);
 public NestedResourceConfig(
     NestedResourceStrategy <TModel, TParenModel> strategy,
     IEntityConfig <TParenModel> parent,
     string name,
     Func <TModel> createModel)
 {
     Strategy    = strategy;
     Name        = name;
     Parent      = parent;
     CreateModel = createModel;
 }
Beispiel #3
0
        public NestedResourceConfig(
            IEntityConfig <TParenModel> parent,
            NestedResourceStrategy <TModel, TParenModel> strategy,
            string name,
            Func <IEngine, TModel> createModel,
            IEnumerable <IEntityConfig> dependencies)
        {
            Parent        = parent;
            Strategy      = strategy;
            Name          = name;
            CreateModel   = createModel;
            _Dependencies = dependencies;

            parent.AddNested(this);
        }
Beispiel #4
0
        public NestedResourceConfig <TNestedModel, TModel> CreateNested <TNestedModel>(
            NestedResourceStrategy <TNestedModel, TModel> strategy,
            string name,
            Func <IEngine, TNestedModel> createModel = null)
            where TNestedModel : class, new()
        {
            // update dependencies
            createModel = createModel ?? (_ => new TNestedModel());
            var engine = new DependencyEngine();

            createModel(engine);
            //
            return(new NestedResourceConfig <TNestedModel, TModel>(
                       this,
                       strategy,
                       name,
                       createModel,
                       engine.Dependencies.Values));
        }