/// <inheritdoc/>
            ITransformationMap <TCollection, TElement> ITransformationMap <TCollection, TElement> .Ignore(params string[] memberSelectors)
            {
                if (memberSelectors is null)
                {
                    throw new ArgumentNullException(nameof(memberSelectors));
                }

                Ignores.AddRange(memberSelectors);
                return(this);
            }
Exemplo n.º 2
0
 /// <inheritdoc/>
 ITransformationMap <TCollection, TElement> ITransformationMap <TCollection, TElement> .Ignore(params string[] memberSelectors)
 {
     Ignores.AddRange(memberSelectors);
     return(this);
 }
Exemplo n.º 3
0
        public CombinedOptions OverrideWith(IEnumerable <Attribute> attributes)
        {
            if (attributes == null)
            {
                return(this);
            }

            if (DisableOverrides)
            {
                Ignores.AddRange(attributes
                                 .Where(attr => attr is YamlIgnoreAttribute)
                                 .Select(attr => (YamlIgnoreAttribute)attr)
                                 .Where(attr => (attr.IfEquals == null) && (attr.IfEquals == null)));
                return(this);
            }

            foreach (var attr in attributes.Reverse())
            {
                var type = attr.GetType();
                if (type == typeof(YamlNameAttribute))
                {
                    Name = ((YamlNameAttribute)attr).Name;
                }
                else if (type == typeof(YamlIgnoreAttribute))
                {
                    Ignores.Add((YamlIgnoreAttribute)attr);
                }
                else if (type == typeof(YamlFormatAttribute))
                {
                    var fmt = (YamlFormatAttribute)attr;
                    if (fmt.Format != null)
                    {
                        Format = fmt.Format;
                    }
                    if (fmt.MaybeBlankLinesBefore.HasValue)
                    {
                        BlankLinesBefore = fmt.MaybeBlankLinesBefore.Value;
                    }
                    if (fmt.MaybeBlankLinesAfter.HasValue)
                    {
                        BlankLinesAfter = fmt.MaybeBlankLinesAfter.Value;
                    }
                    if (fmt.MaybeAlwaysNested.HasValue)
                    {
                        AlwaysNested = fmt.MaybeAlwaysNested.Value;
                    }
                    if (fmt.MaybeQuoted.HasValue)
                    {
                        Quoted = fmt.MaybeQuoted.Value;
                    }
                    if (fmt.MaybeDoubleQuoted.HasValue)
                    {
                        DoubleQuoted = fmt.MaybeDoubleQuoted.Value;
                    }
                    if (fmt.MaybeBlock.HasValue)
                    {
                        Block = fmt.MaybeBlock.Value;
                    }
                    if (fmt.MaybeIndentStep.HasValue)
                    {
                        IndentStep = fmt.MaybeIndentStep.Value;
                    }
                }
                else if (type == typeof(YamlCommentAttribute))
                {
                    Comments.Add((YamlCommentAttribute)attr);
                }
            }

            return(this);
        }