Пример #1
0
 private IProductScope GetProduct(ProductType productType)
 {
     if (_productGetters == null)
     {
         _productGetters = ProductType
                           .GetAll <ProductType>()
                           .Select(pt => new
         {
             ProductType = pt,
             Getter      = pt.Selector.ToGetter()
         })
                           .ToDictionary(x => x.ProductType, x => x.Getter);
     }
     return(_productGetters[productType](this));
 }
Пример #2
0
 private void SetProduct(ProductType productType, IProductScope product)
 {
     if (_productSetters == null)
     {
         _productSetters = ProductType
                           .GetAll <ProductType>()
                           .Select(pt => new
         {
             ProductType = pt,
             Setter      = pt.Selector.ToSetter()
         })
                           .ToDictionary(x => x.ProductType, x => x.Setter);
     }
     _productSetters[productType](this, product);
 }
Пример #3
0
 private IProductScope NewProduct(ProductType productType)
 {
     if (_productConstructors == null)
     {
         _productConstructors = ProductType
                                .GetAll <ProductType>()
                                .Select(pt => new
         {
             ProductType = pt,
             Constructor = ExpressionUtils.CreateDefaultConstructor <IProductScope>(pt.Type)
         })
                                .ToDictionary(x => x.ProductType, x => x.Constructor);
     }
     return(_productConstructors[productType]());
 }