string IMappingEngineRunner.FormatValue(ResolutionContext context) { TypeMap contextTypeMap = context.GetContextTypeMap(); IFormatterConfiguration configuration = contextTypeMap != null ? ConfigurationProvider.GetProfileConfiguration(contextTypeMap.Profile) : ConfigurationProvider.GetProfileConfiguration(ConfigurationStore.DefaultProfileName); object valueToFormat = context.SourceValue; string formattedValue = context.SourceValue.ToNullSafeString(); var formatters = configuration.GetFormattersToApply(context); foreach (var valueFormatter in formatters) { formattedValue = valueFormatter.FormatValue(context.CreateValueContext(valueToFormat)); valueToFormat = formattedValue; } if (formattedValue == null && !((IMappingEngineRunner)this).ShouldMapSourceValueAsNull(context)) { return(string.Empty); } return(formattedValue); }
private static bool CheckTypeSpecificSkipList(IFormatterConfiguration valueFormatter, Type formatterType) { if (valueFormatter == null) { return(true); } return(!valueFormatter.GetFormatterTypesToSkip().Contains(formatterType)); }
private static bool CheckTypeSpecificSkipList(IFormatterConfiguration valueFormatter, Type formatterType) { if (valueFormatter == null) { return true; } return !valueFormatter.GetFormatterTypesToSkip().Contains(formatterType); }
public BomSelectionModel(IFormatterConfiguration formatter) { ConfigurationSectionBoms configuration = formatter.BomConfiguration; foreach (ConfigurationElementBom bom in configuration.BomCollection) { if (bom.Enabled) { _boms.Add(bom.Name, bom.DisplayName); _bomKeyList.Add(bom.Name); NumberBoms++; } } }
public BomOutput(Excel.Application excelInstance, BomInput bomInput, ConfigurationElementBom bomElement, IFormatterConfiguration formatterConfiguration) { _excelAppInstance = excelInstance; _formatterConfiguration = formatterConfiguration; _bomInput = bomInput; _bomConfig = bomElement; foreach (ConfigurationElementColumn column in bomElement.ColumnCollection) { _bomDataTable.AddColumn(new BomDataColumn(column)); } TemplateRow = new BomDataRowHolder(_bomDataTable); }
public string FormatValue(ResolutionContext context) { Type valueType = context.SourceType; object valueToFormat = context.SourceValue; IFormatterConfiguration typeSpecificFormatterConfig = null; string formattedValue = context.SourceValue.ToNullSafeString(); if (context.PropertyMap != null) { foreach (IValueFormatter formatter in context.PropertyMap.GetFormatters()) { formattedValue = formatter.FormatValue(context.CreateValueContext(valueToFormat)); valueToFormat = formattedValue; } if (_formatterConfiguration.GetTypeSpecificFormatters().TryGetValue(valueType, out typeSpecificFormatterConfig)) { if (!context.PropertyMap.FormattersToSkipContains(typeSpecificFormatterConfig.GetType())) { var typeSpecificFormatter = new ValueFormatter(typeSpecificFormatterConfig); formattedValue = typeSpecificFormatter.FormatValue(context); valueToFormat = formattedValue; } } } else if (_formatterConfiguration.GetTypeSpecificFormatters().TryGetValue(valueType, out typeSpecificFormatterConfig)) { var typeSpecificFormatter = new ValueFormatter(typeSpecificFormatterConfig); formattedValue = typeSpecificFormatter.FormatValue(context); valueToFormat = formattedValue; } foreach (IValueFormatter formatter in _formatterConfiguration.GetFormatters()) { Type formatterType = GetFormatterType(formatter); if (CheckPropertyMapSkipList(context, formatterType) && CheckTypeSpecificSkipList(typeSpecificFormatterConfig, formatterType)) { formattedValue = formatter.FormatValue(context.CreateValueContext(valueToFormat)); valueToFormat = formattedValue; } } return(formattedValue); }
string IMappingEngineRunner.FormatValue(ResolutionContext context) { TypeMap contextTypeMap = context.GetContextTypeMap(); IFormatterConfiguration configuration = contextTypeMap != null ? ConfigurationProvider.GetProfileConfiguration(contextTypeMap.Profile) : ConfigurationProvider.GetProfileConfiguration(ConfigurationStore.DefaultProfileName); var valueFormatter = new ValueFormatter(configuration); var formattedValue = valueFormatter.FormatValue(context); if (formattedValue == null && !((IMappingEngineRunner)this).ShouldMapSourceValueAsNull(context)) { return(string.Empty); } return(formattedValue); }
public BomFormatFormViewModel(IWindowManager windowManager, SimpleContainer container, IFactory <PopUpViewModel> popUpViewFactory) { this._windowManager = windowManager; this._container = container; _popUpViewModelFactory = popUpViewFactory; IFormatterConfiguration config = _container.GetInstance <IFormatterConfiguration>(); _productNumber = new ProductNumberModel(config); BomSelectionModel = new BomSelectionModel(config); Activated += (object sender, ActivationEventArgs e) => { IFormatterConfiguration configuration = _container.GetInstance <IFormatterConfiguration>(); if (configuration.FileConfiguration.RootDirectory.Length == 0) { FolderSelect(); } }; }
public ValueFormatter(IFormatterConfiguration formatterConfiguration) { _formatterConfiguration = formatterConfiguration; }
public BomFormat(IFormatterConfiguration formatterConfiguration, string selectedBom, ProductNumberModel productNumber) { this._formatterConfiguration = formatterConfiguration; this._selectedBom = selectedBom; this._productNumberModel = productNumber; }
public ValueFormatter(IFormatterConfiguration formatterConfiguration) { _formatterConfiguration = formatterConfiguration; }
public ProductNumberModel(IFormatterConfiguration configuration) { _regex = new Regex(configuration.ParsingConfiguration.ProdutRegex); }