public void TestCreateObjectWithArgs() { var invoker = new ObjectInvoker<TestClass>(typeof(TestClass)); var test = invoker.GetObject("Scott"); Assert.AreEqual(test.Name,"Scott"); }
public void TestCreateTypeInferface() { string typeName = "Expression.Tests.TestClass"; Type t = Type.GetType(typeName); var invoker = new ObjectInvoker<ITestClass>(t); var test = invoker.GetObject(); Assert.IsInstanceOfType(test, typeof(TestClass)); }
public void Invoke(IncomingContext context, Action next) { var messageToHandle = context.IncomingLogicalMessage; var callbackInvoked = context.Get <bool>("NServiceBus.CallbackInvocationBehavior.CallbackWasInvoked"); var handlerGenericType = typeof(IHandleMessagesAsync <>).MakeGenericType(messageToHandle.MessageType); List <dynamic> handlers = context.Builder.BuildAll(handlerGenericType).ToList(); if (!callbackInvoked && !handlers.Any() && context.PhysicalMessage.MessageIntent != MessageIntentEnum.Reply) { var error = string.Format("No handlers could be found for message type: {0}", messageToHandle.MessageType); throw new InvalidOperationException(error); } foreach (var handler in handlers) { using (CreateSnapshotRegion(context)) { var lambda = ObjectInvoker.Invoker(handler, messageToHandle.MessageType); var loadedHandler = new AsyncMessageHandler { Handler = handler, Invocation = lambda }; context.Set(loadedHandler); next(); if (context.HandlerInvocationAborted) { //if the chain was aborted skip the other handlers break; } } } }
public void TestCreateObject() { var invoker = new ObjectInvoker<TestClass>(typeof(TestClass)); var test = invoker.GetObject(); Assert.IsNotNull(test); }
public void GetObjectTest() { var r = ObjectInvoker.GetObject().ConfigureAwait(false).GetAwaiter().GetResult(); }