Пример #1
0
        /// <summary>
        /// Adds the given set of layers to the map,
        /// ordering each one in turn under all other layers.
        /// </summary>
        /// <param name="layers">The set of layers to add.</param>
        public void AddLayers(IEnumerable <ILayer> layers)
        {
            if (layers == null)
            {
                throw new ArgumentNullException("layers");
            }

            List <String> layerNames = new List <String>(16);

            foreach (ILayer layer in layers)
            {
                if (layer == null)
                {
                    throw new ArgumentException("One of the layers is null.");
                }
                checkForDuplicateLayerName(layer);
                layerNames.Add(layer.LayerName);
            }

            for (Int32 i = 0; i < layerNames.Count; i++)
            {
                for (Int32 j = i + 1; j < layerNames.Count; j++)
                {
                    if (String.Compare(layerNames[i], layerNames[j], StringComparison.CurrentCultureIgnoreCase) == 0)
                    {
                        throw new ArgumentException("Layers to be added contain a duplicate name: " + layerNames[i]);
                    }
                }
            }

            lock (Layers.LayersChangeSync)
            {
                _layers.AddRange(layers);
            }
        }