private Quotation(SerializationInfo info, StreamingContext context) { if (info is null) { throw new ArgumentNullException(nameof(info)); } OpenQuotation = info.GetChar("open"); CloseQuotation = info.GetChar("close"); EscapeOpenQuotation = info.GetChar("escOpen"); EscapeCloseQuotation = info.GetChar("escClose"); HasOpenQuotation = info.GetBoolean("hasOpen"); }
// Deserialization private CommaSeparateValue(SerializationInfo info, StreamingContext context) { if (info is null) { throw new ArgumentNullException(nameof(info)); } Separator = info.GetChar("separator"); QuotationMark = info.GetChar("quotation"); Comment = info.GetChar("comment"); Options = (CommaSeparateValueOptions)(info.GetInt32("options")); CoreUpdate(); }
protected ISerializableTestObject(SerializationInfo info, StreamingContext context) { _stringValue = info.GetString("stringValue"); _intValue = info.GetInt32("intValue"); _dateTimeOffsetValue = (DateTimeOffset)info.GetValue( "dateTimeOffsetValue", typeof(DateTimeOffset) ); _personValue = (Person)info.GetValue("personValue", typeof(Person)); _nullPersonValue = (Person)info.GetValue("nullPersonValue", typeof(Person)); _nullableInt = (int?)info.GetValue("nullableInt", typeof(int?)); _booleanValue = info.GetBoolean("booleanValue"); _byteValue = info.GetByte("byteValue"); _charValue = info.GetChar("charValue"); _dateTimeValue = info.GetDateTime("dateTimeValue"); _decimalValue = info.GetDecimal("decimalValue"); _shortValue = info.GetInt16("shortValue"); _longValue = info.GetInt64("longValue"); _sbyteValue = info.GetSByte("sbyteValue"); _floatValue = info.GetSingle("floatValue"); _ushortValue = info.GetUInt16("ushortValue"); _uintValue = info.GetUInt32("uintValue"); _ulongValue = info.GetUInt64("ulongValue"); }
protected NativeTypes(SerializationInfo info, StreamingContext context) { if (info == null) { throw new ArgumentNullException(nameof(info)); } Bool = info.GetBoolean(nameof(Bool)); Byte = info.GetByte(nameof(Byte)); Sbyte = info.GetSByte(nameof(Sbyte)); Char = info.GetChar(nameof(Char)); Decimal = info.GetDecimal(nameof(Decimal)); Double = info.GetDouble(nameof(Double)); Float = info.GetSingle(nameof(Float)); Int = info.GetInt32(nameof(Int)); Uint = info.GetUInt32(nameof(Uint)); Long = info.GetInt64(nameof(Long)); Ulong = info.GetUInt64(nameof(Ulong)); Short = info.GetInt16(nameof(Short)); Ushort = info.GetUInt16(nameof(Ushort)); String = info.GetString(nameof(String)); DateTime = info.GetDateTime(nameof(DateTime)); Guid = Guid.Parse(info.GetString(nameof(Guid))); Null = info.GetValue(nameof(Null), typeof(object)); }
public object SetObjectData(object obj, SerializationInfo info, StreamingContext context, ISurrogateSelector selector) { Utility.SetFieldValue(ref obj, "_baseUrl", Utility.PrivateInstance, info.GetString("baseUrl")); Utility.SetFieldValue(ref obj, "_token", Utility.PrivateInstance, info.GetString("token")); Utility.SetFieldValue(ref obj, "_mapType", Utility.PrivateInstance, info.GetChar("mapType")); return(obj); }
public void SerializationInfo_AddGet() { var value = new Serializable(); var si = new SerializationInfo(typeof(Serializable), new FormatterConverter()); var sc = new StreamingContext(); value.GetObjectData(si, sc); Assert.AreEqual(typeof(Serializable), si.ObjectType); Assert.AreEqual(typeof(Serializable).FullName, si.FullTypeName); // TODO: Implement AssemblyName property // Assert.AreEqual(typeof(Serializable).Assembly.FullName, si.AssemblyName); Assert.AreEqual(15, si.MemberCount); Assert.AreEqual(true, si.GetBoolean("bool")); Assert.AreEqual("hello", si.GetString("string")); Assert.AreEqual('a', si.GetChar("char")); Assert.AreEqual(byte.MaxValue, si.GetByte("byte")); Assert.AreEqual(decimal.MaxValue, si.GetDecimal("decimal")); Assert.AreEqual(double.MaxValue, si.GetDouble("double")); Assert.AreEqual(short.MaxValue, si.GetInt16("short")); Assert.AreEqual(int.MaxValue, si.GetInt32("int")); Assert.AreEqual(long.MaxValue, si.GetInt64("long")); Assert.AreEqual(sbyte.MaxValue, si.GetSByte("sbyte")); Assert.AreEqual(float.MaxValue, si.GetSingle("float")); Assert.AreEqual(ushort.MaxValue, si.GetUInt16("ushort")); Assert.AreEqual(uint.MaxValue, si.GetUInt32("uint")); Assert.AreEqual(ulong.MaxValue, si.GetUInt64("ulong")); Assert.AreEqual(DateTime.MaxValue, si.GetDateTime("datetime")); }
protected Primitives(SerializationInfo info, StreamingContext context) { SerializationCtorCalled = true; Byte = info.GetByte("byte"); Bytes = (byte[])info.GetValue("bytes", typeof(byte[])); Sbyte = info.GetSByte("sbyte"); Sbytes = (sbyte[])info.GetValue("sbytes", typeof(sbyte[])); Bool = info.GetBoolean("bool"); Bools = (bool[])info.GetValue("bools", typeof(bool[])); Char = info.GetChar("char"); Chars = (char[])info.GetValue("chars", typeof(char[])); Short = info.GetInt16("short"); Shorts = (short[])info.GetValue("shorts", typeof(short[])); Ushort = info.GetUInt16("ushort"); Ushorts = (ushort[])info.GetValue("ushorts", typeof(ushort[])); Int = info.GetInt32("int"); Ints = (int[])info.GetValue("ints", typeof(int[])); Uint = info.GetUInt32("uint"); Uints = (uint[])info.GetValue("uints", typeof(uint[])); Long = info.GetInt64("long"); Longs = (long[])info.GetValue("longs", typeof(long[])); Ulong = info.GetUInt64("ulong"); Ulongs = (ulong[])info.GetValue("ulongs", typeof(ulong[])); Float = info.GetSingle("float"); Floats = (float[])info.GetValue("floats", typeof(float[])); Double = info.GetDouble("double"); Doubles = (double[])info.GetValue("doubles", typeof(double[])); Decimal = info.GetDecimal("decimal"); Decimals = (decimal[])info.GetValue("decimals", typeof(decimal[])); Guid = (Guid)info.GetValue("guid", typeof(Guid)); Guids = (Guid[])info.GetValue("guids", typeof(Guid[])); DateTime = info.GetDateTime("datetime"); DateTimes = (DateTime[])info.GetValue("datetimes", typeof(DateTime[])); String = info.GetString("string"); Strings = (string[])info.GetValue("strings", typeof(string[])); IntPtr = (IntPtr)info.GetInt64("intptr"); IntPtrs = (IntPtr[])info.GetValue("intptrs", typeof(IntPtr[])); UIntPtr = (UIntPtr)info.GetInt64("uintptr"); UIntPtrs = (UIntPtr[])info.GetValue("uintptrs", typeof(UIntPtr[])); }
protected BootstrapContext(SerializationInfo info, StreamingContext context) { if (info == null) { return; } switch (info.GetChar(_tokenTypeKey)) { case _securityTokenType: { SecurityTokenHandler sth = context.Context as SecurityTokenHandler; if (sth != null) { using (XmlDictionaryReader reader = XmlDictionaryReader.CreateTextReader(Convert.FromBase64String(info.GetString(_tokenKey)), XmlDictionaryReaderQuotas.Max)) { reader.MoveToContent(); if (sth.CanReadToken(reader)) { string tokenName = reader.LocalName; string tokenNamespace = reader.NamespaceURI; SecurityToken token = sth.ReadToken(reader); if (token == null) { _tokenString = Text.Encoding.UTF8.GetString(Convert.FromBase64String(info.GetString(_tokenKey))); } else { _token = token; } } } } else { _tokenString = Text.Encoding.UTF8.GetString(Convert.FromBase64String(info.GetString(_tokenKey))); } } break; case _stringTokenType: { _tokenString = info.GetString(_tokenKey); } break; case _byteTokenType: { _tokenBytes = (byte[])info.GetValue(_tokenKey, typeof(byte[])); } break; default: break; } }
/// <summary> /// Constructor for deserializing objects /// </summary> /// <param name="info">Stores data for serialization and deserialization</param> /// <param name="context">The source/destination of the file stream</param> public Order(SerializationInfo info, StreamingContext context) { // Retrieves serialized values ordnum = info.GetInt32("ordnum"); // Int32 would be considered an "int" datatype Custname = info.GetString("custname"); Pnum = info.GetString("pnum"); Ctype = info.GetChar("ctype"); Qty = info.GetInt32("qty"); orddate = info.GetDateTime("orddate").Date; Delivdate = info.GetDateTime("delivdate").Date; }
/// <summary> /// Initializes a new instance of the Nucleotide class. /// Constructor for deserialization. /// </summary> /// <param name="info">Serialization Info.</param> /// <param name="context">Streaming context.</param> protected Nucleotide(SerializationInfo info, StreamingContext context) { if (info == null) { throw new ArgumentNullException("info"); } val = info.GetByte("Nucleotide:Value"); symbol = info.GetChar("Nucleotide:Symbol"); name = info.GetString("Nucleotide:Name"); IsGap = info.GetBoolean("Nucleotide:IsGap"); IsAmbiguous = info.GetBoolean("Nucleotide:IsAmbiguous"); }
public TimeSlice(SerializationInfo _Info, StreamingContext _Context) { char version = _Info.GetChar("Version"); Time = _Info.GetInt32("Time"); Event = _Info.GetString("Event"); Zone = _Info.GetString("Zone"); UnitDatas = (Dictionary <int, UnitData>)_Info.GetValue("UnitDatas", typeof(Dictionary <int, UnitData>)); if (version == 2) { ChangedUnitDatas = (List <int>)_Info.GetValue("ChangedUnitDatas", typeof(List <int>)); } }
public CTileDescr(SerializationInfo info, StreamingContext context) { _terrain = info.GetString("terrain"); string scolor = info.GetString("color"); string[] scolors = scolor.Split(new char[] { ',' }); TileColor = Color.FromArgb(int.Parse(scolors[0].Trim()), int.Parse(scolors[1].Trim()), int.Parse(scolors[2].Trim())); Descr = info.GetString("descr"); try { TileMarker = info.GetChar("tilemarker"); } catch { } }
public SftpDrive(SerializationInfo info, StreamingContext context) { Name = info.GetString("name"); Host = info.GetString("host"); Port = info.GetInt32("port"); Letter = info.GetChar("drive"); Root = info.GetString("path"); Automount = info.GetBoolean("mount"); Username = info.GetString("user"); try { ProxyType = info.GetInt32("proxyType"); ProxyHost = info.GetString("proxyHost"); ProxyUser = info.GetString("proxyUser"); ProxyPass = info.GetString("proxyPass"); } catch { } try { KeepAliveInterval = info.GetInt16("keepAliveInterval"); } catch { KeepAliveInterval = 1; } ConnectionType = (ConnectionType)info.GetByte("c"); if (ConnectionType == ConnectionType.Password) { Password = Utilities.UnprotectString(info.GetString("p")); } else { Passphrase = Utilities.UnprotectString(info.GetString("p")); PrivateKey = info.GetString("k"); } try { MountPoint = info.GetString("mountpoint"); } catch { MountPoint = Name; //default is name after version update } }
protected BootstrapContext(SerializationInfo info, StreamingContext context) { if (info == null) { return; } char chr = info.GetChar("K"); if (chr == 'B') { this._tokenBytes = (byte[])info.GetValue("T", typeof(byte[])); } else { if (chr == 'S') { this._tokenString = info.GetString("T"); return; } if (chr == 'T') { SecurityTokenHandler securityTokenHandler = context.Context as SecurityTokenHandler; if (securityTokenHandler == null) { this._tokenString = Encoding.UTF8.GetString(Convert.FromBase64String(info.GetString("T"))); return; } using (XmlDictionaryReader xmlDictionaryReader = XmlDictionaryReader.CreateTextReader(Convert.FromBase64String(info.GetString("T")), XmlDictionaryReaderQuotas.Max)) { xmlDictionaryReader.MoveToContent(); if (securityTokenHandler.CanReadToken(xmlDictionaryReader)) { string localName = xmlDictionaryReader.LocalName; string namespaceURI = xmlDictionaryReader.NamespaceURI; SecurityToken securityToken = securityTokenHandler.ReadToken(xmlDictionaryReader); if (securityToken != null) { this._token = securityToken; } else { this._tokenString = Encoding.UTF8.GetString(Convert.FromBase64String(info.GetString("T"))); return; } } } } } }
/// <summary> /// Initializes a new instance of the AminoAcid class. /// Constructor for deserialization. /// </summary> /// <param name="info">Serialization Info.</param> /// <param name="context">Streaming context.</param> protected AminoAcid(SerializationInfo info, StreamingContext context) { if (info == null) { throw new ArgumentNullException("info"); } val = info.GetByte("AminoAcid:Value"); symbol = info.GetChar("AminoAcid:Symbol"); extSymbol = info.GetString("AmminoAcid:ExternalSymbol"); name = info.GetString("AminoAcid:Name"); IsGap = info.GetBoolean("AminoAcid:IsGap"); IsAmbiguous = info.GetBoolean("AminoAcid:IsAmbiguous"); IsTermination = info.GetBoolean("AminoAcid:IsTermination"); }
public FightData(SerializationInfo _Info, StreamingContext _Context) { char version = _Info.GetChar("Version"); FightName = _Info.GetString("FightName"); FightUnitID = _Info.GetInt32("FightUnitID"); TimeSlices = (List <TimeSlice>)_Info.GetValue("TimeSlices", typeof(List <TimeSlice>)); StartDateTime = _Info.GetDateTime("StartDateTime"); FightDuration = _Info.GetInt32("FightDuration"); PerfectSync = _Info.GetBoolean("PerfectSync"); if (version == 2) { RaidID = _Info.GetInt32("RaidID"); RaidResetDateTime = _Info.GetDateTime("RaidResetDateTime"); } }
/// <summary> /// ISerializer constructor /// </summary> /// <param name="info"></param> /// <param name="context"></param> public ShardKey(SerializationInfo info, StreamingContext context) { if (info.MemberCount == 3) { _origin = info.GetChar("origin"); _shardId = (short)info.GetValue("shardId", typeof(short)); _recordId = (TRecord)info.GetValue("recordId", typeof(TRecord)); } else { var tmp = FromExternalString(info.GetString("shardKey")); _origin = tmp.Origin; _shardId = tmp.ShardId; _recordId = tmp.RecordId; } }
/// <summary> /// ISerializer constructor /// </summary> /// <param name="info"></param> /// <param name="context"></param> public ShardKey(SerializationInfo info, StreamingContext context) { if (info.MemberCount == 4) { char origin = info.GetChar("origin"); var shardId = (short)info.GetValue("shardId", typeof(short)); TRecord recordId = (TRecord)info.GetValue("recordId", typeof(TRecord)); _key = new ShardKey <TRecord>(origin, shardId, recordId); _childId = (TChild)info.GetValue("childId", typeof(TChild)); } else { var tmp = FromExternalString(info.GetString("ShardKey")); _key = tmp.Key; _childId = tmp.ChildId; } }
} // end constructor // Deserializer public Airport(SerializationInfo info, StreamingContext ctxt) { this.Iata = info.GetString("Iata"); this.Icao = info.GetString("Icao"); this.Name = info.GetString("Name"); this.Region = SaveGamePublic.SaveGame.Regions[info.GetString("Region")]; this.Hub = info.GetBoolean("Hub"); this.Coordinate = (GeoCoordinate)info.GetValue("Coordinate", typeof(GeoCoordinate)); this.Size = info.GetChar("Size"); this.Municipality = info.GetString("Municipality");; this.RunwayLength = info.GetInt16("RunwayLength"); this.RunwayCount = info.GetInt16("RunwayCount"); this.Slots = info.GetInt16("Slots"); this._TotalPassengers = info.GetInt32("TotalPassengers"); } // End Deserializer
protected CharacterChromosome(SerializationInfo info, StreamingContext context) { var length = info.GetInt32("_length"); _validCharacters = (CharSeq)info.GetValue("_validCharacters", typeof(CharSeq)); var genes = MutableSeq.OfLength <CharacterGene>(length); for (var i = 0; i < length; ++i) { var gene = CharacterGene.Of( info.GetChar("_gene_" + i), _validCharacters ); genes[i] = gene; } Genes = genes.ToImmutableSeq(); }
// Deserialization private Escaper(SerializationInfo info, StreamingContext context) { if (info is null) { throw new ArgumentNullException(nameof(info)); } string typeName = info.GetString("comparer"); IEqualityComparer <char> comparer = Activator.CreateInstance(Type.GetType(typeName)) as IEqualityComparer <char>; m_MustBeEscaped = new HashSet <char>(info.GetString("escape"), comparer); HasEscapeSymbol = info.GetBoolean("hasSymbol"); if (HasEscapeSymbol) { EscapeSymbol = info.GetChar("symbol"); } }
public SftpDrive(SerializationInfo info, StreamingContext context) { Name = info.GetString("name"); Host = info.GetString("host"); Port = info.GetInt32("port"); Letter = info.GetChar("drive"); Root = info.GetString("path"); Automount = info.GetBoolean("mount"); Username = info.GetString("user"); ConnectionType = (ConnectionType)info.GetByte("c"); if (ConnectionType == ConnectionType.Password) { Password = Utilities.UnprotectString(info.GetString("p")); } else { Passphrase = Utilities.UnprotectString(info.GetString("p")); PrivateKey = info.GetString("k"); } }
/// <summary>Initializes a new instance of the <see cref="T:System.IdentityModel.Tokens.BootstrapContext" /> class from a stream.</summary> /// <param name="info">The serialized data.</param> /// <param name="context">The context for serialization.</param> /// <exception cref="T:System.ArgumentNullException"> /// <paramref name="info" /> is null.</exception> protected BootstrapContext(SerializationInfo info, StreamingContext context) { if (info == null) { return; } switch (info.GetChar("K")) { case 'B': _tokenBytes = (byte[])info.GetValue("T", typeof(byte[])); break; case 'S': _tokenString = info.GetString("T"); break; case 'T': _tokenString = Encoding.UTF8.GetString( Convert.FromBase64String(info.GetString("T") ?? throw new InvalidOperationException())); break; } }
/// <summary> /// Конструктор десериализации. /// </summary> /// <param name="info">Информация для десериализации.</param> /// <param name="context">Контекст десериализации.</param> public ObjectStringDataView(SerializationInfo info, StreamingContext context) { this.objectType = (Type)info.GetValue("objectType", typeof(Type)); this.objectedData = (object[])info.GetValue("data", typeof(object[])); this.separator = info.GetChar("separator"); this.masters = (MasterObjStruct[])info.GetValue("masters", typeof(MasterObjStruct[])); Type tp = (Type)info.GetValue("keytype", typeof(Type)); string s = info.GetString("keystr"); MethodInfo mi = tp.GetMethod("Parse", BindingFlags.Static | BindingFlags.Public); if (mi != null) { this.key = mi.Invoke(null, new object[] { s }); } else { this.key = Activator.CreateInstance(tp, new object[] { s }); } }
/// <summary>Initializes a new instance of the <see cref="BootstrapContext"/> class from a stream.</summary> protected BootstrapContext(SerializationInfo info, StreamingContext context) { if (info == null) { throw new ArgumentNullException("info"); } char type = info.GetChar("K"); switch (type) { case 'S': Token = info.GetString("T"); break; case 'B': TokenBytes = (byte [])info.GetValue("T", typeof(byte [])); break; case 'T': Token = Encoding.UTF8.GetString(Convert.FromBase64String(info.GetString("T"))); break; } }
/// <summary> /// Creates a new <see cref="ConfigurationCell3"/> from serialization parameters. /// </summary> /// <param name="info">The <see cref="SerializationInfo"/> with populated with data.</param> /// <param name="context">The source <see cref="StreamingContext"/> for this deserialization.</param> private ConfigurationCell3(SerializationInfo info, StreamingContext context) : base(info, context) { float getSingle(string name) { return(!(info.GetValue(name, typeof(string)) is string element) || element == "INF" ? float.PositiveInfinity : float.Parse(element)); } // Deserialize configuration cell m_formatFlags = (FormatFlags)info.GetValue("formatFlags", typeof(FormatFlags)); GlobalID = Guid.TryParse(info.GetOrDefault("globalID", Guid.Empty.ToString()), out Guid globalID) ? globalID : Guid.Empty; // Decode PMU_LAT, PMU_LON, PMU_ELEV, SVC_CLASS, WINDOW, GRP_DLY values Latitude = getSingle("latitude"); Longitude = getSingle("longitude"); Elevation = getSingle("elevation"); ServiceClass = info.GetChar("serviceClass"); Window = info.GetInt32("window"); GroupDelay = info.GetInt32("groupDelay"); DataModified = info.GetBoolean("dataModified"); }
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; Boolean fValue; Char chValue; SByte sbtValue; Byte btValue; Int16 i16Value; Int32 i32Value; Int64 i64Value; UInt16 ui16Value; UInt32 ui32Value; UInt64 ui64Value; Double dblValue; Single sglValue; DateTime dtValue; Decimal dcmValue; StringBuilder sbldr1; String strValue; Random rnd1; try { do { strLoc = "Loc_6573cd"; serinfo1 = new SerializationInfo(typeof(Int32), new FormatterConverter()); iCountTestcases++; if (serinfo1.MemberCount != 0) { iCountErrors++; Console.WriteLine("Err_0246sd! Wrong number of members, " + serinfo1.MemberCount.ToString()); } strLoc = "Loc_6853vd"; fValue = false; serinfo1.AddValue("Boolean_1", fValue); iCountTestcases++; if (serinfo1.GetBoolean("Boolean_1") != fValue) { iCountErrors++; Console.WriteLine("Err_0945csd! wrong value returned, " + serinfo1.GetBoolean("Boolean_1")); } fValue = true; serinfo1.AddValue("Boolean_2", fValue); iCountTestcases++; if (serinfo1.GetBoolean("Boolean_2") != fValue) { iCountErrors++; Console.WriteLine("Err_6753vd! wrong value returned, " + serinfo1.GetBoolean("Boolean_2")); } try { iCountTestcases++; serinfo1.AddValue("Boolean_2", fValue); iCountErrors++; Console.WriteLine("Err_1065753cd! Exception not thrown"); }catch (SerializationException) { }catch (Exception ex) { iCountErrors++; Console.WriteLine("Err_5739cd! Wrong exception thrown, " + ex); } Console.WriteLine("Large String, ticks, " + Environment.TickCount); sbldr1 = new StringBuilder("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); fValue = false; serinfo1.AddValue(sbldr1.ToString(), fValue); iCountTestcases++; if (serinfo1.GetBoolean(sbldr1.ToString()) != fValue) { iCountErrors++; Console.WriteLine("Err_6538fvd! wrong value returned, " + serinfo1.GetBoolean(sbldr1.ToString())); } try { iCountTestcases++; serinfo1.AddValue(null, fValue); iCountErrors++; Console.WriteLine("Err_0156ds! Exception not thrown"); }catch (ArgumentNullException) { }catch (Exception ex) { iCountErrors++; Console.WriteLine("Err_57834fd! Wrong exception thrown, " + ex); } Console.WriteLine("Char ticks, " + Environment.TickCount); rnd1 = new Random(); for (int i = 0; i < 50; i++) { strLoc = "Loc_6753cd_" + i; chValue = (Char)(65536 * rnd1.NextDouble()); strValue = "Char_" + i; serinfo1.AddValue(strValue, chValue); iCountTestcases++; if (serinfo1.GetChar(strValue) != chValue) { iCountErrors++; Console.WriteLine("Err_65730dsw_" + i + "! Wrong Char returned, " + serinfo1.GetChar(strValue)); } } try { iCountTestcases++; serinfo1.AddValue("Char_1", 'a'); iCountErrors++; Console.WriteLine("Err_643cd! Exception not thrown"); }catch (SerializationException) { }catch (Exception ex) { iCountErrors++; Console.WriteLine("Err_02457fd! Wrong exception thrown, " + ex); } try { iCountTestcases++; serinfo1.AddValue("Boolean_1", 'a'); iCountErrors++; Console.WriteLine("Err_5732fcd! Exception not thrown"); }catch (SerializationException) { }catch (Exception ex) { iCountErrors++; Console.WriteLine("Err_024568fd! Wrong exception thrown, " + ex); } Console.WriteLine("SByte ticks, " + Environment.TickCount); for (int i = (int)SByte.MinValue; i < (int)SByte.MaxValue; i++) { strLoc = "Loc_56473vd_" + i; sbtValue = (SByte)i;; strValue = "SByte_" + i; serinfo1.AddValue(strValue, sbtValue); iCountTestcases++; if (serinfo1.GetSByte(strValue) != sbtValue) { iCountErrors++; Console.WriteLine("Err_4627fds_" + i + "! Wrong Sbyte returned, " + serinfo1.GetSByte(strValue)); } } Console.WriteLine("Byte ticks, " + Environment.TickCount); for (int i = (int)Byte.MinValue; i < (int)Byte.MaxValue; i++) { strLoc = "Loc_01192ds_" + i; btValue = (Byte)i;; strValue = "Byte_" + i; serinfo1.AddValue(strValue, btValue); iCountTestcases++; if (serinfo1.GetByte(strValue) != btValue) { iCountErrors++; Console.WriteLine("Err_0267fe_" + i + "! Wrong byte returned, " + serinfo1.GetByte(strValue)); } } Console.WriteLine("Int16 ticks, " + Environment.TickCount); for (int i = 0; i < 50; i++) { strLoc = "Loc_012965565ds_" + i; i16Value = (short)((int)Int16.MaxValue * rnd1.NextDouble()); if (rnd1.NextDouble() < 0.5) { i16Value = (short)(-1 * i16Value); } strValue = "Int16_" + i; serinfo1.AddValue(strValue, i16Value); iCountTestcases++; if (serinfo1.GetInt16(strValue) != i16Value) { iCountErrors++; Console.WriteLine("Err_0267fe_" + i + "! Wrong value returned, " + serinfo1.GetInt16(strValue)); } } Console.WriteLine("Int32 ticks, " + Environment.TickCount); for (int i = 0; i < 50; i++) { strLoc = "Loc_015643ds_" + i; i32Value = (int)(Int32.MaxValue * rnd1.NextDouble()); if (rnd1.NextDouble() < 0.5) { i32Value = (-1 * i32Value); } strValue = "Int32_" + i; serinfo1.AddValue(strValue, i32Value); iCountTestcases++; if (serinfo1.GetInt32(strValue) != i32Value) { iCountErrors++; Console.WriteLine("Err_5427ds_" + i + "! Wrong value returned, " + serinfo1.GetInt32(strValue)); } } Console.WriteLine("Int64 ticks, " + Environment.TickCount); for (int i = 0; i < 50; i++) { strLoc = "Loc_625bfg_" + i; i64Value = (long)((long)Int64.MaxValue * rnd1.NextDouble()); if (rnd1.NextDouble() < 0.5) { i64Value = (long)(-1 * i64Value); } strValue = "Int64_" + i; serinfo1.AddValue(strValue, i64Value); iCountTestcases++; if (serinfo1.GetInt64(strValue) != i64Value) { iCountErrors++; Console.WriteLine("Err_6427dc_" + i + "! Wrong value returned, " + serinfo1.GetInt64(strValue)); } } Console.WriteLine("UInt16 ticks, " + Environment.TickCount); for (int i = 0; i < 50; i++) { strLoc = "Loc_6473cd_" + i; ui16Value = (ushort)((int)UInt16.MaxValue * rnd1.NextDouble()); strValue = "UInt16_" + i; serinfo1.AddValue(strValue, ui16Value); iCountTestcases++; if (serinfo1.GetUInt16(strValue) != ui16Value) { iCountErrors++; Console.WriteLine("Err_748vd_" + i + "! Wrong value returned, " + serinfo1.GetUInt16(strValue)); } } Console.WriteLine("UInt32 ticks, " + Environment.TickCount); for (int i = 0; i < 50; i++) { strLoc = "Loc_7573cd_" + i; ui32Value = (uint)(UInt32.MaxValue * rnd1.NextDouble()); strValue = "UInt32_" + i; serinfo1.AddValue(strValue, ui32Value); iCountTestcases++; if (serinfo1.GetUInt32(strValue) != ui32Value) { iCountErrors++; Console.WriteLine("Err_4738cd_" + i + "! Wrong value returned, " + serinfo1.GetUInt32(strValue)); } } Console.WriteLine("UInt64 ticks, " + Environment.TickCount); for (int i = 0; i < 50; i++) { strLoc = "Loc_63dc_" + i; ui64Value = (ulong)(UInt64.MaxValue * rnd1.NextDouble()); strValue = "UInt64_" + i; serinfo1.AddValue(strValue, ui64Value); iCountTestcases++; if (serinfo1.GetUInt64(strValue) != ui64Value) { iCountErrors++; Console.WriteLine("Err_6583fd_" + i + "! Wrong value returned, " + serinfo1.GetUInt64(strValue)); } } Console.WriteLine("Double ticks, " + Environment.TickCount); for (int i = 0; i < 50; i++) { strLoc = "Loc_7539cd_" + i; dblValue = Double.MaxValue * rnd1.NextDouble(); if (rnd1.NextDouble() < 0.5) { dblValue = (-1 * dblValue); } strValue = "Double_" + i; serinfo1.AddValue(strValue, dblValue); iCountTestcases++; if (serinfo1.GetDouble(strValue) != dblValue) { iCountErrors++; Console.WriteLine("Err_653cfd_" + i + "! Wrong value returned, " + serinfo1.GetDouble(strValue)); } } Console.WriteLine("Single ticks, " + Environment.TickCount); for (int i = 0; i < 50; i++) { strLoc = "Loc_0247fd_" + i; sglValue = (float)(Single.MaxValue * rnd1.NextDouble()); if (rnd1.NextDouble() < 0.5) { sglValue = (-1 * sglValue); } strValue = "Single_" + i; serinfo1.AddValue(strValue, sglValue); iCountTestcases++; if (serinfo1.GetSingle(strValue) != sglValue) { iCountErrors++; Console.WriteLine("Err_0468fd_" + i + "! Wrong value returned, " + serinfo1.GetSingle(strValue)); } } strValue = "This is a String"; serinfo1.AddValue("String_1", strValue); iCountTestcases++; if (!serinfo1.GetString("String_1").Equals(strValue)) { iCountErrors++; Console.WriteLine("Err_0945csd! wrong value returned, " + serinfo1.GetString("String_1")); } strValue = ""; serinfo1.AddValue("String_2", strValue); iCountTestcases++; if (!serinfo1.GetString("String_2").Equals(String.Empty)) { iCountErrors++; Console.WriteLine("Err_0945csd! wrong value returned, " + serinfo1.GetString("String_2")); } strValue = null; serinfo1.AddValue("String_3", strValue); iCountTestcases++; if (serinfo1.GetString("String_3") != null) { iCountErrors++; Console.WriteLine("Err_0945csd! wrong value returned, " + serinfo1.GetString("String_3")); } try { iCountTestcases++; serinfo1.AddValue("String_2", fValue); iCountErrors++; Console.WriteLine("Err_1065753cd! Exception not thrown"); }catch (SerializationException) { }catch (Exception ex) { iCountErrors++; Console.WriteLine("Err_5739cd! Wrong exception thrown, " + ex); } Console.WriteLine("Single ticks, " + Environment.TickCount); for (int i = 0; i < 50; i++) { strLoc = "Loc_0247fd_" + i; dblValue = (double)(DateTime.MaxValue.ToOADate() * rnd1.NextDouble()); strValue = "DateTime_" + i; dtValue = DateTime.FromOADate(dblValue); serinfo1.AddValue(strValue, dtValue); iCountTestcases++; if (serinfo1.GetDateTime(strValue) != dtValue) { iCountErrors++; Console.WriteLine("Err_0468fd_" + i + "! Wrong value returned, " + serinfo1.GetDateTime(strValue)); } } for (int i = 0; i < 50; i++) { strLoc = "Loc_0247fd_" + i; dcmValue = (Decimal)((double)Decimal.MaxValue * rnd1.NextDouble()); if (rnd1.NextDouble() < 0.5) { dcmValue = (Decimal)(-1 * dcmValue); } strValue = "Decimal_" + i; serinfo1.AddValue(strValue, dcmValue); iCountTestcases++; if (serinfo1.GetDecimal(strValue) != dcmValue) { iCountErrors++; Console.WriteLine("Err_2342fdsg_" + i + "! Wrong value returned, " + serinfo1.GetDecimal(strValue)); } } } while (false); } 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); } }
/// <summary> /// Creates a new <see cref="PhasorDefinition"/> from serialization parameters. /// </summary> /// <param name="info">The <see cref="SerializationInfo"/> with populated with data.</param> /// <param name="context">The source <see cref="StreamingContext"/> for this deserialization.</param> protected PhasorDefinition(SerializationInfo info, StreamingContext context) : base(info, context) { OriginalSourceIndex = info.GetInt32("originalSourceIndex"); Phase = info.GetChar("phase"); }
/// <summary> /// Initializes a new instance of the <see cref="Jantu.FoodKind"/> class /// from serialized data. /// </summary> /// <param name='info'> /// Info. /// </param> /// <param name='ctx'> /// Context. /// </param> public FoodKind(SerializationInfo info, StreamingContext ctx) { _name = (string)info.GetValue("Name", typeof(string)); _symbol = info.GetChar("Symbol"); }
public VirtualDrive(SerializationInfo info, StreamingContext context) { Letter = info.GetChar("letter"); }
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; Boolean fValue; Char chValue; SByte sbtValue; Byte btValue; Int16 i16Value; Int32 i32Value; Int64 i64Value; UInt16 ui16Value; UInt32 ui32Value; UInt64 ui64Value; Double dblValue; Single sglValue; DateTime dtValue; Decimal dcmValue; StringBuilder sbldr1; String strValue; Random rnd1; try { do { strLoc="Loc_6573cd"; serinfo1 = new SerializationInfo(typeof(Int32), new FormatterConverter()); iCountTestcases++; if(serinfo1.MemberCount != 0) { iCountErrors++; Console.WriteLine("Err_0246sd! Wrong number of members, " + serinfo1.MemberCount.ToString()); } strLoc="Loc_6853vd"; fValue = false; serinfo1.AddValue("Boolean_1", fValue); iCountTestcases++; if(serinfo1.GetBoolean("Boolean_1") != fValue) { iCountErrors++; Console.WriteLine("Err_0945csd! wrong value returned, " + serinfo1.GetBoolean("Boolean_1")); } fValue = true; serinfo1.AddValue("Boolean_2", fValue); iCountTestcases++; if(serinfo1.GetBoolean("Boolean_2") != fValue) { iCountErrors++; Console.WriteLine("Err_6753vd! wrong value returned, " + serinfo1.GetBoolean("Boolean_2")); } try { iCountTestcases++; serinfo1.AddValue("Boolean_2", fValue); iCountErrors++; Console.WriteLine("Err_1065753cd! Exception not thrown"); }catch(SerializationException){ }catch(Exception ex){ iCountErrors++; Console.WriteLine("Err_5739cd! Wrong exception thrown, " + ex); } Console.WriteLine("Large String, ticks, " + Environment.TickCount); sbldr1 = new StringBuilder("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); fValue = false; serinfo1.AddValue(sbldr1.ToString(), fValue); iCountTestcases++; if(serinfo1.GetBoolean(sbldr1.ToString()) != fValue) { iCountErrors++; Console.WriteLine("Err_6538fvd! wrong value returned, " + serinfo1.GetBoolean(sbldr1.ToString())); } try { iCountTestcases++; serinfo1.AddValue(null, fValue); iCountErrors++; Console.WriteLine("Err_0156ds! Exception not thrown"); }catch(ArgumentNullException){ }catch(Exception ex){ iCountErrors++; Console.WriteLine("Err_57834fd! Wrong exception thrown, " + ex); } Console.WriteLine("Char ticks, " + Environment.TickCount); rnd1 = new Random(); for(int i=0; i<50; i++) { strLoc="Loc_6753cd_" + i; chValue = (Char)(65536 * rnd1.NextDouble()); strValue = "Char_" + i; serinfo1.AddValue(strValue, chValue); iCountTestcases++; if(serinfo1.GetChar(strValue)!= chValue) { iCountErrors++; Console.WriteLine("Err_65730dsw_" + i + "! Wrong Char returned, " + serinfo1.GetChar(strValue)); } } try { iCountTestcases++; serinfo1.AddValue("Char_1", 'a'); iCountErrors++; Console.WriteLine("Err_643cd! Exception not thrown"); }catch(SerializationException){ }catch(Exception ex){ iCountErrors++; Console.WriteLine("Err_02457fd! Wrong exception thrown, " + ex); } try { iCountTestcases++; serinfo1.AddValue("Boolean_1", 'a'); iCountErrors++; Console.WriteLine("Err_5732fcd! Exception not thrown"); }catch(SerializationException){ }catch(Exception ex){ iCountErrors++; Console.WriteLine("Err_024568fd! Wrong exception thrown, " + ex); } Console.WriteLine("SByte ticks, " + Environment.TickCount); for(int i=(int)SByte.MinValue; i<(int)SByte.MaxValue; i++) { strLoc="Loc_56473vd_" + i; sbtValue = (SByte)i;; strValue = "SByte_" + i; serinfo1.AddValue(strValue, sbtValue); iCountTestcases++; if(serinfo1.GetSByte(strValue)!= sbtValue) { iCountErrors++; Console.WriteLine("Err_4627fds_" + i + "! Wrong Sbyte returned, " + serinfo1.GetSByte(strValue)); } } Console.WriteLine("Byte ticks, " + Environment.TickCount); for(int i=(int)Byte.MinValue; i<(int)Byte.MaxValue; i++) { strLoc="Loc_01192ds_" + i; btValue = (Byte)i;; strValue = "Byte_" + i; serinfo1.AddValue(strValue, btValue); iCountTestcases++; if(serinfo1.GetByte(strValue)!= btValue) { iCountErrors++; Console.WriteLine("Err_0267fe_" + i + "! Wrong byte returned, " + serinfo1.GetByte(strValue)); } } Console.WriteLine("Int16 ticks, " + Environment.TickCount); for(int i=0; i<50; i++) { strLoc="Loc_012965565ds_" + i; i16Value = (short)((int)Int16.MaxValue * rnd1.NextDouble()); if(rnd1.NextDouble()<0.5) i16Value = (short)(-1 * i16Value); strValue = "Int16_" + i; serinfo1.AddValue(strValue, i16Value); iCountTestcases++; if(serinfo1.GetInt16(strValue)!= i16Value) { iCountErrors++; Console.WriteLine("Err_0267fe_" + i + "! Wrong value returned, " + serinfo1.GetInt16(strValue)); } } Console.WriteLine("Int32 ticks, " + Environment.TickCount); for(int i=0; i<50; i++) { strLoc="Loc_015643ds_" + i; i32Value = (int)(Int32.MaxValue * rnd1.NextDouble()); if(rnd1.NextDouble()<0.5) i32Value = (-1 * i32Value); strValue = "Int32_" + i; serinfo1.AddValue(strValue, i32Value); iCountTestcases++; if(serinfo1.GetInt32(strValue)!= i32Value) { iCountErrors++; Console.WriteLine("Err_5427ds_" + i + "! Wrong value returned, " + serinfo1.GetInt32(strValue)); } } Console.WriteLine("Int64 ticks, " + Environment.TickCount); for(int i=0; i<50; i++) { strLoc="Loc_625bfg_" + i; i64Value = (long)((long)Int64.MaxValue * rnd1.NextDouble()); if(rnd1.NextDouble()<0.5) i64Value = (long)(-1 * i64Value); strValue = "Int64_" + i; serinfo1.AddValue(strValue, i64Value); iCountTestcases++; if(serinfo1.GetInt64(strValue)!= i64Value) { iCountErrors++; Console.WriteLine("Err_6427dc_" + i + "! Wrong value returned, " + serinfo1.GetInt64(strValue)); } } Console.WriteLine("UInt16 ticks, " + Environment.TickCount); for(int i=0; i<50; i++) { strLoc="Loc_6473cd_" + i; ui16Value = (ushort)((int)UInt16.MaxValue * rnd1.NextDouble()); strValue = "UInt16_" + i; serinfo1.AddValue(strValue, ui16Value); iCountTestcases++; if(serinfo1.GetUInt16(strValue)!= ui16Value) { iCountErrors++; Console.WriteLine("Err_748vd_" + i + "! Wrong value returned, " + serinfo1.GetUInt16(strValue)); } } Console.WriteLine("UInt32 ticks, " + Environment.TickCount); for(int i=0; i<50; i++) { strLoc="Loc_7573cd_" + i; ui32Value = (uint)(UInt32.MaxValue * rnd1.NextDouble()); strValue = "UInt32_" + i; serinfo1.AddValue(strValue, ui32Value); iCountTestcases++; if(serinfo1.GetUInt32(strValue)!= ui32Value) { iCountErrors++; Console.WriteLine("Err_4738cd_" + i + "! Wrong value returned, " + serinfo1.GetUInt32(strValue)); } } Console.WriteLine("UInt64 ticks, " + Environment.TickCount); for(int i=0; i<50; i++) { strLoc="Loc_63dc_" + i; ui64Value = (ulong)(UInt64.MaxValue * rnd1.NextDouble()); strValue = "UInt64_" + i; serinfo1.AddValue(strValue, ui64Value); iCountTestcases++; if(serinfo1.GetUInt64(strValue)!= ui64Value) { iCountErrors++; Console.WriteLine("Err_6583fd_" + i + "! Wrong value returned, " + serinfo1.GetUInt64(strValue)); } } Console.WriteLine("Double ticks, " + Environment.TickCount); for(int i=0; i<50; i++) { strLoc="Loc_7539cd_" + i; dblValue = Double.MaxValue * rnd1.NextDouble(); if(rnd1.NextDouble()<0.5) dblValue = (-1 * dblValue); strValue = "Double_" + i; serinfo1.AddValue(strValue, dblValue); iCountTestcases++; if(serinfo1.GetDouble(strValue)!= dblValue) { iCountErrors++; Console.WriteLine("Err_653cfd_" + i + "! Wrong value returned, " + serinfo1.GetDouble(strValue)); } } Console.WriteLine("Single ticks, " + Environment.TickCount); for(int i=0; i<50; i++) { strLoc="Loc_0247fd_" + i; sglValue = (float)(Single.MaxValue * rnd1.NextDouble()); if(rnd1.NextDouble()<0.5) sglValue = (-1 * sglValue); strValue = "Single_" + i; serinfo1.AddValue(strValue, sglValue); iCountTestcases++; if(serinfo1.GetSingle(strValue)!= sglValue) { iCountErrors++; Console.WriteLine("Err_0468fd_" + i + "! Wrong value returned, " + serinfo1.GetSingle(strValue)); } } strValue = "This is a String"; serinfo1.AddValue("String_1", strValue); iCountTestcases++; if(!serinfo1.GetString("String_1").Equals(strValue)) { iCountErrors++; Console.WriteLine("Err_0945csd! wrong value returned, " + serinfo1.GetString("String_1")); } strValue = ""; serinfo1.AddValue("String_2", strValue); iCountTestcases++; if(!serinfo1.GetString("String_2").Equals(String.Empty)) { iCountErrors++; Console.WriteLine("Err_0945csd! wrong value returned, " + serinfo1.GetString("String_2")); } strValue = null; serinfo1.AddValue("String_3", strValue); iCountTestcases++; if(serinfo1.GetString("String_3") != null) { iCountErrors++; Console.WriteLine("Err_0945csd! wrong value returned, " + serinfo1.GetString("String_3")); } try { iCountTestcases++; serinfo1.AddValue("String_2", fValue); iCountErrors++; Console.WriteLine("Err_1065753cd! Exception not thrown"); }catch(SerializationException){ }catch(Exception ex){ iCountErrors++; Console.WriteLine("Err_5739cd! Wrong exception thrown, " + ex); } Console.WriteLine("Single ticks, " + Environment.TickCount); for(int i=0; i<50; i++) { strLoc="Loc_0247fd_" + i; dblValue = (double)(DateTime.MaxValue.ToOADate() * rnd1.NextDouble()); strValue = "DateTime_" + i; dtValue = DateTime.FromOADate(dblValue); serinfo1.AddValue(strValue, dtValue); iCountTestcases++; if(serinfo1.GetDateTime(strValue)!= dtValue) { iCountErrors++; Console.WriteLine("Err_0468fd_" + i + "! Wrong value returned, " + serinfo1.GetDateTime(strValue)); } } for(int i=0; i<50; i++) { strLoc="Loc_0247fd_" + i; dcmValue = (Decimal)((double)Decimal.MaxValue * rnd1.NextDouble()); if(rnd1.NextDouble()<0.5) dcmValue = (Decimal)(-1 * dcmValue); strValue = "Decimal_" + i; serinfo1.AddValue(strValue, dcmValue); iCountTestcases++; if(serinfo1.GetDecimal(strValue)!= dcmValue) { iCountErrors++; Console.WriteLine("Err_2342fdsg_" + i + "! Wrong value returned, " + serinfo1.GetDecimal(strValue)); } } } while (false); } 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; } }