public Factory( Event.IBus eventBus, Data.IProvider dataProvider) { _eventBus = eventBus; _dataProvider = dataProvider; }
public Factory(Navigation.IService navigationService, Data.IProvider dataProvider, Event.IBus eventBus, Platform.ISchedulers platformSchedulers) { _navigationService = navigationService; _dataProvider = dataProvider; _eventBus = eventBus; _platformSchedulers = platformSchedulers; }
public State(Navigation.IService navigationService, Data.IProvider dataProvider, Lensman.Event.IBus eventBus, Platform.ISchedulers schedulers, Guid userId) { _navigationService = navigationService; _eventBus = eventBus; _dataProvider = dataProvider; _schedulers = schedulers; _userId = userId; }
/// <summary> /// Show current setup /// </summary> /// <param name="config">Config</param> /// <param name="args">CMD Args</param> /// <param name="provider">Provider</param> /// <returns>Exit code</returns> private static int ShowInfo(Data.MailiasConfig config, Args args, Data.IProvider provider) { CoEx.WriteLine($"Used Provider: {config.Provider}"); CoEx.WriteLine($"Mail Domain: {config.MailDomain}"); CoEx.WriteLine($"Alias Target: {config.TargetAddress}"); CoEx.WriteLine($"Prefix: {config.Prefix}"); CoEx.WriteLine($"Code Length: {config.UniqeIdLength}"); return(0); }
/// <summary> /// Create a provider instance /// </summary> /// <param name="config">Config</param> /// <returns>The created provider</returns> private static Data.IProvider CreateProvider(Data.MailiasConfig config) { Data.IProvider provider = Providers.SingleOrDefault(p => p.ProviderKey == config.Provider); if (provider == null) { return(null); } provider.Configure(config); return(provider); }
public ViewModel(Data.IProvider dataProvider, Lensman.Event.IBus eventBus, Platform.ISchedulers schedulers, Guid userId) { _dataProvider = dataProvider; _eventBus = eventBus; _userId = userId; _schedulers = schedulers; _logger = global::Uno.Extensions.LogExtensionPoint.AmbientLoggerFactory.CreateLogger <ViewModel>(); _recognised = new BehaviorSubject <Director.Client.Recognition>(null); _face = new MVx.Observable.Property <Director.Client.Face>(nameof(Face), args => PropertyChanged?.Invoke(this, args)); _ian = new MVx.Observable.Command(); _rachel = new MVx.Observable.Command(); _mia = new MVx.Observable.Command(); _max = new MVx.Observable.Command(); _alan = new MVx.Observable.Command(); _notAFace = new MVx.Observable.Command(); }
public ViewModel(Data.IProvider dataProvider, Platform.ISchedulers schedulers) { _dataProvider = dataProvider; _schedulers = schedulers; _currentContainer = new MVx.Observable.Property <Common.Container>(nameof(CurrentContainer), args => PropertyChanged?.Invoke(this, args)); _sliderMinimum = new MVx.Observable.Property <long>(nameof(SliderMinimum), args => PropertyChanged?.Invoke(this, args)); _sliderMaximum = new MVx.Observable.Property <long>(nameof(SliderMaximum), args => PropertyChanged?.Invoke(this, args)); _sliderCurrent = new MVx.Observable.Property <long>(nameof(SliderCurrent), args => PropertyChanged?.Invoke(this, args)); _selectedRegion = new MVx.Observable.Property <int>(0, nameof(SelectedRegion), args => PropertyChanged?.Invoke(this, args)); _regionIntensity = new MVx.Observable.Property <IReadOnlyDictionary <int, double?> >(Enumerable.Range(0, 15).ToDictionary(i => i, _ => default(double?)), nameof(RegionIntensity), args => PropertyChanged?.Invoke(this, args)); _currentComposition = new MVx.Observable.Property <IReadOnlyDictionary <string, double> >(Enum.GetNames(typeof(Common.FuelType)).ToDictionary(name => name, _ => 0.0), nameof(CurrentComposition), args => PropertyChanged?.Invoke(this, args)); _currentPeriod = new MVx.Observable.Property <Common.Period>(nameof(CurrentPeriod), args => PropertyChanged?.Invoke(this, args)); _currentRegion = new MVx.Observable.Property <Common.Region>(nameof(CurrentRegion), args => PropertyChanged?.Invoke(this, args)); _currentOperator = new MVx.Observable.Property <Common.Operator>(nameof(CurrentOperator), args => PropertyChanged?.Invoke(this, args)); _currentRegionPopulation = new MVx.Observable.Property <int>(nameof(CurrentRegionPopulation), args => PropertyChanged?.Invoke(this, args)); _currentRegionGeneration = new MVx.Observable.Property <Common.RegionGeneration>(nameof(CurrentRegionGeneration), args => PropertyChanged?.Invoke(this, args)); _tonnesOfCO2PerHour = new MVx.Observable.Property <double>(nameof(TonnesOfCO2PerHour), args => PropertyChanged?.Invoke(this, args)); _domesticConsumption = new MVx.Observable.Property <double>(nameof(DomesticConsumption), args => PropertyChanged?.Invoke(this, args)); _domesticCarbonOffsetCostPerHour = new MVx.Observable.Property <double>(nameof(DomesticCarbonOffsetCostPerHour), args => PropertyChanged?.Invoke(this, args)); _domesticCarbonOffsetCostPerPersonPerYear = new MVx.Observable.Property <double>(nameof(DomesticCarbonOffsetCostPerPersonPerYear), args => PropertyChanged?.Invoke(this, args)); }
public Resuming(Aggregate.IRoot aggregateRoot, Data.IProvider dataProvider) { _aggregateRoot = aggregateRoot; _dataProvider = dataProvider; }
/// <summary> /// List existing aliases /// </summary> /// <param name="config">Config</param> /// <param name="args">CMD Args</param> /// <param name="provider">Provider</param> /// <returns>Exit Code</returns> private static async Task <int> ListAliases(Data.MailiasConfig config, Args args, Data.IProvider provider) { // Table header var header = new string[] { "Source", "Targets" }; // Convert the alias items into table rows var aliases = (await provider.GetAliases(config)) .Select(a => a.SourceAddress) .ToList(); if (aliases.Count > 0) { CoEx.WriteLine(string.Join(Environment.NewLine, aliases)); return(0); } else { // no aliases found return(1); } }
/// <summary> /// Delete an existing alias /// </summary> /// <param name="config">Config</param> /// <param name="args">CMD Args</param> /// <param name="provider">Provider</param> /// <returns>Exit Code</returns> private static async Task <int> DeleteAlias(Data.MailiasConfig config, Args args, Data.IProvider provider) { var exists = (await provider.GetAliases(config)) .Any(alias => alias.SourceAddress == args.DeleteAlias); if (exists) { if (args.Force || YesNo("Really delete alias '" + args.DeleteAlias + "'?")) { var result = await provider.DeleteAliasAddress(args.DeleteAlias); if (result == Data.DeleteResult.Success) { return(0); } if (!args.Silent) { CoEx.WriteLine("Delete failed."); } return(1); } else { return(0); } } else { if (!args.Silent) { CoEx.WriteLine("Alias not found or didn't match the format of an alias which was created with this application."); } return(1); } }
/// <summary> /// Create an alias /// </summary> /// <param name="config">Config</param> /// <param name="args">CMD Args</param> /// <param name="provider">Provider</param> /// <returns>Exit code</returns> private static async Task <int> CreateAlias(Data.MailiasConfig config, Args args, Data.IProvider provider) { // Create a new random id var chars = "abcdefghijklmnopqrstuvwxyz0123456789"; var builder = new StringBuilder(); var random = new Random(); while (builder.Length < config.UniqeIdLength) { var index = random.Next(0, chars.Length - 1); builder.Append(chars[index]); } // Build the email address var prefix = string.IsNullOrWhiteSpace(config.Prefix) ? "" : config.Prefix + "."; var key = builder.ToString(); var mailAddress = $"{prefix}{args.CreateName}.{key}@{config.MailDomain}"; // Check if the email address already exists var exists = (await provider.GetAliases(config)) .FirstOrDefault(a => a.SourceAddress.StartsWith($"{prefix}{args.CreateName}.")); if (exists != null && args.Force == false) { if (!YesNo($"There is already an alias ({exists.SourceAddress}) with this name. Proceed?")) { return(1); } } // Delete the existing alias if (exists != null && args.DeleteExisting) { if (args.Force || YesNo($"Dou you want do delete the existing alias '{exists.SourceAddress}', before creating a new one?")) { var deleteExistingResult = await provider.DeleteAliasAddress(exists.SourceAddress); if (deleteExistingResult != Data.DeleteResult.Success && !args.Silent) { CoEx.WriteLine("Deleting existing alias failed."); return(1); } } } // Create the new alias var result = await provider.CreateAlias(mailAddress, config.TargetAddress); if (result == Data.CreateResult.Success || result == Data.CreateResult.AlreadyExists) { CoEx.WriteLine(mailAddress); return(0); } else { if (!args.Silent) { CoEx.WriteLine("Creation failed."); } return(1); } }