public static Identifier Parse(string identifier)
 {
     var tokens = identifier.Split('.');
     var region = new Region(tokens[0]);
     var id = Guid.Parse(tokens[1]);
     return new Identifier(id, region);
 }
        public Identifier Persist(Region region, string serializedTask)
        {
            var id = region.NewIdentifier();
            Persist(id, serializedTask);

            return id;
        }
 public SynchronousExecutor(string name)
 {
     if (string.IsNullOrWhiteSpace(name))
     {
         throw new ArgumentException("Argument name should be not null not empty string", "name");
     }
     _name = name;
     _region = new Region(name);
 }
        public IEnumerable<KeyValuePair<Identifier, ITask>> LoadAll(Region region)
        {
            Contract.Require(region.IsValid, "region.IsValid");

            var serialized = _database.GetAll(region);

            var results = serialized.Select(Deserialize);

            return results;
        }
        public IEnumerable<KeyValuePair<Identifier, string>> GetAll(Region region)
        {
            foreach (var kvp in _database)
            {
                var id = Identifier.Parse(kvp.Key);

                if(!id.Region.Equals(region)) continue;

                yield return new KeyValuePair<Identifier, string>(id, kvp.Value);
            }
        }
        public QueuedExecutor(QueuedExecutorSettings settings, IPersister persister)
        {
            if (settings == null)
            {
                throw new ArgumentNullException("settings");
            }

            settings.Validate();

            _settings = settings;
            _persister = persister;
            _region = new Region(_settings.Name);
            _queue = new ConcurrentQueue<ExecutionEnvelope>();
        }
        public Identifier(Guid id, Region region)
        {
            if (Guid.Empty.Equals(id))
            {
                throw new ArgumentException("Id should be not empty Guid.", "id");
            }

            if(string.IsNullOrWhiteSpace(region.Name))
            {
                throw new ArgumentException("Region should be initialized with not null not empty value", "region");
            }

            _id = id;
            _region = region;
        }
 public IEnumerable<KeyValuePair<Identifier, ITask>> LoadAll(Region region)
 {
     return _empty;
 }
Exemple #9
0
 public bool Equals(Region other)
 {
     return string.Equals(_name, other._name);
 }
 public IEnumerable<KeyValuePair<Identifier, string>> GetAll(Region region)
 {
     return _tasks.Where(x => x.Key.Region.Equals(region));
 }