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(); } } } }
/// <summary> /// Generates the code for declarations (fields, methods, property) with CLR protection level <c>public</c>. /// </summary> protected virtual void GenerateCodePublicDeclarations() { foreach (MemberFieldDefinition field in _classDefinition.PublicFields) { if (!field.IsIgnored) { //if (CheckTypeMemberForGetProperty(field) == false) // AddMethodsForField(field); //else GenerateCodePropertyField(field); _codeBuilder.AppendEmptyLine(); } } foreach (MemberPropertyDefinition p in _classDefinition.GetProperties()) { if (IsPropertyAllowed(p) && (p.ProtectionLevel == ProtectionLevel.Public || (AllowSubclassing && (p.IsStatic || !p.IsVirtual)) || (AllowProtectedMembers && p.ProtectionLevel == ProtectionLevel.Protected))) { GenerateCodeProperty(EnhanceProperty(p)); _codeBuilder.Append("\n"); } } foreach (MemberMethodDefinition f in _classDefinition.PublicMethods) { if (f.IsOperatorOverload) { if (f.NativeName.EndsWith("==")) { if (!f.IsIgnored) { GenerateCodePredefinedMethods(PredefinedMethods.Equals); } _codeBuilder.AppendEmptyLine(); } else if (f.NativeName.EndsWith("=")) { if (!f.IsIgnored) { GenerateCodePredefinedMethods(PredefinedMethods.CopyTo); } _codeBuilder.AppendEmptyLine(); } } else if (f.IsDeclarableFunction) { GenerateCodeMethod(f); _codeBuilder.Append("\n"); } } if (_classDefinition.HasAttribute <IncludePredefinedMethodAttribute>()) { GenerateCodePredefinedMethods(_classDefinition.GetAttribute <IncludePredefinedMethodAttribute>().Methods); _codeBuilder.AppendEmptyLine(); } foreach (ClassDefinition cls in _interfaces) { if (cls == _classDefinition) { continue; } GenerateCodeInterfaceImplementation(cls); } }