private void MapToViewModelWithAttributes(IEnumerable<IPublishedContent> countryNodes, XElement relatedLinksXml, UberDocTypeViewModelWithAttribute model)
 {
     Mapper.Map(CurrentPage, model, new Dictionary<string, PropertyMapping> 
             { 
                 { 
                     "ConditionalValueMet", new PropertyMapping 
                         { 
                             SourceProperty = "heading",
                             MapIfPropertyMatches = new KeyValuePair<string, string>("isApproved", "true"),
                         } 
                 }, 
                 { 
                     "ConditionalValueNotMet", new PropertyMapping 
                         { 
                             SourceProperty = "heading",
                             MapIfPropertyMatches = new KeyValuePair<string, string>("isApproved", "0"),
                         } 
                 },
                 { 
                     "UpperCaseHeading", new PropertyMapping 
                         { 
                             SourceProperty = "heading",
                             StringValueFormatter = x => 
                             {
                                 return x.ToUpper();
                             }
                         } 
                 }, 
                 { 
                     "FormattedCreatedOnDate", new PropertyMapping 
                         { 
                             SourceProperty = "CreateDate",
                             StringValueFormatter = x => 
                             {
                                 return DateTime.Parse(x).ToString("dd MMMM, yyyy");
                             }
                         } 
                 }, 
             })
         .MapCollection(CurrentPage.Children, model.Comments)
         .MapCollection(countryNodes, model.Countries)
         .MapCollection(relatedLinksXml, model.RelatedLinks, null, "link")
         .Map(GetSingleXml(), model, new Dictionary<string, PropertyMapping> { { "SingleValueFromXml", new PropertyMapping { SourceProperty = "Day" } }, })
         .MapCollection(GetCollectionXml(), model.CollectionFromXml, null, "Month")
         .Map(GetSingleDictionary(), model, new Dictionary<string, PropertyMapping> { { "SingleValueFromDictionary", new PropertyMapping { SourceProperty = "Animal" } }, })
         .MapCollection(GetCollectionDictionary(), model.CollectionFromDictionary)
         .Map(GetSingleJson(), model, new Dictionary<string, PropertyMapping> { { "SingleValueFromJson", new PropertyMapping { SourceProperty = "Name" } }, })
         .MapCollection(GetCollectionJson(), model.CollectionFromJson)
         .Map(CurrentPage, model.SubModel);
 }
        public ActionResult UberDocTypeWithAttributeAndDiagnostics()
        {
            // Get related content
            var countryNodes = GetRelatedNodes();
            var relatedLinksXml = GetRelatedLinks();

            var sw = new Stopwatch();

            var model = new UberDocTypeViewModelWithAttribute();

            var times = 10000;

            sw.Start();
            for (int i = 0; i < times; i++)
            {
                MapToViewModelWithAttributes(countryNodes, relatedLinksXml, model);
            }

            var timeTaken = sw.ElapsedMilliseconds;
            sw.Stop();

            model.TimeTaken = string.Format("Time taken for {0} mapping operations: {1}ms", times, timeTaken);
            return CurrentTemplate(model);
        }
        public ActionResult UberDocTypeWithAttribute()
        {
            // Get related content
            var countryNodes = GetRelatedNodes();
            var relatedLinksXml = GetRelatedLinks();

            // Create view model and run mapping
            var model = new UberDocTypeViewModelWithAttribute();
            MapToViewModelWithAttributes(countryNodes, relatedLinksXml, model);

            return CurrentTemplate(model);
        }