public IFieldMapper Parse(JobParser parser, ParseState state) { var selector = state.TryGet("Select", DefaultPath, true); if (selector.StartsWith("/")) { selector = DefaultPath + selector; } var getter = parser.CompileGetter(typeof(T), selector); var name = state.TryGet("Name", DefaultName ?? SuggestName(getter.SuggestedName)); var fieldType = (FieldType)Enum.Parse(typeof(FieldType), state.TryGet("Type", "Dimension"), true); IFieldMapper mapper = new SimpleFieldMapper(state.AffixName(name), scope => SelectItem(scope).TryGet(item => getter.Getter(item, scope), getter.DefaultValue), getter.ValueType, fieldType); var labelState = state.Select("Labels"); if (labelState != null) { var labels = labelState.Keys.ToDictionary(labelState.AffixName, key => (ILabelProvider) new SitecoreFieldLabelProvider(labelState.TryGet <string>(key), parser.DefaultLanguage)); if (labels.Count > 0) { return(new LabeledFieldMapper(mapper, labels)); } } return(mapper); }
private void ApplyToAllFields(SimpleFieldMapper mappingFunction) { for (int column = 0; column < Map.ColumnCount; column++) { for (int row = 0; row < Map.RowCount; row++) { Map.Fields[column, row] = mappingFunction(column, row, Map.Fields[column, row]); } } }
public IFieldMapper Parse(JobParser parser, ParseState state) { var value = state.Require <string>("Value", true); SimpleFieldMapper mapper; long longValue; if (long.TryParse(value, out longValue)) { mapper = new SimpleFieldMapper(state.TryGet("Name", value), scope => longValue, typeof(long), FieldType.Dimension); } else { mapper = new SimpleFieldMapper(state.TryGet("Name", value), scope => value, typeof(string), FieldType.Dimension); } mapper.Hide = state.Require <bool>("Hide", false); return(mapper); }
private void ApplyToAllFields(SimpleFieldMapper mappingFunction) { for (int column = 0; column < Map.ColumnCount; column++) for (int row = 0; row < Map.RowCount; row++) Map.Fields[column, row] = mappingFunction(column, row, Map.Fields[column, row]); }