public OverrideValueParseMap(IValueParseMap innerParseMap, params IValueParser[] overrides) { innerParseMap.ThrowIfNullArgument(nameof(innerParseMap)); overrides.ThrowIfNullArgument(nameof(overrides)); this.overrides = new IValueParser[overrides.Length]; for (int i = 0; i < overrides.Length; i++) { IValueParser parser = overrides[i]; if (parser.IsNull()) { throw new ArgumentNullException($"Encountered null value at index {i}", nameof(overrides)); } if (this.overrides.Any(x => x?.ParseType == parser.ParseType)) { throw new ArgumentException($"Attempted to register override for type {parser.ParseType} more than once", nameof(overrides)); } this.overrides[i] = parser; } this.innerParseMap = innerParseMap; }
public ValueScalarMapperBuilder(string nodeDataName, Type fieldType, IValueParseMap parseMap) { nodeDataName.ThrowIfNullArgument(nameof(nodeDataName)); fieldType.ThrowIfNullArgument(nameof(fieldType)); parseMap.ThrowIfNullArgument(nameof(parseMap)); this.nodeDataName = nodeDataName; this.fieldType = fieldType; this.parseMap = parseMap; }
public ValueListMapperBuilder(string nodeDataName, Type fieldType, IValueParseMap parseMap) { nodeDataName.ThrowIfNullArgument(nameof(nodeDataName)); fieldType.ThrowIfNullArgument(nameof(fieldType)); parseMap.ThrowIfNullArgument(nameof(parseMap)); this.nodeDataName = nodeDataName; this.parseMap = parseMap; if (fieldType.IsListType()) { elementType = fieldType.GetGenericArguments()[0]; } }
public NodeDataBuilder(NodeData nodeData, IFieldWrapper fieldWrapper, IValueParseMap defaultValueParseMap) { nodeData.ThrowIfNullArgument(nameof(nodeData)); fieldWrapper.ThrowIfNullArgument(nameof(fieldWrapper)); defaultValueParseMap.ThrowIfNullArgument(nameof(defaultValueParseMap)); this.nodeData = nodeData; this.fieldWrapper = fieldWrapper; object[] attributes = fieldWrapper.MemberInfo.GetCustomAttributes(true); if (attributes.OfType <IUseParser>().Any()) { IValueParser[] overrides = attributes.OfType <IUseParser>().Select(x => x.CreateParser()).ToArray(); valueParseMap = new OverrideValueParseMap(defaultValueParseMap, overrides); } else { valueParseMap = defaultValueParseMap; } }
public ValueParseMapWrapper(IValueParseMap map) { map.ThrowIfNullArgument(nameof(map)); this.map = map; }