本文整理汇总了C#中IActionScriptSerializer类的典型用法代码示例。如果您正苦于以下问题:C# IActionScriptSerializer类的具体用法?C# IActionScriptSerializer怎么用?C# IActionScriptSerializer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IActionScriptSerializer类属于命名空间,在下文中一共展示了IActionScriptSerializer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AMFDataOutput
/// <summary>
/// Creates an AMF data output writer.
/// Initially uses the <see cref="AMFObjectEncoding.AMF0" /> object encoding.
/// </summary>
/// <param name="stream">The output stream</param>
/// <param name="serializer">The ActionScript serializer to use for object serialization</param>
public AMFDataOutput(Stream stream, IActionScriptSerializer serializer)
{
this.stream = stream;
this.serializer = serializer;
objectEncoding = AMFObjectEncoding.AMF0;
utf8Encoding = new UTF8Encoding(false, false);
}
示例2: SetUp
public override void SetUp()
{
base.SetUp();
stream = new MemoryStream();
serializer = Mocks.CreateMock<IActionScriptSerializer>();
input = new AMFDataInput(stream, serializer);
}
示例3: AMFDataInput
/// <summary>
/// Creates an AMF data input reader.
/// Initially uses the <see cref="AMFObjectEncoding.AMF0" /> object encoding,
/// switches modes automatically if <see cref="AMFObjectEncoding.AMF3" /> data is encountered.
/// </summary>
/// <param name="stream">The input stream</param>
/// <param name="serializer">The ActionScript serializer to use for object serialization</param>
public AMFDataInput(Stream stream, IActionScriptSerializer serializer)
{
this.stream = stream;
this.serializer = serializer;
objectReader = new AMF0ObjectReader(this);
utf8Encoding = new UTF8Encoding(false, false);
}
示例4: WriteStringData
void IASValueVisitor.VisitXml(IActionScriptSerializer serializer, string xmlString)
{
output.WriteByte((byte)AMF3ObjectTypeCode.Xml);
WriteStringData(xmlString);
}
示例5: AMFException
void IASValueVisitor.VisitObject(IActionScriptSerializer serializer, ASClass @class, IEnumerable<IASValue> memberValues,
IEnumerable<KeyValuePair<string, IASValue>> dynamicProperties,
IExternalizable externalizableValue)
{
int objectReferenceId = AddCurrentValueToCache(AMF3ObjectTypeCode.Object);
output.WriteByte((byte)AMF3ObjectTypeCode.Object);
// Look for a suitable existing class definition in the cache.
int classDefinitionId;
if (classDefinitionCache.TryGetValue(@class, out classDefinitionId))
{
// Use class definition reference.
output.WriteVWInt29(classDefinitionId * 4 + 1);
}
else
{
// Include class definition inline and add it to the cache.
classDefinitionCache.Add(@class, objectReferenceId);
output.WriteVWInt29(@class.MemberNames.Count * 16 + (int)@class.Layout * 4 + 3);
WriteStringData(@class.ClassAlias);
foreach (string memberName in @class.MemberNames)
{
if (String.IsNullOrEmpty(memberName))
throw new AMFException(ExceptionPrefix + "Cannot serialize an object with a null or empty member name.");
WriteStringData(memberName);
}
}
if (@class.Layout == ASClassLayout.Externalizable)
{
if (externalizableValue == null)
throw new AMFException(ExceptionPrefix + "The class layout is Externalizable but the object does not provide an ExternalizableValue.");
externalizableValue.WriteExternal(output);
}
else
{
// Write the members first as a sequence of values.
int memberCount = @class.MemberNames.Count;
int memberIndex = 0;
foreach (IASValue memberValue in memberValues)
{
if (memberIndex == memberCount)
throw new AMFException(ExceptionPrefix + "The number of member values provided by the object is greater than was indicated by its class.");
WriteObject(memberValue);
memberIndex += 1;
}
if (memberIndex != memberCount)
throw new AMFException(ExceptionPrefix + "The number of member values provided by the object is less than was indicated by its class.");
if (@class.Layout == ASClassLayout.Dynamic)
{
// Write dynamic key/value pairs.
foreach (KeyValuePair<string, IASValue> pair in dynamicProperties)
{
if (String.IsNullOrEmpty(pair.Key))
throw new AMFException(ExceptionPrefix + "Cannot serialize an object with a null or empty string key.");
WriteStringData(pair.Key);
WriteObject(pair.Value);
}
// Terminate with empty string.
WriteStringData("");
}
}
}
示例6: AMFException
void IASValueVisitor.VisitByteArray(IActionScriptSerializer serializer, int length, IEnumerable<ArraySegment<byte>> segments)
{
// Serialize the value as a plain old array of numbers for AMF0.
AddCurrentValueToCache();
output.WriteByte((byte)AMF0ObjectTypeCode.Array);
output.WriteInt(length);
if (length != 0)
{
int bytesRemaining = length;
foreach (ArraySegment<byte> bytes in segments)
{
if (bytesRemaining < bytes.Count)
throw new AMFException(ExceptionPrefix + "The byte array provided more bytes than were indicated by its length.");
bytesRemaining -= bytes.Count;
int offset = bytes.Offset;
int count = bytes.Count;
byte[] array = bytes.Array;
while (count-- > 0)
WriteNumber(array[offset++]);
}
if (bytesRemaining != 0)
throw new AMFException(ExceptionPrefix + "The byte array did not provide as many bytes as were indicated by its length.");
}
}
示例7: AcceptVisitor
/// <inheritdoc />
public override void AcceptVisitor(IActionScriptSerializer serializer, IASValueVisitor visitor)
{
visitor.VisitInt29(serializer, value);
}
示例8: GetServiceForMessage
/// <inheritdoc />
public IService GetServiceForMessage(IActionScriptSerializer serializer, IMessage message)
{
if (serializer == null)
throw new ArgumentNullException("serializer");
if (message == null)
throw new ArgumentNullException("message");
return UncheckedGetServiceForMessage(serializer, message);
}
示例9:
void IASValueVisitor.VisitBoolean(IActionScriptSerializer serializer, bool value)
{
output.WriteByte(value ? (byte)AMF3ObjectTypeCode.True : (byte)AMF3ObjectTypeCode.False);
}
示例10: AcceptVisitor
/// <inheritdoc />
public override void AcceptVisitor(IActionScriptSerializer serializer, IASValueVisitor visitor)
{
ArraySegment<byte>[] segments = new ArraySegment<byte>[] { bytes };
visitor.VisitByteArray(serializer, bytes.Count, segments);
}
示例11: AcceptVisitor
/// <inheritdoc />
public override void AcceptVisitor(IActionScriptSerializer serializer, IASValueVisitor visitor)
{
ThrowIfNotInitialized();
mapper.AcceptVisitor(serializer, nativeArray, visitor);
}
示例12: AcceptVisitor
/// <inheritdoc />
public override void AcceptVisitor(IActionScriptSerializer serializer, IASValueVisitor visitor)
{
ThrowIfNotInitialized();
visitor.VisitObject(serializer, @class, memberValues, dynamicProperties, null);
}
示例13:
void IASValueVisitor.VisitBoolean(IActionScriptSerializer serializer, bool value)
{
output.WriteByte((byte)AMF0ObjectTypeCode.Boolean);
output.WriteBoolean(value);
}
示例14: WriteNull
void IASValueVisitor.VisitNull(IActionScriptSerializer serializer)
{
WriteNull();
}
示例15: AcceptVisitor
/// <inheritdoc />
public override void AcceptVisitor(IActionScriptSerializer serializer, IASValueVisitor visitor)
{
ThrowIfNotInitialized();
visitor.VisitObject(serializer, @class,
EmptyArray<IASValue>.Instance, EmptyDictionary<string, IASValue>.Instance,
externalizableValue);
}