예제 #1
0
            // ReSharper disable once UnusedMember.Local
            public async Task <HandleResult> HandleMessage(string rawMessage)
            {
                var messageHandler = (IMessageHandler <TMessage>)_resolver.Get(_messageHandlerType);

                var message = _messageParser.DeserializeMessage <TMessage>(rawMessage);
                var result  = await messageHandler.Handle(message);

                return(new HandleResult(message, result));
            }
 public override object Get(Type type)
 {
     return
         (base.CanGet(type)
             ? base.Get(type)
             : _secondaryContainer.CanGet(type)
                 ? _secondaryContainer.Get(type)
                 : ThrowResolveException(type));
 }
예제 #3
0
 private object[] CreateConstructorArgs(
     IEnumerable <ParameterInfo> targetConstructorParameters, IResolver resolver)
 {
     return(targetConstructorParameters.Select(parameter =>
     {
         object argValue;
         if (TryGetTargetMemberValue(parameter.Name, parameter.ParameterType, out argValue))
         {
             return argValue;
         }
         if (resolver != null && resolver.CanGet(parameter.ParameterType))
         {
             return resolver.Get(parameter.ParameterType);
         }
         return parameter.HasDefaultValue ? parameter.DefaultValue : null;
     }).ToArray());
 }
예제 #4
0
        public App(IComponentProvider provider)
        {
            InitializeComponent();

            var config = new ResolverConfig();

            RegisterComponents(config);
            provider.RegisterComponents(config);
            Resolver = config.ToResolver();

            MainPage = new NavigationPage {
                BarBackgroundColor = (Color)Resources["MetroBlueDark"]
            };

            var navigationService = Resolver.Get <INavigator>();

            navigationService.ForwardAsync("/LoginPage");
        }
예제 #5
0
        public async Task <OkResult> Post([FromBody] Microsoft.Bot.Connector.Activity activity)
        {
            if (activity.Type == ActivityTypes.Message)
            {
                //MicrosoftAppCredentials.TrustServiceUrl(activity.ServiceUrl);
                var appCredentials = new MicrosoftAppCredentials(_microsoftAppSettingsResolver.Get(activity.From.Id).Id, _microsoftAppSettingsResolver.Get(activity.From.Id).Password, _logger);
                var connector      = new ConnectorClient(new Uri(activity.ServiceUrl), appCredentials);

                // return our reply to the user
                var reply = activity.CreateReply("HelloWorld");
                await connector.Conversations.ReplyToActivityAsync(reply);
            }
            else
            {
                //HandleSystemMessage(activity);
            }
            return(Ok());
        }
예제 #6
0
        private object[] CreateArgs(IEnumerable <ParameterInfo> parameters, IResolver resolver)
        {
            var argsList = new List <object>();

            foreach (var parameter in parameters)
            {
                object argValue;

                if (TryGetValueForInstance(parameter.Name, parameter.ParameterType, out argValue))
                {
                    argsList.Add(argValue);
                }
                else if (resolver != null && resolver.CanGet(parameter.ParameterType))
                {
                    argsList.Add(resolver.Get(parameter.ParameterType));
                }
                else
                {
                    argsList.Add(parameter.HasDefaultValue ? parameter.DefaultValue : null);
                }
            }

            return(argsList.ToArray());
        }
예제 #7
0
 public void GivenIAddedTheFollowingFillup(Table table) => table
 .CreateInstance <AddFillUpCommand>()
 .Finally(_resolver
          .Get <ICommandHandler <AddFillUpCommand> >()
          .Handle);
예제 #8
0
 /// <summary>
 /// Return an object for this Type based on this configuration.
 /// </summary>
 /// <returns>an object for this Type based on this configuration.</returns>
 public object Get(params object[] @params) => resolver.Get(@params);