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


C# StreamingContext类代码示例

本文整理汇总了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);
        }
开发者ID:Corillian,项目名称:corefx,代码行数:30,代码来源:SerializationInfoTests.cs

示例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);
 }
开发者ID:craus,项目名称:UnityTest,代码行数:7,代码来源:Vector3SerializationSurrogate.cs

示例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);
 }
开发者ID:phpdiva,项目名称:Synergy-repo,代码行数:8,代码来源:SaveData.cs

示例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"));
        }
开发者ID:Corillian,项目名称:corefx,代码行数:31,代码来源:SerializationInfoTests.cs

示例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 ());
		}
	}
开发者ID:DreamSea,项目名称:GuiShips,代码行数:7,代码来源:PlayerData.cs

示例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)));
 }
开发者ID:Samaed,项目名称:ChickenDodge,代码行数:7,代码来源:GameplayMessage.cs

示例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));
 }
开发者ID:Endevrie,项目名称:Verdant_Story,代码行数:7,代码来源:ProfileSaveData.cs

示例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)");
		}
开发者ID:Zman0169,项目名称:mono,代码行数:7,代码来源:appdomain2.cs

示例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);
	}
开发者ID:vsanchez1987,项目名称:team-ragnarok,代码行数:8,代码来源:Saving.cs

示例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);
 }
开发者ID:ragnarok089,项目名称:CS451,代码行数:8,代码来源:SaveData.cs

示例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);
 }
开发者ID:ThomasPlayHaven,项目名称:LaunchProject,代码行数:8,代码来源:FileManager.cs

示例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;
 }
开发者ID:TheAaltoWindrawTeam,项目名称:AaltoWindraw,代码行数:7,代码来源:SampledStroke.cs

示例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[]));
 }
开发者ID:AidinMolavy,项目名称:GrayMan-Prototype,代码行数:8,代码来源:CChair_SALContainer.cs

示例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);
 }
开发者ID:ChubbRck,项目名称:SFB,代码行数:7,代码来源:Object2PropertiesMappingListWrapper.cs

示例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));
 }
开发者ID:AidinMolavy,项目名称:GrayMan-Prototype,代码行数:8,代码来源:CBahram_SALContainer.cs


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