public static Access Resolve(Member member)
        {
            if (member.IsAutoProperty)
            {
                var property = (PropertyMember)member;

                if (property.Set != null && !(property.Set.IsPrivate || property.Set.IsInternal))
                {
                    return(Access.Property);
                }

                return(Access.BackField);
            }

            if (member.IsProperty)
            {
                var property = (PropertyMember)member;

                if (property.Set != null && !(property.Set.IsPrivate || property.Set.IsInternal))
                {
                    return(Access.Property);
                }

                Member backingField;

                if (!property.TryGetBackingField(out backingField))
                {
                    return(Access.Property); // just use default, don't think we can do anything here
                }
                return(Access.ReadOnlyPropertyWithField(Naming.Determine(backingField.Name)));
            }

            if (member.IsMethod)
            {
                var method = (MethodMember)member;

                Member backingField;

                if (!method.TryGetBackingField(out backingField))
                {
                    return(Access.Property); // just use default, don't think we can do anything here
                }
                return(Access.Field);        // use a field because we just access methods backing fields directly
            }

            if (member.IsField)
            {
                return(Access.Field);
            }

            return(Access.Property); // just default it if we can't guess, NH will complain but oh well
        }
示例#2
0
 public void Lowercase()
 {
     Naming.Determine("alllowercase")
     .ShouldEqual(NamingStrategy.LowerCase);
 }
示例#3
0
 public void PascalcaseM()
 {
     Naming.Determine("mPascalCase")
     .ShouldEqual(NamingStrategy.PascalCaseM);
 }
示例#4
0
 public void PascalcaseUnderscore()
 {
     Naming.Determine("_PascalCase")
     .ShouldEqual(NamingStrategy.PascalCaseUnderscore);
 }
示例#5
0
 public void CamelcaseMUnderscore()
 {
     Naming.Determine("m_camelCase")
     .ShouldEqual(NamingStrategy.Unknown);
 }
示例#6
0
 public void CamelcaseUnderscore()
 {
     Naming.Determine("_camelCase")
     .ShouldEqual(NamingStrategy.CamelCaseUnderscore);
 }
示例#7
0
 public void Camelcase()
 {
     Naming.Determine("camelCase")
     .ShouldEqual(NamingStrategy.CamelCase);
 }
示例#8
0
 public void LowercaseMUnderscore()
 {
     Naming.Determine("m_alllowercase")
     .ShouldEqual(NamingStrategy.Unknown);
 }
示例#9
0
 public void LowercaseUnderscore()
 {
     Naming.Determine("_alllowercase")
     .ShouldEqual(NamingStrategy.LowerCaseUnderscore);
 }