Beispiel #1
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="returnMask">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="item">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 returnMask
        /// 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="typeInfo">A variable that receives a pointer to the ITypeInfo interface
        /// associated with the item. This parameter receives null if returnMask 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 returnMask, out object item, out IntPtr typeInfo)
        {
            if ((returnMask & ScriptInfoFlags.IUnknown) > 0)
            {
                item = GetItem(name);
                if (item == null)
                {
                    throw new COMException(string.Format("{0} not found.", name), TYPE_E_ELEMENTNOTFOUND);
                }
            }
            else
            {
                item = null;
            }

            if ((returnMask & ScriptInfoFlags.ITypeInfo) > 0)
            {
                typeInfo = GetTypeInfo(name);
                if (typeInfo == null)
                {
                    throw new COMException(string.Format("{0} not found.", name), TYPE_E_ELEMENTNOTFOUND);
                }
            }
            else
            {
                typeInfo = IntPtr.Zero;
            }
        }
 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(string name, ScriptInfoFlags mask, ref IntPtr pUnkItem, ref IntPtr pTypeInfo)
 {
     if (mask == ScriptInfoFlags.IUnknown)
     {
         // Look up list of host objects.
         if (scriptEngine.HostObjects.ContainsKey(name))
         {
             pUnkItem = Marshal.GetIUnknownForObject(scriptEngine.HostObjects[name]);
         }
         else
         {
             object disp = scriptEngine.ActiveScript.GetScriptDispatch(name);
             pUnkItem = Marshal.GetIUnknownForObject(disp);
         }
     }
 }
Beispiel #5
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());
            }
        }
Beispiel #6
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="returnMask">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="item">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 returnMask
        /// 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="typeInfo">A variable that receives a pointer to the ITypeInfo interface
        /// associated with the item. This parameter receives null if returnMask 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 returnMask, out object item, out IntPtr typeInfo)
        {
            if ((returnMask & ScriptInfoFlags.IUnknown) > 0)
            {
                item = GetItem(name);
                if (item == null)
                {
                    throw new COMException(string.Format(Strings.Runtime_ItemNotFound, name), TYPE_ERROR_ELEMENT_NOT_FOUND);
                }
            }
            else
            {
                item = null;
            }

            if ((returnMask & ScriptInfoFlags.ITypeInfo) > 0)
            {
                typeInfo = GetTypeInfo(name);
            }
            else
            {
                typeInfo = IntPtr.Zero;
            }
        }
            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="returnMask">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="item">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 returnMask
        /// 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 returnMask 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 returnMask, out object item, out IntPtr pTypeInfo)
        {
            if ((returnMask & ScriptInfoFlags.IUnknown) > 0)
            {
                item = GetItem(name);
                if (item == null)
                {
                    throw new COMException(string.Format(Strings.Runtime_ItemNotFound, name), TYPE_ERROR_ELEMENT_NOT_FOUND);
                }
            }
            else
            {
                item = null;
            }

            if ((returnMask & ScriptInfoFlags.ITypeInfo) > 0)
            {
                pTypeInfo = GetTypeInfo(name);
            }
            else
            {
                pTypeInfo = IntPtr.Zero;
            }
        }
        /// <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="returnMask">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="item">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 returnMask
        /// 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="typeInfo">A variable that receives a pointer to the ITypeInfo interface
        /// associated with the item. This parameter receives null if returnMask 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 returnMask, out object item, out IntPtr typeInfo)
        {
            if ((returnMask & ScriptInfoFlags.IUnknown) > 0)
            {
                item = GetItem(name);
                if (item == null) throw new COMException(string.Format("{0} not found.", name), TYPE_E_ELEMENTNOTFOUND);
            }
            else
            {
                item = null;
            }

            if ((returnMask & ScriptInfoFlags.ITypeInfo) > 0)
            {
                typeInfo = GetTypeInfo(name);
                if (typeInfo == null)
                    throw new COMException(string.Format("{0} not found.", name), TYPE_E_ELEMENTNOTFOUND);
            }
            else
            {
                typeInfo = IntPtr.Zero;
            }
        }
		/// <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());
			}
		}