예제 #1
0
        /*
         * Handle the input from the user on a menu
         */
        public static void HandleMenuSelection(string selChar)
        {
            if (!IsValidMenuSelection(selChar))
            {
                return;
            }

            var selection      = MenuToNum(selChar);
            var menuItem       = ShortList[selection - 1];
            var functionLoader = new FunctionLoader();

            functionLoader.Load(menuItem);
        }
예제 #2
0
        public void TestFunctionLoaderGetInfo()
        {
            var functionId         = Guid.NewGuid().ToString();
            var directory          = "/Users/tylerleonhardt/Desktop/Tech/PowerShell/AzureFunctions/azure-functions-powershell-worker/examples/PSCoreApp/MyHttpTrigger";
            var scriptPathExpected = $"{directory}/run.ps1";
            var name     = "MyHttpTrigger";
            var metadata = new RpcFunctionMetadata
            {
                Name       = name,
                EntryPoint = "",
                Directory  = directory,
                ScriptFile = scriptPathExpected
            };

            metadata.Bindings.Add("req", new BindingInfo
            {
                Direction = BindingInfo.Types.Direction.In,
                Type      = "httpTrigger"
            });
            metadata.Bindings.Add("res", new BindingInfo
            {
                Direction = BindingInfo.Types.Direction.Out,
                Type      = "http"
            });

            var functionLoadRequest = new FunctionLoadRequest {
                FunctionId = functionId,
                Metadata   = metadata
            };

            var functionLoader = new FunctionLoader();

            functionLoader.Load(functionLoadRequest);

            var funcInfo = functionLoader.GetFunctionInfo(functionId);

            Assert.Equal(directory, funcInfo.Directory);
            Assert.Equal(name, funcInfo.FunctionName);
            Assert.Equal(2, funcInfo.AllBindings.Count);
            Assert.Single(funcInfo.OutputBindings);
        }
        public void TestFunctionLoaderGetFuncWithEntryPoint()
        {
            var functionId         = Guid.NewGuid().ToString();
            var directory          = "/Users/azure/PSCoreApp/MyHttpTrigger";
            var scriptPathExpected = $"{directory}/run.ps1";
            var entryPointExpected = "Foo";
            var metadata           = new RpcFunctionMetadata
            {
                Name       = "MyHttpTrigger",
                EntryPoint = entryPointExpected,
                Directory  = directory,
                ScriptFile = scriptPathExpected
            };

            metadata.Bindings.Add("req", new BindingInfo
            {
                Direction = BindingInfo.Types.Direction.In,
                Type      = "httpTrigger"
            });
            metadata.Bindings.Add("res", new BindingInfo
            {
                Direction = BindingInfo.Types.Direction.Out,
                Type      = "http"
            });

            var functionLoadRequest = new FunctionLoadRequest {
                FunctionId = functionId,
                Metadata   = metadata
            };

            var functionLoader = new FunctionLoader();

            functionLoader.Load(functionLoadRequest);

            var funcInfo = functionLoader.GetFunctionInfo(functionId);

            Assert.Equal(scriptPathExpected, funcInfo.ScriptPath);
            Assert.Equal(entryPointExpected, funcInfo.EntryPoint);
        }
예제 #4
0
 public static IntPtr GetConsoleWindow() => FunctionLoader.Load <GetConsoleWindow_t>("GetConsoleWindow")();
예제 #5
0
 public static void ShowWindow(IntPtr hWnd, int nCmdShow) => FunctionLoader.Load <ShowWindow_t>("ShowWindow")(hWnd, nCmdShow);