当前位置: 首页>>代码示例>>C#>>正文


C# IDisposable.GetType方法代码示例

本文整理汇总了C#中IDisposable.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# IDisposable.GetType方法的具体用法?C# IDisposable.GetType怎么用?C# IDisposable.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IDisposable的用法示例。


在下文中一共展示了IDisposable.GetType方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DeterministicFinalizer

        public DeterministicFinalizer(IDisposable comObject)
        {
            var unknown = Marshal.GetIUnknownForObject(comObject);
            //TODO: GetIDispatchForObject if any interfaces are ComInterfaceType InterfaceIsDual or InterfaceIsIDispatch.
            var interfacePointers = comObject.GetType()
                .GetInterfaces()
                .Where(Marshal.IsTypeVisibleFromCom)
                .Select(@interface => Marshal.GetComInterfaceForObject(comObject, @interface))
                .ToList();
            var supportErrorInfo = wrappers.Wrap(unknown, new Guid("df0b3d60-548f-101b-8e65-08002b2bd119"), 4);
            var provideClassInfo = wrappers.Wrap(unknown, new Guid("B196B283-BAB4-101A-B69C-00AA00341D07"), 4);
            var connectionPointContainer = wrappers.Wrap(unknown, new Guid("B196B284-BAB4-101A-B69C-00AA00341D07"), 5);
            //TODO: optional (?) IConnectionPoint "B196B286-BAB4-101A-B69C-00AA00341D07" functionCount=8 (3 + 5)
            //TODO: optional (if IExpando) IDispatchEx "A6EF9860-C720-11d0-9337-00A0C90DCAA9" functionCount=15 (3 + 4 + 8)
            //TODO: optional (if IEnumerable) IEnumVARIANT "00020404-0000-0000-C000-000000000046" functionCount=7 (3 + 4)

            hooks.Add(new CcwHook(comObject, unknown, wrappers));
            foreach (var interfacePointer in interfacePointers)
                hooks.Add(new CcwHook(comObject, interfacePointer, wrappers));
            hooks.Add(new CcwHook(comObject, supportErrorInfo, wrappers));
            hooks.Add(new CcwHook(comObject, provideClassInfo, wrappers));
            hooks.Add(new CcwHook(comObject, connectionPointContainer, wrappers));

            Marshal.Release(unknown);
            foreach (var interfacePointer in interfacePointers)
                Marshal.Release(interfacePointer);
            Marshal.Release(supportErrorInfo.Wrapper);
            Marshal.Release(provideClassInfo.Wrapper);
            Marshal.Release(connectionPointContainer.Wrapper);
        }
开发者ID:jmfb,项目名称:TestComHooks,代码行数:30,代码来源:DeterministicFinalizer.cs

示例2: getShortcutText

        private static string getShortcutText(IDisposable mi)
        {
            var t = (string)mi.GetType().InvokeMember(
                @"GetShortcutText",
                BindingFlags.InvokeMethod | BindingFlags.NonPublic | BindingFlags.Instance,
                null,
                mi,
                new object[] { });

            return t;
        }
开发者ID:iraychen,项目名称:ZetaHtmlEditControl,代码行数:11,代码来源:MyToolStripRenderer.cs

示例3: DisposeOf

		private static void DisposeOf(IDisposable disposable)
		{
			try
			{
				disposable.Dispose();
			}
			catch (ObjectDisposedException ex)
			{
				// not supposed to happen, but sometimes does
				var logger = LoggerFactory.GetCurrentClassLogger();
				var msg = string.Format("Object of type {0} raised ObjectDisposedException during disposal",
				                        disposable.GetType());
				logger.Warn(msg, ex);
			}
			catch (Exception ex)
			{
				var logger = LoggerFactory.GetCurrentClassLogger();
				var msg = string.Format("Object of type {0} raised an exception during disposal: {1}",
				                        disposable.GetType(),
				                        ex.Message);
				logger.Error(msg, ex);
			}
		}
