public DefaultImplementationForIDispatchHelper(IDispatchHelper e)
		{
			e.GetDoubleArray =
				offset =>
				{
					int offseti = (int)offset;
					int len = e.GetLength(null) - offseti;

					var a = new double[len];

					for (var i = 0; i < a.Length; i++)
					{
						uint ii = (uint)i;
						uint j = ii + offset;

						a[i] = e.GetDouble(j);
					}

					return a;
				};

			e.GetInt32Array =
				offset =>
				{
					int offseti = (int)offset;
					int len = e.GetLength(null) - offseti;
					var a = new int[len];

					for (var i = 0; i < a.Length; i++)
					{
						uint ii = (uint)i;
						uint j = ii + offset;

						a[i] = e.GetInt32(j);
					}

					return a;
				};

			e.GetStringArray =
				offset =>
				{
					int offseti = (int)offset;
					int len = e.GetLength(null) - offseti;
					var a = new string[len];

					for (var i = 0; i < a.Length; i++)
					{
						uint ii = (uint)i;
						uint j = ii + offset;

						a[i] = e.GetString(j);
					}

					return a;
				};
		}
        public DefaultImplementationForIDispatchHelper(IDispatchHelper e)
        {
            e.GetDoubleArray =
                offset =>
            {
                int offseti = (int)offset;
                int len     = e.GetLength(null) - offseti;

                var a = new double[len];

                for (var i = 0; i < a.Length; i++)
                {
                    uint ii = (uint)i;
                    uint j  = ii + offset;

                    a[i] = e.GetDouble(j);
                }

                return(a);
            };

            e.GetInt32Array =
                offset =>
            {
                int offseti = (int)offset;
                int len     = e.GetLength(null) - offseti;
                var a       = new int[len];

                for (var i = 0; i < a.Length; i++)
                {
                    uint ii = (uint)i;
                    uint j  = ii + offset;

                    a[i] = e.GetInt32(j);
                }

                return(a);
            };

            e.GetStringArray =
                offset =>
            {
                int offseti = (int)offset;
                int len     = e.GetLength(null) - offseti;
                var a       = new string[len];

                for (var i = 0; i < a.Length; i++)
                {
                    uint ii = (uint)i;
                    uint j  = ii + offset;

                    a[i] = e.GetString(j);
                }

                return(a);
            };
        }
        /// <summary>
        /// Executes a procedure inside a standard module in a VBA project
        /// </summary>
        /// <param name="name">the name of the procedure to invoke</param>
        /// <param name="args">arguments to pass to the procedure</param>
        /// <remarks>the returned object can be a COM object, and the callee is responsible for releasing it appropriately</remarks>
        /// <returns>an object representing the return value from the procedure, or null if none.</returns>
        public object StdModExecute(string name, object[] args = null)
        {
            // We search for the dispId using the real type info rather than using staticModule.GetIdsOfNames,
            // as we can then also include PRIVATE scoped procedures.
            var func = _parent.Funcs.Find(name, PROCKIND.PROCKIND_PROC);

            if (func == null)
            {
                throw new ArgumentException($"StdModExecute failed.  Couldn't find procedure named '{name}'");
            }

            var staticModule = GetStdModAccessor();

            try
            {
                return(IDispatchHelper.Invoke(staticModule, func.FuncDesc.memid, IDispatchHelper.InvokeKind.DISPATCH_METHOD, args));
            }
            finally
            {
                RdMarshal.ReleaseComObject(staticModule);
            }
        }
            public bool Dispatch(Messages e, IDispatchHelper h)
            {
                if (!DispatchTableDelegates.ContainsKey(e))
                {
                    return(false);
                }
                var hx = DispatchTableDelegates[e];

                if (hx == null)
                {
                    throw new Exception("Dispatch handler null for " + e);
                }

                if (hx(null) == null)
                {
                    return(false);
                }
                if (!DispatchTable.ContainsKey(e))
                {
                    return(false);
                }
                DispatchTable[e](h);
                return(true);
            }
 bool IEventsDispatch.DispatchInt32(int e, IDispatchHelper h)
 {
     return(Dispatch((Messages)e, h));
 }
 public bool Dispatch(Messages e, IDispatchHelper h)
 {
     if (!DispatchTableDelegates.ContainsKey(e)) return false;
     if (DispatchTableDelegates[e](null) == null) return false;
     if (!DispatchTable.ContainsKey(e)) return false;
     DispatchTable[e](h);
     return true;
 }
            public bool Dispatch(Messages e, IDispatchHelper h)
            {
                if (!DispatchTableDelegates.ContainsKey(e)) return false;
                var hx = DispatchTableDelegates[e];

                if (hx == null)
                    throw new Exception("Dispatch handler null for " + e);

                if (hx(null) == null) return false;
                if (!DispatchTable.ContainsKey(e)) return false;
                DispatchTable[e](h);
                return true;
            }