コード例 #1
0
        protected void FinishInit()
        {
            Current = this;
            _listingFilter = new NSFWListingFilter();
            if (IsInDesignMode)
            {
                _initializationBlob = new InitializationBlob { Settings = new Dictionary<string, string>(), NSFWFilter = new Dictionary<string, bool>() };
            }
            else
            {
                OfflineService = new OfflineService();
                _initializationBlob = OfflineService.LoadInitializationBlob("");
            }
            Settings = new Model.Settings(_initializationBlob.Settings);
            SettingsHub = new SettingsViewModel(Settings);

            RedditUserState = _initializationBlob.DefaultUser ?? new UserState();

            SnooStreamViewModel.ActivityManager.OAuth = SnooStreamViewModel.RedditUserState != null && SnooStreamViewModel.RedditUserState.OAuth != null ?
                    JsonConvert.SerializeObject(SnooStreamViewModel.RedditUserState) : "";

            SnooStreamViewModel.ActivityManager.CanStore = SnooStreamViewModel.RedditUserState != null && SnooStreamViewModel.RedditUserState.IsDefault;

            NotificationService = new Common.NotificationService();
            CaptchaProvider = new CaptchaService();
            RedditService = new Reddit(_listingFilter, RedditUserState, OfflineService, CaptchaProvider, "3m9rQtBinOg_rA", null, "http://www.google.com");
            Login = new LoginViewModel();

            _listingFilter.Initialize(Settings, OfflineService, RedditService, _initializationBlob.NSFWFilter);
            CommandDispatcher = new CommandDispatcher();
            SubredditRiver = new SubredditRiverViewModel(_initializationBlob.Subreddits);
            SelfStream = new SelfStreamViewModel();
            ModStream = new ModStreamViewModel();
            NavMenu = new NavMenu(Enumerable.Empty<LinkRiverViewModel>(), this);
            MessengerInstance.Register<UserLoggedInMessage>(this, OnUserLoggedIn);

            if (RedditUserState.Username != null)
            {
                SelfUser = new AboutUserViewModel(RedditUserState.Username);
            }
        }