Пример #1
0
 public static string DefaultConvention(MemberContext context)
 {
     return context.Member.GetAttribute<XmlAttributeAttribute>()
         .MapOrDefault(x => x.AttributeName)
         .PipeWhen(x => !x.IsEmpty()) ??
            context.Member.GetAttribute<XmlElementAttribute>()
                .MapOrDefault(x => x.ElementName)
                .PipeWhen(x => !x.IsEmpty()) ??
            context.Member.PipeWhen(x => x.Type.Map(y => y.IsEnumerable && !y.IsSimpleType))
                .MapOrDefault(x => x.GetAttribute<XmlArrayAttribute>())
                .MapOrDefault(x => x.ElementName)
                .PipeWhen(x => !x.IsEmpty()) ??
            context.Member.Name;
 }
Пример #2
0
 public static string DefaultConvention(MemberContext context)
 {
     return(context.Member
            .GetAttribute <System.Xml.Serialization.XmlAttributeAttribute>()
            .MapOrDefault(x => x.AttributeName)
            .PipeWhen(x => !x.IsEmpty()) ??
            context.Member
            .GetAttribute <XmlAttributeAttribute>()
            .MapOrDefault(x => x.AttributeName)
            .PipeWhen(x => !x.IsEmpty()) ??
            context.Member.GetAttribute <XmlElementAttribute>()
            .MapOrDefault(x => x.ElementName)
            .PipeWhen(x => !x.IsEmpty()) ??
            context.Member.PipeWhen(x => x.Type.Map(y => y.IsEnumerable && !y.IsSimpleType))
            .MapOrDefault(x => x.GetAttribute <XmlArrayAttribute>())
            .MapOrDefault(x => x.ElementName)
            .PipeWhen(x => !x.IsEmpty()) ??
            context.Member.PipeWhen(x => x.Type.Map(y => y.IsEnumerable && !y.IsSimpleType))
            .MapOrDefault(x => x.GetAttribute <XmlSiblingsAttribute>())
            .MapOrDefault(x => x.ElementName)
            .PipeWhen(x => !x.IsEmpty()) ??
            context.Member.Name);
 }