當前位置: 首頁>>代碼示例>>C#>>正文


C# Serialization.ObjectManager類代碼示例

本文整理匯總了C#中System.Runtime.Serialization.ObjectManager的典型用法代碼示例。如果您正苦於以下問題:C# ObjectManager類的具體用法?C# ObjectManager怎麽用?C# ObjectManager使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ObjectManager類屬於System.Runtime.Serialization命名空間,在下文中一共展示了ObjectManager類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: SoapReader

		public SoapReader(SerializationBinder binder, ISurrogateSelector selector, StreamingContext context) 
		{
			_binder = binder;
			objMgr = new ObjectManager(selector, context);
			_context = context;
			_surrogateSelector = selector;
			_fieldIndices = new Hashtable();
		}
開發者ID:calumjiao,項目名稱:Mono-Class-Libraries,代碼行數:8,代碼來源:SoapReader.cs

示例2: ObjectReader

		public ObjectReader (BinaryFormatter formatter)
		{
//			_formatter = formatter;
			_surrogateSelector = formatter.SurrogateSelector;
			_context = formatter.Context;
			_binder = formatter.Binder;
			_manager = new ObjectManager (_surrogateSelector, _context);
			
			_filterLevel = formatter.FilterLevel;
		}
開發者ID:corngood,項目名稱:mono,代碼行數:10,代碼來源:ObjectReader.cs

示例3: 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

示例4: DeserializationContext

	public DeserializationContext(BinaryFormatter formatter,
		BinaryReader reader)
	{
		Formatter = formatter;
		Reader = reader;
		mTypeStore = new Hashtable();
		mAssemblyStore = new Hashtable();
		Manager = new ObjectManager(formatter.SurrogateSelector, 
										formatter.Context);
	}
開發者ID:jjenki11,項目名稱:blaze-chem-rendering,代碼行數:10,代碼來源:BinaryValueReader.cs

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: 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

示例10: 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

示例11: DecrementFixupsRemaining

 internal void DecrementFixupsRemaining(ObjectManager manager) {
     m_missingElementsRemaining--;
     
     if (RequiresValueTypeFixup) {
         UpdateDescendentDependencyChain(-1, manager);
     }
 }
開發者ID:ArildF,項目名稱:masters,代碼行數:7,代碼來源:objectmanager.cs

示例12: SetObjectValue

        [System.Security.SecurityCritical]  // auto-generated
        internal void SetObjectValue(Object obj, ObjectManager manager) {
            m_object = obj; 
            if (obj == manager.TopObject)
                m_reachable = true; 
            if (obj is TypeLoadExceptionHolder) 
                m_typeLoad = (TypeLoadExceptionHolder)obj;
 
            if (m_markForFixupWhenAvailable) {
                manager.CompleteObject(this, true);
            }
        } 
開發者ID:wsky,項目名稱:System.Runtime.Remoting,代碼行數:12,代碼來源:ObjectManager.cs

示例13: InitFullDeserialization

 private void InitFullDeserialization()
 {
     this.bFullDeserialization = true;
     this.stack = new SerStack("ObjectReader Object Stack");
     this.m_objectManager = new ObjectManager(this.m_surrogates, this.m_context, false, this.bIsCrossAppDomain);
     if (this.m_formatterConverter == null)
     {
         this.m_formatterConverter = new FormatterConverter();
     }
 }
開發者ID:pritesh-mandowara-sp,項目名稱:DecompliedDotNetLibraries,代碼行數:10,代碼來源:ObjectReader.cs

示例14: Deserialize

 internal object Deserialize(HeaderHandler handler, __BinaryParser serParser, bool fCheck, bool isCrossAppDomain, IMethodCallMessage methodCallMessage)
 {
     if (serParser == null)
     {
         throw new ArgumentNullException("serParser", Environment.GetResourceString("ArgumentNull_WithParamName", new object[] { serParser }));
     }
     this.bFullDeserialization = false;
     this.TopObject = null;
     this.topId = 0L;
     this.bMethodCall = false;
     this.bMethodReturn = false;
     this.bIsCrossAppDomain = isCrossAppDomain;
     this.bSimpleAssembly = this.formatterEnums.FEassemblyFormat == FormatterAssemblyStyle.Simple;
     if (fCheck)
     {
         CodeAccessPermission.Demand(PermissionType.SecuritySerialization);
     }
     this.handler = handler;
     if (this.bFullDeserialization)
     {
         this.m_objectManager = new ObjectManager(this.m_surrogates, this.m_context, false, this.bIsCrossAppDomain);
         this.serObjectInfoInit = new SerObjectInfoInit();
     }
     serParser.Run();
     if (this.bFullDeserialization)
     {
         this.m_objectManager.DoFixups();
     }
     if (!this.bMethodCall && !this.bMethodReturn)
     {
         if (this.TopObject == null)
         {
             throw new SerializationException(Environment.GetResourceString("Serialization_TopObject"));
         }
         if (this.HasSurrogate(this.TopObject.GetType()) && (this.topId != 0L))
         {
             this.TopObject = this.m_objectManager.GetObject(this.topId);
         }
         if (this.TopObject is IObjectReference)
         {
             this.TopObject = ((IObjectReference) this.TopObject).GetRealObject(this.m_context);
         }
     }
     if (this.bFullDeserialization)
     {
         this.m_objectManager.RaiseDeserializationEvent();
     }
     if (handler != null)
     {
         this.handlerObject = handler(this.headers);
     }
     if (this.bMethodCall)
     {
         object[] topObject = this.TopObject as object[];
         this.TopObject = this.binaryMethodCall.ReadArray(topObject, this.handlerObject);
     }
     else if (this.bMethodReturn)
     {
         object[] returnA = this.TopObject as object[];
         this.TopObject = this.binaryMethodReturn.ReadArray(returnA, methodCallMessage, this.handlerObject);
     }
     return this.TopObject;
 }
開發者ID:pritesh-mandowara-sp,項目名稱:DecompliedDotNetLibraries,代碼行數:63,代碼來源:ObjectReader.cs

示例15: FixupImpl

		protected override void FixupImpl (ObjectManager manager) {
			ObjectToBeFixed.SetMemberValue (manager, _memberName, ObjectRequired.ObjectInstance);
		}
開發者ID:calumjiao,項目名稱:Mono-Class-Libraries,代碼行數:3,代碼來源:ObjectManager.cs


注:本文中的System.Runtime.Serialization.ObjectManager類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。