public GridAutoMapping(IVmPropertyMappingsFinder vmPropertyMappingsFinder, ISchemaMetaService schemaMetaService, IYuzuConfiguration config, IYuzuDeliveryImportConfiguration importConfig)
        {
            this.schemaMetaService = schemaMetaService;
            this.config            = config;
            this.importConfig      = importConfig;

            var rowMappings = vmPropertyMappingsFinder.GetMappings <vmBlock_DataRows>();

            foreach (var i in rowMappings)
            {
                var  configType   = AddConfigMapping <vmBlock_DataRows>(i.DestProperty, ConfigType.Rows);
                Type resolverType = null;

                if (i.SourceType != null)
                {
                    if (configType == null)
                    {
                        resolverType = typeof(GridRowConvertor <,>).MakeGenericType(i.SourceType, i.DestType);
                    }
                    else
                    {
                        resolverType = typeof(GridRowConvertor <, ,>).MakeGenericType(i.SourceType, i.DestType, configType);
                    }

                    AddResolverMapping(i, resolverType);
                }
            }

            var gridMappings = vmPropertyMappingsFinder.GetMappings <vmBlock_DataGrid>();

            foreach (var i in gridMappings)
            {
                var rowsConfigType = AddConfigMapping <vmBlock_DataGrid>(i.DestProperty, ConfigType.Rows);
                var colsConfigType = AddConfigMapping <vmBlock_DataGrid>(i.DestProperty, ConfigType.Cells);

                Type resolverType = null;

                if (i.SourceType != null)
                {
                    if (rowsConfigType == null && colsConfigType == null)
                    {
                        resolverType = typeof(GridRowColumnConvertor <,>).MakeGenericType(i.SourceType, i.DestType);
                    }
                    else if (colsConfigType == null)
                    {
                        resolverType = typeof(GridRowColumnConvertor <, ,>).MakeGenericType(i.SourceType, i.DestType, rowsConfigType);
                    }
                    else
                    {
                        resolverType = typeof(GridRowColumnConvertor <, , ,>).MakeGenericType(i.SourceType, i.DestType, rowsConfigType, colsConfigType);
                    }

                    AddResolverMapping(i, resolverType);
                }
            }
        }
        public GroupedConfigMappings(IStoredConfigAsService storedConfigAsService, IYuzuConfiguration config, IYuzuDeliveryImportConfiguration importConfig, IVmGetterService vmGetterService)
        {
            var groupedConfigs = storedConfigAsService.GetAll <GroupStoreContentAs>();

            foreach (var group in groupedConfigs)
            {
                var vmName            = group.Key;
                var documentTypeAlias = group.Value.DocumentTypeAlias;
                var groupSettings     = group.Value.StoreContentAs.As <GroupStoreContentAs>();

                var groupName = group.Value.StoreContentAs.GroupName;
                if (string.IsNullOrEmpty(groupName))
                {
                    groupName = importConfig.DefaultPropertyGroup;
                }

                var parentPropertyName = groupSettings.ParentPropertyName;

                var sourceType = config.CMSModels.Where(x => x.Name.ToLower() == documentTypeAlias.ToLower()).FirstOrDefault();
                var destParent = config.ViewModels.Where(x => x.Name == groupSettings.ParentPropertyType).FirstOrDefault();
                var destChild  = config.ViewModels.Where(x => x.Name == vmName).FirstOrDefault();

                if (sourceType != null && destParent != null && destChild != null)
                {
                    ManualMaps.AddGroup(sourceType, destParent, destChild, parentPropertyName, groupName);
                }
            }
        }
Exemplo n.º 3
0
 public DefaultGroupMapper(IYuzuDeliveryImportConfiguration importConfig)
 {
     this.importConfig = importConfig;
 }
Exemplo n.º 4
0
 public DefaultPropertyFactoryMapper(IYuzuDeliveryImportConfiguration importConfig, IMappingContextFactory contextFactory)
 {
     this.importConfig   = importConfig;
     this.contextFactory = contextFactory;
 }
Exemplo n.º 5
0
        public GlobalConfigMappings(IStoredConfigAsService storedConfigAsService, IYuzuConfiguration config, IYuzuDeliveryImportConfiguration importConfig, IVmHelperService vmHelperService)
        {
            var globalConfigs = storedConfigAsService.GetAll <GlobalStoreContentAs>();

            foreach (var global in globalConfigs)
            {
                var vmName = global.Key;

                var documentTypeAlias = global.Value.DocumentTypeAlias;
                if (string.IsNullOrEmpty(documentTypeAlias))
                {
                    documentTypeAlias = vmHelperService.Get(vmName).ContentType.Alias;
                }

                var groupName = global.Value.StoreContentAs.GroupName;

                var sourceType = config.CMSModels.Where(x => x.Name.ToLower() == documentTypeAlias.ToLower()).FirstOrDefault();
                var dest       = config.ViewModels.Where(x => x.Name == vmName).FirstOrDefault();

                if (sourceType != null && dest != null)
                {
                    ManualMaps.AddGlobal(sourceType, dest, groupName);
                }
            }
        }