コード例 #1
0
        public static string GetXmlDataFromBCMTIOpen511API(string service, string queryString = null)
        {
            //Establish parameters of ssl connection
            Uri          bcMTIOpen511Uri = new Uri(defaultBcMTIOpen511Uri);
            ServicePoint pointOfService  = ServicePointManager.FindServicePoint(bcMTIOpen511Uri);

            ServicePointManager.Expect100Continue = true;
            ServicePointManager.SecurityProtocol  = SecurityProtocolType.Tls12;

            string httpResponseBody;

            using (HttpClient clientInstance = new HttpClient())
            {
                //Transmit GET to BCMTI api service
                Task <HttpResponseMessage> messageTask = clientInstance.GetAsync(defaultBcMTIOpen511Uri + service + "?" + queryString);
                System.Runtime.CompilerServices.TaskAwaiter <HttpResponseMessage> messageProcessor = messageTask.GetAwaiter();
                HttpResponseMessage responseMessage = messageProcessor.GetResult();

                //Capture reply of BCMTI api service
                Task <string> replyTask = responseMessage.Content.ReadAsStringAsync();
                System.Runtime.CompilerServices.TaskAwaiter <string> replyProcessor = replyTask.GetAwaiter();
                httpResponseBody = replyProcessor.GetResult();
            }
            return(httpResponseBody);
        }
コード例 #2
0
 public void DisplayValue1()
 {
     System.Runtime.CompilerServices.TaskAwaiter <double> awaiter = GetValueAsync(1234.5, 1.01).GetAwaiter();
     awaiter.OnCompleted(() =>
     {
         double result = awaiter.GetResult();
         Console.WriteLine("Value is : " + result);
     });
 }
コード例 #3
0
ファイル: Program.cs プロジェクト: ewin66/CSharp-Study
 //我们可以效仿一下异步任务
 public void AlikeMethod()
 {
     System.Runtime.CompilerServices.TaskAwaiter <int> awaiter = QueryScore().GetAwaiter();
     awaiter.OnCompleted(() =>
     {
         int result  = awaiter.GetResult();
         string info = $"您的考试成绩是:{result}";
         Console.WriteLine(info);
     });
 }
        static void WriteBackInstance(ILRuntime.Runtime.Enviorment.AppDomain __domain, StackObject *ptr_of_this_method, IList <object> __mStack, ref System.Runtime.CompilerServices.TaskAwaiter instance_of_this_method)
        {
            ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method);
            switch (ptr_of_this_method->ObjectType)
            {
            case ObjectTypes.Object:
            {
                __mStack[ptr_of_this_method->Value] = instance_of_this_method;
            }
            break;

            case ObjectTypes.FieldReference:
            {
                var ___obj = __mStack[ptr_of_this_method->Value];
                if (___obj is ILTypeInstance)
                {
                    ((ILTypeInstance)___obj)[ptr_of_this_method->ValueLow] = instance_of_this_method;
                }
                else
                {
                    var t = __domain.GetType(___obj.GetType()) as CLRType;
                    t.SetFieldValue(ptr_of_this_method->ValueLow, ref ___obj, instance_of_this_method);
                }
            }
            break;

            case ObjectTypes.StaticFieldReference:
            {
                var t = __domain.GetType(ptr_of_this_method->Value);
                if (t is ILType)
                {
                    ((ILType)t).StaticInstance[ptr_of_this_method->ValueLow] = instance_of_this_method;
                }
                else
                {
                    ((CLRType)t).SetStaticFieldValue(ptr_of_this_method->ValueLow, instance_of_this_method);
                }
            }
            break;

            case ObjectTypes.ArrayReference:
            {
                var instance_of_arrayReference = __mStack[ptr_of_this_method->Value] as System.Runtime.CompilerServices.TaskAwaiter[];
                instance_of_arrayReference[ptr_of_this_method->ValueLow] = instance_of_this_method;
            }
            break;
            }
        }
