示例#1
0
        /// <summary>
        /// Returns true if a value for the parameter exists in the xml.
        /// </summary>
        private bool CanResolveParameterValue(ParameterInfo targetParameter, IResolver resolver)
        {
            object dummy;

            if (TryGetTargetMemberValue(targetParameter.Name, targetParameter.ParameterType, out dummy))
            {
                return(true);
            }

            if (resolver != null && resolver.CanGet(targetParameter.ParameterType))
            {
                return(true);
            }

            return(false);
        }
示例#2
0
        /// <summary>
        /// Returns true if a value for the parameter exists in the xml or is the resolver
        /// can reolve the parameter's type.
        /// </summary>
        private bool CanResolveParameterValue(ParameterInfo parameter, IResolver resolver)
        {
            object dummy;

            if (TryGetValueForInstance(parameter.Name, parameter.ParameterType, out dummy))
            {
                return(true);
            }

            if (resolver != null && resolver.CanGet(parameter.ParameterType))
            {
                return(true);
            }

            return(false);
        }
示例#3
0
 private object[] CreateConstructorArgs(
     IEnumerable <ParameterInfo> targetConstructorParameters, IResolver resolver)
 {
     return(targetConstructorParameters.Select(parameter =>
     {
         object argValue;
         if (TryGetTargetMemberValue(parameter.Name, parameter.ParameterType, out argValue))
         {
             return argValue;
         }
         if (resolver != null && resolver.CanGet(parameter.ParameterType))
         {
             return resolver.Get(parameter.ParameterType);
         }
         return parameter.HasDefaultValue ? parameter.DefaultValue : null;
     }).ToArray());
 }
示例#4
0
        private object[] CreateArgs(IEnumerable <ParameterInfo> parameters, IResolver resolver)
        {
            var argsList = new List <object>();

            foreach (var parameter in parameters)
            {
                object argValue;

                if (TryGetValueForInstance(parameter.Name, parameter.ParameterType, out argValue))
                {
                    argsList.Add(argValue);
                }
                else if (resolver != null && resolver.CanGet(parameter.ParameterType))
                {
                    argsList.Add(resolver.Get(parameter.ParameterType));
                }
                else
                {
                    argsList.Add(parameter.HasDefaultValue ? parameter.DefaultValue : null);
                }
            }

            return(argsList.ToArray());
        }
示例#5
0
 public bool CanResolve(IResolver resolver)
 {
     return(_parameters.All(p => resolver.CanGet(p) && !p.IsPrimitivish()));
 }
 public override bool CanGet(Type type)
 {
     return(base.CanGet(type) || _secondaryContainer.CanGet(type));
 }
 public bool CanResolve(IResolver resolver)
 {
     return _parameters.All(p => resolver.CanGet(p) && !p.IsPrimitivish());
 }