Пример #1
0
        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;
        }