Mono.VisualC.Interop.CppType.ToManagedType C# (CSharp) Method

ToManagedType() public method

public ToManagedType ( ) : Type
return Type
		public Type ToManagedType ()
		{
			CppType me = this;
			Type mappedType = (from checkType in CppTypeToManagedMap
			                   where checkType (me) != null
			                   select checkType (me)).FirstOrDefault ();

			return mappedType;
		}

Usage Example

Example #1
0
    // Return the CodeDom type reference corresponding to T, or null
    public CodeTypeReference CppTypeToCodeDomType(CppType t, out bool byref)
    {
        CodeTypeReference rtype = null;

        byref = false;
        Type mtype = t.ToManagedType ();
        if (mtype != null) {
            if (mtype.IsByRef) {
                byref = true;
                mtype = mtype.GetElementType ();
            }
            return new CodeTypeReference (mtype);
        }

        if (t.Modifiers.Count > 0 && t.ElementType != CppTypes.Void && t.ElementType != CppTypes.Class)
            return null;
        switch (t.ElementType) {
        case CppTypes.Void:
            if (t.Modifiers.Count > 0) {
                if (t.Modifiers.Count == 1 && t.Modifiers [0] == CppModifiers.Pointer)
                    rtype = new CodeTypeReference (typeof (IntPtr));
                else
                    return null;
            } else {
                rtype = new CodeTypeReference (typeof (void));
            }
            break;
        case CppTypes.Bool:
            rtype = new CodeTypeReference (typeof (bool));
            break;
        case CppTypes.Int:
            rtype = new CodeTypeReference (typeof (int));
            break;
        case CppTypes.Float:
            rtype = new CodeTypeReference (typeof (float));
            break;
        case CppTypes.Double:
            rtype = new CodeTypeReference (typeof (double));
            break;
        case CppTypes.Char:
            rtype = new CodeTypeReference (typeof (char));
            break;
        case CppTypes.Class:
            // FIXME: Full name
            rtype = new CodeTypeReference (t.ElementTypeName);
            break;
        default:
            return null;
        }
        return rtype;
    }