Esempio n. 1
0
        public DefaultResourceLoader(IResourceLoader loader)
        {
            if (loader == null)
                throw new ArgumentNullException("wrappedLoader");

            this.loader = loader;
        }
Esempio n. 2
0
 public GooglePlayCSVGenerator (IEditorUtil util, ProductIdRemapper remapper, InventoryDatabase db, IResourceLoader loader) {
     this.util = util;
     this.remapper = remapper;
     this.db = db;
     remapper.initialiseForPlatform(BillingPlatform.GooglePlay);
     this.inventory = XDocument.Load(loader.openTextFile("unibillInventory"));
 }
 // TODO: this should use inputstreams from the loader, not File!
 public virtual void Inform(IResourceLoader loader)
 {
     if (mapping != null)
     {
         IList<string> wlist = null;
         if (File.Exists(mapping))
         {
             wlist = new List<string>(GetLines(loader, mapping));
         }
         else
         {
             var files = SplitFileNames(mapping);
             wlist = new List<string>();
             foreach (string file in files)
             {
                 var lines = GetLines(loader, file.Trim());
                 wlist.AddRange(lines);
             }
         }
         NormalizeCharMap.Builder builder = new NormalizeCharMap.Builder();
         ParseRules(wlist, builder);
         normMap = builder.Build();
         if (normMap.map == null)
         {
             // if the inner FST is null, it means it accepts nothing (e.g. the file is empty)
             // so just set the whole map to null
             normMap = null;
         }
     }
 }
        public ChangeDefaultsFlyoutViewModel(ICheckoutDataRepository checkoutDataRepository, IResourceLoader resourceLoader)
        {
            _checkoutDataRepository = checkoutDataRepository;
            _resourceLoader = resourceLoader;

            GoBackCommand = new DelegateCommand(() => GoBack());
        }
        public CheckoutSummaryPageViewModel(INavigationService navigationService,
            IOrderService orderService,
            IOrderRepository orderRepository,
            IShippingMethodService shippingMethodService,
            ICheckoutDataRepository checkoutDataRepository,
            IShoppingCartRepository shoppingCartRepository,
            IAccountService accountService,
            IResourceLoader resourceLoader,
            IAlertMessageService alertMessageService,
            ISignInUserControlViewModel signInUserControlViewModel)
        {
            _navigationService = navigationService;
            _orderService = orderService;
            _orderRepository = orderRepository;
            _shippingMethodService = shippingMethodService;
            _checkoutDataRepository = checkoutDataRepository;
            _shoppingCartRepository = shoppingCartRepository;
            _resourceLoader = resourceLoader;
            _accountService = accountService;
            _alertMessageService = alertMessageService;
            _signInUserControlViewModel = signInUserControlViewModel;

            SubmitCommand = DelegateCommand.FromAsyncHandler(SubmitAsync, CanSubmit);

            EditCheckoutDataCommand = new DelegateCommand(EditCheckoutData);
            SelectCheckoutDataCommand = new DelegateCommand(async () => await SelectCheckoutDataAsync());
            AddCheckoutDataCommand = new DelegateCommand(AddCheckoutData);
        }
 public RemoteConfigManager(IResourceLoader loader, IStorage storage, ILogger logger, RuntimePlatform platform)
 {
     this.storage = storage;
     logger.prefix = "Unibill.RemoteConfigManager";
     this.XML = loader.openTextFile ("unibillInventory.json").ReadToEnd ();
     Config = new UnibillConfiguration(XML, platform, logger);
     if (Config.UseHostedConfig) {
         string val = storage.GetString (CACHED_CONFIG_PATH, string.Empty);
         if (string.IsNullOrEmpty (val)) {
             logger.Log ("No cached config available. Using bundled");
         } else {
             logger.Log ("Cached config found, attempting to parse");
             try {
                 Config = new UnibillConfiguration(val, platform, logger);
                 if (Config.inventory.Count == 0) {
                     logger.LogError ("No purchasable items in cached config, ignoring.");
                     Config = new UnibillConfiguration (XML, platform, logger);
                 } else {
                     logger.Log (string.Format ("Using cached config with {0} purchasable items", Config.inventory.Count));
                     XML = val;
                 }
             } catch (Exception e) {
                 logger.LogError ("Error parsing inventory: {0}", e.Message);
                 Config = new UnibillConfiguration(XML, platform, logger);
             }
         }
         refreshCachedConfig (Config.HostedConfigUrl, logger);
     } else {
         logger.Log ("Not using cached inventory, using bundled.");
         Config = new UnibillConfiguration(XML, platform, logger);
     }
 }
        /// <summary>
        /// See http://www.w3.org/TR/html-imports/#dfn-import-request.
        /// </summary>
        public override async Task LoadAsync(IConfiguration configuration, IResourceLoader loader)
        {
            var link = Link;
            var document = link.Owner;
            var list = ImportLists.GetOrCreateValue(document);
            var location = Url;
            var request = link.CreateRequestFor(location);
            var item = new ImportEntry 
            { 
                Relation = this,
                IsCycle = CheckCycle(document, location)
            };
            _isasync = link.HasAttribute(AttributeNames.Async);
            list.Add(item);
            
            if (!item.IsCycle)
            {
                var nestedStatus = new TaskCompletionSource<Boolean>();
                var download = loader.DownloadAsync(request);
                SetDownload(download);

                await link.ProcessResponse(download, async response =>
                {
                    var context = new BrowsingContext(document.Context, Sandboxes.None);
                    var options = new CreateDocumentOptions(response, configuration)
                    {
                        ImportAncestor = document
                    };
                    _import = await context.OpenAsync(options, CancellationToken.None).ConfigureAwait(false);
                    nestedStatus.SetResult(true);
                }).ConfigureAwait(false);
                await nestedStatus.Task.ConfigureAwait(false);
            }
        }
        public ShoppingCartPageViewModel(IShoppingCartRepository shoppingCartRepository,
            INavigationService navigationService,
            IAccountService accountService,
            ISignInUserControlViewModel signInUserControlViewModel,
            IResourceLoader resourceLoader,
            IAlertMessageService alertMessageService,
            ICheckoutDataRepository checkoutDataRepository,
            IOrderRepository orderRepository,
            IEventAggregator eventAggregator)
        {
            _shoppingCartRepository = shoppingCartRepository;
            _navigationService = navigationService;
            _accountService = accountService;
            _signInUserControlViewModel = signInUserControlViewModel;
            _resourceLoader = resourceLoader;
            _alertMessageService = alertMessageService;
            _checkoutDataRepository = checkoutDataRepository;
            _orderRepository = orderRepository;

            CheckoutCommand = DelegateCommand.FromAsyncHandler(CheckoutAsync, CanCheckout);
            RemoveCommand = DelegateCommand<ShoppingCartItemViewModel>.FromAsyncHandler(Remove);
            IncrementCountCommand = DelegateCommand.FromAsyncHandler(IncrementCount);
            DecrementCountCommand = DelegateCommand.FromAsyncHandler(DecrementCount, CanDecrementCount);

            // Subscribe to the ShoppingCartUpdated event
            if (eventAggregator != null)
            {
                eventAggregator.GetEvent<ShoppingCartUpdatedEvent>().Subscribe(UpdateShoppingCartAsync);
            }
        }
