public FilesHandler(IResourcesProvider resourceProvider , IOptions <FileDirectoryPathSettings> options , ILogger <FilesService> logger) { _resourceProvider = resourceProvider; _options = options; _logger = logger; }
protected virtual void OnInitialize() { _typeResolver = new AndroidFrameworkTypeResolver(this); _loggingProvider = new DefaultLoggingProvider(); _resourcesProvider = new AndroidResourcesProvider(this); _synchronizationProvider = new AndroidSynchronizationProvider(); _navigationProvider = new AndroidNavigationProvider(_typeResolver, _synchronizationProvider, _resourcesProvider); }
protected virtual void OnInitialize() { _typeResolver = new iOSFrameworkTypeResolver(); _loggingProvider = new DefaultLoggingProvider(); _resourcesProvider = new iOSResourcesProvider(); _synchronizationProvider = new iOSSynchronizationProvider(this); _navigationProvider = new iOSNavigationProvider(NavigationController, _typeResolver, new PlatformProviders(GetNavigationProvider, _synchronizationProvider, _resourcesProvider)); }
public PerWindowPlatformProviders(INavigationProvider navigation, ISynchronizationProvider synchronization, IResourcesProvider resources) { Guard.AgainstNull(navigation, "navigation"); _navigation = navigation; Guard.AgainstNull(synchronization, "synchronization"); _synchronization = synchronization; Guard.AgainstNull(resources, "resources"); _resources = resources; }
protected virtual void OnInitialize(IActivatedEventArgs args) { _loggingProvider = new DefaultLoggingProvider(); _synchronization = new SynchronizationProvider(); _resources = new WindowsRuntimeResourcesProvider(ResourceLoader.GetForViewIndependentUse(Constants.StoreAppsInfrastructureResourceMapId)); _typeResolver = new DefaultMvvmTypeResolver(); _lifecycleProvider = new UwpLifecycleProvider(_typeResolver, _synchronization, _resources); _navigationProvider = CreateNavigationManager(Window.Current, _typeResolver, _synchronization, _resources); }
public LinkItemViewModel( INavigationService navigationService, ILinkItemRepository linkItemDatabase, IOptionsRepository optionsRepository, IClipboardInfo clipboardInfo, IResourcesProvider resourcesProvider) : base(navigationService, linkItemDatabase, optionsRepository, clipboardInfo, resourcesProvider) { }
public CMSOutput(OutputContext context, Asset asset, IAssetRepository AssetRepository, IAssetPathResolver AssetPathResolver, IResourcesProvider ResourcesProvider) : base(context, asset) { this.AssetPathResolver = AssetPathResolver; this.AssetRepository = AssetRepository; this.ResourcesProvider = ResourcesProvider; }
public static IResourceDictionary LoadResources(string xaml, IResourcesProvider rootView) { void ehandler(Exception e) => ResourceLoader.ExceptionHandler2?.Invoke((e, XamlFilePathAttribute.GetFilePathForObject(rootView))); using (var textReader = new StringReader(xaml)) using (var reader = XmlReader.Create(textReader)) { while (reader.Read()) { //Skip until element if (reader.NodeType == XmlNodeType.Whitespace) { continue; } if (reader.NodeType == XmlNodeType.XmlDeclaration) { continue; } if (reader.NodeType != XmlNodeType.Element) { Debug.WriteLine("Unhandled node {0} {1} {2}", reader.NodeType, reader.Name, reader.Value); continue; } //the root is set to null, and not to rootView, on purpose as we don't want to erase the current Resources of the view RootNode rootNode = new RuntimeRootNode(new XmlType(reader.NamespaceURI, reader.Name, null), null, (IXmlNamespaceResolver)reader); XamlParser.ParseXaml(rootNode, reader); var rNode = (IElementNode)rootNode; if (!rNode.Properties.TryGetValue(new XmlName("http://xamarin.com/schemas/2014/forms", "Resources"), out var resources)) { return(null); } var visitorContext = new HydrationContext { ExceptionHandler = ResourceLoader.ExceptionHandler2 != null ? ehandler : (Action <Exception>)null, }; var cvv = new CreateValuesVisitor(visitorContext); cvv.Visit((ElementNode)resources, null); visitorContext.RootElement = visitorContext.Values[resources]; resources.Accept(new XamlNodeVisitor((node, parent) => node.Parent = parent), null); //set parents for {StaticResource} resources.Accept(new ExpandMarkupsVisitor(visitorContext), null); resources.Accept(new PruneIgnoredNodesVisitor(false), null); resources.Accept(new NamescopingVisitor(visitorContext), null); //set namescopes for {x:Reference} resources.Accept(new CreateValuesVisitor(visitorContext), null); resources.Accept(new RegisterXNamesVisitor(visitorContext), null); resources.Accept(new FillResourceDictionariesVisitor(visitorContext), null); resources.Accept(new ApplyPropertiesVisitor(visitorContext, true), null); return(visitorContext.Values[resources] as IResourceDictionary); } } return(null); }
public void LoadResources(string layer, Action <string> LoadOverAction) { ResourcesLayerID = layer; Debug.Log(ResourcesLayerID); loadResourcesState = new ListState <string>(""); foreach (string s in resourcesManagers.Keys) { IResourcesProvider manager = FrameManager.CreateInstence <IResourcesProvider>(); //resourcesManagers[s].AddNode(manager); } loadResourcesState.TmpReductionStateEvent = LoadOverAction; }
public ViewModelBase( INavigationService navigationService, ILinkItemRepository linkItemDatabase, IOptionsRepository optionsDatabase, IClipboardInfo clipboardInfo, IResourcesProvider resourcesProvider) { this.navigationService = navigationService; this.database = linkItemDatabase; this.options = optionsDatabase; this.clipboardInfo = clipboardInfo; this.resourcesProvider = resourcesProvider; }
public static IEnumerable <StyleSheet> GetStyleSheets(this IResourcesProvider resourcesProvider) { if (!resourcesProvider.IsResourcesCreated) { yield break; } if (resourcesProvider.XamlResources.StyleSheets == null) { yield break; } foreach (var styleSheet in resourcesProvider.XamlResources.StyleSheets) { yield return(styleSheet); } }
public static IResourceDictionary LoadResources(string xaml, IResourcesProvider rootView) { void ehandler(Exception e) => ResourceLoader.ExceptionHandler2?.Invoke((e, XamlFilePathAttribute.GetFilePathForObject(rootView))); using (var textReader = new StringReader(xaml)) using (var reader = XmlReader.Create(textReader)) { while (reader.Read()) { //Skip until element if (reader.NodeType == XmlNodeType.Whitespace) { continue; } if (reader.NodeType == XmlNodeType.XmlDeclaration) { continue; } if (reader.NodeType != XmlNodeType.Element) { Debug.WriteLine("Unhandled node {0} {1} {2}", reader.NodeType, reader.Name, reader.Value); continue; } //the root is set to null, and not to rootView, on purpose as we don't want to erase the current Resources of the view RootNode rootNode = new RuntimeRootNode(new XmlType(reader.NamespaceURI, reader.Name, null), null, (IXmlNamespaceResolver)reader) { LineNumber = ((IXmlLineInfo)reader).LineNumber, LinePosition = ((IXmlLineInfo)reader).LinePosition }; XamlParser.ParseXaml(rootNode, reader); var rNode = (IElementNode)rootNode; if (!rNode.Properties.TryGetValue(new XmlName(XamlParser.MauiUri, "Resources"), out var resources)) { return(null); } var visitorContext = new HydrationContext { ExceptionHandler = ResourceLoader.ExceptionHandler2 != null ? ehandler : (Action <Exception>)null, }; var cvv = new CreateValuesVisitor(visitorContext); if (resources is ElementNode resourcesEN && (resourcesEN.XmlType.NamespaceUri != XamlParser.MauiUri || resourcesEN.XmlType.Name != nameof(ResourceDictionary))) { //single implicit resource resources = new ElementNode(new XmlType(XamlParser.MauiUri, nameof(ResourceDictionary), null), XamlParser.MauiUri, rootNode.NamespaceResolver); ((ElementNode)resources).CollectionItems.Add(resourcesEN); }
public TransactionController(IRepositoriesHandler repositoriesHandler, IServiceHandler serviceHandler, IResourcesProvider resourcesProvider) { this.repositoriesHandler = repositoriesHandler; this.serviceHandler = serviceHandler; this.resourcesProvider = resourcesProvider; }
public Localizer(IResourcesProvider provider, bool throwWhenNotFound = false) { _provider = provider; _throwWhenNotFound = throwWhenNotFound; }
public FrameworkPageViewModel(IPlatformProviders arguments) { Navigation = arguments.WindowProviders.Navigation; Synchronization = arguments.WindowProviders.Synchronization; Resources = arguments.WindowProviders.Resources; }
public static void SetResourcesProvider(IResourcesProvider resourcesProvider) { _resourcesProvider = resourcesProvider; }
public CustomerController(IRepositoriesHandler repositoriesHandler, IServiceHandler serviceHandler, IResourcesProvider resourcesProvider) { this.repositoriesHandler = repositoriesHandler; this.serviceHandler = serviceHandler; this.resourcesProvider = resourcesProvider; }
public async Task <Result> GenerateCardRandomTransactionsAsync(int toCardID, IRepositoriesHandler repositoriesHandler, IResourcesProvider resourcesProvider) { var result = new Result(); if (toCardID == 0) { result.Success = false; result.Error = resourcesProvider.GetGeneralResource("CCIdNull"); return(result); } var cards = await repositoriesHandler.СreditCardRepository.GetCollectionForRandomTranAsync(toCardID); if (cards.Count == 0) { result.Success = false; result.Error = resourcesProvider.GetGeneralResource("NotEnCards"); return(result); } int counter = 0; var transactionResult = new Result(); foreach (var card in cards) { Random rnd = new Random(); var transaction = new Domain.Models.Transaction(); transaction.Amount = rnd.Next(1, (int)card.Amount); transaction.Comment = resourcesProvider.GetGeneralResource("RndTran"); transaction.Date = DateTime.Now; transaction.FromCreditCardID = card.CreditCardID; transaction.ToCreditCardID = toCardID; transactionResult = await this.PerformTransactionAsync(transaction, repositoriesHandler, resourcesProvider); if (transactionResult.Success) { counter++; } } if (counter > 0) { result.Success = true; result.SuccessMessage = resourcesProvider.GetGeneralResource("TransGenDone"); return(result); } else { result.Success = false; result.Error = resourcesProvider.GetGeneralResource("TranAllCCOutOfFunds"); return(result); } }
/// <summary> /// Инициализирует экземпляр ссылкой на <see cref="IResourcesProvider" /> /// </summary> /// <param name="resourcesProvider"></param> public XmlResourcesMessageSerializer(IResourcesProvider resourcesProvider) { xsd = resourcesProvider.ThrowIfNull(nameof(resourcesProvider)) .GetResourceStream <T>() .ToList(); }
public async Task <Result> PerformTransactionAsync(Domain.Models.Transaction newTransaction, IRepositoriesHandler repositoriesHandler, IResourcesProvider resourcesProvider) { var result = new Result(); result.Success = newTransaction.Amount > 0; if (!result.Success) { result.Error = resourcesProvider.GetGeneralResource("IncAmount"); return(result); } var fromCreditCard = await repositoriesHandler.СreditCardRepository.GetByIdAsync(newTransaction.FromCreditCardID); result.Success = fromCreditCard.Amount > newTransaction.Amount; if (!result.Success) { result.Error = resourcesProvider.GetGeneralResource("TranOutOfFunds"); return(result); } var toCreditCard = await repositoriesHandler.СreditCardRepository.GetByIdAsync(newTransaction.ToCreditCardID); if (fromCreditCard.CreditCardID == toCreditCard.CreditCardID) { result.Success = false; result.Error = resourcesProvider.GetGeneralResource("SelectDifCards"); return(result); } try { using (var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) { fromCreditCard.Amount -= newTransaction.Amount; await repositoriesHandler.СreditCardRepository.UpdateAsync(fromCreditCard); toCreditCard.Amount += newTransaction.Amount; await repositoriesHandler.СreditCardRepository.UpdateAsync(toCreditCard); newTransaction.Date = DateTime.Now; await repositoriesHandler.TransactionRepository.InsertAsync(newTransaction); scope.Complete(); } result.Success = true; result.SuccessMessage = resourcesProvider.GetGeneralResource("TranOk"); return(result); } catch (Exception ex) { result.Success = false; result.Error = $"{resourcesProvider.GetGeneralResource("TranFail")} {ex.Message}."; return(result); } }
public Result UpdateCustomer(EditedCustomer editedCustomer, IRepositoriesHandler repositoriesHandler, IPasswordService passwordService, IResourcesProvider resourcesProvider) { var result = new Result(); var isLoginExist = repositoriesHandler.СustomerRepository.GetCollection().Any(x => x.Login == editedCustomer.Login && x.CustomerID != editedCustomer.CustomerID); if (isLoginExist) { result.Success = false; result.Error = resourcesProvider.GetGeneralResource("LogExist"); return(result); } if (editedCustomer.CustomerID == 0) { result.Success = false; result.Error = resourcesProvider.GetGeneralResource("CusIdNull"); return(result); } if (!IsCutomerDataValid(editedCustomer.Login, editedCustomer.CurrentPassword)) { result.Success = false; result.Error = resourcesProvider.GetGeneralResource("NoLogPass"); return(result); } var storedCustomer = repositoriesHandler.СustomerRepository.GetById(editedCustomer.CustomerID); if (passwordService.ComparePasswords(editedCustomer.CurrentPassword, storedCustomer.Password)) { storedCustomer.CustomerID = editedCustomer.CustomerID; storedCustomer.FirstName = editedCustomer.FirstName; storedCustomer.LastName = editedCustomer.LastName; storedCustomer.Login = editedCustomer.Login; storedCustomer.Password = string.IsNullOrEmpty(editedCustomer.NewPassword) ? storedCustomer.Password : passwordService.HashPassword(editedCustomer.NewPassword); repositoriesHandler.СustomerRepository.Update(storedCustomer); result.Success = true; result.SuccessMessage = resourcesProvider.GetGeneralResource("CusUpdt"); return(result); } else { result.Success = false; result.Error = resourcesProvider.GetGeneralResource("PassDontMatch"); return(result); } }
public Result CreateNewCustomer(Customer newCustomer, IRepositoriesHandler repositoriesHandler, IPasswordService passwordService, IResourcesProvider resourcesProvider) { var result = new Result(); var isLoginExist = repositoriesHandler.СustomerRepository.GetCollection().Any(x => x.Login == newCustomer.Login); if (isLoginExist) { result.Success = false; result.Error = resourcesProvider.GetGeneralResource("LogExist"); return(result); } if (!IsCutomerDataValid(newCustomer.Login, newCustomer.Password)) { result.Success = false; result.Error = resourcesProvider.GetGeneralResource("NoLogPass"); return(result); } newCustomer.Password = passwordService.HashPassword(newCustomer.Password); newCustomer.DateOfRegistration = DateTime.Now; repositoriesHandler.СustomerRepository.Insert(newCustomer); result.Success = true; result.SuccessMessage = resourcesProvider.GetGeneralResource("CusCreat"); return(result); }
public Result CreateNewCreditCard(CreditCard newCreditCard, IRepositoriesHandler repositoriesHandler, IPasswordService passwordService, IResourcesProvider resourcesProvider) { var result = new Result(); var isCardNumExist = repositoriesHandler.СreditCardRepository.GetCollection().Any(x => x.CardNumber == newCreditCard.CardNumber); if (isCardNumExist) { result.Success = false; result.Error = resourcesProvider.GetGeneralResource("CCNumExist"); return(result); } if (!IsCreditCardDataValid(newCreditCard.CardNumber, newCreditCard.PIN)) { result.Success = false; result.Error = resourcesProvider.GetGeneralResource("NoNumPin"); return(result); } newCreditCard.PIN = passwordService.HashPassword(newCreditCard.PIN); newCreditCard.DateOfCreation = DateTime.Now; repositoriesHandler.СreditCardRepository.Insert(newCreditCard); result.Success = true; result.SuccessMessage = resourcesProvider.GetGeneralResource("CCCreated"); return(result); }
public static void AddProvider(IResourcesProvider provider) { Providers.Add(provider.ModPrefix, provider); }
public Result UpdateCreditCard(EditedCreditCard editedCreditCard, IRepositoriesHandler repositoriesHandler, IPasswordService passwordService, IResourcesProvider resourcesProvider) { var result = new Result(); var isCardNumExist = repositoriesHandler.СreditCardRepository.GetCollection().Any(x => x.CardNumber == editedCreditCard.CardNumber && x.CreditCardID != editedCreditCard.CreditCardID); if (isCardNumExist) { result.Success = false; result.Error = resourcesProvider.GetGeneralResource("CCNumExist"); return(result); } if (!IsCreditCardDataValid(editedCreditCard.CardNumber, editedCreditCard.CurrentPIN)) { result.Success = false; result.Error = resourcesProvider.GetGeneralResource("NoNumPin"); return(result); } var storedCreditCard = repositoriesHandler.СreditCardRepository.GetById(editedCreditCard.CreditCardID); if (passwordService.ComparePasswords(editedCreditCard.CurrentPIN, storedCreditCard.PIN)) { storedCreditCard.CardNumber = editedCreditCard.CardNumber; storedCreditCard.Amount = editedCreditCard.Amount; storedCreditCard.PIN = string.IsNullOrEmpty(editedCreditCard.NewPIN) ? storedCreditCard.PIN : passwordService.HashPassword(editedCreditCard.NewPIN); repositoriesHandler.СreditCardRepository.Update(storedCreditCard); result.Success = true; result.SuccessMessage = resourcesProvider.GetGeneralResource("CCUpdt"); return(result); } else { result.Success = false; result.Error = resourcesProvider.GetGeneralResource("PinsDontMatch"); return(result); } }