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


C# ISerializationContext类代码示例

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


ISerializationContext类属于命名空间,在下文中一共展示了ISerializationContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ChannelChangeInfo

        public ChannelChangeInfo(ISerializationContext context, IValueReader reader)
        {
            if (reader == null)
                throw new ArgumentNullException("reader");

            Deserialize (context, reader);
        }
开发者ID:ermau,项目名称:Gablarski,代码行数:7,代码来源:ChannelChangeInfo.cs

示例2: OnMobileSerializeState

        protected override void OnMobileSerializeState(ISerializationContext context)
        {
            base.OnMobileSerializeState(context);

            context.AddState("v", this.Value);
            context.AddState("t", this.TypeName);
        }
开发者ID:569550384,项目名称:Rafy,代码行数:7,代码来源:SysState.cs

示例3: ReadEntity

        private NetworkEntity ReadEntity(ISerializationContext context, IValueReader reader)
        {
            var entity = new NetworkEntity (reader.ReadString (), EntityType.Client);

            entity.NetworkID = reader.ReadUInt16 ();
            UInt16 fieldCount = reader.ReadUInt16 ();

            for (int f = 0; f < fieldCount; f++)
            {
                string name = reader.ReadString ();
                ushort typeID = reader.ReadUInt16 ();

                Type type;
                context.TypeMap.TryGetType (typeID, out type);

                object value;

                if (type == typeof (Vector2))
                    value = reader.Read (context, Vector2Serializer.Instance);
                else if (type == typeof (Vector3))
                    value = reader.Read (context, Vector3Serializer.Instance);
                else
                    value = reader.Read (context, type);

                entity.Fields.Add (name, new PropertyGroup (value, type));
            }

            return entity;
        }
开发者ID:NullSoldier,项目名称:Cinco,代码行数:29,代码来源:EntitySnapshotMessage.cs

示例4: SerializeMember

        /// <summary>
        /// Serializes the member.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="memberValue">The member value.</param>
        public override void SerializeMember(ISerializationContext context, MemberValue memberValue)
        {
            base.SerializeMember(context, memberValue);

            var value = memberValue.Value;
            if (value != null)
            {
                var valueType = value.GetType();
                if (valueType.IsGenericTypeEx())
                {
                    if (valueType.GetGenericTypeDefinitionEx() == typeof(KeyValuePair<,>))
                    {
                        var keyProperty = valueType.GetPropertyEx("Key");
                        var valueProperty = valueType.GetPropertyEx("Value");

                        var kvpKey = keyProperty.GetValue(value, null);
                        var kvpValue = valueProperty.GetValue(value, null);

                        var finalValue = string.Format("{0}{1}{2}{1}{3}{1}{4}{1}{5}", Prefix, Splitter,
                            keyProperty.PropertyType, valueProperty.PropertyType,
                            ObjectToStringHelper.ToString(kvpKey), ObjectToStringHelper.ToString(kvpValue));

                        memberValue.Value = finalValue;
                    }
                }
            }
        }
开发者ID:matthijskoopman,项目名称:Catel,代码行数:32,代码来源:KeyValuePairSerializerModifier.cs

示例5: OnMobileDeserializeState

        protected override void OnMobileDeserializeState(ISerializationContext context)
        {
            this.Value = context.GetState<object>("v");
            this.TypeName = context.GetState<string>("t");

            base.OnMobileDeserializeState(context);
        }
开发者ID:569550384,项目名称:Rafy,代码行数:7,代码来源:SysState.cs

示例6: DeserializeMember

        /// <summary>
        /// Deserializes the member.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="memberValue">The member value.</param>
        public override void DeserializeMember(ISerializationContext context, MemberValue memberValue)
        {
            var valueAsString = memberValue.Value as string;
            if (!string.IsNullOrEmpty(valueAsString))
            {
                if (valueAsString.StartsWith(Prefix))
                {
                    var splittedValues = valueAsString.Split(new[] { Splitter }, StringSplitOptions.None);

                    var keyValuePairType = typeof(KeyValuePair<,>);
                    var keyType = TypeCache.GetTypeWithoutAssembly(splittedValues[1]);
                    var valueType = TypeCache.GetTypeWithoutAssembly(splittedValues[2]);
                    var keyValue = splittedValues[3];
                    var valueValue = splittedValues[4];

                    // TODO: consider caching
                    var keyValuePairGenericType = keyValuePairType.MakeGenericType(keyType, valueType);

                    var key = StringToObjectHelper.ToRightType(keyType, keyValue);
                    var value = StringToObjectHelper.ToRightType(valueType, valueValue);

                    var keyValuePair = Activator.CreateInstance(keyValuePairGenericType, new [] { key, value });

                    memberValue.Value = keyValuePair;
                }
            }

            base.DeserializeMember(context, memberValue);
        }
