Exemple #1
0
        //
        // WriteClassSetup
        //
        public void WriteClassSetup(CodeFacet facet)
        {
            WritePragmaMark("Setup");
            WriteLine("");
            WriteLine($"+ (const char *)monoClassName{LT}");
            if (OutputFileType == OutputType.Implementation)
            {
                string name = CodeFacet.NormalizeGenericTypesInManagedIdentifier(facet.NameFromType);
                WriteLine("{");
                PushTabIndent();
                WriteLine($"return \"{facet.TypeNamespace}.{name}\";");
                PopIndent();
                WriteLine("}");
                WriteLine("");
            }

            WriteLine($"+ (const char *)monoAssemblyName{LT}");
            if (OutputFileType == OutputType.Implementation)
            {
                WriteLine("{");
                PushTabIndent();
                WriteLine($"return \"{AssemblyFacet.Name}\";");
                PopIndent();
                WriteLine("}");
            }
        }
        //
        // ManagedTypeForAssociation
        //
        // Processes the managed type so that it can act as a type
        // suitable for Obj-C type association
        //
        string ManagedTypeForAssociation(CodeFacet managedFacet)
        {
            string managedType = null;

            // if the type represents a generic type parameter then the actual
            // type argument will remain unknown until runtime.
            if (managedFacet.IsGenericParameter)
            {
                managedType = GenericTypePlaceholder;
            }
            else if (managedFacet.IsArray)
            {
                // We want System.Byte[] to associate with NSData
                if (managedFacet.Type != "System.Byte[]")
                {
                    managedType = "System.Array";
                }
            }
            else if (managedFacet.IsGenericType)
            {
                managedType = CodeFacet.NormalizeGenericTypesInManagedIdentifier(managedFacet.Type);
            }

            if (managedType == null)
            {
                if (managedFacet.IsByRef || managedFacet.IsPointer)
                {
                    managedType = managedFacet.ElementType;
                }
                else
                {
                    managedType = managedFacet.Type;
                }
            }
            return(managedType);
        }