コード例 #5
0
        static StackObject *GetResult_1(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 1);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method);
            System.Runtime.CompilerServices.TaskAwaiter <System.String> instance_of_this_method = (System.Runtime.CompilerServices.TaskAwaiter <System.String>) typeof(System.Runtime.CompilerServices.TaskAwaiter <System.String>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));

            var result_of_this_method = instance_of_this_method.GetResult();

            WriteBackInstance(__domain, ptr_of_this_method, __mStack, ref instance_of_this_method);

            return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method));
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: eeroom/Azeroth.Core
        /// <summary>
        /// 官方的等价翻译
        /// 翻译等价代码的技巧:
        /// 按照原代码的顺序从上往下写,遇到await语句,就转成xxx.GetAwaiter(),并且定义一个对应的TaskAwaiter类型字段
        /// 然后进入IsCompleted判断,每个await语句对应的判断块都类似,不同点:把state设为不同值,这里为方便阅读代码,按照代码顺序递增state的值
        /// 关键方法:builder.AwaitUnsafeOnCompleted;这个方法不会阻塞,当前方法所在线程直接return,去执行其它任务,类库内部帮我们后续再回调到MoveNext
        /// 然后定义一个标签位置,后续代码写在标签之后
        /// </summary>
        public void MoveNext()
        {
            //这里就是配合下面翻译的代码,做的配合工作
            switch (this.state)
            {
            case 0:
                goto block0;

            case 1:
                goto block1;

            default:
                break;
            }
            //翻译等价代码的技巧:
            //按照原代码的顺序从上往下写,遇到await语句,就转成xxx.GetAwaiter(),并且定义一个对应的TaskAwaiter类型字段
            //然后进入IsCompleted判断,每个await语句对应的判断块都类似,不同点:把state设为不同值,这里为方便阅读代码,按照代码顺序递增state的值
            //然后定义一个标签位置,后续代码写在标签之后
            Console.WriteLine("进入Handler1");
            this.awaiterDelay2000 = Task.Delay(2000).GetAwaiter();
            if (!this.awaiterDelay2000.IsCompleted)
            {
                this.state = 0;
                Handler1StateMachine h1s = this;
                this.builder.AwaitUnsafeOnCompleted(ref this.awaiterDelay2000, ref h1s);
                return;
            }
block0:
            this.awaiterDelay2000.GetResult();
            Console.WriteLine("执行完Task.Delay(2000)");
            this.awaiterHandler2 = Program.Handler2(this.vv).GetAwaiter();
            if (!this.awaiterHandler2.IsCompleted)
            {
                this.state = 1;
                Handler1StateMachine h1s = this;
                this.builder.AwaitUnsafeOnCompleted(ref this.awaiterHandler2, ref h1s);
                return;
            }
block1:
            var rt = this.awaiterHandler2.GetResult();

            this.value = rt;
            Console.WriteLine("执行完Handler2");
            this.state = -2;
            this.builder.SetResult();
        }
コード例 #7
0
        static StackObject *GetResult_1(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 1);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method);
            System.Runtime.CompilerServices.TaskAwaiter instance_of_this_method = (System.Runtime.CompilerServices.TaskAwaiter) typeof(System.Runtime.CompilerServices.TaskAwaiter).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags) 16);

            instance_of_this_method.GetResult();

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            WriteBackInstance(__domain, ptr_of_this_method, __mStack, ref instance_of_this_method);

            __intp.Free(ptr_of_this_method);
            return(__ret);
        }
コード例 #8
0
        static StackObject *get_IsCompleted_0(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 1);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method);
            System.Runtime.CompilerServices.TaskAwaiter <ETModel.IResponse> instance_of_this_method = (System.Runtime.CompilerServices.TaskAwaiter <ETModel.IResponse>) typeof(System.Runtime.CompilerServices.TaskAwaiter <ETModel.IResponse>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));

            var result_of_this_method = instance_of_this_method.IsCompleted;

            WriteBackInstance(__domain, ptr_of_this_method, __mStack, ref instance_of_this_method);

            __ret->ObjectType = ObjectTypes.Integer;
            __ret->Value      = result_of_this_method ? 1 : 0;
            return(__ret + 1);
        }
