本文整理汇总了C#中AMFReader类的典型用法代码示例。如果您正苦于以下问题:C# AMFReader类的具体用法?C# AMFReader怎么用?C# AMFReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AMFReader类属于命名空间,在下文中一共展示了AMFReader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Read
public static DsoAmfBody Read(AMFReader reader, bool isAmf3) {
reader.Reset();
ushort targetUriLen = reader.ReadUInt16();
string targetUri = reader.ReadUTF(targetUriLen); // When the message holds a response from a remote endpoint, the target URI specifies which method on the local client (i.e. reader request originator) should be invoked to handle the response.
ushort responseUriLen = reader.ReadUInt16();
string responseUri = reader.ReadUTF(responseUriLen); // The response's target URI is set to the request's response URI with an '/onResult' suffix to denote a success or an '/onStatus' suffix to denote a failure.
long dataLen = reader.ReadUInt32();
if (dataLen >= 2147483648) {
dataLen = -4294967296;
}
object bodyObj;
// Check for AMF3 kAvmPlusObjectType object type
if (isAmf3) {
byte typeMarker = reader.ReadByte();
if (typeMarker == 17) {
bodyObj = reader.ReadAMF3Data();
} else {
bodyObj = reader.ReadData();
}
} else {
bodyObj = reader.ReadData();
}
DsoAmfBody body = new DsoAmfBody(targetUri, responseUri, bodyObj);
return body;
}
示例2: Read
public void Read(byte[] data) {
using (MemoryStream ms = new MemoryStream(data)) {
using (AMFReader amf = new AMFReader(ms)) {
Header = new List<object>();
Bodies = new List<object>();
// AMF0_VERSION = 0;
// AMF1_VERSION = 1; // There is no AMF1 but FMS uses it for some reason, hence special casing.
// AMF3_VERSION = 3;
ushort version = amf.ReadUInt16();
// Number of headers
ushort numHeaders = amf.ReadUInt16();
while (numHeaders-- > 0) {
var head = DsoAmfHeader.Read(amf);
if (head != null) {
Bodies.Add(head);
}
}
// Number of bodys
ushort numBodies = amf.ReadUInt16();
while (numBodies-- > 0) {
var body = DsoAmfBody.Read(amf);
if (body != null) {
Bodies.Add(body);
}
}
}
}
}
示例3: GetReflectionOptimizer
public IReflectionOptimizer GetReflectionOptimizer(Type type, ClassDefinition classDefinition, AMFReader reader, object instance)
{
if( classDefinition == null )
return new AMF0ReflectionOptimizer(type, reader).Generate(instance);
else
return new AMF3ReflectionOptimizer(type, classDefinition, reader).Generate(instance);
}
示例4: AMF0ReflectionOptimizer
public AMF0ReflectionOptimizer(Type type, AMFReader reader, object instance) {
_createInstanceMethod = CreateCreateInstanceMethod(type);
#if !(MONO) && !(NET_2_0) && !(NET_3_5) && !(SILVERLIGHT)
_ps = new PermissionSet(PermissionState.None);
_ps.AddPermission(new ReflectionPermission(ReflectionPermissionFlag.MemberAccess));
#endif
_readDataMethod = CreateReadDataMethod(type, reader, instance);
}
示例5: 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;
}
示例6: GetReflectionOptimizer
public IReflectionOptimizer GetReflectionOptimizer(Type type, ClassDefinition classDefinition, AMFReader reader, object instance)
{
#if NET_1_1
return null;
#else
if (classDefinition == null)
return new AMF0ReflectionOptimizer(type, reader, instance);
return new AMF3ReflectionOptimizer(type, classDefinition, reader, instance);
#endif
}
示例7: Read
public static DsoAmfHeader Read(AMFReader reader) {
reader.Reset();
ushort nameLen = reader.ReadUInt16();
string name = reader.ReadUTF(nameLen);
bool required = (reader.ReadByte() > 0); // find the must understand flag
uint dataLen = reader.ReadUInt32();
object headObj = reader.ReadData();
DsoAmfHeader header = new DsoAmfHeader(name, required, headObj);
return header;
}
示例8: ReadData
public object ReadData(AMFReader reader, ClassDefinition classDefinition) {
ASObject aso = new ASObject(_typeIdentifier);
reader.AddAMF3ObjectReference(aso);
string key = reader.ReadAMF3String();
aso.TypeName = _typeIdentifier;
while (key != string.Empty) {
object value = reader.ReadAMF3Data();
aso.Add(key, value);
key = reader.ReadAMF3String();
}
return aso;
}
示例9: ReadData
public object ReadData(AMFReader reader, ClassDefinition classDefinition)
{
var instance = ObjectFactory.CreateInstance(classDefinition.ClassName);
if (instance == null) {
throw new FluorineException(String.Format(Resources.Type_InitError, classDefinition.ClassName));
}
reader.AddAMF3ObjectReference(instance);
if (instance is IExternalizable)
{
var externalizable = instance as IExternalizable;
var dataInput = new DataInput(reader);
externalizable.ReadExternal(dataInput);
return instance;
}
throw new FluorineException(String.Format(Resources.Externalizable_CastFail, instance.GetType().FullName));
}
示例10: ReadData
public object ReadData(AMFReader reader, ClassDefinition classDefinition) {
object instance = ObjectFactory.CreateInstance(classDefinition.ClassName);
if (instance == null) {
string msg = __Res.GetString(__Res.Type_InitError, classDefinition.ClassName);
throw new FluorineException(msg);
}
reader.AddAMF3ObjectReference(instance);
if (instance is IExternalizable) {
IExternalizable externalizable = instance as IExternalizable;
DataInput dataInput = new DataInput(reader);
externalizable.ReadExternal(dataInput);
return instance;
} else {
string msg = __Res.GetString(__Res.Externalizable_CastFail, instance.GetType().FullName);
throw new FluorineException(msg);
}
}
示例11: LoadObject
private IPersistable LoadObject(string name, IPersistable obj) {
string fileName = PersistenceUtils.GetFilename(_scope, _path, name, _extension);
FileInfo file = _scope.Context.GetResource(fileName).File;
if (!file.Exists)
return null;// No such file
IPersistable result = obj;
lock (this.SyncRoot) {
using (FileStream fs = new FileStream(file.FullName, FileMode.Open, FileAccess.Read, FileShare.Read)) {
AMFReader reader = new AMFReader(fs);
string typeName = reader.ReadData() as string;
result = ObjectFactory.CreateInstance(typeName) as IPersistable;
//result.Path = GetObjectPath(name, result.Name);
//result = amfDeserializer.ReadData() as IPersistable;
result.Deserialize(reader);
}
}
return result;
}
示例12: Read
public static DsoAmfBody Read(AMFReader reader) {
reader.Reset();
ushort targetUriLen = reader.ReadUInt16();
string targetUri = reader.ReadUTF(targetUriLen); // When the message holds a response from a remote endpoint, the target URI specifies which method on the local client (i.e. reader request originator) should be invoked to handle the response.
ushort responseUriLen = reader.ReadUInt16();
string responseUri = reader.ReadUTF(responseUriLen); // The response's target URI is set to the request's response URI with an '/onResult' suffix to denote a success or an '/onStatus' suffix to denote a failure.
int numBytes = 4;
uint dataLen = 0;
while (numBytes-- > 0)
dataLen = (dataLen << 8) | reader.ReadByte();
// Need to skip 1 byte more, dont know why..
reader.ReadByte();
object bodyObj = reader.ReadData(); // turn the element into real data
DsoAmfBody body = new DsoAmfBody(targetUri, responseUri, bodyObj);
return body;
}
示例13: 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
}
示例14: ReadData
public object ReadData(AMFReader reader)
{
return reader.ReadAMF3Int();
}
示例15: ReadData
public object ReadData(AMFReader reader)
{
return reader.ReadAMF3XmlDocument();
}