示例#1
0
        public static async Task <bool> SignUp(Registration model, RemoteUser user)
        {
            if (model.Password != model.ConfirmPassword)
            {
                throw new PasswordConfirmException("Passwords do not match.");
            }

            if (model.Email != model.ConfirmEmail)
            {
                throw new PasswordConfirmException("Emails do not match.");
            }

            model.Browser   = user.Browser;
            model.IpAddress = user.IpAddress;

            var registration = model.Adapt <DTO.Registration>();

            registration.Password = PasswordManager.GetHashedPassword(model.Password);

            string registrationId = Registrations.Register(registration).ToString();

            if (string.IsNullOrWhiteSpace(registrationId))
            {
                return(false);
            }

            var email = new SignUpEmail(registration, registrationId);
            await email.SendAsync();

            return(true);
        }
示例#2
0
        /// <summary>
        /// Gets a dictionary of services that should be registered.
        /// </summary>
        /// <returns>The dictionary of types that should be registered.</returns>
        public Dictionary <Type, List <Type> > GetServicesThatShouldRegistered()
        {
            Dictionary <Type, List <Type> > serviceTypeToImplementationTypes = new Dictionary <Type, List <Type> >();

            Registrations registrations = new Registrations();

            registrations.Register((factory, serviceType) =>
            {
                if (serviceTypeToImplementationTypes.TryGetValue(serviceType, out List <Type> implementationTypes) == false)
                {
                    implementationTypes = new List <Type>();
                    serviceTypeToImplementationTypes.Add(serviceType, implementationTypes);
                }

                implementationTypes.Add(factory().GetType());
            });

            Type platformRegistrationsType = Type.GetType("ReactiveUI.Wpf.Registrations, ReactiveUI.Wpf");

            if (platformRegistrationsType == null)
            {
                platformRegistrationsType = Type.GetType("ReactiveUI.XamForms.Registrations, ReactiveUI.XamForms");
            }

            if (platformRegistrationsType == null)
            {
                platformRegistrationsType = Type.GetType("ReactiveUI.Winforms.Registrations, ReactiveUI.Winforms");
            }

            if (platformRegistrationsType != null)
            {
                var platformRegistrations                      = Activator.CreateInstance(platformRegistrationsType);
                System.Reflection.MethodInfo register          = platformRegistrationsType.GetMethod("Register");
                Action <Func <object>, Type> registerParameter = new Action <Func <object>, Type>((factory, serviceType) =>
                {
                    if (serviceTypeToImplementationTypes.TryGetValue(serviceType, out List <Type> implementationTypes) == false)
                    {
                        implementationTypes = new List <Type>();
                        serviceTypeToImplementationTypes.Add(serviceType, implementationTypes);
                    }

                    implementationTypes.Add(factory().GetType());
                });
                register.Invoke(platformRegistrations, new object[] { registerParameter });
            }

            return(serviceTypeToImplementationTypes);
        }
        /// <summary>
        /// Constructor for the Application object.
        /// </summary>
        public App()
        {
            // Standard XAML initialization
            InitializeComponent();

            // Language display initialization
            InitializeLanguage();

            // Show graphics profiling information while debugging.
            if (Debugger.IsAttached)
            {
                // Display the current frame rate counters
                Application.Current.Host.Settings.EnableFrameRateCounter = true;

                // Show the areas of the app that are being redrawn in each frame.
                //Application.Current.Host.Settings.EnableRedrawRegions = true;

                // Enable non-production analysis visualization mode,
                // which shows areas of a page that are handed off to GPU with a colored overlay.
                //Application.Current.Host.Settings.EnableCacheVisualization = true;

                // Prevent the screen from turning off while under the debugger by disabling
                // the application's idle detection.
                // Caution:- Use this under debug mode only. Application that disables user idle detection will continue to run
                // and consume battery power when the user is not using the phone.
                PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;
            }

            Locator.CurrentMutable.Register(() => new AppBootstrapper(), typeof(IApplicationRootState));

            var registrator = new Registrations();
            registrator.Register((o, t) => Locator.CurrentMutable.Register(o, t));

            var host = Locator.Current.GetService<ISuspensionHost>();
            host.SetupDefaultSuspendResume();
        }
示例#4
0
        static void Main(string[] args)
        {
            var container = new UnityContainer();

            Registrations.Register(container);

            var robot  = container.Resolve <IRobot>();
            var skills = container.Resolve <IEnumerable <ISkill <ISkillInput> > >();

            LogoHelper.RenderLogo();

            Console.WriteLine();
            Console.WriteLine("Skills installed:");

            //register some console stuffs to see what is going on internally
            foreach (var skill in skills)
            {
                Console.WriteLine($"{skill.GetType().Name} '{skill.InvocationPhrase}'");

                skill.OnSkillExecuting += (sender, e) =>
                {
                    Console.WriteLine($"Executing skill: {e.Name}");
                    Console.WriteLine($"Keyword: {e.Keyword}");
                };

                skill.OnSkillExecuted += (sender, e) =>
                {
                    Console.WriteLine($"{e.TextToRead}");
                };
            }

            _showMenu();

            do
            {
                Console.WriteLine($"What shall I do?");

                var selection = Console.ReadKey(true);

                switch (selection.KeyChar)
                {
                case 'c':
                    //TODO: consider making this a skill
                    robot.StopTalking();
                    break;

                case 's':
                    //TODO: consider removing this since we have the voice search now
                    robot.LookupInformation(_getInput("Enter search term:"));
                    break;

                case 't':
                    robot.Say(_getInput("What shall I say?"));
                    break;

                case 'l':
                    Console.WriteLine("Listening...");
                    robot.ListenForCommand();
                    break;

                case 'g':
                    //TODO: make this a skill
                    robot.Greet(_getInput("Who are we meeting?"));
                    break;

                case 'q':
                    Environment.Exit(0);
                    break;

                default:
                    _showMenu();
                    break;
                }
            } while (true);
        }
示例#5
0
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     Registrations.Register(services);
     services.AddMvc();
     services.AddRouting();
 }
示例#6
0
 public GlobalHooks(IObjectContainer objectContainer)
 {
     Registrations.Register(objectContainer);
     _objectContainer = objectContainer;
 }