Esempio n. 9
0
        public MenuViewModel(INavigationService navigationService, IResourceLoader resourceLoader)
        {
            _navigationService = navigationService;

            Commands = new ObservableCollection<MenuItemViewModel>
            {
                new MenuItemViewModel { DisplayName = resourceLoader.GetString("DTSBehaviorSampleMenuItemDisplayName"), FontIcon = "\ue15f", Command = new DelegateCommand(() => NavigateToSamplePage(PageTokens.DTSBehaviorSample), () => CanNavigateToSamplePage(PageTokens.DTSBehaviorSample)) },
                new MenuItemViewModel { DisplayName = resourceLoader.GetString("DTSSampleMenuItemDisplayName"), FontIcon = "\ue19f", Command = new DelegateCommand(() => NavigateToSamplePage(PageTokens.DTSSample), () => CanNavigateToSamplePage(PageTokens.DTSSample)) },
                new MenuItemViewModel { DisplayName = resourceLoader.GetString("IncrementalLoadingMenuItemDisplayName"), FontIcon = "\ue19f", Command = new DelegateCommand(() => NavigateToSamplePage(PageTokens.IncrementalLoadingSample), () => CanNavigateToSamplePage(PageTokens.IncrementalLoadingSample)) },
                new MenuItemViewModel { DisplayName = resourceLoader.GetString("DeferLoadStrategyMenuItemDisplayName"), FontIcon = "\ue19f", Command = new DelegateCommand(() => NavigateToSamplePage(PageTokens.DeferLoadStrategySample), () => CanNavigateToSamplePage(PageTokens.DeferLoadStrategySample)) },
                new MenuItemViewModel { DisplayName = resourceLoader.GetString("CustomLVIPMenuItemDisplayName"), FontIcon = "\ue19f", Command = new DelegateCommand(() => NavigateToSamplePage(PageTokens.CustomLVIPSample), () => CanNavigateToSamplePage(PageTokens.CustomLVIPSample)) },
                new MenuItemViewModel { DisplayName = resourceLoader.GetString("StateTriggerMenuItemDisplayName"), FontIcon = "\ue19f", Command = new DelegateCommand(() => NavigateToSamplePage(PageTokens.StateTriggerSample), () => CanNavigateToSamplePage(PageTokens.StateTriggerSample)) },
                new MenuItemViewModel { DisplayName = resourceLoader.GetString("CVSMenuItemDisplayName"), FontIcon = "\ue19f", Command = new DelegateCommand(() => NavigateToSamplePage(PageTokens.CollectionViewSourceSample), () => CanNavigateToSamplePage(PageTokens.CollectionViewSourceSample)) },
                new MenuItemViewModel { DisplayName = resourceLoader.GetString("DeviceSpecificMenuItemDisplayName"), FontIcon = "\ue19f", Command = new DelegateCommand(() => NavigateToSamplePage(PageTokens.DeviceSpecificSample), () => CanNavigateToSamplePage(PageTokens.DeviceSpecificSample)) },
                new MenuItemViewModel { DisplayName = resourceLoader.GetString("ExpanderSampleMenuItemDisplayName"), FontIcon = "\ue19f", Command = new DelegateCommand(() => NavigateToSamplePage(PageTokens.ExpanderSample), () => CanNavigateToSamplePage(PageTokens.ExpanderSample)) },
                new MenuItemViewModel { DisplayName = resourceLoader.GetString("OldMainPageMenuItemDisplayName"), FontIcon = "\ue19f", Command = new DelegateCommand(() => NavigateToSamplePage(PageTokens.OldMain), () => CanNavigateToSamplePage(PageTokens.OldMain)) },
            };

            _currentPageToken = PageTokens.DTSBehaviorSample;
            _canNavigateLookup = new Dictionary<PageTokens, bool>();

            foreach (PageTokens pageToken in Enum.GetValues(typeof(PageTokens)))
            {
                _canNavigateLookup.Add(pageToken, true);
            }

            _canNavigateLookup[_currentPageToken] = false;
        }
