/// <summary> /// perform method as latebind call with parameters /// </summary> /// <param name="comObject">target object</param> /// <param name="name">name of method</param> /// <param name="paramsArray">array with parameters</param> public static void Method(COMObject comObject, string name, object[] paramsArray) { try { if( (Settings.EnableSafeMode) && (!comObject.EntityIsAvailable(name,SupportEntityType.Method))) throw new EntityNotSupportedException(string.Format("Method {0} is not available.", name)); comObject.InstanceType.InvokeMember(name, BindingFlags.InvokeMethod | BindingFlags.GetProperty, null, comObject.UnderlyingObject, paramsArray, Settings.ThreadCulture); } catch (Exception throwedException) { DebugConsole.WriteException(throwedException); throw new System.Runtime.InteropServices.COMException(_exceptionMessage, throwedException); } }
/// <summary> /// perform property set as latebind call /// </summary> /// <param name="comObject">target object</param> /// <param name="name">name of property</param> /// <param name="paramsArray">array with parameters</param> /// <param name="value">value to be set</param> public static void PropertySet(COMObject comObject, string name, object[] paramsArray, object value) { try { if ((Settings.EnableSafeMode) && (!comObject.EntityIsAvailable(name, SupportEntityType.Property))) throw new EntityNotSupportedException(string.Format("Property {0} is not available.", name)); object[] newParamsArray = new object[paramsArray.Length + 1]; for (int i = 0; i < paramsArray.Length; i++) newParamsArray[i] = paramsArray[i]; newParamsArray[newParamsArray.Length - 1] = value; comObject.InstanceType.InvokeMember(name, BindingFlags.SetProperty, null, comObject.UnderlyingObject, newParamsArray, Settings.ThreadCulture); } catch (Exception throwedException) { DebugConsole.WriteException(throwedException); throw new System.Runtime.InteropServices.COMException(_exceptionMessage, throwedException); } }
/// <summary> /// perform property set as latebind call /// </summary> /// <param name="comObject">target object</param> /// <param name="name">name of property</param> /// <param name="value">value array to be set</param> /// <param name="paramModifiers">array with modifiers correspond paramsArray</param> public static void PropertySet(COMObject comObject, string name, object[] value, ParameterModifier[] paramModifiers) { try { if ((Settings.EnableSafeMode) && (!comObject.EntityIsAvailable(name, SupportEntityType.Property))) throw new EntityNotSupportedException(string.Format("Property {0} is not available.", name)); comObject.InstanceType.InvokeMember(name, BindingFlags.SetProperty, null, comObject.UnderlyingObject, value, paramModifiers, Settings.ThreadCulture, null); } catch (Exception throwedException) { DebugConsole.WriteException(throwedException); throw new System.Runtime.InteropServices.COMException(_exceptionMessage, throwedException); } }
/// <summary> /// perform property get as latebind call with return value /// </summary> /// <param name="comObject">target object</param> /// <param name="name">name of property</param> /// <returns>any return value</returns> public static object PropertyGet(COMObject comObject, string name) { try { if ((Settings.EnableSafeMode) && (!comObject.EntityIsAvailable(name, SupportEntityType.Property))) throw new EntityNotSupportedException(string.Format("Property {0} is not available.", name)); object returnValue = comObject.InstanceType.InvokeMember(name, BindingFlags.GetProperty, null, comObject.UnderlyingObject, null, Settings.ThreadCulture); return returnValue; } catch (Exception throwedException) { DebugConsole.WriteException(throwedException); throw new System.Runtime.InteropServices.COMException(_exceptionMessage, throwedException); } }