public void DeleteConfiguration(CmdApplicationConfiguration applicationConfiguration) { if (applicationConfiguration == null) throw new ArgumentNullException(nameof(applicationConfiguration)); this.FileStoreWriter.Delete(applicationConfiguration); }
public bool CheckIfConfigurationWithSameNameExists(CmdApplicationConfiguration applicationConfiguration) { if (applicationConfiguration == null) throw new ArgumentNullException(nameof(applicationConfiguration)); return this.FileStoreReader.CheckIfFileExists(applicationConfiguration); }
public void CreateNewConfiguration(CmdApplicationConfiguration applicationConfiguration) { if (applicationConfiguration == null) throw new ArgumentNullException(nameof(applicationConfiguration)); using (var stream = this.FileStoreWriter.OpenStreamFor(applicationConfiguration)) using (var writer = new StreamWriter(stream)) this.serializer.Serialize(writer, applicationConfiguration); }
public SaveCmdApplicationConfigurationCommand(Guid messageId, CmdApplicationConfiguration applicationConfiguration) { if (messageId == null || messageId == Guid.Empty) throw new ArgumentNullException(nameof(messageId)); if (applicationConfiguration == null) throw new ArgumentNullException(nameof(applicationConfiguration)); this.MessageId = messageId; this.ApplicationConfiguration = applicationConfiguration; }
public DeleteCmdApplicationConfigurationCommand(Guid messageId, CmdApplicationConfiguration applicationConfiguration) { if (messageId == null || messageId == Guid.Empty) { throw new ArgumentNullException(nameof(messageId)); } if (applicationConfiguration == null) { throw new ArgumentNullException(nameof(applicationConfiguration)); } this.MessageId = messageId; this.ApplicationConfiguration = applicationConfiguration; }
public CmdApplicationConfigurationViewModel Create( CmdApplicationConfiguration applicationConfiguration, CmdApplicationMeta applicationMeta) { if (applicationConfiguration == null) throw new ArgumentNullException(nameof(applicationConfiguration)); if (applicationMeta == null) throw new ArgumentNullException(nameof(applicationMeta)); var properties = new List<ParameterViewModel>(); foreach (var parameterMeta in applicationMeta.ParameterMetas) { ParameterViewModel viewModel = null; if (parameterMeta.ParameterType == typeof(NameValueParameter)) { viewModel = new NameValueParameterViewModel(parameterMeta.Name, parameterMeta.DisplayName); viewModel.WithParameter(applicationConfiguration .Parameters .FirstOrDefault(a => a.Name == parameterMeta.Name)); } else if (parameterMeta.ParameterType == typeof(NameOnlyParameter)) { viewModel = new NameOnlyParameterViewModel(parameterMeta.Name, parameterMeta.DisplayName); viewModel.WithParameter(applicationConfiguration.Parameters.FirstOrDefault(a => a.Name == parameterMeta.Name)); } else { throw new ArgumentException(string.Format("Type {0} not supported for parameter {1}", parameterMeta.ParameterType, parameterMeta.Name)); } properties.Add(viewModel); } var returnValue = new CmdApplicationConfigurationViewModel( applicationMeta, properties, Channel, StringParsers); returnValue.FriendlyName = (string)applicationConfiguration.Name; return returnValue; }
public Maybe <CmdApplicationConfiguration> Parse(T data, CmdApplicationMeta applicationMeta) { var friendlyName = this.GetFriendlyName(data, applicationMeta); var parameters = this.GetParameters(data, applicationMeta); if (parameters == null || !parameters.Any()) { return(Maybe.Empty <CmdApplicationConfiguration>()); } if (friendlyName == null) { friendlyName = Name.EmptyName; } var configuration = new CmdApplicationConfiguration( friendlyName, applicationMeta.ApplicationName, new System.Collections.ObjectModel.ReadOnlyCollection <IParameter>(parameters) ); return(Maybe.ToMaybe(configuration)); }
private CmdApplicationConfiguration CreateCmdApplicationConfiguration( string friendlyName, CmdApplicationMeta meta) { var parameterList = new List<IParameter>(); IParameter parameter = new NameOnlyParameter((Name)"-E"); parameterList.Add(parameter); parameter = new NameValueParameter((Name)"-S", "Value"); parameterList.Add(parameter); var configuration = new CmdApplicationConfiguration( (Name)friendlyName, (Name)meta.ApplicationName, new ReadOnlyCollection<IParameter>(parameterList)); return configuration; }
public void GetFileNameWithNullValueThrowsException(CmdApplicationConfiguration sut) { Assert.Throws<ArgumentNullException>(() => sut.GetFileName(null)); }