开发者ID:matthewc-mps-aust,项目名称:quokka,代码行数:23,代码来源:DisposableExtensions.cs

示例4: SilentDispose

 public static void SilentDispose(IDisposable disposable)
 {
     if (disposable != null)
     {
         try
         {
             disposable.Dispose();
         }
         catch (Exception e)
         {
             Trace.TraceWarning("[{0}] Failed to dispose object of type [{1}]. {2}", typeof(DisposeHelper), disposable.GetType(), e);
         }
     }
 }
开发者ID:hjb417,项目名称:rabbitmq-wcf-transports,代码行数:14,代码来源:DisposeHelper.cs

示例5: Dispose

        private static void Dispose(IDisposable disposable, Boolean isDisposing)
        {
            Debug.Assert(disposable != null);

            // Dispose of the fields in each type down to, but excluding, System.Object
            Type type = disposable.GetType();
            do {
                FieldInfo[] instanceFields = type.GetFields(AllInstanceMembers);
                if (isDisposing) {
                    DisposableExtensions.ReleaseManagedResources(disposable, instanceFields);
                }
                DisposableExtensions.ReleaseUnmanagedResources(disposable, instanceFields);
            }
            while ((type = type.BaseType) != typeof(Object));

            if (isDisposing) {
                GC.SuppressFinalize(disposable);
            }
        }
开发者ID:cegreer,项目名称:Common,代码行数:19,代码来源:DisposableExtensions.cs

示例6: Start

        public void Start(string bootstrapperName, Dictionary<string, string> properties, MarshalByRefObject remoteListener)
        {
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

            //var domainSetup = AppDomain.CurrentDomain.SetupInformation;

            // TODO -- what the hell here? This is bad bad bad.
            //System.Environment.CurrentDirectory = domainSetup.ApplicationBase;

            // TODO -- need to handle exceptions gracefully here
            EventAggregator.Start((IRemoteListener) remoteListener);

            var loader = ApplicationLoaderFinder.FindLoader(bootstrapperName);
            _shutdown = loader.Load(properties);

            EventAggregator.SendMessage(new LoaderStarted
            {
                LoaderTypeName = _shutdown.GetType().FullName
            });
        }
开发者ID:kingreatwill,项目名称:fubumvc,代码行数:20,代码来源:RemoteServicesProxy.cs

示例7: Start

        public void Start(string bootstrapperName, Dictionary<string, string> properties, MarshalByRefObject remoteListener)
        {
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

            var domainSetup = AppDomain.CurrentDomain.SetupInformation;
            System.Environment.CurrentDirectory = domainSetup.ApplicationBase;

            // TODO -- need to handle exceptions gracefully here
            EventAggregator.Start((IRemoteListener) remoteListener);

            properties.Each(x => PackageRegistry.Properties[x.Key] = x.Value);

            var loader = BottleServiceApplication.FindLoader(bootstrapperName);
            _shutdown = loader.Load();

            EventAggregator.SendMessage(new LoaderStarted
            {
                LoaderTypeName = _shutdown.GetType().FullName
            });
        }
开发者ID:DarthFubuMVC,项目名称:bottles,代码行数:20,代码来源:RemoteServicesProxy.cs

示例8: Add

        public static void Add(IDisposable obj)
        {
            Debug.WriteLine(string.Format("Adding object `{0}`",
                obj.GetType().Name));

            var sb = new StringBuilder();

            // Shove the first frame and build a stack trace
            foreach (StackFrame frame in new StackTrace(true).GetFrames().Skip(1))
            {
                var method = frame.GetMethod();
                sb.Append(string.Format("> [{0}] {1} {2}",
                    method.DeclaringType != null? method.DeclaringType.FullName : "",
                    method.ToString(),
                    frame.GetFileName() == null ?
                        Environment.NewLine :
                        frame.ToString()));
            }

            _dict.Add(RuntimeHelpers.GetHashCode(obj),
                new DisposableObject(obj, sb.ToString()));
        }
