Exemplo n.º 1
0
        public void LambdaHandlerBuidParamTypeArray()
        {
            LambdaHandler handler = new LambdaHandler("mscorlib::System.Environment::ExpandEnvironmentVariables");

            handler.ParamTypeArray.Length.Should().Be(2);
            handler.ParamTypeArray[0].Should().Be("System.String");
            handler.ParamTypeArray[1].Should().Be("System.String");
        }
Exemplo n.º 2
0
        public void LambdaHandlerGetters()
        {
            LambdaHandler handler = new LambdaHandler("mscorlib::System.Environment::ExpandEnvironmentVariables");

            handler.GetAssembly().Should().Be("mscorlib");
            handler.GetFullType().Should().Be("System.Environment");
            handler.GetMethodName().Should().Be("ExpandEnvironmentVariables");
        }
Exemplo n.º 3
0
        public Function()
        {
            var eventHandlers = new EventHandlersRegistry();

            eventHandlers.RegisterEventHandler <AnyToS3Handler>();

            lambdaHandler = new LambdaHandler(
                new Authentication(),
                eventHandlers,
                new EventPayloadFactory());
        }
        /// <summary>
        /// Asynchronous Lambda Entry Point
        /// </summary>
        /// <param name="jsonInput">json input from AWS</param>
        /// <param name="context">contextual information from AWS</param>
        public async Task ExecuteAsync(JToken jsonInput, ILambdaContext context)
        {
            await ExecuteWithScope(context, jsonInput, async (cancellationToken) =>
            {
                var handlerType = LambdaHandler.GetType();
                var method      = handlerType.GetMethod(nameof(IAsyncLambdaHandler <object> .HandleAsync));
                var inputType   = handlerType.GetInterface($"{nameof(IAsyncLambdaHandler<object>)}`1")
                                  .GenericTypeArguments.Single();

                await(Task) method.Invoke(LambdaHandler, new object[] { jsonInput.ToObject(inputType), context, cancellationToken });

                return(new LambdaResponse <int>(System.Net.HttpStatusCode.OK, null, 0, false, false));
            });
        }
Exemplo n.º 5
0
        public void Initialize()
        {
            mockAuthentication      = new Mock <IAuthentication>();
            mockEventHandlers       = new Mock <IEventHandlersRegistry>();
            mockEventPayloadFactory = new Mock <IEventPayloadFactory>();
            mockLambdaContext       = new Mock <ILambdaContext>();
            mockLambdaLogger        = new Mock <ILambdaLogger>();

            mockLambdaContext
            .Setup(mock => mock.Logger)
            .Returns(mockLambdaLogger.Object);

            lambdaHandler = new LambdaHandler(
                mockAuthentication.Object,
                mockEventHandlers.Object,
                mockEventPayloadFactory.Object);
        }
Exemplo n.º 6
0
        static void Main(string[] args)
        {
            var strArray1 = new List()
            {
                "every", "moment", "of", "the", "year"
            };
            var strArray2 = new List()
            {
                "I", "love", "Paris"
            };

            LambdaHandler consoleOutFormat = () => Console.WriteLine("");

            ClassProgrammer progger = new ClassProgrammer();

            progger.Delete += strArray1.DisplayList;
            progger.Delete += strArray1.RemoveAt;
            progger.Delete += strArray1.DisplayList;
            progger.DeleteItem(2);
            consoleOutFormat();
            progger.Mutate += strArray2.DisplayList;
            progger.Mutate += strArray2.ChangeRandomItem;
            progger.Mutate += i => strArray2[i] += "OOOOOOOOOOOOOOOOOOOOOOOOOO";
            progger.Mutate += strArray2.DisplayList;

            progger.ChangeList(2);

            StringBuilder str = new StringBuilder("синее, синее  небо.,");

            Console.WriteLine($"Исходная строка: {str}");
            Action <StringBuilder> action = StringMethods.RemovePunctuation;

            action += StringMethods.RemoveSpaces;
            action += StringMethods.StringToUppercase;
            action += StringMethods.AppendQuestionMark;
            action += StringMethods.ToEnglishLetter;
            action(str);
            Console.WriteLine($"Строка после преобразований: {str}");

            Console.Read();
        }
        /// <summary>
        /// Synchronous Lambda Entry Point
        /// </summary>
        /// <param name="jsonInput">json input from AWS</param>
        /// <param name="context">contextual information from AWS</param>
        /// <returns>HTTP style response message with payload</returns>
        public async Task <object> ExecuteAsync(JToken jsonInput, ILambdaContext context)
        {
            var result = await ExecuteWithScope(context, jsonInput, async (cancellationToken) => {
                var handlerType   = LambdaHandler.GetType();
                var method        = handlerType.GetMethod(nameof(ISyncLambdaHandler <object, object> .HandleAsync));
                var interfaceType = handlerType.GetInterface($"{nameof(ISyncLambdaHandler<object, object>)}`2");
                var inputType     = interfaceType.GenericTypeArguments.First();
                var outputType    = interfaceType.GenericTypeArguments.Last();

                var task = (Task)method.Invoke(LambdaHandler, new object[] { jsonInput.ToObject(inputType), context, cancellationToken });

                await task;

                return((ILambdaResponse)task
                       .GetType()
                       .GetProperty(nameof(Task <ILambdaResponse> .Result))
                       .GetValue(task));
            });

            return(PrepareResult(result));
        }
Exemplo n.º 8
0
 public TestApp()
 {
     _handler = new LambdaHandler();
     _context = new TestLambdaContext();
 }