Stetic.CecilClassDescriptor.FindProperty C# (CSharp) Method

FindProperty() private method

private FindProperty ( Mono.Cecil.TypeDefinition cls, string name ) : Mono.Cecil.PropertyDefinition
cls Mono.Cecil.TypeDefinition
name string
return Mono.Cecil.PropertyDefinition
        PropertyDefinition FindProperty(TypeDefinition cls, string name)
        {
            foreach (PropertyDefinition propInfo in cls.Properties)
                if (propInfo.Name == name)
                    return propInfo;

            string baseType = cls.BaseType.FullName;
            Type t = Registry.GetType (baseType, false);
            if (t != null) {
                PropertyInfo prop = t.GetProperty (name);
                if (prop != null) {
                    TypeReference tref  = new TypeReference (prop.PropertyType.Name, prop.PropertyType.Namespace, null, prop.PropertyType.IsValueType);
                    PropertyDefinition pdef = new PropertyDefinition (name, tref, (Mono.Cecil.PropertyAttributes) 0);
                    PropertyDefinition.CreateGetMethod (pdef);
                    PropertyDefinition.CreateSetMethod (pdef);
                    return pdef;
                }
            }

            TypeDefinition bcls = cecilLib.FindTypeDefinition (baseType);
            if (bcls != null)
                return FindProperty (bcls, name);
            else
                return null;
        }