本文整理匯總了C#中AMFReader.ReadAMF3Data方法的典型用法代碼示例。如果您正苦於以下問題:C# AMFReader.ReadAMF3Data方法的具體用法?C# AMFReader.ReadAMF3Data怎麽用?C# AMFReader.ReadAMF3Data使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類AMFReader
的用法示例。
在下文中一共展示了AMFReader.ReadAMF3Data方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: 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;
}
示例3: CreateReadDataMethod
protected virtual ReadDataInvoker CreateReadDataMethod(Type type, AMFReader reader, object instance)
{
#if !(MONO) && !(NET_2_0) && !(NET_3_5) && !(SILVERLIGHT)
bool canSkipChecks = _ps.IsSubsetOf(AppDomain.CurrentDomain.PermissionSet);
#else
bool canSkipChecks = SecurityManager.IsGranted(new ReflectionPermission(ReflectionPermissionFlag.MemberAccess));
#endif
DynamicMethod method = new DynamicMethod(string.Empty, typeof(object), new Type[] { typeof(AMFReader), typeof(ClassDefinition) }, this.GetType(), canSkipChecks);
ILGenerator il = method.GetILGenerator();
LocalBuilder instanceLocal = il.DeclareLocal(type);//[0] instance
LocalBuilder typeCodeLocal = il.DeclareLocal(typeof(byte));//[1] uint8 typeCode
LocalBuilder keyLocal = il.DeclareLocal(typeof(string));//[2] string key
LocalBuilder objTmp = il.DeclareLocal(typeof(object));//[3] temp object store
LocalBuilder intTmp1 = il.DeclareLocal(typeof(int));//[4] temp int store, length
LocalBuilder intTmp2 = il.DeclareLocal(typeof(int));//[5] temp int store, index
LocalBuilder objTmp2 = il.DeclareLocal(typeof(object));//[6] temp object store
LocalBuilder typeTmp = il.DeclareLocal(typeof(Type));//[7] temp Type store
EmitHelper emit = new EmitHelper(il);
ConstructorInfo typeConstructor = type.GetConstructor(EmitHelper.AnyVisibilityInstance, null, CallingConventions.HasThis, System.Type.EmptyTypes, null);
MethodInfo miAddReference = typeof(AMFReader).GetMethod("AddAMF3ObjectReference");
MethodInfo miReadByte = typeof(AMFReader).GetMethod("ReadByte");
emit
//object instance = new object();
.newobj(typeConstructor) //Create the new instance and push the object reference onto the evaluation stack
.stloc_0 //Pop from the top of the evaluation stack and store it in a the local variable list at index 0
//reader.AddReference(instance);
.ldarg_0 //Push the argument indexed at 1 onto the evaluation stack 'reader'
.ldloc_0 //Loads the local variable at index 0 onto the evaluation stack 'instance'
.callvirt(miAddReference) //Arguments are popped from the stack, the method call is performed, return value is pushed onto the stack
//typeCode = 0;
.ldc_i4_0 //Push the integer value of 0 onto the evaluation stack as an int32
.stloc_1 //Pop and store it in a the local variable list at index 1
//string key = null;
.ldnull //Push a null reference onto the evaluation stack
.stloc_2 //Pop and store it in a the local variable list at index 2 'key'
.end()
;
for (int i = 0; i < _classDefinition.MemberCount; i++)
{
string key = _classDefinition.Members[i].Name;
byte typeCode = reader.ReadByte();
object value = reader.ReadAMF3Data(typeCode);
reader.SetMember(instance, key, value);
emit
//.ldarg_1
//.callvirt(typeof(ClassDefinition).GetMethod("get_Members"))
//.ldc_i4(i)
//.conv_ovf_i
//.ldelem_ref
//.stloc_2
.ldarg_0
.callvirt(miReadByte)
.stloc_1
.end()
;
MemberInfo[] memberInfos = type.GetMember(key);
if (memberInfos != null && memberInfos.Length > 0)
GeneratePropertySet(emit, typeCode, memberInfos[0]);
else
{
//Log this error (do not throw exception), otherwise our current AMF stream becomes unreliable
log.Warn(__Res.GetString(__Res.Optimizer_Warning));
string msg = __Res.GetString(__Res.Reflection_MemberNotFound, string.Format("{0}.{1}", type.FullName, key));
log.Warn(msg);
//reader.ReadAMF3Data(typeCode);
emit
.ldarg_0 //Push 'reader'
.ldloc_1 //Push 'typeCode'
.callvirt(typeof(AMFReader).GetMethod("ReadAMF3Data", new Type[] { typeof(byte) }))
.pop
.end()
;
}
}
Label labelExit = emit.DefineLabel();
emit
.MarkLabel(labelExit)
//return instance;
.ldloc_0 //Load the local variable at index 0 onto the evaluation stack
.ret() //Return
;
return (ReadDataInvoker)method.CreateDelegate(typeof(ReadDataInvoker));
}
示例4: ReadData
public object ReadData(AMFReader reader)
{
return reader.ReadAMF3Data();
}