[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/QPC-database/ClearScript/master/ClearScript/DelegateFactory.tt [Back]  [Original]

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.


using System;
using System.Reflection;
using System.Diagnostics.CodeAnalysis;

namespace Microsoft.ClearScript
{
    internal static partial class DelegateFactory
    {
        private const int maxArgCount = ;

         "T" + index)) + ", TDelegate>";
            var allByValueExpr = (count == 0) ? "true" : "GetAllByValue(" + string.Join(", ", Enumerable.Range(1, count).Select(index => "typeof(T" + index + ")")) + ")";
            var methodParamList = string.Join(", ", Enumerable.Range(1, count).Select(index => "T" + index + " a" + index));
            var argList = string.Join(", ", Enumerable.Range(1, count).Select(index => "a" + index));
            var varDeclList = string.Join("\r\n                    ", Enumerable.Range(1, count).Select(index => "var v" + index + " = GetArgValue(a" + index + ");"));
            var byRefArgList = string.Join(", ", Enumerable.Range(1, count).Select(index => "ref v" + index));
            var varAssignList = string.Join("\r\n                        ", Enumerable.Range(1, count).Select(index => "SetArgValue(a" + index + ", v" + index + ");"));
        #>

        [ExcludeFromCodeCoverage]
        private class ProcShim : ProcShim
        {
            private static readonly MethodInfo method = typeof(ProcShim).GetMethod("InvokeTarget");
            private static readonly bool allByValue = ;
            private readonly object target;
            private readonly Delegate del;

            public ProcShim(ScriptEngine engine, object target)
                : base(engine)
            {
                this.target = GetCompatibleTarget(typeof(TDelegate), target);
                del = Delegate.CreateDelegate(typeof(TDelegate), this, method);
            }

            // ReSharper disable UnusedMember.Local

            public void InvokeTarget()
            {
                if (allByValue || Engine.EnableAutoHostVariables)
                {
                    Invoke(() => ((dynamic)target)());
                }
                else
                {
                    
                    try
                    {
                        Invoke(() => ((dynamic)target)());
                    }
                    finally
                    {
                        
                    }
                }
            }

            // ReSharper restore UnusedMember.Local

            #region DelegateShim overrides

            public override Delegate Delegate
            {
                get { return del; }
            }

            #endregion
        }
        

         "T" + index)) + ", TResult, TDelegate>";
            var allByValueExpr = (count == 0) ? "true" : "GetAllByValue(" + string.Join(", ", Enumerable.Range(1, count).Select(index => "typeof(T" + index + ")")) + ")";
            var methodParamList = string.Join(", ", Enumerable.Range(1, count).Select(index => "T" + index + " a" + index));
            var argList = string.Join(", ", Enumerable.Range(1, count).Select(index => "a" + index));
            var varDeclList = string.Join("\r\n                ", Enumerable.Range(1, count).Select(index => "var v" + index + " = GetArgValue(a" + index + ");"));
            var byRefArgList = string.Join(", ", Enumerable.Range(1, count).Select(index => "ref v" + index));
            var varAssignList = string.Join("\r\n                    ", Enumerable.Range(1, count).Select(index => "SetArgValue(a" + index + ", v" + index + ");"));
        #>

        [ExcludeFromCodeCoverage]
        private class FuncShim : FuncShim
        {
            private static readonly MethodInfo method = typeof(FuncShim).GetMethod("InvokeTarget");
            private static readonly bool allByValue = ;
            private readonly object target;
            private readonly Delegate del;

            public FuncShim(ScriptEngine engine, object target)
                : base(engine)
            {
                this.target = GetCompatibleTarget(typeof(TDelegate), target);
                del = Delegate.CreateDelegate(typeof(TDelegate), this, method);
            }

            // ReSharper disable UnusedMember.Local

            public TResult InvokeTarget()
            {
                if (allByValue || Engine.EnableAutoHostVariables)
                {
                    return Invoke(() => (TResult)((dynamic)target)());
                }

                
                try
                {
                    return Invoke(() => (TResult)((dynamic)target)());
                }
                finally
                {
                    
                }
            }

            // ReSharper restore UnusedMember.Local

            #region DelegateShim overrides

            public override Delegate Delegate
            {
                get { return del; }
            }

            #endregion
        }
        

        private static readonly Type[] procTemplates =
        {
            

            typeof(Action),
            

        };

        private static readonly Type[] funcTemplates =
        {
             "/*T" + index + "*/")) + ", /*TResult*/>";
            #>

            typeof(Func),
            

        };

        private static readonly Type[] procShimTemplates =
        {
             "/*T" + index + "*/")) + ", /*TDelegate*/>";
            #>

            typeof(ProcShim),
            

        };

        private static readonly Type[] funcShimTemplates =
        {
             "/*T" + index + "*/")) + ", /*TResult*/, /*TDelegate*/>";
            #>

            typeof(FuncShim),
            

        };
    }
}

Web Proxy Viewer  |  New URL  |  Original Page