Exemple #1
0
        public static bool IsFieldProperty(IMemberDefinition property, IEmitter emitter)
        {
            bool isAuto = property.CustomAttributes.Any(a => a.AttributeType.FullName == "Bridge.FieldPropertyAttribute");

            if (!isAuto && emitter.AssemblyInfo.AutoPropertyToField)
            {
                return(Helpers.IsAutoPropertyOfDefinition((PropertyDefinition)property));
            }
            return(isAuto);
        }
Exemple #2
0
        public static bool IsFieldProperty(IMember propertyMember, IEmitter emitter)
        {
            if (propertyMember.ImplementedInterfaceMembers.Count > 0)
            {
                return(false);
            }

            bool isAuto = propertyMember.Attributes.Any(a => a.AttributeType.FullName == "Bridge.FieldPropertyAttribute");

            if (!isAuto && emitter.AssemblyInfo.AutoPropertyToField)
            {
                var typeDef = emitter.GetTypeDefinition(propertyMember.DeclaringType);
                var propDef = typeDef.Properties.FirstOrDefault(p => p.Name == propertyMember.Name);
                return(Helpers.IsAutoPropertyOfDefinition(propDef));
            }
            return(isAuto);
        }
Exemple #3
0
        public static bool IsFieldProperty(PropertyDeclaration property, IEmitter emitter)
        {
            ResolveResult resolveResult = emitter.Resolver.ResolveNode(property, emitter) as MemberResolveResult;

            if (resolveResult != null && ((MemberResolveResult)resolveResult).Member != null)
            {
                return(IsFieldProperty(((MemberResolveResult)resolveResult).Member, emitter));
            }

            string name  = "Bridge.FieldProperty";
            string name1 = name + "Attribute";

            foreach (var i in property.Attributes)
            {
                foreach (var j in i.Attributes)
                {
                    if (j.Type.ToString() == name || j.Type.ToString() == name1)
                    {
                        return(true);
                    }
                    resolveResult = emitter.Resolver.ResolveNode(j, emitter);
                    if (resolveResult != null && resolveResult.Type != null && resolveResult.Type.FullName == name1)
                    {
                        return(true);
                    }
                }
            }

            if (!emitter.AssemblyInfo.AutoPropertyToField)
            {
                return(false);
            }

            var typeDef = emitter.GetTypeDefinition();
            var propDef = typeDef.Properties.FirstOrDefault(p => p.Name == property.Name);

            return(Helpers.IsAutoPropertyOfDefinition(propDef));
        }