本文整理汇总了C#中ISerializationContext类的典型用法代码示例。如果您正苦于以下问题:C# ISerializationContext类的具体用法?C# ISerializationContext怎么用?C# ISerializationContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ISerializationContext类属于命名空间,在下文中一共展示了ISerializationContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: DeserializeMember
public override void DeserializeMember(ISerializationContext context, MemberValue memberValue)
{
if (string.Equals(memberValue.Name, "ProjectTypes"))
{
// TODO: Match the list with WP8 => WP80 somehow?
}
base.DeserializeMember(context, memberValue);
}
开发者ID:GeertvanHorrik,项目名称:Caitlyn,代码行数:9,代码来源:RuleSerializerModifier.cs
示例17: WritePayload
public override void WritePayload(ISerializationContext context, IValueWriter writer)
{
writer.WriteInt32 (Entities.Count);
foreach (SnapshotEntity sentity in Entities)
{
WriteEntity (sentity.Entity, context, writer);
}
}
开发者ID:NullSoldier,项目名称:Cinco,代码行数:9,代码来源:EntitySnapshotMessage.cs
示例18: ReadPayload
public override void ReadPayload(ISerializationContext context, IValueReader reader)
{
int numUsers = reader.ReadInt32();
IUser[] users = new IUser[numUsers];
for (int i = 0; i < users.Length; ++i)
users[i] = new User (reader.ReadInt32(), reader.ReadString());
Users = users;
}
开发者ID:ermau,项目名称:Gablarski,代码行数:9,代码来源:UserListMessage.cs
示例19: ItemValueSerializerNode
public ItemValueSerializerNode(object value,
TypeSpec expectedBaseType,
string expandPath,
ISerializationContext context,
ISerializerNode parentNode,
bool isRemoved = false)
: base(expectedBaseType, expandPath, context, parentNode, isRemoved)
{
Value = value;
}
开发者ID:Pomona,项目名称:Pomona,代码行数:10,代码来源:ItemValueSerializerNode.cs
示例20: SerializeAsync
/// <summary>
/// Serializes the provided object asynchronously.
/// </summary>
/// <param name="obj">The object.</param>
/// <param name="textWriter">The <see cref="TextWriter"/> used to write the object content.</param>
/// <param name="context">The context.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>
/// A Task promising the serialized object as a string.
/// </returns>
public Task SerializeAsync(
object obj,
TextWriter textWriter,
ISerializationContext context = null,
CancellationToken cancellationToken = default(CancellationToken))
{
Contract.Requires(textWriter != null);
Contract.Ensures(Contract.Result<Task>() != null);
return Contract.Result<Task>();
}
开发者ID:raimu,项目名称:kephas,代码行数:21,代码来源:ISerializer.cs
注:本文中的ISerializationContext类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论