开发者ID:matthijskoopman,项目名称:Catel,代码行数:34,代码来源:KeyValuePairSerializerModifier.cs

示例7: ServerInfo

        internal ServerInfo(ISerializationContext context, IValueReader reader)
        {
            if (reader == null)
                throw new ArgumentNullException ("reader");

            Deserialize (context, reader);
        }
开发者ID:ermau,项目名称:Gablarski,代码行数:7,代码来源:ServerInfo.cs

示例8: Normalize

        public static TextReader Normalize(TextReader tr, ISerializationContext ctx)
        {
            string s = tr.ReadToEnd();
            TextReader reader = Normalize(s, ctx);
            tr.Close();

            return reader;
        }
开发者ID:logikonline,项目名称:DDay.iCal,代码行数:8,代码来源:TextUtil.cs

示例9: ReadPayload

        public override void ReadPayload(ISerializationContext context, IValueReader reader)
        {
            AudioSource[] sourceInfos = new AudioSource[reader.ReadInt32()];
            for (int i = 0; i < sourceInfos.Length; ++i)
                sourceInfos[i] = new AudioSource (context, reader);

            this.Sources = sourceInfos;
        }
开发者ID:ermau,项目名称:Gablarski,代码行数:8,代码来源:SourceListMessage.cs

示例10: SetObjectData

 public override void SetObjectData(ISerializationData dataHolder, ISerializationContext context)
 {
     base.SetObjectData(dataHolder, context);
     if (dataHolder.ContainsField("Priority"))
         Priority = dataHolder.GetValue<float>("Priority");
     else
         Priority = context.Context as float? ?? DEFAULT_ACTION_PRIORITY;
 }
开发者ID:GAIPS-INESC-ID,项目名称:FAtiMA-Toolkit,代码行数:8,代码来源:ActionTendency.cs

示例11: ReadPayload

        public override void ReadPayload(ISerializationContext context, IValueReader reader)
        {
            int[] sourceIds = new int[reader.ReadInt32()];
            for (int i = 0; i < sourceIds.Length; ++i)
                sourceIds[i] = reader.ReadInt32();

            this.SourceIds = sourceIds;
        }
开发者ID:ermau,项目名称:Gablarski,代码行数:8,代码来源:SourcesRemovedMessage.cs

示例12: WritePayload

 public override void WritePayload(ISerializationContext context, IValueWriter writer)
 {
     using (var ms = new MemoryStream())
     {
         ScreenFrame.Save(ms, ImageFormat.Png);
         writer.WriteBytes(ms.GetBuffer());
     }
 }
开发者ID:erpframework,项目名称:screenshare,代码行数:8,代码来源:ScreenFrameResponseMessage.cs

示例13: ReadPayload

		public override void ReadPayload (ISerializationContext context, IValueReader reader)
		{
			if (reader.ReadBool())
				SenderId = reader.ReadString();

			GroupId = reader.ReadInt32();
			Text = reader.ReadString();
		}
开发者ID:ermau,项目名称:Tempest.Social,代码行数:8,代码来源:TextMessage.cs

示例14: WritePayload

		public override void WritePayload (ISerializationContext context, IValueWriter writer)
		{
			if (writer.WriteBool (SenderId != null))
				writer.WriteString (SenderId);

			writer.WriteInt32 (GroupId);
			writer.WriteString (Text);
		}
开发者ID:ermau,项目名称:Tempest.Social,代码行数:8,代码来源:TextMessage.cs

示例15: RegisterId

 public virtual void RegisterId(string id, object value, ISerializationContext context)
 {
     if (value != null)
     {
         var type = Serializer.GetSerializationInfo(value.GetType(), true);
         InsertIntoIdStore(id, value, type);
         context.Register(value, new Uri(id, UriKind.Relative), this);
     }
 }
开发者ID:FrederikP,项目名称:NMF,代码行数:9,代码来源:XmlSerializationEntity.cs


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