Beispiel #1
0
        internal override void Validate()
        {
            base.Validate();

            if ((string.IsNullOrWhiteSpace(Username) || string.IsNullOrWhiteSpace(Password)) && string.IsNullOrWhiteSpace(ApiKey))
            {
                throw new ConfigurationException("Login Credentials or an API Key is required.");
            }

            if ((!string.IsNullOrWhiteSpace(Username) || !string.IsNullOrWhiteSpace(Password)) && !string.IsNullOrWhiteSpace(ApiKey))
            {
                throw new ConfigurationException("Cannot provide both Login Credentials and an API key.");
            }

            if (string.IsNullOrWhiteSpace(ApiKey))
            {
                if (string.IsNullOrEmpty(Username))
                {
                    throw new ConfigurationException("UserName is missing.");
                }

                if (Username.Trim().Length > 50)
                {
                    throw new ConfigurationException("UserName must be 50 characters or less.");
                }

                if (string.IsNullOrEmpty(Password))
                {
                    throw new ConfigurationException("Password is missing.");
                }

                if (Password.Trim().Length > 50)
                {
                    throw new ConfigurationException("Password must be 50 characters or less.");
                }
            }

            if (string.IsNullOrWhiteSpace(MerchantName))
            {
                throw new ConfigurationException("MerchantName is required");
            }

            #region Validate endpoint

            if (ServiceUrl != ServiceEndpoints.BILLPAY_CERTIFICATION &&
                ServiceUrl != ServiceEndpoints.BILLPAY_PRODUCTION &&
                ServiceUrl != ServiceEndpoints.BILLPAY_TEST &&
                !ServiceUrl.Contains("localhost"))
            {
                throw new ConfigurationException("Please use one of the pre-defined BillPay service urls.");
            }

            #endregion
        }
Beispiel #2
0
        protected override void MapUriRequested(HttpMapTileDataSource sender, MapTileUriRequestedEventArgs args)
        {
            var deferral = args.Request.GetDeferral();

            if (!(args.ZoomLevel < 4 && Epsg == 4326))
            {
                var extent      = GetTileExtent(args.X, args.Y, args.ZoomLevel);
                var urlTemplate = string.Concat(ServiceUrl,
                                                ServiceUrl.EndsWith("?")
            ? string.Empty
            : ServiceUrl.EndsWith("&") ? string.Empty : (ServiceUrl.Contains("?") ? "&" : "?"), WmsPostFix);
                var url = string.Format(CultureInfo.InvariantCulture,
                                        urlTemplate, extent.XLow, extent.YLow, extent.XHigh, extent.YHigh, TileSize, Epsg,
                                        string.Join(",", Layers),
                                        Version, ReferenceSystemName, ImageType);

#if DEBUG
                Debug.WriteLine("Tile x={0}, y={1}, zoom={2}", args.X, args.Y, args.ZoomLevel);
                Debug.WriteLine("adding uri {0}", url);
#endif
                args.Request.Uri = new Uri(url);
            }
            deferral.Complete();
        }