本文整理汇总了C#中StreamingContext类的典型用法代码示例。如果您正苦于以下问题:C# StreamingContext类的具体用法?C# StreamingContext怎么用?C# StreamingContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StreamingContext类属于命名空间,在下文中一共展示了StreamingContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SerializationInfoEnumerate
public void SerializationInfoEnumerate()
{
var value = new Serializable();
var si = new SerializationInfo(typeof(Serializable), new FormatterConverter());
var sc = new StreamingContext();
value.GetObjectData(si, sc);
int items = 0;
foreach (SerializationEntry entry in si)
{
items++;
switch (entry.Name)
{
case "int":
Assert.Equal(int.MaxValue, (int)entry.Value);
Assert.Equal(typeof(int), entry.ObjectType);
break;
case "string":
Assert.Equal("hello", (string)entry.Value);
Assert.Equal(typeof(string), entry.ObjectType);
break;
case "bool":
Assert.Equal(true, (bool)entry.Value);
Assert.Equal(typeof(bool), entry.ObjectType);
break;
}
}
Assert.Equal(si.MemberCount, items);
}
示例2: GetObjectData
public void GetObjectData(System.Object obj, SerializationInfo info, StreamingContext context)
{
Vector3 v3 = (Vector3)obj;
info.AddValue("x", v3.x);
info.AddValue("y", v3.y);
info.AddValue("z", v3.z);
}
示例3: GetObjectData
// Required by the ISerializable class to be properly serialized. This is called automatically
public void GetObjectData(SerializationInfo info, StreamingContext ctxt)
{
// Repeat this for each var defined in the Values section
info.AddValue("foundGem1", (foundGem1));
info.AddValue("score", score);
info.AddValue("levelReached", levelReached);
}
示例4: SerializationInfoAddGet
public void SerializationInfoAddGet()
{
var value = new Serializable();
var si = new SerializationInfo(typeof(Serializable), new FormatterConverter());
var sc = new StreamingContext();
value.GetObjectData(si, sc);
Assert.Equal(typeof(Serializable), si.ObjectType);
Assert.Equal(typeof(Serializable).FullName, si.FullTypeName);
Assert.Equal(typeof(Serializable).GetTypeInfo().Assembly.FullName, si.AssemblyName);
Assert.Equal(15, si.MemberCount);
Assert.Equal(true, si.GetBoolean("bool"));
Assert.Equal("hello", si.GetString("string"));
Assert.Equal('a', si.GetChar("char"));
Assert.Equal(byte.MaxValue, si.GetByte("byte"));
Assert.Equal(decimal.MaxValue, si.GetDecimal("decimal"));
Assert.Equal(double.MaxValue, si.GetDouble("double"));
Assert.Equal(short.MaxValue, si.GetInt16("short"));
Assert.Equal(int.MaxValue, si.GetInt32("int"));
Assert.Equal(long.MaxValue, si.GetInt64("long"));
Assert.Equal(sbyte.MaxValue, si.GetSByte("sbyte"));
Assert.Equal(float.MaxValue, si.GetSingle("float"));
Assert.Equal(ushort.MaxValue, si.GetUInt16("ushort"));
Assert.Equal(uint.MaxValue, si.GetUInt32("uint"));
Assert.Equal(ulong.MaxValue, si.GetUInt64("ulong"));
Assert.Equal(DateTime.MaxValue, si.GetDateTime("datetime"));
}
示例5: GetObjectData
public void GetObjectData(SerializationInfo info, StreamingContext context) {
info.AddValue ("count", count);
info.AddValue ("weaponCount", weapons.Count);
for (int i = 0; i < weapons.Count; i++) {
info.AddValue ("weaponCD_" + i, weapons [i].GetCooldown ());
}
}
示例6: GameplayMessage
public GameplayMessage(SerializationInfo info, StreamingContext context)
{
Message = (MessageValue)info.GetByte ("Message");
PlayerID = info.GetInt32 ("PlayerID");
MoveDelta = new Vector2((float)info.GetValue("x",typeof(float)),(float)info.GetValue("y",typeof(float)));
OldPosition = new Vector3((float)info.GetValue("xloc", typeof(float)), (float)info.GetValue("yloc", typeof(float)), (float)info.GetValue("zloc", typeof(float)));
}
示例7: ProfileSaveData
public ProfileSaveData(SerializationInfo aInfo, StreamingContext aContext)
: base()
{
m_Name = (string)aInfo.GetValue("Name", typeof(string));
m_ProfileName = (string)aInfo.GetValue("ProfileName", typeof(string));
m_ProgressionLevel = (int)aInfo.GetValue("ProgressionLevel", typeof(int));
}
示例8: GetObjectData
public void GetObjectData (SerializationInfo info, StreamingContext context) {
info.AddValue ("a", a);
if (s1 != null)
info.AddValue ("s1", s1);
else
info.AddValue ("s1", "(null)");
}
示例9: GetObjectData
// Serialization funciton.
public void GetObjectData(SerializationInfo info, StreamingContext ctxt)
{
// You can use any name/value pair, as long as you read them with the same names
info.AddValue("Health", health);
info.AddValue("Name", name);
}
示例10: GetObjectData
// Required by the ISerializable class to be properly serialized. This is called automatically
public void GetObjectData(SerializationInfo info, StreamingContext ctxt)
{
// Repeat this for each var defined in the Values section
info.AddValue("boardWidth", (boardWidth));
info.AddValue("boardHeight", boardHeight);
info.AddValue("tiles", tiles);
}
示例11: GetObjectData
// Required by the ISerializable class to be properly serialized. This is called automatically
public void GetObjectData(SerializationInfo info, StreamingContext ctxt)
{
// Repeat this for each var defined in the Values section
info.AddValue("ConeUnlocked", (ConeUnlocked));
info.AddValue("HiScore", HiScore);
info.AddValue("ExplosivesLeft", ExplosivesLeft);
}
示例12: SampledStroke
public SampledStroke(SerializationInfo info, StreamingContext ctxt)
{
beginning = info.GetInt32("beginning");
str = (List<Dot>)info.GetValue("str", typeof(List<Dot>));
positionX = 0;
positionY = 0;
}
示例13: CChair_SALContainer
//Serializatoin counstructor. call when Deserialize function called.
private CChair_SALContainer(SerializationInfo info, StreamingContext context)
: base(info,context)
{
var1 = info.GetInt32("var1");
var2 = info.GetInt32("var2");
str1 = (string[])info.GetValue("str1",typeof(string[]));
}
示例14: GetObjectData
public void GetObjectData(SerializationInfo info, StreamingContext ctxt)
{
info.AddValue("object2PropertiesMappings", this.object2PropertiesMappings);
info.AddValue("EZR_VERSION", EZR_VERSION);
info.AddValue("recordingInterval", this.recordingInterval);
//base.GetObjectData(info, context);
}
示例15: CBahram_SALContainer
//Serializatoin counstructor. call when Deserialize function called.
public CBahram_SALContainer(SerializationInfo info, StreamingContext context)
{
var1 = (int)info.GetValue("var1",typeof(int));
var2 = (int)info.GetValue("var2",typeof(int));
var3 = (int)info.GetValue("var3",typeof(int));
var4 = (int)info.GetValue("var4",typeof(int));
}