/// <summary> /// Support for <see cref="ISerializable"/>. /// </summary> public virtual void GetObjectData(SerializationInfo info, StreamingContext context) { if (info == null) { throw PSTraceSource.NewArgumentNullException("info"); } string serializedContent = this.ToString(); info.AddValue("ScriptText", serializedContent); info.SetType(typeof(ScriptBlockSerializationHelper)); }
public bool runTest() { Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver : " + s_strDtTmVer); int iCountErrors = 0; int iCountTestcases = 0; String strLoc = "Loc_000oo"; SerializationInfo serinfo1 = null; Type type = null; String strValue; try { type = typeof(Int32); serinfo1 = new SerializationInfo(type, new FormatterConverter()); iCountTestcases++; if(!type.FullName.Equals(serinfo1.FullTypeName)){ iCountErrors++; Console.WriteLine("Err_0256csd! Wrong type long name, " + serinfo1.FullTypeName + " " + type.FullName); } type = typeof(String); serinfo1.SetType(type); if(!type.FullName.Equals(serinfo1.FullTypeName)){ iCountErrors++; Console.WriteLine("Err_39745sg! Wrong type long name, " + serinfo1.FullTypeName + " " + type.FullName); } type = typeof(System.Runtime.Serialization.SerializationInfo); serinfo1.SetType(type); iCountTestcases++; if(!type.FullName.Equals(serinfo1.FullTypeName)){ iCountErrors++; Console.WriteLine("Err_02346fsd! Wrong type name, " + serinfo1.FullTypeName + " " + type.FullName); } type = typeof(UserDefined); serinfo1.SetType(type); iCountTestcases++; if(!serinfo1.FullTypeName.Equals("UserDefined")){ iCountErrors++; Console.WriteLine("Err_02346fsd! Wrong type name, " + serinfo1.FullTypeName + " " + type.FullName); } if(serinfo1.AssemblyName.IndexOf("co8634settype_type")<0){ iCountErrors++; Console.WriteLine("Err_02346fsd! Wrong type name, " + serinfo1.FullTypeName + " " + serinfo1.AssemblyName); } iCountTestcases++; try{ serinfo1.SetType(null); iCountErrors++; Console.WriteLine("Err_39475sdg! Exception not thrown"); }catch(ArgumentException){ }catch(Exception ex){ iCountErrors++; Console.WriteLine("Err_39475sdg! Wrong Exception thrown" + ex.GetType().Name); } } catch (Exception exc_general ) { ++iCountErrors; Console.WriteLine (s_strTFAbbrev + " : Error Err_8888yyy! strLoc=="+ strLoc +", exc_general==\n"+exc_general.StackTrace); } if ( iCountErrors == 0 ) { Console.WriteLine( "paSs. "+s_strTFPath +" "+s_strTFName+" ,iCountTestcases=="+iCountTestcases.ToString()); return true; } else { Console.WriteLine("FAiL! "+s_strTFPath+" "+s_strTFName+" ,iCountErrors=="+iCountErrors.ToString()+" , BugNums?: "+s_strActiveBugNums ); return false; } }
public void GetObjectData(SerializationInfo info, StreamingContext context) { if (context.State == StreamingContextStates.CrossAppDomain) { GenericIdentity gIdent = new GenericIdentity(this.Name, this.AuthenticationType); info.SetType(gIdent.GetType()); System.Reflection.MemberInfo[] serializableMembers; object[] serializableValues; serializableMembers = FormatterServices.GetSerializableMembers(gIdent.GetType()); serializableValues = FormatterServices.GetObjectData(gIdent, serializableMembers); for (int i = 0; i < serializableMembers.Length; i++) { info.AddValue(serializableMembers[i].Name, serializableValues[i]); } } else { throw new InvalidOperationException("Serialization not supported"); } }
public void GetObjectData(SerializationInfo info, StreamingContext context) { info.SetType(typeof(SerializablePhotonPlayer)); info.AddValue("ID", ID); }
void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) { info.SetType(typeof(SingletonSerializationHelper)); // No other values need to be added }