Exemplo n.º 1
0
 public City(string name, Region region, ICityLevelRule cityLevelRule = null, Tuple <decimal, decimal> coords = null)
     : base(name, region)
 {
     if (string.IsNullOrWhiteSpace(name) || region == null)
     {
         throw new ArgumentException("Can't create city: unnamed city or undentified region");
     }
     BaseConstructor(region, cityLevelRule, coords);
 }
Exemplo n.º 2
0
 public City(string name, ICityLevelRule cityLevelRule = null, Tuple <decimal, decimal> coords = null)
     : base(name, null)
 {
     if (string.IsNullOrWhiteSpace(name))
     {
         throw new ArgumentException("Can't create city: unnamed city");
     }
     BaseConstructor(null, cityLevelRule, coords);
 }
Exemplo n.º 3
0
        public City AddLevels(ICityLevelRule cityLevelRule)
        {
            var lvls = cityLevelRule.GetLevels();

            foreach (var lvl in lvls)
            {
                AddLevel(lvl.Key, lvl.Value);
            }
            return(this);
        }
Exemplo n.º 4
0
        public Map AddCity(string name, Region region, ICityLevelRule rule = null, Tuple <decimal, decimal> coords = null)
        {
            if (string.IsNullOrWhiteSpace(name) || region == null)
            {
                throw new ArgumentException("Can't add undefined city or udentified region");
            }
            var city = new City(name, region, rule, coords);

            return(this);
        }
Exemplo n.º 5
0
        public Map AddCity(string name, string regionName, ICityLevelRule rule = null, Tuple <decimal, decimal> coords = null)
        {
            if (string.IsNullOrWhiteSpace(name) || string.IsNullOrWhiteSpace(regionName))
            {
                throw new ArgumentException("Can't add undefined city or udentified region");
            }
            var region = LookupOrCreateRegion(regionName);

            AddCity(name, region, rule, coords);
            return(this);
        }
Exemplo n.º 6
0
        private void BaseConstructor(Region region = null,
                                     ICityLevelRule cityLevelRule = null, Tuple <decimal, decimal> coords = null)
        {
            TmpLevels = new Dictionary <int, int>();
            Coords    = coords;

            //todo: need to remove it (and parameter too) and move to abstract class
            if (region != null)
            {
                region.AddCity(this);
            }
            if (cityLevelRule != null)
            {
                var lvls = cityLevelRule.GetLevels();
                foreach (var lvl in lvls)
                {
                    AddLevel(lvl.Key, lvl.Value);
                }
            }
        }
Exemplo n.º 7
0
        public Region AddCity(string name, ICityLevelRule cityLvlRule = null, Tuple <decimal, decimal> coords = null)
        {
            var city = new City(name, this, cityLvlRule, coords);

            return(this);
        }