Beispiel #1
0
        // This helper can produce a builder for types that are directly supported by Variant.
        private static SimpleArgBuilder GetSimpleArgBuilder(Type elementType, VarEnum elementVarEnum)
        {
            SimpleArgBuilder argBuilder;

            switch (elementVarEnum)
            {
            case VarEnum.VT_BSTR:
                argBuilder = new StringArgBuilder(elementType);
                break;

            case VarEnum.VT_BOOL:
                argBuilder = new BoolArgBuilder(elementType);
                break;

            case VarEnum.VT_DATE:
                argBuilder = new DateTimeArgBuilder(elementType);
                break;

            case VarEnum.VT_CY:
                argBuilder = new CurrencyArgBuilder(elementType);
                break;

            case VarEnum.VT_DISPATCH:
                argBuilder = new DispatchArgBuilder(elementType);
                break;

            case VarEnum.VT_UNKNOWN:
                argBuilder = new UnknownArgBuilder(elementType);
                break;

            case VarEnum.VT_VARIANT:
            case VarEnum.VT_ARRAY:
            case VarEnum.VT_RECORD:
                argBuilder = new VariantArgBuilder(elementType);
                break;

            case VarEnum.VT_ERROR:
                argBuilder = new ErrorArgBuilder(elementType);
                break;

            default:
                var marshalType = GetManagedMarshalType(elementVarEnum);
                if (elementType == marshalType)
                {
                    argBuilder = new SimpleArgBuilder(elementType);
                }
                else
                {
                    argBuilder = new ConvertArgBuilder(elementType, marshalType);
                }

                break;
            }

            return(argBuilder);
        }
Beispiel #2
0
        // This helper can produce a builder for types that are directly supported by Variant.
        private static SimpleArgBuilder GetSimpleArgBuilder(Type elementType, VarEnum elementVarEnum)
        {
            SimpleArgBuilder argBuilder;

            switch (elementVarEnum)
            {
                case VarEnum.VT_BSTR:
                    argBuilder = new StringArgBuilder(elementType);
                    break;
                case VarEnum.VT_BOOL:
                    argBuilder = new BoolArgBuilder(elementType);
                    break;
                case VarEnum.VT_DATE:
                    argBuilder = new DateTimeArgBuilder(elementType);
                    break;
                case VarEnum.VT_CY:
                    argBuilder = new CurrencyArgBuilder(elementType);
                    break;
                case VarEnum.VT_DISPATCH:
                    argBuilder = new DispatchArgBuilder(elementType);
                    break;
                case VarEnum.VT_UNKNOWN:
                    argBuilder = new UnknownArgBuilder(elementType);
                    break;
                case VarEnum.VT_VARIANT:
                case VarEnum.VT_ARRAY:
                case VarEnum.VT_RECORD:
                    argBuilder = new VariantArgBuilder(elementType);
                    break;
                case VarEnum.VT_ERROR:
                    argBuilder = new ErrorArgBuilder(elementType);
                    break;
                default:
                    var marshalType = GetManagedMarshalType(elementVarEnum);
                    if (elementType == marshalType)
                    {
                        argBuilder = new SimpleArgBuilder(elementType);
                    }
                    else
                    {
                        argBuilder = new ConvertArgBuilder(elementType, marshalType);
                    }
                    break;
            }

            return argBuilder;
        }