本文整理汇总了C#中AMFWriter类的典型用法代码示例。如果您正苦于以下问题:C# AMFWriter类的具体用法?C# AMFWriter怎么用?C# AMFWriter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AMFWriter类属于命名空间,在下文中一共展示了AMFWriter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: WriteData
public void WriteData(AMFWriter writer, object data)
{
NameObjectCollectionBase collection = data as NameObjectCollectionBase;
object[] attributes = collection.GetType().GetCustomAttributes(typeof(DefaultMemberAttribute), false);
if (attributes != null && attributes.Length > 0)
{
DefaultMemberAttribute defaultMemberAttribute = attributes[0] as DefaultMemberAttribute;
PropertyInfo pi = collection.GetType().GetProperty(defaultMemberAttribute.MemberName, new Type[] { typeof(string) });
if (pi != null)
{
ASObject aso = new ASObject();
for (int i = 0; i < collection.Keys.Count; i++)
{
string key = collection.Keys[i];
object value = pi.GetValue(collection, new object[]{ key });
aso.Add(key, value);
}
writer.WriteByte(AMF3TypeCode.Object);
writer.WriteAMF3Object(aso);
return;
}
}
//We could not access an indexer so write out as it is.
writer.WriteByte(AMF3TypeCode.Object);
writer.WriteAMF3Object(data);
}
开发者ID:apakian,项目名称:fluorinefx,代码行数:27,代码来源:AMF3NameObjectCollectionWriter.cs
示例2: WriteData
public void WriteData(AMFWriter writer, object data) {
if (data is INullable) {
if ((data as INullable).IsNull) {
writer.WriteAMF3Null();
return;
}
}
if (data is SqlByte) {
writer.WriteAMF3Data(((SqlByte)data).Value);
return;
}
if (data is SqlInt16) {
writer.WriteAMF3Data(((SqlInt16)data).Value);
return;
}
if (data is SqlInt32) {
writer.WriteAMF3Data(((SqlInt32)data).Value);
return;
}
if (data is SqlInt64) {
writer.WriteAMF3Data(((SqlInt64)data).Value);
return;
}
if (data is SqlSingle) {
writer.WriteAMF3Data(((SqlSingle)data).Value);
return;
}
if (data is SqlDouble) {
writer.WriteAMF3Data(((SqlDouble)data).Value);
return;
}
if (data is SqlDecimal) {
writer.WriteAMF3Data(((SqlDecimal)data).Value);
return;
}
if (data is SqlMoney) {
writer.WriteAMF3Data(((SqlMoney)data).Value);
return;
}
if (data is SqlDateTime) {
writer.WriteAMF3Data(((SqlDateTime)data).Value);
return;
}
if (data is SqlString) {
writer.WriteAMF3String(((SqlString)data).Value);
return;
}
if (data is SqlGuid) {
writer.WriteAMF3Data(((SqlGuid)data).Value.ToString("D"));
return;
}
if (data is SqlBoolean) {
writer.WriteAMF3Bool(((SqlBoolean)data).Value);
return;
}
string msg = string.Format("Could not find serializer for type {0}", data.GetType().FullName);
if (_log.IsErrorEnabled)
_log.Error(msg);
throw new FluorineException(msg);
}
开发者ID:GodLesZ,项目名称:svn-dump,代码行数:60,代码来源:AMF3SqlTypesWriter.cs
示例3: WriteData
public void WriteData(AMFWriter writer, object data)
{
var collection = data as NameObjectCollectionBase;
var attributes = collection.GetType().GetCustomAttributes(typeof(DefaultMemberAttribute), false);
if (attributes != null && attributes.Length > 0)
{
var defaultMemberAttribute = attributes[0] as DefaultMemberAttribute;
var pi = collection.GetType().GetProperty(defaultMemberAttribute.MemberName, new[] { typeof(string) });
if (pi != null)
{
var aso = new ASObject();
for (var i = 0; i < collection.Keys.Count; i++)
{
var key = collection.Keys[i];
var value = pi.GetValue(collection, new object[]{ key });
aso.Add(key, value);
}
writer.WriteASO(ObjectEncoding.AMF0, aso);
return;
}
}
//We could not access an indexer so write out as it is.
writer.WriteObject(ObjectEncoding.AMF0, data);
}
开发者ID:mstaessen,项目名称:fluorinefx,代码行数:25,代码来源:AMF0NameObjectCollectionWriter.cs
示例4: FlvWriter
public FlvWriter(Stream stream, bool append)
{
_writer = new AMFWriter(stream);
_append = append;
if (_append)
{
if (stream.Length > 9 + 15)
{
try
{
//Skip header
stream.Position = 9;
byte[] tagBuffer = new byte[15];
//previousTagSize
stream.Read(tagBuffer, 0, 4);
//start of flv tag
byte dataType = (byte)stream.ReadByte();
if (dataType == IOConstants.TYPE_METADATA)
{
_metaPosition = stream.Position - 1;
//body size
stream.Read(tagBuffer, 5, 3);
int bodySize = tagBuffer[5] << 16 | tagBuffer[6] << 8 | tagBuffer[7];
//timestamp
stream.Read(tagBuffer, 8, 4);
//streamid
stream.Read(tagBuffer, 12, 3);
byte[] buffer = new byte[bodySize];
stream.Read(buffer, 0, buffer.Length);
MemoryStream ms = new MemoryStream(buffer);
AMFReader input = new AMFReader(ms);
string onMetaData = input.ReadData() as string;//input.ReadString();
IDictionary properties = input.ReadData() as IDictionary;
if (properties.Contains("duration"))
_duration = System.Convert.ToInt32(properties["duration"]);
else
{
#if !SILVERLIGHT
log.Warn("Could not read Flv duration from metadata");
#endif
}
}
else
{
#if !SILVERLIGHT
log.Warn("Could not read Flv duration");
#endif
}
}
catch (Exception ex)
{
#if !SILVERLIGHT
log.Warn("Error reading Flv duration", ex);
#endif
}
}
stream.Seek(0, SeekOrigin.End);//Appending
}
}
开发者ID:Nicholi,项目名称:fluorinefx-mod,代码行数:59,代码来源:FlvWriter.cs
示例5: WriteData
public void WriteData(AMFWriter writer, object data) {
if (data is byte[])
data = new ByteArray(data as byte[]);
if (data is ByteArray) {
writer.WriteByteArray(data as ByteArray);
}
}
开发者ID:GodLesZ,项目名称:svn-dump,代码行数:8,代码来源:AMF3ByteArrayWriter.cs
示例6: ByteArray
/// <summary>
/// Initializes a new instance of the ByteArray class.
/// </summary>
public ByteArray() {
_memoryStream = new MemoryStream();
AMFReader amfReader = new AMFReader(_memoryStream);
AMFWriter amfWriter = new AMFWriter(_memoryStream);
_dataOutput = new DataOutput(amfWriter);
_dataInput = new DataInput(amfReader);
_objectEncoding = ObjectEncoding.AMF3;
}
开发者ID:GodLesZ,项目名称:svn-dump,代码行数:11,代码来源:ByteArray.cs
示例7: WriteData
public void WriteData(AMFWriter writer, object data)
{
if( data is IList )
{
IList list = data as IList;
object[] array = new object[list.Count];
list.CopyTo(array, 0);
writer.WriteArray(ObjectEncoding.AMF0, array);
return;
}
#if !(SILVERLIGHT)
IListSource listSource = data as IListSource;
if (listSource != null)
{
IList list = listSource.GetList();
object[] array = new object[list.Count];
list.CopyTo(array, 0);
writer.WriteArray(ObjectEncoding.AMF0, array);
return;
}
#endif
if(data is IDictionary)
{
writer.WriteAssociativeArray(ObjectEncoding.AMF0, data as IDictionary);
return;
}
if(data is Exception)
{
writer.WriteASO(ObjectEncoding.AMF0, new ExceptionASO(data as Exception) );
return;
}
if (data is IEnumerable)
{
List<object> tmp = new List<object>();
foreach (object element in (data as IEnumerable))
{
tmp.Add(element);
}
writer.WriteArray(ObjectEncoding.AMF0, tmp.ToArray());
return;
}
writer.WriteObject(ObjectEncoding.AMF0, data);
}
开发者ID:ByteSempai,项目名称:Ubiquitous,代码行数:43,代码来源:AMF0ObjectWriter.cs
示例8: WriteData
public void WriteData(AMFWriter writer, object data)
{
writer.WriteByte(AMF0TypeCode.String);
writer.WriteUTF( new String( (char)data, 1) );
}
开发者ID:mstaessen,项目名称:fluorinefx,代码行数:5,代码来源:AMF0CharWriter.cs
示例9: WriteData
public void WriteData(AMFWriter writer, object data) {
writer.WriteByte(AMF3TypeCode.Object);
writer.WriteAMF3Object(data);
}
开发者ID:GodLesZ,项目名称:svn-dump,代码行数:4,代码来源:AMF3ASObjectWriter.cs
示例10: WriteData
public void WriteData(AMFWriter writer, object data)
{
writer.WriteAMF3String(data as string);
}
开发者ID:Boreeas,项目名称:LoLNotes,代码行数:4,代码来源:AMF3StringWriter.cs
示例11: WriteData
public void WriteData(AMFWriter writer, object data)
{
writer.WriteByte(AMF0TypeCode.Number);
double dbl = (double)Convert.ToInt32(data);
writer.WriteDouble(dbl);
}
开发者ID:ByteSempai,项目名称:Ubiquitous,代码行数:6,代码来源:AMF0EnumWriter.cs
示例12: Serialize
public void Serialize(AMFWriter writer)
{
writer.WriteString(this.Name);
writer.WriteString(this.Path);
writer.WriteData(ObjectEncoding.AMF0, _attributes);
}
开发者ID:Nicholi,项目名称:fluorinefx-mod,代码行数:6,代码来源:SharedObject.cs
示例13: ByteArray
/// <summary>
/// Initializes a new instance of the ByteArray class.
/// </summary>
/// <param name="buffer">The array of unsigned bytes from which to create the current ByteArray.</param>
public ByteArray(byte[] buffer)
{
_memoryStream = new MemoryStream();
_memoryStream.Write(buffer, 0, buffer.Length);
_memoryStream.Position = 0;
AMFReader amfReader = new AMFReader(_memoryStream);
AMFWriter amfWriter = new AMFWriter(_memoryStream);
_dataOutput = new DataOutput(amfWriter);
_dataInput = new DataInput(amfReader);
_objectEncoding = ObjectEncoding.AMF3;
}
开发者ID:ResQue1980,项目名称:LoLTeamChecker,代码行数:15,代码来源:ByteArray.cs
示例14: InjectMetaData
/// <summary>
/// Injects metadata (other than Cue points) into a tag.
/// </summary>
/// <param name="meta">Metadata.</param>
/// <param name="tag">Tag.</param>
/// <returns></returns>
private ITag InjectMetaData(MetaData meta, ITag tag) {
MemoryStream ms = new MemoryStream();
AMFWriter writer = new AMFWriter(ms);
writer.WriteData(ObjectEncoding.AMF0, "onMetaData");
writer.WriteData(ObjectEncoding.AMF0, meta);
byte[] buffer = ms.ToArray();
return new Tag(IOConstants.TYPE_METADATA, 0, buffer.Length, buffer, tag.PreviousTagSize);
}
开发者ID:GodLesZ,项目名称:svn-dump,代码行数:14,代码来源:MetaService.cs
示例15: WriteData
public void WriteData(AMFWriter writer, object data)
{
int value = Convert.ToInt32(data);
writer.WriteAMF3Int(value);
}
开发者ID:DarkActive,项目名称:daFluorineFx,代码行数:5,代码来源:AMF3IntWriter.cs
示例16: WriteBody
internal void WriteBody(ObjectEncoding objectEncoding, AMFWriter writer)
{
writer.Reset();
if (this.Target == null)
writer.WriteUTF("null");
else
writer.WriteUTF(this.Target);
if (this.Response == null)
writer.WriteUTF("null");
else
writer.WriteUTF(this.Response);
writer.WriteInt32(-1);
WriteBodyData(objectEncoding, writer);
}
开发者ID:ByteSempai,项目名称:Ubiquitous,代码行数:16,代码来源:AMFBody.cs
示例17: WriteBodyData
/// <summary>
/// This method supports the Fluorine infrastructure and is not intended to be used directly from your code.
/// </summary>
protected virtual void WriteBodyData(ObjectEncoding objectEncoding, AMFWriter writer)
{
object content = this.Content;
writer.WriteData(objectEncoding, content);
}
开发者ID:ByteSempai,项目名称:Ubiquitous,代码行数:8,代码来源:AMFBody.cs
示例18: WriteData
public void WriteData(AMFWriter writer, object data)
{
ASObject aso = TypeHelper.ConvertDataSetToASO(data as DataSet, false);
writer.WriteByte(AMF3TypeCode.Object);
writer.WriteAMF3Object(aso);
}
开发者ID:ByteSempai,项目名称:Ubiquitous,代码行数:6,代码来源:AMF3DataSetWriter.cs
示例19: Uncompress
/// <summary>
/// Decompresses the byte array. The byte array must have been previously compressed with the Compress() method.
/// </summary>
/// <param name="algorithm">The compression algorithm to use when decompressing. This must be the same compression algorithm used to compress the data. Valid values are defined as constants in the CompressionAlgorithm class. The default is to use zlib format.</param>
public void Uncompress(string algorithm)
{
ValidationUtils.ArgumentConditionTrue(algorithm == CompressionAlgorithm.Deflate || algorithm == CompressionAlgorithm.Zlib, "algorithm", "Invalid parameter");
#if SILVERLIGHT
throw new NotSupportedException();
#else
if (algorithm == CompressionAlgorithm.Zlib)
{
//The zlib format is specified by RFC 1950. Zlib also uses deflate, plus 2 or 6 header bytes, and a 4 byte checksum at the end.
//The first 2 bytes indicate the compression method and flags. If the dictionary flag is set, then 4 additional bytes will follow.
//Preset dictionaries aren't very common and we don't support them
Position = 0;
ZlibStream deflateStream = new ZlibStream(_memoryStream, CompressionMode.Decompress, false);
MemoryStream ms = new MemoryStream();
byte[] buffer = new byte[1024];
// Chop off the first two bytes
//int b = _memoryStream.ReadByte();
//b = _memoryStream.ReadByte();
while (true)
{
int readCount = deflateStream.Read(buffer, 0, buffer.Length);
if (readCount > 0)
ms.Write(buffer, 0, readCount);
else
break;
}
deflateStream.Close();
_memoryStream.Close();
_memoryStream.Dispose();
_memoryStream = ms;
_memoryStream.Position = 0;
}
if (algorithm == CompressionAlgorithm.Deflate)
{
Position = 0;
DeflateStream deflateStream = new DeflateStream(_memoryStream, CompressionMode.Decompress, false);
MemoryStream ms = new MemoryStream();
byte[] buffer = new byte[1024];
while (true)
{
int readCount = deflateStream.Read(buffer, 0, buffer.Length);
if (readCount > 0)
ms.Write(buffer, 0, readCount);
else
break;
}
deflateStream.Close();
_memoryStream.Close();
_memoryStream.Dispose();
_memoryStream = ms;
_memoryStream.Position = 0;
}
AMFReader amfReader = new AMFReader(_memoryStream);
AMFWriter amfWriter = new AMFWriter(_memoryStream);
_dataOutput = new DataOutput(amfWriter);
_dataInput = new DataInput(amfReader);
#endif
}
开发者ID:ResQue1980,项目名称:LoLTeamChecker,代码行数:62,代码来源:ByteArray.cs
示例20: Compress
/// <summary>
/// Compresses the byte array using zlib compression. The entire byte array is compressed.
/// </summary>
/// <param name="algorithm">The compression algorithm to use when compressing. Valid values are defined as constants in the CompressionAlgorithm class. The default is to use zlib format.</param>
/// <remarks>
/// After the call, the Length property of the ByteArray is set to the new length. The position property is set to the end of the byte array.
/// </remarks>
public void Compress(string algorithm)
{
ValidationUtils.ArgumentConditionTrue(algorithm == CompressionAlgorithm.Deflate || algorithm == CompressionAlgorithm.Zlib, "algorithm", "Invalid parameter");
#if SILVERLIGHT
throw new NotSupportedException();
#else
if (algorithm == CompressionAlgorithm.Deflate)
{
byte[] buffer = _memoryStream.ToArray();
MemoryStream ms = new MemoryStream();
DeflateStream deflateStream = new DeflateStream(ms, CompressionMode.Compress, true);
deflateStream.Write(buffer, 0, buffer.Length);
deflateStream.Close();
_memoryStream.Close();
_memoryStream = ms;
AMFReader amfReader = new AMFReader(_memoryStream);
AMFWriter amfWriter = new AMFWriter(_memoryStream);
_dataOutput = new DataOutput(amfWriter);
_dataInput = new DataInput(amfReader);
}
if (algorithm == CompressionAlgorithm.Zlib)
{
byte[] buffer = _memoryStream.ToArray();
MemoryStream ms = new MemoryStream();
ZlibStream zlibStream = new ZlibStream(ms, CompressionMode.Compress, true);
zlibStream.Write(buffer, 0, buffer.Length);
zlibStream.Flush();
zlibStream.Close();
zlibStream.Dispose();
_memoryStream.Close();
_memoryStream = ms;
AMFReader amfReader = new AMFReader(_memoryStream);
AMFWriter amfWriter = new AMFWriter(_memoryStream);
_dataOutput = new DataOutput(amfWriter);
_dataInput = new DataInput(amfReader);
}
#endif
}
开发者ID:ResQue1980,项目名称:LoLTeamChecker,代码行数:45,代码来源:ByteArray.cs
注:本文中的AMFWriter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论