static string CheckAndCreateRouteString(string routePrefix)
        {
            // aspnet routing integration is supported only under aspnet compat mode
            ServiceHostingEnvironment.EnsureInitialized();
            if (!ServiceHostingEnvironment.AspNetCompatibilityEnabled)
            {
                throw FxTrace.Exception.AsError(new InvalidOperationException(SR.Hosting_RouteServiceRequiresCompatibilityMode));
            }
            // we support emptystring as routeprfix as aspnet allows it
            if (routePrefix == null)
            {
                throw FxTrace.Exception.ArgumentNull("routePrefix");
            }
            else if (routePrefix.Contains(LeftCurlyBracket) || routePrefix.Contains(RightCurlyBracket))
            {
                throw FxTrace.Exception.Argument("routePrefix", SR.Hosting_CurlyBracketFoundInRoutePrefix("{", "}"));
            }

            if (routePrefix.EndsWith(PathSeperator.ToString(), StringComparison.CurrentCultureIgnoreCase) ||
                routePrefix.Equals(String.Empty, StringComparison.CurrentCultureIgnoreCase))
            {
                routePrefix = string.Format(CultureInfo.CurrentCulture, "{0}{1}", routePrefix, UnmatchedPathSegment);
            }
            else
            {
                routePrefix = string.Format(CultureInfo.CurrentCulture, "{0}/{1}", routePrefix, UnmatchedPathSegment);
            }
            return(routePrefix);
        }
Exemple #2
0
        private static string CheckAndCreateRouteString(string routePrefix)
        {
            ServiceHostingEnvironment.EnsureInitialized();
            if (!ServiceHostingEnvironment.AspNetCompatibilityEnabled)
            {
                throw FxTrace.Exception.AsError(new InvalidOperationException(System.ServiceModel.Activation.SR.Hosting_RouteServiceRequiresCompatibilityMode));
            }
            if (routePrefix == null)
            {
                throw FxTrace.Exception.ArgumentNull("routePrefix");
            }
            if (routePrefix.Contains("{") || routePrefix.Contains("}"))
            {
                throw FxTrace.Exception.Argument("routePrefix", System.ServiceModel.Activation.SR.Hosting_CurlyBracketFoundInRoutePrefix("{", "}"));
            }
            char ch = '/';

            if (routePrefix.EndsWith(ch.ToString(), StringComparison.CurrentCultureIgnoreCase) || routePrefix.Equals(string.Empty, StringComparison.CurrentCultureIgnoreCase))
            {
                routePrefix = string.Format(CultureInfo.CurrentCulture, "{0}{1}", new object[] { routePrefix, "{*pathInfo}" });
                return(routePrefix);
            }
            routePrefix = string.Format(CultureInfo.CurrentCulture, "{0}/{1}", new object[] { routePrefix, "{*pathInfo}" });
            return(routePrefix);
        }
Exemple #3
0
        public static void TestFixtureSetup(TestContext context)
        {
            if (!HostingEnvironment.IsHosted)
            {
                // The instance constructor hooks up the singleton hosting environment, ewww...
                new HostingEnvironment();

                // Check the hosting environment is fully initialized
                ServiceHostingEnvironment.EnsureInitialized();
            }
        }
Exemple #4
0
            public void SetUp()
            {
                if (HostingEnvironment.IsHosted)
                {
                    return;
                }

                new HostingEnvironment();


                ServiceHostingEnvironment.EnsureInitialized();
            }