Esempio n. 1
0
        /// <summary>
        /// Initializes a new instance of the FeatureLayer class.
        /// </summary>
        /// <param name="featureLayerUri">The URL of the feature layer.</param>
        /// <param name="layerDescription">The reference to the layer description object.</param>
        /// <param name="requestSender">The reference to the request sender object.</param>
        /// <exception cref="System.ArgumentNullException"><paramref name="featureLayerUri"/>,
        /// <paramref name="layerDescription"/> or <paramref name="requestSender"/> argument is
        /// a null reference.</exception>
        public FeatureLayer(
            Uri featureLayerUri,
            LayerDescription layerDescription,
            IFeatureServiceRequestSender requestSender)
        {
            if (featureLayerUri == null)
            {
                throw new ArgumentNullException("featureLayerUri");
            }

            if (layerDescription == null)
            {
                throw new ArgumentNullException("layerDescription");
            }

            if (requestSender == null)
            {
                throw new ArgumentNullException("requestSender");
            }

            var serializer = new JsonSerializer(VrpRequestBuilder.JsonTypes, true);

            _mapper           = new FeatureRecordMapper <TFeatureRecord>(layerDescription, serializer);
            _requestSender    = requestSender;
            _uri              = featureLayerUri;
            _layerDescription = layerDescription;
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes a new instance of the FeatureService class.
        /// </summary>
        /// <param name="serviceUrl">The URL of the feature service.</param>
        /// <param name="serviceInfo">The reference to the service info object.</param>
        /// <param name="requestSender">The reference to the request sender object.</param>
        /// <exception cref="System.ArgumentNullException"><paramref name="serviceUrl"/>,
        /// <paramref name="serviceInfo"/> or <paramref name="requestSender"/> argument is
        /// a null reference.</exception>
        public FeatureService(
            Uri serviceUrl,
            ServiceInfo serviceInfo,
            IFeatureServiceRequestSender requestSender)
        {
            if (serviceUrl == null)
            {
                throw new ArgumentNullException("serviceUrl");
            }

            if (serviceInfo == null)
            {
                throw new ArgumentNullException("serviceInfo");
            }

            if (requestSender == null)
            {
                throw new ArgumentNullException("requestSender");
            }

            _requestSender     = requestSender;
            _serviceInfo       = serviceInfo;
            _serviceUrl        = serviceUrl;
            _layerDescriptions = serviceInfo.AllLayers
                                 .ToLookup(
                info => info.Name,
                info => new LayerInfo
            {
                ID  = info.ID,
                Url = new Uri(string.Format(
                                  TABLE_QUERY_FORMAT,
                                  _serviceUrl.AbsoluteUri,
                                  info.ID)),
            })
                                 .ToDictionary(item => item.Key, item => item.First());

            this.Layers = serviceInfo.AllLayers.ToList();
        }