Exemplo n.º 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));
        }
Exemplo n.º 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)
		{
			var users = (User[]) source.Value;

			var inputs = users.Select(user => Mapper.Map<User, UserInput>(user)).ToList();

			return
				new ResolutionResult(inputs);
		}
 public ResolutionResult Resolve(ResolutionResult source)
 {
     if (_nullSubstitute == null)
     {
         return source;
     }
     return source.Value == null
             ? source.New(_nullSubstitute)
             : source;
 }
            public ResolutionResult Resolve(ResolutionResult source)
            {
                // Get the parent FeatureModel
                FeatureModel parentFeatureModel = (FeatureModel)source.Context.InstanceCache.Values.Where(v => v.GetType() == typeof(FeatureModel)).First();

                // Get the Feature corresponding to the given Identifier
                string featureIdentifier = (string)source.Value;
                Feature feature = parentFeatureModel.Features.Where(f => f.Identifier == featureIdentifier).First();
                return source.New(feature);
            }
Exemplo n.º 6
0
 public ResolutionResult Resolve(ResolutionResult source)
 {
     if (_nullSubstitute == null)
     {
         return(source);
     }
     return(source.Value == null
                                 ? source.New(_nullSubstitute)
                                 : source);
 }
 public ResolutionResult Resolve(ResolutionResult source)
 {
     try
     {
         return _inner.Resolve(source);
     }
     catch (NullReferenceException)
     {
         return source.New(null, MemberType);
     }
 }
Exemplo n.º 8
0
 public ResolutionResult Resolve(ResolutionResult source)
 {
     try
     {
         return(_inner.Resolve(source));
     }
     catch (NullReferenceException)
     {
         return(source.New(null, MemberType));
     }
 }
Exemplo n.º 9
0
        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());
            }

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

            return(source.New(result, MemberType));
        }
        public ResolutionResult Resolve(ResolutionResult source)
        {
            var relationSourceEntity = source.Context.DestinationValue as TypedPersistenceEntity;
            var relationDestinationNode = source.Context.SourceValue as EntityUIModel;
            if (relationSourceEntity == null && relationDestinationNode == null) return source;

            var relationCollection = new EntityRelationCollection(relationSourceEntity);
            relationCollection.Add(new RelationById(new ContentTreeRelationType(), relationSourceEntity.Id,
                                                    relationDestinationNode.ParentId));

            return source;
        }
Exemplo n.º 11
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);

		    var result = _propertyInfo.GetValue(source.Value, null);

			return source.New(result);
		}
Exemplo n.º 12
0
        public ResolutionResult ResolveValue(ResolutionContext context)
        {
            Seal();

            var result = new ResolutionResult(context);

            foreach (var resolver in _cachedResolvers)
            {
                result = resolver.Resolve(result);
            }

            return(result);
        }
 public ResolutionResult Resolve(ResolutionResult source)
 {
     var post = source.Context.DestinationValue as Post;
     var vm = source.Context.SourceValue as PostViewModel;
     var selectedTags = vm.Tags.Split(',');
     var tagsToDelete = post.Tags.Where(t => !selectedTags.Contains(t.Name));
     var tagsToAdd = selectedTags.Where(tagName => !post.Tags.Select(tag => tag.Name).Contains(tagName))
                                 .Select(tagName => availableTags.ContainsKey(tagName)
                                                  ? availableTags[tagName]
                                                  : new Tag { Name = tagName });
     tagsToDelete.ToList().ForEach(tag => post.Tags.Remove(tag));
     tagsToAdd.ToList().ForEach(tag => post.Tags.Add(tag));
     return source.New(post.Tags);
 }
            public ResolutionResult Resolve(ResolutionResult source)
            {
                // Get the parent FeatureModel
                FeatureModel parentFeatureModel = (FeatureModel)source.Context.InstanceCache.Values.Where(v => v.GetType() == typeof(FeatureModel)).First();

                // Get the Features corresponding to the given Identifiers
                List<string> featureIdentifiers = (List<string>)source.Value;
                List<Feature> featuresList = new List<Feature>();
                for (int i = 0; i < featureIdentifiers.Count; i++)
                {
                    Feature feature = parentFeatureModel.Features.Where(f => f.Identifier == featureIdentifiers[i]).First();
                    featuresList.Add(feature);
                }
                return source.New(featuresList);
            }
Exemplo n.º 15
0
        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());
            }

            object result;

            try
            {
                result = _method((TSource)source.Value);
            }
            catch (NullReferenceException)
            {
                result = null;
            }

            return(source.New(result));
        }
Exemplo n.º 16
0
        public ResolutionResult Resolve(ResolutionResult result)
        {
            if (Mapper.Container.HasResolver(result.Context.DestinationType))
            {
                var context = result.Context.GetDataContext();
                var obj = Mapper.Container.Resolve(result.Context.DestinationType, context);
                if (obj != null)
                    context.DestinationValue = obj;
                result.ShouldIgnore = true;
            }

            if (result.Value == null)
            {
                result.ShouldIgnore = true;
                return result;
            }

            if (!result.Context.PropertyMap.CanBeSet)
                result.ShouldIgnore = true;

            return result;
        }
Exemplo n.º 17
0
 public ResolutionResult Resolve(ResolutionResult source)
 {
     var possibleRaids = Mapper.Map<IEnumerable<SelectListItem>>(_context.Set<Raid>().ToList());
     return source.New(possibleRaids, typeof(IEnumerable<SelectListItem>));
 }
Exemplo n.º 18
0
 public TypeMap ResolveTypeMap(ResolutionResult resolutionResult, Type destinationType)
 {
     return(ResolveTypeMap(resolutionResult.Value, null, resolutionResult.Type, destinationType) ??
            ResolveTypeMap(resolutionResult.Value, null, resolutionResult.MemberType, destinationType));
 }
        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)));
        }
Exemplo n.º 21
0
 public TypeMap FindTypeMapFor(ResolutionResult resolutionResult, Type destinationType)
 {
     return(FindTypeMapFor(resolutionResult.Value, null, resolutionResult.Type, destinationType) ??
            FindTypeMapFor(resolutionResult.Value, null, resolutionResult.MemberType, destinationType));
 }
Exemplo n.º 22
0
		public ResolutionResult Resolve(ResolutionResult source)
		{
			return new ResolutionResult(null);
		}
        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);
        }
Exemplo n.º 25
0
 public ResolutionResult Resolve(ResolutionResult source)
 {
     return new ResolutionResult(ResolutionContext.New(
         string.Format("the value is {0}", source.Value)));
 }