2 +++ cli_ure/source/bootstrap/managed_bootstrap.cs
4 +/*************************************************************************
10 + * last change: $Author: $ $Date: $
12 + * The Contents of this file are made available subject to the terms of
13 + * either of the following licenses
15 + * - GNU Lesser General Public License Version 2.1
16 + * - Sun Industry Standards Source License Version 1.1
18 + * Sun Microsystems Inc., October, 2000
20 + * GNU Lesser General Public License Version 2.1
21 + * =============================================
22 + * Copyright 2000 by Sun Microsystems, Inc.
23 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
25 + * This library is free software; you can redistribute it and/or
26 + * modify it under the terms of the GNU Lesser General Public
27 + * License version 2.1, as published by the Free Software Foundation.
29 + * This library is distributed in the hope that it will be useful,
30 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
31 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
32 + * Lesser General Public License for more details.
34 + * You should have received a copy of the GNU Lesser General Public
35 + * License along with this library; if not, write to the Free Software
36 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
40 + * Sun Industry Standards Source License Version 1.1
41 + * =================================================
42 + * The contents of this file are subject to the Sun Industry Standards
43 + * Source License Version 1.1 (the "License"); You may not use this file
44 + * except in compliance with the License. You may obtain a copy of the
45 + * License at http://www.openoffice.org/license.html.
47 + * Software provided under this License is provided on an "AS IS" basis,
48 + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
49 + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
50 + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
51 + * See the License for the specific provisions governing your rights and
52 + * obligations concerning the Software.
54 + * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
56 + * Copyright: 2000 by Sun Microsystems, Inc.
58 + * All Rights Reserved.
60 + * Contributor(s): _______________________________________
63 + ************************************************************************/
69 +using System.Collections;
70 +using System.Runtime.InteropServices;
72 +public class Bootstrap
74 + private Bootstrap() {}
76 + public static unoidl.com.sun.star.uno.XComponentContext
77 + defaultBootstrap_InitialComponentContext()
79 + return defaultBootstrap_InitialComponentContext(null, null);
82 + public static unoidl.com.sun.star.uno.XComponentContext
83 + defaultBootstrap_InitialComponentContext(
85 + IDictionaryEnumerator bootstrapParameters)
87 + if (bootstrapParameters != null)
89 + bootstrapParameters.Reset();
90 + while (bootstrapParameters.MoveNext())
92 + string key = (string)bootstrapParameters.Key;
93 + string value = (string)bootstrapParameters.Value;
95 + native_bootstrap_set(key, key.Length, value, value.Length);
99 + System.Console.WriteLine("Bootstrap with ini " + iniFile);
100 + // bootstrap native uno
102 + if (iniFile == null)
104 + context = native_defaultBootstrap_InitialComponentContext();
108 + context = native_defaultBootstrap_InitialComponentContext(iniFile, iniFile.Length);
111 + return (unoidl.com.sun.star.uno.XComponentContext)ExtractObject(context);
114 + public static unoidl.com.sun.star.uno.XComponentContext bootstrap()
116 + return (unoidl.com.sun.star.uno.XComponentContext)ExtractObject(native_bootstrap());
119 + static object ExtractObject(IntPtr managed)
121 + GCHandle handle = (GCHandle)managed;
122 + object ret = handle.Target;
127 + [DllImport("cli_uno_glue")]
128 + private static extern void native_bootstrap_set(
129 + [MarshalAs(UnmanagedType.LPWStr)] string key, int keyLength,
130 + [MarshalAs(UnmanagedType.LPWStr)] string value, int valueLength);
132 + [DllImport("cli_uno_glue", EntryPoint="native_defaultBootstrap_InitialComponentContext")]
133 + private static extern IntPtr native_defaultBootstrap_InitialComponentContext();
135 + [DllImport("cli_uno_glue", EntryPoint="native_defaultBootstrap_InitialComponentContext_iniFile")]
136 + private static extern IntPtr native_defaultBootstrap_InitialComponentContext(
137 + [MarshalAs(UnmanagedType.LPWStr)] string iniFile, int nameLength);
139 + [DllImport("cli_uno_glue")]
140 + private static extern IntPtr native_bootstrap();