public void NullFile_ShouldDoNothing()
        {
            IPropertiesFile file = null;
            ICommand        cmd  = new RemovePropertyByKeyCommand(file, "TestKey");

            cmd.Execute();
        }
        public void RemovePropertiesFile(IPropertiesFile file)
        {
            if (!_propertiesFiles.Contains(file))
            {
                throw new ArgumentException("No such file is tracked");
            }

            _propertiesFiles.Remove(file);

            _eventAggregator.GetEvent <PubSubEvent <RemovedPropertiesFileEvent> >().Publish(new RemovedPropertiesFileEvent(file));
        }
 public FileWithTwoProperties()
 {
     _file = new InMemoryPropertiesFile(new List <PropertyPair>
     {
         new PropertyPair {
             Key = "Key1", Value = "Value1"
         },
         new PropertyPair {
             Key = "Key2", Value = "Value2"
         }
     });
 }
        public Task <IReadOnlyDictionary <string, string> > ParseFileAsync(IPropertiesFile file)
        {
            return(Task.Run(() =>
            {
                var dataWriteable = new Dictionary <string, string>();

                var streamReader = new StreamReader(file.FilePath.OpenRead());
                string line;

                while ((line = streamReader.ReadLine()) != null)
                {
                    var strings = line.Split('=');

                    dataWriteable.Add(strings[0], strings[1]);
                }

                return new ReadOnlyDictionary <string, string>(dataWriteable) as IReadOnlyDictionary <string, string>;
            }));
        }
        public async Task <IEnumerable <ValidationResult> > ValidateFile(IPropertiesFile propertiesFile)
        {
            var validationRules             = _container.ResolveAll <IValidationRule <IPropertiesFile> >();
            List <ValidationResult> results = new List <ValidationResult>();

            foreach (IValidationRule <IPropertiesFile> validationRule in validationRules)
            {
                try
                {
                    results.AddRange(await validationRule.ValidateAsync(propertiesFile));
                }
                catch (Exception e)
                {
                    return(new[] { new ValidationResult(e.Message) });
                }
            }

            return(results);
        }
 public AddedPropertiesFileEvent(IPropertiesFile propertiesFile)
     : base(propertiesFile)
 {
 }
Exemplo n.º 7
0
 protected PropertiesFileEventBase(IPropertiesFile propertiesFile)
 {
     _propertiesFile = propertiesFile;
 }
Exemplo n.º 8
0
 public AddPropertyCommand(IPropertiesFile file, PropertyPair newProperty, IUserConfirmation userConfirmation)
 {
     _file             = file;
     _propertyToAdd    = newProperty;
     _userConfirmation = userConfirmation;
 }
 public void RemovePropertiesFile(IPropertiesFile file)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 10
0
 public RemovedPropertiesFileEvent(IPropertiesFile propertiesFile)
     : base(propertiesFile)
 {
 }
Exemplo n.º 11
0
 public StripCommentsCommand(IPropertiesFile file)
 {
     _file = file;
 }
Exemplo n.º 12
0
 public RemovePropertyByKeyCommand(IPropertiesFile file, string targetKey)
 {
     _file      = file;
     _targetKey = targetKey;
 }
Exemplo n.º 13
0
 public FileViewModel(IPropertiesFile propFile, IPropertiesFileService propertiesFileService)
 {
     _propertiesFile        = propFile;
     _propertiesFileService = propertiesFileService;
 }
Exemplo n.º 14
0
 public PlusNameJob()
 {
     propertiesFile = new PropertiesFileReName();
 }
Exemplo n.º 15
0
 public StripEmptyLinesCommand(IPropertiesFile file)
 {
     _file = file;
 }