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


C# ObjectManager.RegisterObject方法代码示例

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


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

示例1: PreserveStackTrace

        private void PreserveStackTrace(Exception exception)
        {
            var context = new StreamingContext(StreamingContextStates.CrossAppDomain);
            var objectManager = new ObjectManager(null, context);
            var serializationInfo = new SerializationInfo(exception.GetType(), new FormatterConverter());

            exception.GetObjectData(serializationInfo, context);
            objectManager.RegisterObject(exception, 1, serializationInfo);
            objectManager.DoFixups();
        }
开发者ID:rodrigoelp,项目名称:NSubstitute,代码行数:10,代码来源:RaiseEventHandler.cs

示例2: PreserveStackTrace

        /// <remarks>
        /// Credit to MvcContrib.TestHelper.AssertionException for PreserveStackTrace
        /// </remarks>
        private static void PreserveStackTrace(Exception e)
        {
            var ctx = new StreamingContext(StreamingContextStates.CrossAppDomain);
            var mgr = new ObjectManager(null, ctx);
            var si = new SerializationInfo(e.GetType(), new FormatterConverter());

            e.GetObjectData(si, ctx);
            mgr.RegisterObject(e, 1, si);
            mgr.DoFixups();
        }
开发者ID:AndyHitchman,项目名称:FluentAutomation,代码行数:13,代码来源:FluentException.cs

示例3: PreserveStackTrace

        /// <summary>Makes sure exception stack trace would not be modify on rethrow.</summary>
        public static Exception PreserveStackTrace(this Exception exception)
        {
            var streamingContext = new StreamingContext(StreamingContextStates.CrossAppDomain);
            var objectManager = new ObjectManager(null, streamingContext);
            var serializationInfo = new SerializationInfo(exception.GetType(), new FormatterConverter());

            exception.GetObjectData(serializationInfo, streamingContext);
            objectManager.RegisterObject(exception, 1, serializationInfo); // prepare for SetObjectData
            objectManager.DoFixups(); // ObjectManager calls SetObjectData
            return exception;
        }
开发者ID:artikh,项目名称:CouchDude,代码行数:12,代码来源:ExceptionUtils.cs

示例4: PreserveStackTrace

        public static void PreserveStackTrace(Exception e)
        {
            var ctx = new StreamingContext(StreamingContextStates.CrossAppDomain);
            var mgr = new ObjectManager(null, ctx);
            var si = new SerializationInfo(e.GetType(), new FormatterConverter());

            e.GetObjectData(si, ctx);
            mgr.RegisterObject(e, 1, si); // prepare for SetObjectData
            mgr.DoFixups(); // ObjectManager calls SetObjectData

            // voila, e is unmodified save for _remoteStackTraceString
        }
开发者ID:e-COS,项目名称:cspspemu,代码行数:12,代码来源:StackTraceUtils.cs

示例5: PreserveStackTrace

        public static void PreserveStackTrace(this Exception exception)
        {
            try
            {
                var context = new StreamingContext(StreamingContextStates.CrossAppDomain);
                var objectManager = new ObjectManager(null, context);
                var serializationInfo = new SerializationInfo(exception.GetType(), new FormatterConverter());

                exception.GetObjectData(serializationInfo, context);
                objectManager.RegisterObject(exception, 1, serializationInfo); // prepare for SetObjectData
                objectManager.DoFixups(); // ObjectManager calls SetObjectData
            }
            catch (Exception)
            {
                //this is a best effort. if we fail to patch the stack trace just let it go
            }
        }
开发者ID:ranji,项目名称:NServiceBus,代码行数:17,代码来源:StackTracePreserver.cs

示例6: InternalPreserveStackTrace

        private static void InternalPreserveStackTrace(Exception e)
        {
            // check if method is applicable (exception type should have the deserialization constructor)
            var bindingFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance;
            var constructor = e.GetType().GetConstructor(bindingFlags, null, new[] { typeof(SerializationInfo), typeof(StreamingContext) }, null);
            if (constructor == null)
            {
                return;
            }

            var ctx = new StreamingContext(StreamingContextStates.CrossAppDomain);
            var mgr = new ObjectManager(null, ctx);
            var si = new SerializationInfo(e.GetType(), new FormatterConverter());

            e.GetObjectData(si, ctx);
            mgr.RegisterObject(e, 1, si); // prepare for SetObjectData
            mgr.DoFixups(); // ObjectManager calls the deserialization constructor

            // voila, e is unmodified save for _remoteStackTraceString
        }
开发者ID:yallie,项目名称:zyan,代码行数:20,代码来源:ExceptionHelper.cs

示例7: PreserveStackTrace

        /// <summary>
        /// Modifies the specified exception's _remoteStackTraceString. I have no idea how this works, but it allows 
        /// for unpacking a re-throwable inner exception from a caught <see cref="TargetInvocationException"/>.
        /// Read <see cref="http://stackoverflow.com/a/2085364/6560"/> for more information.
        /// </summary>
        public static void PreserveStackTrace(this Exception exception)
        {
            try
            {
                var ctx = new StreamingContext(StreamingContextStates.CrossAppDomain);
                var mgr = new ObjectManager(null, ctx);
                var si = new SerializationInfo(exception.GetType(), new FormatterConverter());

                exception.GetObjectData(si, ctx);
                mgr.RegisterObject(exception, 1, si); // prepare for SetObjectData
                mgr.DoFixups(); // ObjectManager calls SetObjectData

                // voila, exception is unmodified save for _remoteStackTraceString
            }
            catch (Exception ex)
            {
                var message = string.Format("This exception was caught while attempting to preserve the stack trace for" +
                                            " an exception: {0} - the original exception is passed as the inner exception" +
                                            " of this exception. This is most likely caused by the absence of a proper" +
                                            " serialization constructor on an exception", ex);

                throw new ApplicationException(message, exception);
            }
        }
开发者ID:CasperTDK,项目名称:RebusSnoopRefactor,代码行数:29,代码来源:ExceptionExtensions.cs

示例8: PrepareExceptionForRethrow

        /// <summary>
        /// Causes the original strack trace of the exception to be preserved when it is rethrown
        /// </summary>
        /// <param name="ex"></param>
		private static void PrepareExceptionForRethrow(Exception ex)
		{
            var ctx = new StreamingContext(StreamingContextStates.CrossAppDomain);
            var mgr = new ObjectManager(null, ctx);
            var si = new SerializationInfo(ex.GetType(), new FormatterConverter());

            ex.GetObjectData(si, ctx);
            mgr.RegisterObject(ex, 1, si); // prepare for SetObjectData
            mgr.DoFixups(); // ObjectManager calls SetObjectData
		}
开发者ID:JohnThomson,项目名称:taglib-sharp,代码行数:14,代码来源:File.cs


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