コード例 #9
0
ファイル: Program.cs プロジェクト: eeroom/Azeroth.Core
        /// <summary>
        /// 简单粗暴翻译
        /// 翻译等价代码的技巧:
        /// 按照原代码的顺序从上往下写,遇到await语句,就转成xxx.GetAwaiter(),并且定义一个对应的TaskAwaiter类型字段
        /// 不做IsCompleted,全部利用builder.AwaitUnsafeOnCompleted方法结束当前方法,释放当前线程
        /// 弊端:遇到Task.FromResult这种代码,就会有点浪费,因为没必要builder.AwaitUnsafeOnCompleted
        /// </summary>
        public void MoveNext2()
        {
            //翻译等价代码的技巧:
            //按照原代码的顺序从上往下写,遇到await语句,就转成xxx.GetAwaiter(),并且定义一个对应的TaskAwaiter类型字段
            //不做IsCompleted,全部利用builder.AwaitUnsafeOnCompleted方法结束当前方法,释放当前线程
            //
            Handler1StateMachine h1s = this;

            switch (this.state)
            {
            case 0:
                Console.WriteLine("进入Handler1");
                this.awaiterDelay2000 = Task.Delay(2000).GetAwaiter();
                this.state            = 1;
                this.builder.AwaitUnsafeOnCompleted(ref this.awaiterDelay2000, ref h1s);
                return;

            case 1:
                this.awaiterDelay2000.GetResult();
                Console.WriteLine("执行完Task.Delay(2000)");
                this.awaiterHandler2 = Program.Handler2(this.vv).GetAwaiter();
                this.state           = 2;
                this.builder.AwaitUnsafeOnCompleted(ref this.awaiterHandler2, ref h1s);
                return;

            case 2:
                var rt = this.awaiterHandler2.GetResult();
                this.value = rt;
                Console.WriteLine("执行完Handler2");
                this.state = 3;
                this.builder.SetResult();
                return;

            default:
                break;
            }
        }
コード例 #10
0
        static StackObject *GetResult_1(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 1);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method);
            System.Runtime.CompilerServices.TaskAwaiter <ETModel.IResponse> instance_of_this_method = (System.Runtime.CompilerServices.TaskAwaiter <ETModel.IResponse>) typeof(System.Runtime.CompilerServices.TaskAwaiter <ETModel.IResponse>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));

            var result_of_this_method = instance_of_this_method.GetResult();

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            WriteBackInstance(__domain, ptr_of_this_method, __mStack, ref instance_of_this_method);

            __intp.Free(ptr_of_this_method);
            object obj_result_of_this_method = result_of_this_method;

            if (obj_result_of_this_method is CrossBindingAdaptorType)
            {
                return(ILIntepreter.PushObject(__ret, __mStack, ((CrossBindingAdaptorType)obj_result_of_this_method).ILInstance));
            }
            return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method));
        }
コード例 #11
0
        static StackObject *AwaitUnsafeOnCompleted_3(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 3);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            ETModel.IAsyncStateMachineClassInheritanceAdaptor.IAsyncStateMachineAdaptor @stateMachine = (ETModel.IAsyncStateMachineClassInheritanceAdaptor.IAsyncStateMachineAdaptor) typeof(ETModel.IAsyncStateMachineClassInheritanceAdaptor.IAsyncStateMachineAdaptor).CheckCLRTypes(__intp.RetriveObject(ptr_of_this_method, __mStack));

            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            System.Runtime.CompilerServices.TaskAwaiter <System.Int32> @awaiter = (System.Runtime.CompilerServices.TaskAwaiter <System.Int32>) typeof(System.Runtime.CompilerServices.TaskAwaiter <System.Int32>).CheckCLRTypes(__intp.RetriveObject(ptr_of_this_method, __mStack));

            ptr_of_this_method = ILIntepreter.Minus(__esp, 3);
            ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method);
            System.Runtime.CompilerServices.AsyncTaskMethodBuilder <System.Int32> instance_of_this_method = (System.Runtime.CompilerServices.AsyncTaskMethodBuilder <System.Int32>) typeof(System.Runtime.CompilerServices.AsyncTaskMethodBuilder <System.Int32>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));

            instance_of_this_method.AwaitUnsafeOnCompleted <System.Runtime.CompilerServices.TaskAwaiter <System.Int32>, ETModel.IAsyncStateMachineClassInheritanceAdaptor.IAsyncStateMachineAdaptor>(ref @awaiter, ref @stateMachine);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            switch (ptr_of_this_method->ObjectType)
            {
            case ObjectTypes.StackObjectReference:
            {
                var    ___dst = ILIntepreter.ResolveReference(ptr_of_this_method);
                object ___obj = @stateMachine;
                if (___dst->ObjectType >= ObjectTypes.Object)
                {
                    if (___obj is CrossBindingAdaptorType)
                    {
                        ___obj = ((CrossBindingAdaptorType)___obj).ILInstance;
                    }
                    __mStack[___dst->Value] = ___obj;
                }
                else
                {
                    ILIntepreter.UnboxObject(___dst, ___obj, __mStack, __domain);
                }
            }
            break;

            case ObjectTypes.FieldReference:
            {
                var ___obj = __mStack[ptr_of_this_method->Value];
                if (___obj is ILTypeInstance)
                {
                    ((ILTypeInstance)___obj)[ptr_of_this_method->ValueLow] = @stateMachine;
                }
                else
                {
                    var ___type = __domain.GetType(___obj.GetType()) as CLRType;
                    ___type.SetFieldValue(ptr_of_this_method->ValueLow, ref ___obj, @stateMachine);
                }
            }
            break;

            case ObjectTypes.StaticFieldReference:
            {
                var ___type = __domain.GetType(ptr_of_this_method->Value);
                if (___type is ILType)
                {
                    ((ILType)___type).StaticInstance[ptr_of_this_method->ValueLow] = @stateMachine;
                }
                else
                {
                    ((CLRType)___type).SetStaticFieldValue(ptr_of_this_method->ValueLow, @stateMachine);
                }
            }
            break;

            case ObjectTypes.ArrayReference:
            {
                var instance_of_arrayReference = __mStack[ptr_of_this_method->Value] as ETModel.IAsyncStateMachineClassInheritanceAdaptor.IAsyncStateMachineAdaptor[];
                instance_of_arrayReference[ptr_of_this_method->ValueLow] = @stateMachine;
            }
            break;
            }

            __intp.Free(ptr_of_this_method);
            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            switch (ptr_of_this_method->ObjectType)
            {
            case ObjectTypes.StackObjectReference:
            {
                var    ___dst = ILIntepreter.ResolveReference(ptr_of_this_method);
                object ___obj = @awaiter;
                if (___dst->ObjectType >= ObjectTypes.Object)
                {
                    if (___obj is CrossBindingAdaptorType)
                    {
                        ___obj = ((CrossBindingAdaptorType)___obj).ILInstance;
                    }
                    __mStack[___dst->Value] = ___obj;
                }
                else
                {
                    ILIntepreter.UnboxObject(___dst, ___obj, __mStack, __domain);
                }
            }
            break;

            case ObjectTypes.FieldReference:
            {
                var ___obj = __mStack[ptr_of_this_method->Value];
                if (___obj is ILTypeInstance)
                {
                    ((ILTypeInstance)___obj)[ptr_of_this_method->ValueLow] = @awaiter;
                }
                else
                {
                    var ___type = __domain.GetType(___obj.GetType()) as CLRType;
                    ___type.SetFieldValue(ptr_of_this_method->ValueLow, ref ___obj, @awaiter);
                }
            }
            break;

            case ObjectTypes.StaticFieldReference:
            {
                var ___type = __domain.GetType(ptr_of_this_method->Value);
                if (___type is ILType)
                {
                    ((ILType)___type).StaticInstance[ptr_of_this_method->ValueLow] = @awaiter;
                }
                else
                {
                    ((CLRType)___type).SetStaticFieldValue(ptr_of_this_method->ValueLow, @awaiter);
                }
            }
            break;

            case ObjectTypes.ArrayReference:
            {
                var instance_of_arrayReference = __mStack[ptr_of_this_method->Value] as System.Runtime.CompilerServices.TaskAwaiter <System.Int32>[];
                instance_of_arrayReference[ptr_of_this_method->ValueLow] = @awaiter;
            }
            break;
            }

            __intp.Free(ptr_of_this_method);
            ptr_of_this_method = ILIntepreter.Minus(__esp, 3);
            WriteBackInstance(__domain, ptr_of_this_method, __mStack, ref instance_of_this_method);

            __intp.Free(ptr_of_this_method);
            return(__ret);
        }
コード例 #12
0
 /// <summary>
 /// </summary>
 public TaskAwaiter(System.Runtime.CompilerServices.TaskAwaiter <T> awaiter)
 {
     m_awaiter = awaiter;
 }
