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());
                }
            }
Exemplo n.º 2
0
        /// <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 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());
                }
            }
		/// <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>
		public void GetItemInfo(string name, ScriptInfoFlags mask, ref IntPtr pUnkItem, ref IntPtr pTypeInfo)
		{
			object item = GetItem(name);
			if (item == null)
			{
				throw new COMException(
					string.Format(Strings.Runtime_ItemNotFound, name), ComErrorCode.ElementNotFound);
			}

			if (mask.HasFlag(ScriptInfoFlags.IUnknown))
			{
				pUnkItem = Marshal.GetIDispatchForObject(item);
			}

			if (mask.HasFlag(ScriptInfoFlags.ITypeInfo))
			{
				pTypeInfo = Marshal.GetITypeInfoForType(item.GetType());
			}
		}