• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# StreamingContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中StreamingContext的典型用法代码示例。如果您正苦于以下问题:C# StreamingContext类的具体用法?C# StreamingContext怎么用?C# StreamingContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



StreamingContext类属于命名空间,在下文中一共展示了StreamingContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: GetObjectData

 // Method called to serialize a Vector3 object
 public void GetObjectData(System.Object obj, SerializationInfo info, StreamingContext context)
 {
     Color c = (Color) obj;
     info.AddValue("r", c.r);
     info.AddValue("g", c.g);
     info.AddValue("b", c.b);
 }
开发者ID:elborio,项目名称:SeriousGamingGame,代码行数:8,代码来源:ColorSerializationSurrogate.cs


示例17: typeof

 void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
 {
     info.AddValue ("SourceID", SourceID, typeof(int));
     info.AddValue ("DestID", DestID, typeof(int));
     info.AddValue ("MessageType", Type, typeof(MessageType));
     info.AddValue ("SerializedContent", SerializedContent, typeof(byte[]));
 }
开发者ID:Samaed,项目名称:ChickenDodge,代码行数:7,代码来源:Message.cs


示例18: Resource

 public Resource(SerializationInfo info, StreamingContext context)
     : base(1,(string) info.GetValue("type", typeof(string)), null, (string) info.GetValue("description", typeof(string)), null)
 {
     // Reset the property value using the GetValue method.
     tier = (int) info.GetValue("tier", typeof(int));
     use = (int) info.GetValue ("use", typeof(int));
 }
开发者ID:RCARL,项目名称:CS380Unity,代码行数:7,代码来源:Resource.cs


示例19: GetObjectData

 /*[SecurityPermissionAttribute(
             SecurityAction.Demand,
             SerializationFormatter = true)]		*/
 public void GetObjectData(SerializationInfo info, StreamingContext ctxt)
 {
     info.AddValue("x", this.x);
     info.AddValue("y", this.y);
     info.AddValue("z", this.z);
     info.AddValue("w", this.w);
 }
开发者ID:ChubbRck,项目名称:SFB,代码行数:10,代码来源:SerQuaternion.cs


示例20: Message

 public Message(SerializationInfo info, StreamingContext context)
 {
     SourceID = info.GetInt32 ("SourceID");
     DestID = info.GetInt32 ("DestID");
     Type = (MessageType)info.GetByte ("MessageType");
     SerializedContent = (byte[])info.GetValue ("SerializedContent", typeof(byte[]));
 }
开发者ID:Samaed,项目名称:ChickenDodge,代码行数:7,代码来源:Message.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# String类代码示例发布时间:2022-05-24
下一篇:
C# StreamWriterLevel类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap