public override IntPtr GetTypeInfo(string name) { lock (SiteItems) { return(!SiteItems.ContainsKey(name) ? IntPtr.Zero : Marshal.GetITypeInfoForType(SiteItems[name].GetType())); } }
void IActiveScriptSite.GetItemInfo( string name, ScriptInfo returnMask, [Out][MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.IUnknown)] object[] item, [Out][MarshalAs(UnmanagedType.LPArray)] IntPtr[] typeInfo) { object obj = GetExposedObject(name); if (obj != null) { if (returnMask == ScriptInfo.IUnknown) { item[0] = obj; } else { typeInfo[0] = Marshal.GetITypeInfoForType(obj.GetType()); } } else { throw new ArgumentException(); } }
public override IntPtr GetTypeInfo(string name) { lock (_siteItems) { if (!_siteItems.ContainsKey(name)) { return(IntPtr.Zero); } return(Marshal.GetITypeInfoForType(_siteItems[name].GetType())); } }
static void Run() { Console.WriteLine("Calling Marshal.GetITypeInfoForType..."); // Get the ITypeInfo pointer for an Object type IntPtr pointer = Marshal.GetITypeInfoForType(typeof(object)); Console.WriteLine("Calling Marshal.Release..."); // Always call Marshal.Release to decrement the reference count. Marshal.Release(pointer); }
public void GetItemInfo(string name, ScriptInfoFlags returnMask, out object item, IntPtr typeInfo) { if (globals.TryGetValue(name, out item)) { if (typeInfo != IntPtr.Zero) { Marshal.WriteIntPtr(typeInfo, Marshal.GetITypeInfoForType(item.GetType())); } } else { throw new COMException(name + " is unknown", TYPE_E_ELEMENTNOTFOUND); } }
public void GetItemInfo(string name, ScriptInfoFlags mask, ref IntPtr pUnkItem, ref IntPtr pTypeInfo) { var item = engine.hostItemMap[name]; if (mask.HasFlag(ScriptInfoFlags.IUnknown)) { pUnkItem = Marshal.GetIDispatchForObject(item); } if (mask.HasFlag(ScriptInfoFlags.ITypeInfo)) { pTypeInfo = Marshal.GetITypeInfoForType(item.GetType()); } }
public void GetItemInfo([In, MarshalAs(UnmanagedType.BStr)] string pstrName, [In, MarshalAs(UnmanagedType.U4)] uint dwReturnMask, [Out, MarshalAs(UnmanagedType.IUnknown)] out object item, IntPtr ppti) { if (GlobalMembers.ContainsKey(pstrName)) { item = GlobalMembers[pstrName]; } else { item = null; return; } if (ppti != IntPtr.Zero) { Marshal.WriteIntPtr(ppti, Marshal.GetITypeInfoForType(item.GetType())); } }
/// <summary> /// Allows the scripting engine to obtain information about an item added with the /// IActiveScript.AddNamedItem method /// </summary> /// <param name="name">The name associated with the item, as specified in the /// IActiveScript.AddNamedItem method</param> /// <param name="mask">A bit mask specifying what information about the item should be /// returned. The scripting engine should request the minimum amount of information possible /// because some of the return parameters (for example, ITypeInfo) can take considerable /// time to load or generate</param> /// <param name="pUnkItem">A variable that receives a pointer to the IUnknown interface associated /// with the given item. The scripting engine can use the IUnknown.QueryInterface method to /// obtain the IDispatch interface for the item. This parameter receives null if mask /// does not include the ScriptInfo.IUnknown value. Also, it receives null if there is no /// object associated with the item name; this mechanism is used to create a simple class when /// the named item was added with the ScriptItem.CodeOnly flag set in the /// IActiveScript.AddNamedItem method.</param> /// <param name="pTypeInfo">A variable that receives a pointer to the ITypeInfo interface /// associated with the item. This parameter receives null if mask does not include the /// ScriptInfo.ITypeInfo value, or if type information is not available for this item. If type /// information is not available, the object cannot source events, and name binding must be /// realized with the IDispatch.GetIDsOfNames method. Note that the ITypeInfo interface /// retrieved describes the item's coclass (TKIND_COCLASS) because the object may support /// multiple interfaces and event interfaces. If the item supports the IProvideMultipleTypeInfo /// interface, the ITypeInfo interface retrieved is the same as the index zero ITypeInfo that /// would be obtained using the IProvideMultipleTypeInfo.GetInfoOfIndex method.</param> void IActiveScriptSite.GetItemInfo(string name, ScriptInfoFlags mask, ref IntPtr pUnkItem, ref IntPtr pTypeInfo) { object item = _hostItems[name]; if (item == null) { throw new COMException( string.Format(NetFrameworkStrings.Runtime_ItemNotFound, name), ComErrorCode.ElementNotFound); } if (mask.HasFlag(ScriptInfoFlags.IUnknown)) { pUnkItem = Marshal.GetIDispatchForObject(item); } if (mask.HasFlag(ScriptInfoFlags.ITypeInfo)) { pTypeInfo = Marshal.GetITypeInfoForType(item.GetType()); } }
public static IntPtr GetITypeInfo(this Type type) { return(Marshal.GetITypeInfoForType(type)); }