Esempio n. 10
0
        public MenuViewModel(IEventAggregator eventAggregator, INavigationService navigationService, IResourceLoader resourceLoader, ISessionStateService sessionStateService)
        {
            eventAggregator.GetEvent<NavigationStateChangedEvent>().Subscribe(OnNavigationStateChanged);
            _navigationService = navigationService;
            _sessionStateService = sessionStateService;

            Commands = new ObservableCollection<MenuItemViewModel>
            {
                new MenuItemViewModel { DisplayName = resourceLoader.GetString("MainPageMenuItemDisplayName"), FontIcon = "\ue19f", Command = new DelegateCommand(() => NavigateToPage(PageTokens.Main), () => CanNavigateToPage(PageTokens.Main)) },
            };

            _canNavigateLookup = new Dictionary<PageTokens, bool>();

            foreach (PageTokens pageToken in Enum.GetValues(typeof(PageTokens)))
            {
                _canNavigateLookup.Add(pageToken, true);
            }

            if (_sessionStateService.SessionState.ContainsKey(CurrentPageTokenKey))
            {
                // Resuming, so update the menu to reflect the current page correctly
                PageTokens currentPageToken;
                if (Enum.TryParse(_sessionStateService.SessionState[CurrentPageTokenKey].ToString(), out currentPageToken))
                {
                    UpdateCanNavigateLookup(currentPageToken);
                    RaiseCanExecuteChanged();
                }
            }
        }
        public override Task LoadAsync(IConfiguration configuration, IResourceLoader loader)
        {
            var link = Link;
            var request = link.CreateRequestFor(Url);
            var download = loader.DownloadAsync(request);
            SetDownload(download);

            return link.ProcessResponse(download, response =>
            {
                var type = link.Type ?? MimeTypeNames.Css;
                var engine = configuration.GetStyleEngine(type);

                if (engine != null)
                {
                    var options = new StyleOptions
                    {
                        Element = link,
                        IsDisabled = link.IsDisabled,
                        IsAlternate = link.RelationList.Contains(Keywords.Alternate),
                        Configuration = configuration
                    };

                    _sheet = engine.ParseStylesheet(response, options);
                    _sheet.Media.MediaText = link.Media ?? String.Empty;
                }
            });
        }
