/// <summary>
 /// Checks whether this property is contained in the specified class or any of its base classes.
 /// </summary>
 /// <param name="clazz">the class to check</param>
 /// <param name="allowInheritedSignature">if this is <c>false</c> only the specified class will be
 /// checked for the property. Otherwise all base classes will be checked as well.</param>
 public bool IsContainedIn(ClassDefinition clazz, bool allowInBaseClass)
 {
     return(clazz.ContainsFunctionSignature(_accessorFunction.Signature, allowInBaseClass));
 }
Exemplo n.º 2
0
        protected virtual void GenerateCodeInterfaceImplementation(ClassDefinition iface)
        {
            _codeBuilder.AppendLine("//------------------------------------------------------------");
            _codeBuilder.AppendLine("// Implementation for " + iface.CLRName);
            _codeBuilder.AppendLine("//------------------------------------------------------------\n");

            foreach (MemberPropertyDefinition ip in iface.GetProperties())
            {
                if (ip.IsStatic)
                {
                    continue;
                }

                if (ip.ProtectionLevel == ProtectionLevel.Public ||
                    (AllowSubclassing && !ip.IsVirtual) ||
                    (AllowProtectedMembers && ip.ProtectionLevel == ProtectionLevel.Protected))
                {
                    if (!ip.IsContainedIn(_classDefinition, true))
                    {
                        GenerateCodeInterfaceProperty(ip);
                        _codeBuilder.Append("\n");
                    }
                }
            }

            foreach (MemberMethodDefinition inf in iface.DeclarableMethods)
            {
                if (inf.IsStatic)
                {
                    continue;
                }

                if (inf.ProtectionLevel == ProtectionLevel.Public ||
                    (AllowSubclassing && !inf.IsVirtual) ||
                    (AllowProtectedMembers && inf.ProtectionLevel == ProtectionLevel.Protected))
                {
                    if (!_classDefinition.ContainsFunctionSignature(inf.Signature, false))
                    {
                        GenerateCodeInterfaceMethod(inf);
                        _codeBuilder.Append("\n");
                    }
                }
            }

            foreach (MemberFieldDefinition field in iface.Fields)
            {
                if (!field.HasAttribute <IgnoreAttribute>())
                {
                    if (field.IsStatic)
                    {
                        continue;
                    }

                    if (field.ProtectionLevel == ProtectionLevel.Public ||
                        AllowSubclassing ||
                        (AllowProtectedMembers && field.ProtectionLevel == ProtectionLevel.Protected))
                    {
                        //if (CheckTypeMemberForGetProperty(field) == false)
                        //    AddInterfaceMethodsForField(field);
                        //else
                        GenerateCodeInterfacePropertyField(field);

                        _codeBuilder.AppendEmptyLine();
                    }
                }
            }
        }