19 using System.Collections.Generic;
21 using System.Runtime.InteropServices;
28 public static object ReleaseComObject(
object obj)
30 if (obj != null && Marshal.IsComObject(obj))
32 int count = Marshal.ReleaseComObject(obj);
33 Logger.Debug(
"ReleaseComObject: Ref count after release is {0}", count);
36 string caller =
new System.Diagnostics.StackFrame(1).GetMethod().Name;
37 Logger.Warn(
"ReleaseComObject: Caller: {0}", caller);
43 Logger.Warn(
"ReleaseComObject: Obj is null or not a COM object (@ {0})",
44 new System.Diagnostics.StackFrame(1).GetMethod().Name);
60 public static bool HasMethod(dynamic obj,
string method)
64 return obj.GetType().GetMethod(method) != null;
66 catch (
System.Reflection.AmbiguousMatchException)
70 Logger.Debug(
"HasMethod: Ambiguous match for {0}, returning true", method);
77 private static NLog.Logger Logger {
get {
return _logger.Value; } }
79 private static readonly Lazy<
NLog.Logger> _logger =
new Lazy<
NLog.Logger>(() =>
NLog.LogManager.GetCurrentClassLogger());
static bool HasMethod(dynamic obj, string method)
Tests whether a given object responds to a given method.