コード例 #13
0
        static StackObject *get_IsCompleted_0(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 1);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method);
            System.Runtime.CompilerServices.TaskAwaiter <System.Collections.Generic.Dictionary <System.Int32, Google.Protobuf.Adapt_IMessage.Adaptor> > instance_of_this_method = (System.Runtime.CompilerServices.TaskAwaiter <System.Collections.Generic.Dictionary <System.Int32, Google.Protobuf.Adapt_IMessage.Adaptor> >) typeof(System.Runtime.CompilerServices.TaskAwaiter <System.Collections.Generic.Dictionary <System.Int32, Google.Protobuf.Adapt_IMessage.Adaptor> >).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));

            var result_of_this_method = instance_of_this_method.IsCompleted;

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            WriteBackInstance(__domain, ptr_of_this_method, __mStack, ref instance_of_this_method);

            __intp.Free(ptr_of_this_method);
            __ret->ObjectType = ObjectTypes.Integer;
            __ret->Value      = result_of_this_method ? 1 : 0;
            return(__ret + 1);
        }
コード例 #14
0
 public FlowingAwaitable(Task <Tuple <Func <TResult>, TState> > task, Action <TState> restoreState)
 {
     _awaiter      = task.GetAwaiter();
     _restoreState = restoreState;
 }
        static StackObject *AwaitUnsafeOnCompleted_6(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 3);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method);
            Framework.Hotfix.IAsyncStateMachineAdaptor.Adaptor stateMachine = (Framework.Hotfix.IAsyncStateMachineAdaptor.Adaptor) typeof(Framework.Hotfix.IAsyncStateMachineAdaptor.Adaptor).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method);
            System.Runtime.CompilerServices.TaskAwaiter <Framework.WindUI.UIAssetLoader.LoaderRequest> awaiter = (System.Runtime.CompilerServices.TaskAwaiter <Framework.WindUI.UIAssetLoader.LoaderRequest>) typeof(System.Runtime.CompilerServices.TaskAwaiter <Framework.WindUI.UIAssetLoader.LoaderRequest>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            ptr_of_this_method = ILIntepreter.Minus(__esp, 3);
            ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method);
            System.Runtime.CompilerServices.AsyncTaskMethodBuilder instance_of_this_method;
            instance_of_this_method = (System.Runtime.CompilerServices.AsyncTaskMethodBuilder) typeof(System.Runtime.CompilerServices.AsyncTaskMethodBuilder).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));

            instance_of_this_method.AwaitUnsafeOnCompleted <System.Runtime.CompilerServices.TaskAwaiter <Framework.WindUI.UIAssetLoader.LoaderRequest>, Framework.Hotfix.IAsyncStateMachineAdaptor.Adaptor>(ref awaiter, ref stateMachine);

            WriteBackInstance(__domain, ptr_of_this_method, __mStack, ref instance_of_this_method);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            switch (ptr_of_this_method->ObjectType)
            {
            case ObjectTypes.StackObjectReference:
            {
                var    ___dst = *(StackObject **)&ptr_of_this_method->Value;
                object ___obj = stateMachine;
                if (___dst->ObjectType >= ObjectTypes.Object)
                {
                    if (___obj is CrossBindingAdaptorType)
                    {
                        ___obj = ((CrossBindingAdaptorType)___obj).ILInstance;
                    }
                    __mStack[___dst->Value] = ___obj;
                }
                else
                {
                    ILIntepreter.UnboxObject(___dst, ___obj, __mStack, __domain);
                }
            }
            break;

            case ObjectTypes.FieldReference:
            {
                var ___obj = __mStack[ptr_of_this_method->Value];
                if (___obj is ILTypeInstance)
                {
                    ((ILTypeInstance)___obj)[ptr_of_this_method->ValueLow] = stateMachine;
                }
                else
                {
                    var ___type = __domain.GetType(___obj.GetType()) as CLRType;
                    ___type.SetFieldValue(ptr_of_this_method->ValueLow, ref ___obj, stateMachine);
                }
            }
            break;

            case ObjectTypes.StaticFieldReference:
            {
                var ___type = __domain.GetType(ptr_of_this_method->Value);
                if (___type is ILType)
                {
                    ((ILType)___type).StaticInstance[ptr_of_this_method->ValueLow] = stateMachine;
                }
                else
                {
                    ((CLRType)___type).SetStaticFieldValue(ptr_of_this_method->ValueLow, stateMachine);
                }
            }
            break;

            case ObjectTypes.ArrayReference:
            {
                var instance_of_arrayReference = __mStack[ptr_of_this_method->Value] as Framework.Hotfix.IAsyncStateMachineAdaptor.Adaptor[];
                instance_of_arrayReference[ptr_of_this_method->ValueLow] = stateMachine;
            }
            break;
            }

            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            switch (ptr_of_this_method->ObjectType)
            {
            case ObjectTypes.StackObjectReference:
            {
                var    ___dst = *(StackObject **)&ptr_of_this_method->Value;
                object ___obj = awaiter;
                if (___dst->ObjectType >= ObjectTypes.Object)
                {
                    if (___obj is CrossBindingAdaptorType)
                    {
                        ___obj = ((CrossBindingAdaptorType)___obj).ILInstance;
                    }
                    __mStack[___dst->Value] = ___obj;
                }
                else
                {
                    ILIntepreter.UnboxObject(___dst, ___obj, __mStack, __domain);
                }
            }
            break;

            case ObjectTypes.FieldReference:
            {
                var ___obj = __mStack[ptr_of_this_method->Value];
                if (___obj is ILTypeInstance)
                {
                    ((ILTypeInstance)___obj)[ptr_of_this_method->ValueLow] = awaiter;
                }
                else
                {
                    var ___type = __domain.GetType(___obj.GetType()) as CLRType;
                    ___type.SetFieldValue(ptr_of_this_method->ValueLow, ref ___obj, awaiter);
                }
            }
            break;

            case ObjectTypes.StaticFieldReference:
            {
                var ___type = __domain.GetType(ptr_of_this_method->Value);
                if (___type is ILType)
                {
                    ((ILType)___type).StaticInstance[ptr_of_this_method->ValueLow] = awaiter;
                }
                else
                {
                    ((CLRType)___type).SetStaticFieldValue(ptr_of_this_method->ValueLow, awaiter);
                }
            }
            break;

            case ObjectTypes.ArrayReference:
            {
                var instance_of_arrayReference = __mStack[ptr_of_this_method->Value] as System.Runtime.CompilerServices.TaskAwaiter <Framework.WindUI.UIAssetLoader.LoaderRequest>[];
                instance_of_arrayReference[ptr_of_this_method->ValueLow] = awaiter;
            }
            break;
            }

            return(__ret);
        }