Esempio n. 12
0
 public BillerFactory(IResourceLoader resourceLoader, ILogger logger, IStorage storage, IRawBillingPlatformProvider platformProvider, UnibillConfiguration config) {
     this.loader = resourceLoader;
     this.logger = logger;
     this.storage = storage;
     this.platformProvider = platformProvider;
     this.config = config;
 }
 public CategoryPageViewModel(IProductCatalogRepository productCatalogRepository, INavigationService navigationService, IAlertMessageService alertMessageService, IResourceLoader resourceLoader)
 {
     _productCatalogRepository = productCatalogRepository;
     _navigationService = navigationService;
     _alertMessageService = alertMessageService;
     _resourceLoader = resourceLoader;
 }
Esempio n. 14
0
 /// <summary>
 /// Add a new resource loader.
 /// </summary>
 /// <param name="loader">Provider to add.</param>
 /// <exception cref="InvalidOperationException">Manager have been started.</exception>
 public void Add(IResourceLoader loader)
 {
     if (_isStarted)
         throw new InvalidOperationException("Manager have been started.");
     _logger.Trace("Adding resource loader '" + loader.GetType().FullName + "'.");
     _providers.Add(loader);
 }
        public virtual void Inform(IResourceLoader loader)
        {
            Stream stream = null;
            try
            {
                if (dictFile != null) // the dictionary can be empty.
                {
                    dictionary = GetWordSet(loader, dictFile, false);
                }
                // TODO: Broken, because we cannot resolve real system id
                // ResourceLoader should also supply method like ClassLoader to get resource URL
                stream = loader.OpenResource(hypFile);
                //InputSource @is = new InputSource(stream);
                //@is.Encoding = encoding; // if it's null let xml parser decide
                //@is.SystemId = hypFile;

                var xmlEncoding = string.IsNullOrEmpty(encoding) ? Encoding.UTF8 : Encoding.GetEncoding(encoding);

                hyphenator = HyphenationCompoundWordTokenFilter.GetHyphenationTree(stream, xmlEncoding);

            }
            finally
            {
                IOUtils.CloseWhileHandlingException(stream);
            }
        }
 public ShippingAddressUserControlViewModel(ICheckoutDataRepository checkoutDataRepository, ILocationService locationService, IResourceLoader resourceLoader)
 {
     _address = new Address();
     _checkoutDataRepository = checkoutDataRepository;
     _locationService = locationService;
     _resourceLoader = resourceLoader;
 }
        public void Inform(IResourceLoader loader)
        {
            TokenizerFactory factory = tokenizerFactory == null ? null : LoadTokenizerFactory(loader, tokenizerFactory);

            Analyzer analyzer = new AnalyzerAnonymousInnerClassHelper(this, factory);

            try
            {
                string formatClass = format;
                if (format == null || format.Equals("solr"))
                {
                    formatClass = typeof(SolrSynonymParser).AssemblyQualifiedName;
                }
                else if (format.Equals("wordnet"))
                {
                    formatClass = typeof(WordnetSynonymParser).AssemblyQualifiedName;
                }
                // TODO: expose dedup as a parameter?
                map = LoadSynonyms(loader, formatClass, true, analyzer);
            }
            catch (Exception e)
            {
                throw new IOException("Error parsing synonyms file:", e);
            }
        }
 private StyleSheetRequestProcessor(HtmlLinkElement link, Document document, IResourceLoader loader)
     : base(loader)
 {
     _link = link;
     _document = document;
     _loader = loader;
 }
