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


C# SerializationInfo.GetValueNoThrow方法代码示例

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


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

示例1: Hash

 internal Hash(SerializationInfo info, StreamingContext context)
 {
     Dictionary<Type, byte[]> valueNoThrow = info.GetValueNoThrow("Hashes", typeof(Dictionary<Type, byte[]>)) as Dictionary<Type, byte[]>;
     if (valueNoThrow != null)
     {
         this.m_hashes = valueNoThrow;
     }
     else
     {
         this.m_hashes = new Dictionary<Type, byte[]>();
         byte[] buffer = info.GetValueNoThrow("Md5", typeof(byte[])) as byte[];
         if (buffer != null)
         {
             this.m_hashes[typeof(System.Security.Cryptography.MD5)] = buffer;
         }
         byte[] buffer2 = info.GetValueNoThrow("Sha1", typeof(byte[])) as byte[];
         if (buffer2 != null)
         {
             this.m_hashes[typeof(System.Security.Cryptography.SHA1)] = buffer2;
         }
         byte[] assemblyBytes = info.GetValueNoThrow("RawData", typeof(byte[])) as byte[];
         if (assemblyBytes != null)
         {
             this.GenerateDefaultHashes(assemblyBytes);
         }
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:27,代码来源:Hash.cs

示例2: Exception

 protected Exception(SerializationInfo info, StreamingContext context)
 {
     if (info == null)
     {
         throw new ArgumentNullException("info");
     }
     this._className = info.GetString("ClassName");
     this._message = info.GetString("Message");
     this._data = (IDictionary) info.GetValueNoThrow("Data", typeof(IDictionary));
     this._innerException = (Exception) info.GetValue("InnerException", typeof(Exception));
     this._helpURL = info.GetString("HelpURL");
     this._stackTraceString = info.GetString("StackTraceString");
     this._remoteStackTraceString = info.GetString("RemoteStackTraceString");
     this._remoteStackIndex = info.GetInt32("RemoteStackIndex");
     this._exceptionMethodString = (string) info.GetValue("ExceptionMethod", typeof(string));
     this.HResult = info.GetInt32("HResult");
     this._source = info.GetString("Source");
     if ((this._className == null) || (this.HResult == 0))
     {
         throw new SerializationException(Environment.GetResourceString("Serialization_InsufficientState"));
     }
     if (context.State == StreamingContextStates.CrossAppDomain)
     {
         this._remoteStackTraceString = this._remoteStackTraceString + this._stackTraceString;
         this._stackTraceString = null;
     }
 }
开发者ID:randomize,项目名称:VimConfig,代码行数:27,代码来源:Exception.cs

示例3: Hash

        internal Hash(SerializationInfo info, StreamingContext context)
        {
            //
            // We have three serialization formats that we might be deserializing, the Whidbey format which
            // contains hash values directly, the Whidbey format which contains a pointer to a PEImage, and
            // the v4 format which contains a dictionary of calculated hashes.
            // 
            // If we have the Whidbey version that has built in hash values, we can convert that, but we
            // cannot do anything with the PEImage format since that is a serialized pointer into another
            // runtime's VM.
            // 

            Dictionary<Type, byte[]> hashes = info.GetValueNoThrow("Hashes", typeof(Dictionary<Type, byte[]>)) as Dictionary<Type, byte[]>;
            if (hashes != null)
            {
                m_hashes = hashes;
            }
            else
            {
                // If there is no hash value dictionary, then check to see if we have the Whidbey multiple
                // hashes version of the evidence.
                m_hashes = new Dictionary<Type, byte[]>();

                byte[] md5 = info.GetValueNoThrow("Md5", typeof(byte[])) as byte[];
                if (md5 != null)
                {
                    m_hashes[typeof(MD5)] = md5;
                }

                byte[] sha1 = info.GetValueNoThrow("Sha1", typeof(byte[])) as byte[];
                if (sha1 != null)
                {
                    m_hashes[typeof(SHA1)] = sha1;
                }

                byte[] rawData = info.GetValueNoThrow("RawData", typeof(byte[])) as byte[];
                if (rawData != null)
                {
                    GenerateDefaultHashes(rawData);
                }
            }
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:42,代码来源:hash.cs

示例4: Exception

        [System.Security.SecuritySafeCritical]  // auto-generated
        protected Exception(SerializationInfo info, StreamingContext context) 
        {
            if (info==null)
                throw new ArgumentNullException("info");
            Contract.EndContractBlock();
    
            _className = info.GetString("ClassName");
            _message = info.GetString("Message");
            _data = (IDictionary)(info.GetValueNoThrow("Data",typeof(IDictionary)));
            _innerException = (Exception)(info.GetValue("InnerException",typeof(Exception)));
            _helpURL = info.GetString("HelpURL");
            _stackTraceString = info.GetString("StackTraceString");
            _remoteStackTraceString = info.GetString("RemoteStackTraceString");
            _remoteStackIndex = info.GetInt32("RemoteStackIndex");

            _exceptionMethodString = (String)(info.GetValue("ExceptionMethod",typeof(String)));
            HResult = info.GetInt32("HResult");
            _source = info.GetString("Source");
    
            // Get the WatsonBuckets that were serialized - this is particularly
            // done to support exceptions going across AD transitions.
            // 
            // We use the no throw version since we could be deserializing a pre-V4
            // exception object that may not have this entry. In such a case, we would
            // get null.
            _watsonBuckets = (Object)info.GetValueNoThrow("WatsonBuckets", typeof(byte[]));

#if FEATURE_SERIALIZATION
            _safeSerializationManager = info.GetValueNoThrow("SafeSerializationManager", typeof(SafeSerializationManager)) as SafeSerializationManager;
#endif // FEATURE_SERIALIZATION

            if (_className == null || HResult==0)
                throw new SerializationException(Environment.GetResourceString("Serialization_InsufficientState"));
            
            // If we are constructing a new exception after a cross-appdomain call...
            if (context.State == StreamingContextStates.CrossAppDomain)
            {
                // ...this new exception may get thrown.  It is logically a re-throw, but 
                //  physically a brand-new exception.  Since the stack trace is cleared 
                //  on a new exception, the "_remoteStackTraceString" is provided to 
                //  effectively import a stack trace from a "remote" exception.  So,
                //  move the _stackTraceString into the _remoteStackTraceString.  Note
                //  that if there is an existing _remoteStackTraceString, it will be 
                //  preserved at the head of the new string, so everything works as 
                //  expected.
                // Even if this exception is NOT thrown, things will still work as expected
                //  because the StackTrace property returns the concatenation of the
                //  _remoteStackTraceString and the _stackTraceString.
                _remoteStackTraceString = _remoteStackTraceString + _stackTraceString;
                _stackTraceString = null;
            }
        }
开发者ID:dasMulli,项目名称:coreclr,代码行数:53,代码来源:Exception.cs

示例5: SafeSerializationManager

 private SafeSerializationManager(SerializationInfo info, StreamingContext context)
 {
     RuntimeType valueNoThrow = info.GetValueNoThrow("CLR_SafeSerializationManager_RealType", typeof(RuntimeType)) as RuntimeType;
     if (valueNoThrow == null)
     {
         this.m_serializedStates = info.GetValue("m_serializedStates", typeof(List<object>)) as List<object>;
     }
     else
     {
         this.m_realType = valueNoThrow;
         this.m_savedSerializationInfo = info;
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:13,代码来源:SafeSerializationManager.cs

示例6: DelegateSerializationHolder

 private DelegateSerializationHolder(SerializationInfo info, StreamingContext context)
 {
     if (info == null)
     {
         throw new ArgumentNullException("info");
     }
     bool flag = true;
     try
     {
         this.m_delegateEntry = (DelegateEntry) info.GetValue("Delegate", typeof(DelegateEntry));
     }
     catch
     {
         this.m_delegateEntry = this.OldDelegateWireFormat(info, context);
         flag = false;
     }
     if (flag)
     {
         DelegateEntry delegateEntry = this.m_delegateEntry;
         int num = 0;
         while (delegateEntry != null)
         {
             if (delegateEntry.target != null)
             {
                 string target = delegateEntry.target as string;
                 if (target != null)
                 {
                     delegateEntry.target = info.GetValue(target, typeof(object));
                 }
             }
             num++;
             delegateEntry = delegateEntry.delegateEntry;
         }
         MethodInfo[] infoArray = new MethodInfo[num];
         int index = 0;
         while (index < num)
         {
             string name = "method" + index;
             infoArray[index] = (MethodInfo) info.GetValueNoThrow(name, typeof(MethodInfo));
             if (infoArray[index] == null)
             {
                 break;
             }
             index++;
         }
         if (index == num)
         {
             this.m_methods = infoArray;
         }
     }
 }
开发者ID:randomize,项目名称:VimConfig,代码行数:51,代码来源:DelegateSerializationHolder.cs

示例7: SecurityException

 protected SecurityException(SerializationInfo info, StreamingContext context) : base(info, context)
 {
     if (info == null)
     {
         throw new ArgumentNullException("info");
     }
     try
     {
         this.m_action = (SecurityAction) info.GetValue("Action", typeof(SecurityAction));
         this.m_permissionThatFailed = (string) info.GetValueNoThrow("FirstPermissionThatFailed", typeof(string));
         this.m_demanded = (string) info.GetValueNoThrow("Demanded", typeof(string));
         this.m_granted = (string) info.GetValueNoThrow("GrantedSet", typeof(string));
         this.m_refused = (string) info.GetValueNoThrow("RefusedSet", typeof(string));
         this.m_denied = (string) info.GetValueNoThrow("Denied", typeof(string));
         this.m_permitOnly = (string) info.GetValueNoThrow("PermitOnly", typeof(string));
         this.m_assemblyName = (AssemblyName) info.GetValueNoThrow("Assembly", typeof(AssemblyName));
         this.m_serializedMethodInfo = (byte[]) info.GetValueNoThrow("Method", typeof(byte[]));
         this.m_strMethodInfo = (string) info.GetValueNoThrow("Method_String", typeof(string));
         this.m_zone = (SecurityZone) info.GetValue("Zone", typeof(SecurityZone));
         this.m_url = (string) info.GetValueNoThrow("Url", typeof(string));
     }
     catch
     {
         this.m_action = (SecurityAction) 0;
         this.m_permissionThatFailed = "";
         this.m_demanded = "";
         this.m_granted = "";
         this.m_refused = "";
         this.m_denied = "";
         this.m_permitOnly = "";
         this.m_assemblyName = null;
         this.m_serializedMethodInfo = null;
         this.m_strMethodInfo = null;
         this.m_zone = SecurityZone.NoZone;
         this.m_url = "";
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:37,代码来源:SecurityException.cs

示例8: MemberInfoSerializationHolder

        internal MemberInfoSerializationHolder(SerializationInfo info, StreamingContext context) 
        {
            if (info == null)
                throw new ArgumentNullException(nameof(info));
            Contract.EndContractBlock();

            String assemblyName = info.GetString("AssemblyName");
            String typeName = info.GetString("ClassName");
            
            if (assemblyName == null || typeName == null)
                throw new SerializationException(Environment.GetResourceString("Serialization_InsufficientState"));

            Assembly assem = FormatterServices.LoadAssemblyFromString(assemblyName);
            m_reflectedType = assem.GetType(typeName, true, false) as RuntimeType;
            m_memberName = info.GetString("Name");
            m_signature = info.GetString("Signature");
            // Only v4.0 and later generates and consumes Signature2
            m_signature2 = (string)info.GetValueNoThrow("Signature2", typeof(string));
            m_memberType = (MemberTypes)info.GetInt32("MemberType");
            m_info = info;
        }
开发者ID:kouvel,项目名称:coreclr,代码行数:21,代码来源:MemberInfoSerializationHolder.cs

示例9: DeserializeDelegate

			public Delegate DeserializeDelegate (SerializationInfo info, int index)
			{
				object realTarget = null;
				if (target != null)
					realTarget = info.GetValue (target.ToString(), typeof(object));

				var key = "method" + index;
				var method = (MethodInfo)info.GetValueNoThrow (key, typeof(MethodInfo));

				Assembly dasm = Assembly.Load (assembly);
				Type dt = dasm.GetType (type);

				if (realTarget != null) {
#if !DISABLE_REMOTING
					if (RemotingServices.IsTransparentProxy (realTarget)) {
						// The call to IsInstanceOfType will force the proxy
						// to load the real type of the remote object. This is
						// needed to make sure that subsequent calls to
						// GetType() return the expected type.
						Assembly tasm = Assembly.Load (targetTypeAssembly);
						Type tt = tasm.GetType (targetTypeName);
						if (!tt.IsInstanceOfType (realTarget))
							throw new RemotingException ("Unexpected proxy type.");
					}
#endif
					return method == null ?
						Delegate.CreateDelegate (dt, realTarget, methodName) :
						Delegate.CreateDelegate (dt, realTarget, method);
				}

				if (method != null)
					return Delegate.CreateDelegate (dt, realTarget, method);

				Type tt2 = Assembly.Load (targetTypeAssembly).GetType (targetTypeName);
				return Delegate.CreateDelegate (dt, tt2, methodName);
			}
开发者ID:Profit0004,项目名称:mono,代码行数:36,代码来源:DelegateSerializationHolder.cs

示例10: SecurityException

        [System.Security.SecuritySafeCritical]  // auto-generated
        protected SecurityException(SerializationInfo info, StreamingContext context) : base (info, context)
        {
            if (info==null) 
                throw new ArgumentNullException("info");
            Contract.EndContractBlock(); 
 
            try
            { 
                m_action = (SecurityAction)info.GetValue(ActionName, typeof(SecurityAction));
                m_permissionThatFailed = (String)info.GetValueNoThrow(FirstPermissionThatFailedName, typeof(String));
                m_demanded = (String)info.GetValueNoThrow(DemandedName, typeof(String));
                m_granted = (String)info.GetValueNoThrow(GrantedSetName, typeof(String)); 
                m_refused = (String)info.GetValueNoThrow(RefusedSetName, typeof(String));
                m_denied = (String)info.GetValueNoThrow(DeniedName, typeof(String)); 
                m_permitOnly = (String)info.GetValueNoThrow(PermitOnlyName, typeof(String)); 
                m_assemblyName = (AssemblyName)info.GetValueNoThrow(Assembly_Name, typeof(AssemblyName));
                m_serializedMethodInfo = (byte[])info.GetValueNoThrow(MethodName_Serialized, typeof(byte[])); 
                m_strMethodInfo = (String)info.GetValueNoThrow(MethodName_String, typeof(String));
                m_zone = (SecurityZone)info.GetValue(ZoneName, typeof(SecurityZone));
                m_url = (String)info.GetValueNoThrow(UrlName, typeof(String));
            } 
            catch
            { 
                m_action = 0; 
                m_permissionThatFailed = "";
                m_demanded = ""; 
                m_granted = "";
                m_refused = "";
                m_denied = "";
                m_permitOnly = ""; 
                m_assemblyName = null;
                m_serializedMethodInfo = null; 
                m_strMethodInfo = null; 
                m_zone = SecurityZone.NoZone;
                m_url = ""; 
            }
        }
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:38,代码来源:SecurityException.cs

示例11: DelegateSerializationHolder

        [System.Security.SecurityCritical]  // auto-generated
        private DelegateSerializationHolder(SerializationInfo info, StreamingContext context)
        {
            if (info == null)
                throw new ArgumentNullException("info");
            Contract.EndContractBlock();
    
            bool bNewWire = true;

            try
            {
                m_delegateEntry = (DelegateEntry)info.GetValue("Delegate", typeof(DelegateEntry));
            }
            catch
            {
                // Old wire format
                m_delegateEntry = OldDelegateWireFormat(info, context);
                bNewWire = false;
            }

            if (bNewWire)
            {
                // retrieve the targets
                DelegateEntry deiter = m_delegateEntry;
                int count = 0;
                while (deiter != null)
                {
                    if (deiter.target != null)
                    {
                        string stringTarget = deiter.target as string; //need test to pass older wire format
                        if (stringTarget != null)
                            deiter.target = info.GetValue(stringTarget, typeof(Object));
                    }
                    count++;
                    deiter = deiter.delegateEntry;
                }

                // If the sender is as recent as us they'll have provided MethodInfos for each delegate. Look for these and pack
                // them into an ordered array if present.
                MethodInfo[] methods = new MethodInfo[count];
                int i;
                for (i = 0; i < count; i++)
                {
                    String methodInfoName = "method" + i;
                    methods[i] = (MethodInfo)info.GetValueNoThrow(methodInfoName, typeof(MethodInfo));
                    if (methods[i] == null)
                        break;
                }

                // If we got the info then make the array available for deserialization.
                if (i == count)
                    m_methods = methods;
            }
        }
开发者ID:jashook,项目名称:coreclr,代码行数:54,代码来源:DelegateSerializationHolder.cs

示例12: SafeSerializationManager

        private SafeSerializationManager(SerializationInfo info, StreamingContext context)
        {
            // We need to determine if we're being called to really deserialize a SafeSerializationManager,
            // or if we're being called because we've intercepted the deserialization callback for the real
            // object being deserialized.  We use the presence of the RealTypeSerializationName field in the
            // serialization info to indicate that this is the interception callback and we just need to
            // safe the info.  If that field is not present, then we should be in a real deserialization
            // construction.
            RuntimeType realType = info.GetValueNoThrow(RealTypeSerializationName, typeof(RuntimeType)) as RuntimeType;

            if (realType == null)
            {
                m_serializedStates = info.GetValue("m_serializedStates", typeof(List<object>)) as List<object>;
            }
            else
            {
                m_realType = realType;
                m_savedSerializationInfo = info;
            }
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:20,代码来源:safeserializationmanager.cs

示例13: Exception

        protected Exception(SerializationInfo info, StreamingContext context) 
        {
            if (info==null)
                throw new ArgumentNullException("info");
    
            _className = info.GetString("ClassName");
            _message = info.GetString("Message");
            _data = (IDictionary)(info.GetValueNoThrow("Data",typeof(IDictionary)));
            _innerException = (Exception)(info.GetValue("InnerException",typeof(Exception)));
            _helpURL = info.GetString("HelpURL");
            _stackTraceString = info.GetString("StackTraceString");
            _remoteStackTraceString = info.GetString("RemoteStackTraceString");
            _remoteStackIndex = info.GetInt32("RemoteStackIndex");

            _exceptionMethodString = (String)(info.GetValue("ExceptionMethod",typeof(String)));
            HResult = info.GetInt32("HResult");
            _source = info.GetString("Source");
    
            if (_className == null || HResult==0)
                throw new SerializationException(Environment.GetResourceString("Serialization_InsufficientState"));
            
            // If we are constructing a new exception after a cross-appdomain call...
            if (context.State == StreamingContextStates.CrossAppDomain)
            {
                // ...this new exception may get thrown.  It is logically a re-throw, but 
                //  physically a brand-new exception.  Since the stack trace is cleared 
                //  on a new exception, the "_remoteStackTraceString" is provided to 
                //  effectively import a stack trace from a "remote" exception.  So,
                //  move the _stackTraceString into the _remoteStackTraceString.  Note
                //  that if there is an existing _remoteStackTraceString, it will be 
                //  preserved at the head of the new string, so everything works as 
                //  expected.
                // Even if this exception is NOT thrown, things will still work as expected
                //  because the StackTrace property returns the concatenation of the
                //  _remoteStackTraceString and the _stackTraceString.
                _remoteStackTraceString = _remoteStackTraceString + _stackTraceString;
                _stackTraceString = null;
            }

        }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:40,代码来源:exception.cs


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