コード例 #16
0
 public StrongAwaiter(Task<TResult> task)
 {
     _task = task;
     _awaiter = _task.GetAwaiter();
 }
コード例 #17
0
        protected ReportResponse FindString(ReportRequest request)
        {
            ReportResponse response2 = new ReportResponse();

            if (string.IsNullOrEmpty(request.FindString))
            {
                response2.Status  = 2;
                response2.Message = "Search value can not be empty.";
                return(response2);
            }
            try
            {
                ReportExecuteResult result = new ReportExecuteResult();
                this.LoadReport(request, ref result);
                this.Render(request, ref result, null);
                this.GetPageNumber(request, ref result);
                AspNetCore.Report.ReportExecutionService.FindStringRequest request2 = new AspNetCore.Report.ReportExecutionService.FindStringRequest
                {
                    FindValue = request.FindString,
                    StartPage = request.PageIndex,
                    EndPage   = result.PageCount
                };
                System.Runtime.CompilerServices.TaskAwaiter <AspNetCore.Report.ReportExecutionService.FindStringResponse> awaiter = this.ReportClient.FindStringAsync(request2).GetAwaiter();
                AspNetCore.Report.ReportExecutionService.FindStringResponse response = awaiter.GetResult();
                if (response.PageNumber > 0)
                {
                    ReportExecuteResult reportExecuteResult = result;
                    int num2 = reportExecuteResult.PageIndex = (request.PageIndex = response.PageNumber);
                }
                else
                {
                    if (request.PageIndex > 1)
                    {
                        request2.StartPage = 1;
                    }
                    awaiter  = this.ReportClient.FindStringAsync(request2).GetAwaiter();
                    response = awaiter.GetResult();
                    if (response.PageNumber < 1)
                    {
                        response2.Status  = 23;
                        response2.Message = "The Find Text not found in the report";
                        return(response2);
                    }
                    ReportExecuteResult reportExecuteResult2 = result;
                    int num2 = reportExecuteResult2.PageIndex = (request.PageIndex = response.PageNumber);
                }
                this.Render(request, ref result, null);
                response2.Data          = this.SetData(result, true);
                response2.Data.Contents = this.GetContent(result.Stream, this.ReportSettings.ShowToolBar);
            }
            catch (System.Exception ex)
            {
                response2.Status  = 1;
                response2.Message = ex.Message;
            }
            return(response2);
        }