开发者ID:migajek,项目名称:EyeDisposable,代码行数:22,代码来源:DisposerRegistry.cs

示例9: Remove

 public static void Remove(IDisposable obj)
 {
     Debug.WriteLine(string.Format("Removing object `{0}`",
         obj.GetType().Name));
     _dict.Remove(RuntimeHelpers.GetHashCode(obj));
 }
开发者ID:migajek,项目名称:EyeDisposable,代码行数:6,代码来源:DisposerRegistry.cs

示例10: GetNotifyIconArea

        internal static RECT GetNotifyIconArea(IDisposable notifyicon)
        {
            var field = notifyicon.GetType().GetField("id", BindingFlags.NonPublic | BindingFlags.Instance);
            var num = (int)field.GetValue(notifyicon);
            var fieldInfo = notifyicon.GetType().GetField("window", BindingFlags.NonPublic | BindingFlags.Instance);
            var window = (NativeWindow)fieldInfo.GetValue(notifyicon);
            var notifyiconidentifier2 = new NOTIFYICONIDENTIFIER { hWnd = window.Handle, uID = (uint)num };
            notifyiconidentifier2.cbSize = (uint)Marshal.SizeOf(notifyiconidentifier2);

            RECT rect;
            Shell_NotifyIconGetRect(ref notifyiconidentifier2, out rect);
            return rect;
        }
开发者ID:AdditionalPylons,项目名称:AudioSwitch,代码行数:13,代码来源:WindowPosition.cs

示例11: listBox1_SelectedIndexChanged

        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            TryCloseForm();

            if (listBox1.SelectedItem == null)
                return;

            Assembly demo = Assembly.Load(listBox1.SelectedItem.ToString());
            Type[] types = demo.GetExportedTypes();
            foreach (Type type in types)
            {
                if (type.BaseType.Name.Equals("Game"))
                {
                    game = (IDisposable)type.InvokeMember(null, BindingFlags.CreateInstance, null, null, null);

                    bool librariesOk = (bool)type.InvokeMember("TestLibraries", BindingFlags.InvokeMethod, null, game, null);
                    if (librariesOk == false)
                        return;
                    
                    new Thread(DemoThread).Start();
                    while (form == null)
                    {
                        form = (Form)game.GetType().InvokeMember("Form", BindingFlags.GetProperty, null, game, null);
                    }
                    form.HandleCreated += new EventHandler(form_HandleCreated);
                    break;
                }
            }
        }
开发者ID:WebFreak001,项目名称:BulletSharp,代码行数:29,代码来源:Form1.cs

示例12: ThrowIfDisposed

 public static void ThrowIfDisposed(IDisposable obj)
 {
     if (obj.IsDisposed) throw new ObjectDisposedException(obj.GetType().FullName);
 }
开发者ID:footprint4me,项目名称:objectpool,代码行数:4,代码来源:ExceptionHelper.cs

示例13: GetNotifyIconPosition

        private static Point GetNotifyIconPosition(IDisposable notifyicon)
        {
            var field = notifyicon.GetType().GetField("id", BindingFlags.NonPublic | BindingFlags.Instance);
            var num = (int) field.GetValue(notifyicon);
            var fieldInfo = notifyicon.GetType().GetField("window", BindingFlags.NonPublic | BindingFlags.Instance);
            var window = (NativeWindow) fieldInfo.GetValue(notifyicon);
            var notifyiconidentifier2 = new NOTIFYICONIDENTIFIER {hWnd = window.Handle, uID = (uint) num};
            notifyiconidentifier2.cbSize = (uint) Marshal.SizeOf(notifyiconidentifier2);

            RECT rect;
            Shell_NotifyIconGetRect(ref notifyiconidentifier2, out rect);
            return new Point(rect.left + (rect.right - rect.left) / 2, rect.top + (rect.bottom - rect.top) / 2);
        }
开发者ID:Vasoman,项目名称:audioswitch,代码行数:13,代码来源:WindowPosition.cs


注:本文中的IDisposable.GetType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。