Beispiel #1
0
        private void AssertExpectedValue(InjectionParameter parameter, Type expectedType, object expectedValue)
        {
            IDependencyResolverPolicy resolver = parameter.GetResolverPolicy(expectedType);
            object result = resolver.Resolve(null);

            Assert.AreEqual(expectedType, parameter.ParameterType);
            AssertExtensions.IsInstanceOfType(resolver, typeof(LiteralValueDependencyResolverPolicy));
            Assert.AreEqual(expectedValue, result);
        }
        /// <summary>
        /// Resolve object from given context.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public object Resolve(IBuilderContext context)
        {
            var uri            = (string)_uriResolver.Resolve(context);
            var resourceLoader = context.NewBuildUp <ResourceLoader>();

            if (_many)
            {
                return(resourceLoader.GetResources(uri));
            }
            return(resourceLoader.GetResource(uri));
        }
Beispiel #3
0
        public void ObjectsConverterToInjectionParametersResolveCorrectly()
        {
            List <InjectionParameterValue> values = GetParameterValues(15);

            InjectionParameter parameter = (InjectionParameter)values[0];

            Assert.AreEqual(typeof(int), parameter.ParameterType);
            IDependencyResolverPolicy policy = parameter.GetResolverPolicy(null);
            int result = (int)policy.Resolve(null);

            Assert.AreEqual(15, result);
        }
 private static string GetValue(IBuilderContext context, IDependencyResolverPolicy resolverPolicy)
 {
     return(resolverPolicy.Resolve(context).ToString());
 }
Beispiel #5
0
        private object ResolveValue(IPolicyList policies, string key)
        {
            IDependencyResolverPolicy resolver = policies.Get <IDependencyResolverPolicy>(key);

            return(resolver.Resolve(null));
        }