Esempio n. 19
0
 public DerDieDasTest(IResourceLoader resourceLoader)
 {
     ParamValidator.EnsureParametersAreValid(new NullValidatorWithValue<IResourceLoader>(() => resourceLoader, resourceLoader));
     _derDieDasData = resourceLoader.LoadResource();
     _testResults = new List<TestResult>();
     SelectTests(new List<string>());
 }
Esempio n. 20
0
 public LibraryPageViewModel(INavigationService navigationService, IResourceLoader resourceLoader)
 {
     _books=new List<BookPreviewViewModel>();
     _books.Add(new BookPreviewViewModel(navigationService, resourceLoader));
     _books.Add(new BookPreviewViewModel(navigationService, resourceLoader));
     _books.Add(new BookPreviewViewModel(navigationService, resourceLoader));
 }
Esempio n. 21
0
        public NewsViewModel(IResourceLoader loader, IGitHubService githubService)
        {
            _loader = loader;
            _githubService = githubService;

            DisplayName = "news";
        }
Esempio n. 22
0
 public SplashPageViewModel(INavigationService navigationService, IOpenhabDatabase database, IEventAggregator eventAggregator, IResourceLoader resourceLoader)
 {
     _navigationService = navigationService;
     _database = database;
     _eventAggregator = eventAggregator;
     _resourceLoader = resourceLoader;
 }
        public ShippingAddressFlyoutViewModel(IShippingAddressUserControlViewModel shippingAddressViewModel, IResourceLoader resourceLoader)
        {
            _shippingAddressViewModel = shippingAddressViewModel;
            _resourceLoader = resourceLoader;

            SaveCommand = new DelegateCommand(SavedShippingAddress);
            GoBackCommand = new DelegateCommand(() => GoBack());
        }
Esempio n. 24
0
 public SitemapsPageViewModel(IResourceLoader resourceLoader, INavigationService navigationService, IOpenhabDatabase database, IEventAggregator eventAggregator, IRestService restService)
 {
     this._navigationService = navigationService;
     this._resourceLoader = resourceLoader;
     this._database = database;
     this._eventAggregator = eventAggregator;
     this._restService = restService;
 }
