Пример #1
0
        public void AddProvider <TMember, TContainer, TContext> (
            Expression <Func <TContainer, TMember> > chainExpression,
            ValueProvider <TMember, TContext> valueProvider) where TContext : ValueProviderContext <TMember>
        {
            var providerKey = ChainedKey.FromExpression(chainExpression, _fastReflectionUtility);

            _valueProviderDictionary.AddValueProvider(providerKey, valueProvider);
            _containerIndexMapping[providerKey] = GetNextIndexInContainer <TContainer>();
        }
Пример #2
0
        public void AddProvider <TMember, TContainer, TMetadata, TContext> (
            Expression <Func <TContainer, TMember> > chainExpression,
            Func <BoundMetadataContext <TContainer>, TMetadata> metadataProviderFunc,
            ValueProvider <TMember, TContext> valueProvider) where TContext : ValueProviderContext <TMember>
        {
            var providerKey = ChainedKey.FromExpression(chainExpression, _fastReflectionUtility);

            _valueProviderDictionary.AddValueProvider(providerKey, valueProvider);
            _containerIndexMapping[providerKey] = GetNextIndexInContainer <TContainer>();

            //here we bend the metadata provider func to our needs :)
            _metadataProviderMapping.Add(providerKey, BendFuncToMetadata(metadataProviderFunc));
        }
Пример #3
0
        public TDependendMember Get <TDependendMember>(Expression <Func <TContainer, TDependendMember> > memberExpression)
        {
            var key = ChainedKey.FromExpression(memberExpression, FastReflection);

            if (!_objectContext.ContainsKey(key))
            {
                throw new ArgumentException(
                          "Could not find key:'" + key +
                          "' in metadata context. Have you registered the dependency before the metadata provider?");
            }

            return((TDependendMember)_objectContext[key]);
        }
Пример #4
0
 public void EnableAutoFill <TMember, TContainer> (Expression <Func <TContainer, TMember> > chainExpression)
 {
     EnableAutoFill(ChainedKey.FromExpression(chainExpression, _fastReflectionUtility));
 }