Beispiel #1
0
        public ResolutionResult Resolve(ResolutionResult source)
        {
            if (source.Value == null)
            {
                return(source);
            }

            var valueType = source.Value.GetType();

            if (!(_sourceType.IsAssignableFrom(valueType)))
            {
                throw new ArgumentException("Expected obj to be of type " + _sourceType + " but was " + valueType);
            }

            object result;

            try
            {
                result = _propertyInfo.GetValue(source.Value, null);
            }
            catch (NullReferenceException)
            {
                result = null;
            }

            return(source.New(result));
        }
Beispiel #2
0
        public ResolutionResult ResolveValue(ResolutionContext context)
        {
            Seal();

            var result = new ResolutionResult(context);

            return(_cachedResolvers.Aggregate(result, (current, resolver) => resolver.Resolve(current)));
        }
 public ResolutionResult Resolve(ResolutionResult source)
 {
     if (_nullSubstitute == null)
     {
         return(source);
     }
     return(source.Value == null
                                 ? source.New(_nullSubstitute)
                                 : source);
 }
		public ResolutionResult Resolve(ResolutionResult source)
		{
			if (_nullSubstitute == null)
			{
				return source;
			}
			return source.Value == null
					? source.New(_nullSubstitute)
					: source;
		}
        public ResolutionResult Resolve(ResolutionResult source)
        {
            if (source.Value != null && !(source.Value is TSource))
            {
                throw new ArgumentException("Expected obj to be of type " + typeof(TSource) + " but was " + source.Value.GetType());
            }

            try
            {
                var result = _method((TSource)source.Value);

                return(source.New(result, MemberType));
            }
            catch (NullReferenceException)
            {
                return(source.New(null, MemberType));
            }
        }
Beispiel #6
0
		public ResolutionResult Resolve(ResolutionResult source)
		{
			if (source.Value == null)
				return source;

		    var valueType = source.Value.GetType();
		    if (!(_sourceType.IsAssignableFrom(valueType)))
                throw new ArgumentException("Expected obj to be of type " + _sourceType + " but was " + valueType);

			object result;
			try
			{
				result = _propertyInfo.GetValue(source.Value, null);
			}
			catch (NullReferenceException)
			{
				result = null;
			}

			return source.New(result);
		}
		public ResolutionResult Resolve(ResolutionResult source)
		{
		    var resolver = _constructor(source.Context);

		    return resolver.Resolve(source);
		}
        public ResolutionResult ResolveValue(ResolutionContext context)
        {
            var result = new ResolutionResult(context);

            return SourceResolvers.Aggregate(result, (current, resolver) => resolver.Resolve(current));
        }
        public ResolutionResult ResolveValue(ResolutionContext context)
        {
            var result = new ResolutionResult(context);

            return(SourceResolvers.Aggregate(result, (current, resolver) => resolver.Resolve(current)));
        }
        public ResolutionResult Resolve(ResolutionResult source)
        {
            var resolver = _constructor(source.Context);

            return(resolver.Resolve(source));
        }
 public TypeMap FindTypeMapFor(ResolutionResult resolutionResult, Type destinationType)
 {
     return(FindTypeMapFor(resolutionResult.Value, resolutionResult.Type, destinationType) ??
            FindTypeMapFor(resolutionResult.Value, resolutionResult.MemberType, destinationType));
 }