本文整理汇总了C#中NetOffice.COMObject.EntityIsAvailable方法的典型用法代码示例。如果您正苦于以下问题:C# COMObject.EntityIsAvailable方法的具体用法?C# COMObject.EntityIsAvailable怎么用?C# COMObject.EntityIsAvailable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NetOffice.COMObject
的用法示例。
在下文中一共展示了COMObject.EntityIsAvailable方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Method
/// <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(comObject.IsDisposed)
throw new InvalidComObjectException();
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(GetExceptionMessage(throwedException), throwedException);
}
}
示例2: PropertySet
/// <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 void PropertySet(COMObject comObject, string name, object[] value, ParameterModifier[] paramModifiers)
{
try
{
if (comObject.IsDisposed)
throw new ObjectDisposedException("COMObject");
if ((Settings.EnableSafeMode) && (!comObject.EntityIsAvailable(name, SupportEntityType.Property)))
throw new EntityNotSupportedException(string.Format("Property {0} is not available.", name));
bool measureStarted = Settings.PerformanceTrace.StartMeasureTime(comObject.ComponentRootName, comObject.InstanceName, name, PerformanceTrace.CallType.PropertySet);
comObject.InstanceType.InvokeMember(name, BindingFlags.SetProperty, null, comObject.UnderlyingObject, value, paramModifiers, Settings.Default.ThreadCulture, null);
if (measureStarted)
Settings.PerformanceTrace.StopMeasureTime(comObject.ComponentRootName, comObject.InstanceName, name, value);
}
catch (Exception throwedException)
{
Console.WriteException(throwedException);
throw new System.Runtime.InteropServices.COMException(GetExceptionMessage(throwedException), throwedException);
}
}
示例3: SingleMethodReturn
/// <summary>
/// Perform method as latebind call with return value
/// </summary>
/// <param name="comObject">target object</param>
/// <param name="name">name of method</param>
/// <param name="paramsArray">array with parameters</param>
/// <returns>any return value</returns>
public object SingleMethodReturn(COMObject comObject, string name, object[] paramsArray)
{
try
{
if (comObject.IsDisposed)
throw new ObjectDisposedException("COMObject");
if ((Settings.EnableSafeMode) && (!comObject.EntityIsAvailable(name, SupportEntityType.Method)))
throw new EntityNotSupportedException(string.Format("Method {0} is not available.", name));
bool measureStarted = Settings.PerformanceTrace.StartMeasureTime(comObject.ComponentRootName, comObject.InstanceName, name, PerformanceTrace.CallType.Function);
object returnValue = comObject.InstanceType.InvokeMember(name, BindingFlags.InvokeMethod | BindingFlags.GetProperty, null, comObject.UnderlyingObject, paramsArray, Settings.Default.ThreadCulture);
if (measureStarted)
Settings.PerformanceTrace.StopMeasureTime(comObject.ComponentRootName, comObject.InstanceName, name);
return returnValue;
}
catch (Exception throwedException)
{
Console.WriteException(throwedException);
throw new System.Runtime.InteropServices.COMException(GetExceptionMessage(throwedException), throwedException);
}
}
示例4: PropertySet
/// <summary>
/// perform property set as latebind call
/// </summary>
/// <param name="comObject">comobject instance</param>
/// <param name="name">name of the property</param>
/// <param name="value">new value of the property</param>
public void PropertySet(COMObject comObject, string name, object[] value)
{
try
{
if (comObject.IsDisposed)
throw new ObjectDisposedException("COMObject");
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, Settings.Default.ThreadCulture);
}
catch (Exception throwedException)
{
Console.WriteException(throwedException);
throw new System.Runtime.InteropServices.COMException(GetExceptionMessage(throwedException), throwedException);
}
}
示例5: SingleMethodReturn
/// <summary>
/// perform method as latebind call with return value
/// </summary>
/// <param name="comObject">target object</param>
/// <param name="name">name of method</param>
/// <param name="paramsArray">array with parameters</param>
/// <param name="paramModifiers">ararry with modifiers correspond paramsArray</param>
/// <returns>any return value</returns>
public object SingleMethodReturn(COMObject comObject, string name, object[] paramsArray, ParameterModifier[] paramModifiers)
{
try
{
if (comObject.IsDisposed)
throw new ObjectDisposedException("COMObject");
if ((Settings.EnableSafeMode) && (!comObject.EntityIsAvailable(name, SupportEntityType.Method)))
throw new EntityNotSupportedException(string.Format("Method {0} is not available.", name));
object returnValue = comObject.InstanceType.InvokeMember(name, BindingFlags.InvokeMethod | BindingFlags.GetProperty, null, comObject.UnderlyingObject, paramsArray, paramModifiers, Settings.Default.ThreadCulture, null);
return returnValue;
}
catch (Exception throwedException)
{
Console.WriteException(throwedException);
throw new System.Runtime.InteropServices.COMException(GetExceptionMessage(throwedException), throwedException);
}
}