Beispiel #1
0
        public override bool TryGetBackingField(out Member field)
        {
            if (backingField != null)
            {
                field = backingField;
                return(true);
            }

            var name = Name;

            if (name.StartsWith("Get", StringComparison.InvariantCultureIgnoreCase))
            {
                name = name.Substring(3);
            }

            var reflectedField = DeclaringType.GetField(name, BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);

            reflectedField = reflectedField ?? DeclaringType.GetField("_" + name, BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
            reflectedField = reflectedField ?? DeclaringType.GetField("m_" + name, BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);

            if (reflectedField == null)
            {
                field = null;
                return(false);
            }

            field = backingField = new FieldMember(reflectedField);
            return(true);
        }
Beispiel #2
0
        public override bool TryGetBackingField(out Member field)
        {
            if (backingField != null)
            {
                field = backingField;
                return(true);
            }

            var reflectedField = DeclaringType.GetField(Name, BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);

            reflectedField = reflectedField ?? DeclaringType.GetField("_" + Name, BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
            reflectedField = reflectedField ?? DeclaringType.GetField("m_" + Name, BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);

            if (reflectedField == null)
            {
                field = null;
                return(false);
            }

            field = backingField = new FieldMember(reflectedField);
            return(true);
        }