示例#1
0
        /// <summary>
        /// Gets the base uri from the configuration file.
        /// </summary>
        /// <returns>Base uri for the service.</returns>
        internal static string GetBaseUri()
        {
            string baseAddress = ConfigurationManager.AppSettings["AtomPubBaseUri"];

            // If base uri does not contain "/" at the end, then add it.
            if (!baseAddress.EndsWith("/", StringComparison.OrdinalIgnoreCase))
            {
                baseAddress += "/";
            }
            return(PlatformConstants.GetServiceHostName() + baseAddress.ToLowerInvariant());
        }
示例#2
0
        /// <summary>
        /// Returns the type of the service e.g. AtomPub, Sword or ORE.
        /// </summary>
        /// <param name="contextUrl">The context URL.</param>
        /// <returns>The service type.</returns>
        private static string GetServiceType(Uri contextUrl)
        {
            const string ServiceType    = "serviceType";
            const string SubServiceType = "subServiceType";
            Uri          baseUri        = new Uri(PlatformConstants.GetServiceHostName());

            UriTemplate doubleArgTemplate = new UriTemplate(string.Format(CultureInfo.InvariantCulture,
                                                                          DoubleArgsURI, ServiceType, SubServiceType));

            UriTemplateMatch doubleArgMatches = doubleArgTemplate.Match(baseUri, contextUrl);

            if (doubleArgMatches != null) // Url matches with double template
            {
                string requestedService    = doubleArgMatches.BoundVariables[ServiceType].ToUpperInvariant();
                string subRequestedService = doubleArgMatches.BoundVariables[SubServiceType].ToUpperInvariant();

                if ((Sword == subRequestedService && AtomPub == requestedService) || //is this required?
                    Ore == subRequestedService)
                {
                    return(subRequestedService);
                }
                else
                {
                    return(doubleArgMatches.BoundVariables[ServiceType].ToUpperInvariant());
                }
            }
            else // If Url doesn't match with double template, check for single template.
            {
                UriTemplate singleArgTemplate = new UriTemplate(string.Format(CultureInfo.InvariantCulture,
                                                                              SingleArgURI, ServiceType));
                UriTemplateMatch singleArgMatch = singleArgTemplate.Match(baseUri, contextUrl);
                //Single argument match for ATOM PUB
                if (null != singleArgMatch)
                {
                    return(singleArgMatch.BoundVariables[ServiceType].ToUpperInvariant());
                }
            }

            return(null);
        }
示例#3
0
        /// <summary>
        /// Gets the base uri from the configuration file.
        /// </summary>
        /// <returns>Base uri for the service.</returns>
        internal static Uri GetBaseUri()
        {
            string baseAddress = ConfigurationManager.AppSettings["SyndicationBaseUri"];

            return(new Uri(PlatformConstants.GetServiceHostName() + baseAddress));
        }