public T LoadFrom(IRoot root, string attributeIdentifier)
 {
     if (ShouldRun(root, attributeIdentifier))
     {
         // TODO: We need to be more flexible and look for the desired element and then map from that level
         var cfNamespace = root.Namespaces.First();
         var returnType  = typeof(T);
         var mapping     = TargetMapping.DeriveMapping("root", "root", returnType.GetTypeInfo()) as TargetNamespaceMapping;
         //var mapper = new CodeFirstMapper();
         var mapper = serviceProvider.GetMapper2 <T>();
         var newObj = mapper.Map(mapping, cfNamespace, null);
         return(newObj as T);
     }
     return(null);
 }
        private IEnumerable <TLocal> CreateChildren <TLocal>(IDom source, TargetChildMapping mapping, CodeFirstMetadata parent)
            where TLocal : CodeFirstMetadata
        {
            var mapper         = serviceProvider.GetMapper2 <TLocal>();
            var sourceChildren = GetSourceChildren(source, mapping);
            var items          = new List <TLocal>();

            if (sourceChildren != null)
            {
                items.AddRange(mapper.MapList(mapping, sourceChildren, parent));
            }
            var newItems2 = mapper.MapFromConstructor(mapping, source, parent);

            items.AddRange(newItems2);
            return(items);
        }