Esempio n. 25
0
        protected LazyCollectionProxy(string uri, IResourceLoader resourceLoader)
        {
            if (uri == null)
                throw new ArgumentNullException(nameof(uri));

            Uri = uri;
            ResourceLoader = resourceLoader;
        }
        /// <summary>
        /// Initialises an instance of a <see cref="MultiServiceHost"/> class.
        /// </summary>
        /// <param name="logger">
        /// Logging provider.
        /// </param>
        public MultiServiceHost(ILogger logger)
        {
            logger.ShouldNotBeNull();

            m_ServiceEntries = new Hashtable();
            m_Logger = logger;
            m_ResourceLoader = new ServicesResourceLoader();
        }
 public PaymentMethodFlyoutViewModel(IPaymentMethodUserControlViewModel paymentMethodViewModel, IResourceLoader resourceLoader)
 {
     _paymentMethodViewModel = paymentMethodViewModel;
     _resourceLoader = resourceLoader;
     
     SaveCommand = new DelegateCommand(SavePaymentMethod);
     GoBackCommand = new DelegateCommand(() => GoBack());
 }
        public BillingAddressFlyoutViewModel(IBillingAddressUserControlViewModel billingAddressViewModel, IResourceLoader resourceLoader)
        {
            _billingAddressViewModel = billingAddressViewModel;
            _resourceLoader = resourceLoader;

            SaveCommand = new DelegateCommand(SaveBillingAddress);
            GoBackCommand = new DelegateCommand(() => GoBack());
        }
Esempio n. 29
0
        public AboutViewModel(IResourceLoader loader)
        {
            _loader = loader;
            VersionText = GetAppVersion();

            GitHubUrl = new Uri("https://github.com/christophwille/wpaghapp/");
            ReleaseHistoryUrl = new Uri("https://github.com/christophwille/wpaghapp/wiki/Release-History");
            PrivacyPolicyUrl = new Uri("https://github.com/christophwille/wpaghapp/wiki/Privacy-Policy");
        }
        public AuthorizeViewModel(IResourceLoader loader, IGitHubService githubService, INavigationService navigationService)
        {
            _loader = loader;
            _githubService = githubService;
            _navigationService = navigationService;

            InfoMessage = _loader.GetString("AuthZ_WhatIsOAuthDoing");
            ShowAuthorizeButton = true;
        }
        private IResourceLoader GetExistBundlesLoader(out AssetBundleManifest manifest)
        {
            IResourceLoader existLoader = null;

            if (_resourceStorage.IsLoaderRegistered <WebRequestBundlesLoader>())
            {
                existLoader = _resourceStorage.GetResourceLoader <WebRequestBundlesLoader>();
                manifest    = ((WebRequestBundlesLoader)existLoader).Manifest;
                return(existLoader);
            }

            if (_resourceStorage.IsLoaderRegistered <LocalFolderBundlesLoader>())
            {
                existLoader = _resourceStorage.GetResourceLoader <LocalFolderBundlesLoader>();
                manifest    = ((LocalFolderBundlesLoader)existLoader).Manifest;
                return(existLoader);
            }

            throw new ResourceSystemException("Not found correct bundles loader!!!");
        }
Esempio n. 32
0
        /// <summary>
        /// Same as <see cref="GetWordSet(IResourceLoader, string, bool)"/>,
        /// except the input is in snowball format.
        /// </summary>
        protected CharArraySet GetSnowballWordSet(IResourceLoader loader, string wordFiles, bool ignoreCase)
        {
            AssureMatchVersion();
            IList <string> files = SplitFileNames(wordFiles);
            CharArraySet   words = null;

            if (files.Count > 0)
            {
                // default stopwords list has 35 or so words, but maybe don't make it that
                // big to start
                words = new CharArraySet(m_luceneMatchVersion, files.Count * 10, ignoreCase);
                foreach (string file in files)
                {
                    using Stream stream     = loader.OpenResource(file.Trim());
                    using TextReader reader = new StreamReader(stream, Encoding.UTF8);
                    WordlistLoader.GetSnowballWordSet(reader, words);
                }
            }
            return(words);
        }