protected virtual void AddPublicDeclarations() { foreach (DefField field in _t.PublicFields) { if (!field.IsIgnored) { //if (CheckTypeMemberForGetProperty(field) == false) // AddMethodsForField(field); //else AddPropertyField(field); _sb.AppendLine(); } } foreach (DefProperty p in _t.GetProperties()) { if (AllowProperty(p) && (p.Function.ProtectionType == ProtectionType.Public || (AllowSubclassing && (p.Function.IsStatic || !p.Function.IsVirtual)) || (AllowProtectedMembers && p.Function.ProtectionType == ProtectionType.Protected))) { AddProperty(EnhanceProperty(p)); _sb.Append("\n"); } } foreach (DefFunction f in _t.PublicMethods) { if (f.IsOperatorOverload) { if (f.Name.EndsWith("==")) { AddPredefinedMethods(PredefinedMethods.Equals); _sb.AppendLine(); } else if (f.Name.EndsWith("=")) { AddPredefinedMethods(PredefinedMethods.CopyTo); _sb.AppendLine(); } } else if (f.IsDeclarableFunction) { AddMethod(f); _sb.Append("\n"); } } if (_t.HasAttribute <IncludePredefinedMethodAttribute>()) { AddPredefinedMethods(_t.GetAttribute <IncludePredefinedMethodAttribute>().Methods); _sb.AppendLine(); } foreach (DefClass cls in _interfaces) { if (cls == _t) { continue; } AddInterfaceImplementation(cls); } }
protected virtual void AddInterfaceImplementation(DefClass iface) { _sb.AppendLine("//------------------------------------------------------------"); _sb.AppendLine("// Implementation for " + iface.CLRName); _sb.AppendLine("//------------------------------------------------------------\n"); foreach (DefProperty ip in iface.GetProperties()) { DefFunction inf = ip.Function; if (inf.IsStatic) { continue; } if (inf.ProtectionType == ProtectionType.Public || (AllowSubclassing && !inf.IsVirtual) || (AllowProtectedMembers && inf.ProtectionType == ProtectionType.Protected)) { if (!_t.ContainsFunctionSignature(inf.Signature, true)) { AddInterfaceProperty(ip); _sb.Append("\n"); } } } foreach (DefFunction inf in iface.DeclarableMethods) { if (inf.IsStatic) { continue; } if (inf.ProtectionType == ProtectionType.Public || (AllowSubclassing && !inf.IsVirtual) || (AllowProtectedMembers && inf.ProtectionType == ProtectionType.Protected)) { if (!_t.ContainsFunctionSignature(inf.Signature, false)) { AddInterfaceMethod(inf); _sb.Append("\n"); } } } foreach (DefField field in iface.Fields) { if (!field.HasAttribute <IgnoreAttribute>()) { if (field.IsStatic) { continue; } if (field.ProtectionType == ProtectionType.Public || AllowSubclassing || (AllowProtectedMembers && field.ProtectionType == ProtectionType.Protected)) { //if (CheckTypeMemberForGetProperty(field) == false) // AddInterfaceMethodsForField(field); //else AddInterfacePropertyField(field); _sb.AppendLine(); } } } }
protected virtual void AddInterfaceImplementation(DefClass iface) { _sb.AppendLine("//------------------------------------------------------------"); _sb.AppendLine("// Implementation for " + iface.CLRName); _sb.AppendLine("//------------------------------------------------------------\n"); foreach (DefProperty ip in iface.GetProperties()) { DefFunction inf = ip.Function; if (inf.IsStatic) continue; if (inf.ProtectionType == ProtectionType.Public || (AllowSubclassing && !inf.IsVirtual) || (AllowProtectedMembers && inf.ProtectionType == ProtectionType.Protected)) { if (!_t.ContainsFunctionSignature(inf.Signature, true)) { AddInterfaceProperty(ip); _sb.Append("\n"); } } } foreach (DefFunction inf in iface.DeclarableMethods) { if (inf.IsStatic) continue; if (inf.ProtectionType == ProtectionType.Public || (AllowSubclassing && !inf.IsVirtual) || (AllowProtectedMembers && inf.ProtectionType == ProtectionType.Protected)) { if (!_t.ContainsFunctionSignature(inf.Signature, false)) { AddInterfaceMethod(inf); _sb.Append("\n"); } } } foreach (DefField field in iface.Fields) { if (!field.HasAttribute<IgnoreAttribute>()) { if (field.IsStatic) continue; if (field.ProtectionType == ProtectionType.Public || AllowSubclassing || (AllowProtectedMembers && field.ProtectionType == ProtectionType.Protected)) { //if (CheckTypeMemberForGetProperty(field) == false) // AddInterfaceMethodsForField(field); //else AddInterfacePropertyField(field); _sb.AppendLine(); } } } }