コード例 #1
0
		public ResolutionResult Resolve(ResolutionResult source)
		{
			if (_nullSubstitute == null)
			{
				return source;
			}
			return source.Value == null
					? source.New(_nullSubstitute)
					: source;
		}
コード例 #2
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);
		}