private static void InitFileViewRoutes(IRouteTable table)
 {
     table
         .AddFileRoute("/", "Views/index.cshtml")
         .AddFileRoute("/about/me", "Views/about.cshtml", new AboutMeModel { Name = "Val" })
         .AddFileRoute("/a", "Views/with_layout.cshtml");
 }
Beispiel #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="WebSocketServer"/> class.
        /// </summary>
        /// <param name="id">The identifier.</param>
        /// <param name="host">The host.</param>
        /// <param name="port">The port.</param>
        /// <param name="dependencyUtility">The dependency utility.</param>
        /// <param name="listenerThreads">The listener threads.</param>
        /// <param name="clientThreadMultiplier">The client thread multiplier.</param>
        public WebSocketServer(string id, string host, int port, IDependencyUtility dependencyUtility = null, int listenerThreads = 1, int clientThreadMultiplier = 3)
        {
            Id   = id;
            Host = host;
            Port = port;

            _listenerThreads        = listenerThreads;
            _clientThreadMultiplier = clientThreadMultiplier;
            _dependencyUtility      = dependencyUtility ?? new DependencyUtility();

            _logger = _dependencyUtility.Resolve <ILogger>() ??
                      _dependencyUtility.Register <ILogger>(new Logger());

            _securityContainer = _dependencyUtility.Resolve <ISecurityContainer>() ??
                                 _dependencyUtility.Register <ISecurityContainer>(new SecurityContainer(null, SslProtocols.None, false, false, false));

            _clientHandler = _dependencyUtility.Resolve <ITcpHandler>() ??
                             _dependencyUtility.Register <ITcpHandler>(new TcpHandler(IPAddress.Parse(Host), Port));

            _connectionManager = _dependencyUtility.Resolve <IWebSocketConnectionManager>() ??
                                 _dependencyUtility.Register <IWebSocketConnectionManager>(new WebSocketConnectionManager(_dependencyUtility));

            _threadHelper = _dependencyUtility.Resolve <IThreadHelper>() ??
                            _dependencyUtility.Register <IThreadHelper>(new ThreadHelper());

            _routeTable = _dependencyUtility.Resolve <IRouteTable>() ??
                          _dependencyUtility.Register <IRouteTable>(BuildRouteTable());
        }
Beispiel #3
0
 public LiaisonApp(
     IRouteTable routeTable,
     IApplicationBuilder app)
 {
     this.routeTable = routeTable;
     this.app        = app;
 }
Beispiel #4
0
 public MessageRouter(Module app, IRouteTable routeTable)
 {
     this.pubSubService = app.GetInstance <IPublishSubscribeService>();
     this.routeTable    = routeTable;
     pubSubService.Subscribe <RouteEvent>(EndPointStartedEventName, EndPointStarted);
     pubSubService.Subscribe <RouteEvent>(EndPointStoppedEventName, EndPointStopped);
 }
Beispiel #5
0
 private static void InitFileViewRoutes(IRouteTable table)
 {
     table
     .AddFileRoute("/", "Views/Home/Index.cshtml")
     .AddFileRoute("/home/index", "Views/Home/Index.cshtml")
     .AddFileRoute("/home/about", "Views/Home/About.cshtml")
     .AddFileRoute("/home/contact", "Views/Home/Contact.cshtml");
 }
        public override void ExecuteCmdlet()
        {
            var getForSubnetResponse = Client.GetRouteTableForSubnet(VirtualNetworkName, SubnetName);

            IRouteTable routeTable = Client.GetRouteTable(getForSubnetResponse.RouteTableName, Detailed);

            WriteObject(routeTable);
        }
 public DetailController(IServiceProvider serviceProvider) : base(serviceProvider)
 {
     productService  = serviceProvider.GetService <IProductService>();
     categoryService = serviceProvider.GetService <ICategoryService>();
     blogService     = serviceProvider.GetService <IBlogService>();
     routeTable      = serviceProvider.GetService <IRouteTable>();
     cacheService    = serviceProvider.GetService <ICacheService>();
 }
Beispiel #8
0
 public LiaisonRoute(
     IRouteTable routeTable,
     string baseUri,
     IApplicationBuilder app)
 {
     this.routeTable = routeTable;
     this.baseUri    = baseUri;
     this.app        = app;
 }
Beispiel #9
0
        public RouteTable(Arm.RouteTable source, TargetSettings targetSettings) : base(ArmConst.MicrosoftNetwork, ArmConst.RouteTables)
        {
            _SourceRouteTable = source;
            this.SetTargetName(source.Name, targetSettings);

            foreach (Arm.Route route in source.Routes)
            {
                _Routes.Add(new Route(route, targetSettings));
            }
        }
Beispiel #10
0
        public RouteTable(Arm.RouteTable source, TargetSettings targetSettings)
        {
            _SourceRouteTable = source;
            this.SetTargetName(source.Name, targetSettings);

            foreach (Arm.Route route in source.Routes)
            {
                _Routes.Add(new Route(route, targetSettings));
            }
        }
Beispiel #11
0
        public RouteTable(AzureContext azureContext, Arm.RouteTable source)
        {
            _AzureContext     = azureContext;
            _SourceRouteTable = source;
            this.TargetName   = source.Name;

            foreach (Arm.Route route in source.Routes)
            {
                _Routes.Add(new Route(route));
            }
        }
Beispiel #12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="WebSocketConnection" /> class.
        /// </summary>
        /// <param name="client">The client.</param>
        /// <param name="dependencyUtility">The dependency utility.</param>
        public WebSocketConnection(TcpClient client, IDependencyUtility dependencyUtility)
        {
            _client            = client;
            _dependencyUtility = dependencyUtility ?? new DependencyUtility();
            _securityContainer = _dependencyUtility.Resolve <ISecurityContainer>() ?? new SecurityContainer(null, SslProtocols.None, false, false, false);
            _routeTable        = _dependencyUtility.Resolve <IRouteTable>() ?? new RouteTable();
            _threadHelper      = _dependencyUtility.Resolve <IThreadHelper>() ?? new ThreadHelper();
            _logger            = _dependencyUtility.Resolve <ILogger>() ?? new Logger();

            _frameReader = new WebSocketFrameReader(_dependencyUtility);
            _frameWriter = new WebSocketFrameWriter(_dependencyUtility);
        }
Beispiel #13
0
 public HomeController(IServiceProvider serviceProvider) : base(serviceProvider)
 {
     aboutUsObjectService       = serviceProvider.GetService <IAboutUsObjectService>();
     privacyPolicyObjectService = serviceProvider.GetService <IPrivacyPolicyObjectService>();
     blogService        = serviceProvider.GetService <IBlogService>();
     languageService    = serviceProvider.GetService <ILanguageService>();
     dynamicPageService = serviceProvider.GetService <IDynamicPageService>();
     emailService       = serviceProvider.GetService <IEmailService>();
     uI_ContactService  = serviceProvider.GetService <IUI_ContactService>();
     mainPageService    = serviceProvider.GetService <IMainPageService>();
     routeTable         = serviceProvider.GetService <IRouteTable>();
     cacheService       = serviceProvider.GetService <ICacheService>();
 }
 public RazorMiddleware(IRouteTable routeTable, IRazorRenderer razorRenderer)
 {
     if (routeTable == null)
     {
         throw new ArgumentNullException("routeTable");
     }
     if (razorRenderer == null)
     {
         throw new ArgumentNullException("razorRenderer");
     }
     this.routeTable = routeTable;
     this.razorRenderer = razorRenderer;
 }
Beispiel #15
0
        private void RefreshRouteTable()
        {
            var assemblies = AdditionalAssemblies == null ? new[] { AppAssembly } : new[] { AppAssembly }.Concat(AdditionalAssemblies);
            var assembliesSet = new HashSet <Assembly>(assemblies);

            if (!_assemblies.SetEquals(assembliesSet))
            {
                Routes = PreferExactMatches
                    ? RouteTableFactory.Create(assemblies)
                    : LegacyRouteTableFactory.Create(assemblies);
                _assemblies.Clear();
                _assemblies.UnionWith(assembliesSet);
            }
        }
 public SeoController(IServiceProvider serviceProvider) : base(serviceProvider)
 {
     categoryService            = serviceProvider.GetService <ICategoryService>();
     productService             = serviceProvider.GetService <IProductService>();
     dynamicPageService         = serviceProvider.GetService <IDynamicPageService>();
     mainPageService            = serviceProvider.GetService <IMainPageService>();
     aboutUsObjectService       = serviceProvider.GetService <IAboutUsObjectService>();
     uI_ContactService          = serviceProvider.GetService <IUI_ContactService>();
     blogService                = serviceProvider.GetService <IBlogService>();
     privacyPolicyObjectService = serviceProvider.GetService <IPrivacyPolicyObjectService>();
     mL_ProductService          = serviceProvider.GetService <IML_ProductService>();
     webHostEnvironment         = serviceProvider.GetService <IWebHostEnvironment>();
     routeTable = serviceProvider.GetService <IRouteTable>();
 }
Beispiel #17
0
        /// <summary>
        /// Creates new instance with <paramref name="baseUrl"/> and inner <paramref name="routeTable"/>.
        /// </summary>
        /// <param name="baseUrl">Base URL prepended to relative URLs.</param>
        /// <param name="routeTable">Inner route table.</param>
        public RelativeRouteTable(string baseUrl, IRouteTable routeTable)
        {
            Ensure.NotNullOrEmpty(baseUrl, "baseUrl");
            Ensure.NotNull(routeTable, "routeTable");

            Uri url;

            if (!Uri.TryCreate(baseUrl, UriKind.Absolute, out url))
            {
                throw Ensure.Exception.ArgumentOutOfRange("baseUrl", "Base URL must be valid and absolute URL.");
            }

            this.baseUrl    = baseUrl;
            this.routeTable = routeTable;
        }
Beispiel #18
0
        public void Setup()
        {
            var routeDictionary = new Dictionary <string, int>();

            routeDictionary.Add("AB", 5);
            routeDictionary.Add("BC", 4);
            routeDictionary.Add("CD", 8);
            routeDictionary.Add("DC", 8);
            routeDictionary.Add("DE", 6);
            routeDictionary.Add("AD", 5);
            routeDictionary.Add("CE", 2);
            routeDictionary.Add("EB", 3);
            routeDictionary.Add("AE", 7);

            _routeTable = new RouteTable(routeDictionary);
        }
Beispiel #19
0
        internal void Print(IRouteTable resource)
        {
            var info = new StringBuilder();

            info.Append("Route Table: ").Append(resource.Id)
            .Append("Name: ").Append(resource.Name)
            .Append("\n\tResource group: ").Append(resource.ResourceGroupName)
            .Append("\n\tRegion: ").Append(resource.Region)
            .Append("\n\tTags: ").Append(resource.Tags);

            // Output routes
            foreach (var route in resource.Routes.Values)
            {
                info.Append("\n\tRoute: ").Append(route.Name)
                .Append("\n\t\tDestination address prefix: ").Append(route.DestinationAddressPrefix)
                .Append("\n\t\tNext hop IP address: ").Append(route.NextHopIPAddress)
                .Append("\n\t\tNext hop type: ").Append(route.NextHopType);
            }

            TestHelper.WriteLine(info.ToString());
        }
Beispiel #20
0
 /// <summary>
 /// Initialize the Razor files
 /// </summary>
 /// <param name="table"></param>
 public static void InitRoutes(IRouteTable table)
 {
     table
     .AddFileRoute("/about/me", "Views/about.cshtml", new { Name = "EmbedIO Razor", Date = DateTime.UtcNow });
 }
Beispiel #21
0
 /// <summary>
 /// Creates new instance with absolute URLs defined in <paramref name="routeTable"/>.
 /// </summary>
 /// <param name="routeTable">Route table with absolute URLs.</param>
 public HttpCommandDispatcher(IRouteTable routeTable)
 {
     Ensure.NotNull(routeTable, "routeTable");
     this.routeTable  = routeTable;
     this.httpAdapter = new HttpClientAdapter(routeTable);
 }
Beispiel #22
0
 public MvcServer(Assembly registeringAssembly)
 {
     this.RouteTable = new DefaultRouteTable();
     this.RouteTable.LoadAttributeRoutes(registeringAssembly);
 }
 public RouteFromExpression(IRouteTable routes, VirtualPath path)
 {
     _routes = routes;
     _path = path;
 }
Beispiel #24
0
 private static void InitEmbeddedViewRoutes(IRouteTable table)
 {
     table.AddFileRoute("/embedded", "/Mezm.Owin.Razor.Example.EmbeddedViews.index.cshtml");
 }
 private void WriteRouteTable(IRouteTable networkSecurityGroup)
 {
     WriteObject(networkSecurityGroup, true);
 }
Beispiel #26
0
        public MultiTenantRouteContext(string path, IRouteTable routeTable, ILoggerFactory loggerFactory)
        {
            _logger = loggerFactory.CreateLogger <MultiTenantRouteContext>();

            // This is a simplification. We are assuming there are no paths like /a//b/. A proper routing
            // implementation would be more sophisticated.
            var segments = path.Trim('/').Split(Separator, StringSplitOptions.RemoveEmptyEntries);

            // Individual segments are URL-decoded in order to support arbitrary characters, assuming UTF-8 encoding.
            // MultiTenant is in first path
            if (segments.Length != 0)
            {
                var tenantIdentifier = segments[0];
                if (routeTable.MatchesRoute(tenantIdentifier))
                {
                    _logger.LogWarning($"Tenant Name matches part of a route.  This is not allowed ({tenantIdentifier})");
                    if (Services == null)
                    {
                        throw new ArgumentNullException("Services not setup");
                    }
                    Services.GetRequiredService <Tenant>().Identifier = null;
                    Services.GetRequiredService <Tenant>().Parameters = new Dictionary <string, string>();
                    throw new TenantException("Invalid tenant name (part of another path)");
                }
                else
                {
                    var tenant = ValidTenant(tenantIdentifier);
                    if (tenant == null)
                    {
                        _logger.LogWarning($"Tenant not found in store ({tenantIdentifier})");
                        if (Services == null)
                        {
                            throw new ArgumentNullException("Services not setup");
                        }
                        Services.GetRequiredService <Tenant>().Identifier = null;
                        Services.GetRequiredService <Tenant>().Parameters = new Dictionary <string, string>();
                        throw new TenantException("Tenant not in store");
                    }
                    else
                    {
                        _logger.LogDebug($"Tenant found");
                        Segments = new string[segments.Length - 1];
                        if (Services == null)
                        {
                            throw new ArgumentNullException("Services not setup");
                        }
                        Services.GetRequiredService <Tenant>().Identifier = tenantIdentifier;
                        Services.GetRequiredService <Tenant>().Parameters = tenant.Parameters;
                        // Change config
                        for (int i = 1; i < segments.Length; i++)
                        {
                            Segments[i - 1] = Uri.UnescapeDataString(segments[i]);
                        }
                    }
                }
            }
            else
            {
                _logger.LogInformation("No tenant was specified");
                if (Services == null)
                {
                    throw new ArgumentNullException("Services not setup");
                }
                Services.GetRequiredService <Tenant>().Identifier = null;
                Services.GetRequiredService <Tenant>().Parameters = new Dictionary <string, string>();
                throw new TenantException("No tenant specified");
            }
        }
Beispiel #27
0
 public BlogDetailConstraint(IRouteTable routeTable)
 {
     this.routeTable = routeTable;
 }
 /// <summary>
 /// Specifies an existing route table to associate with the subnet.
 /// </summary>
 /// <param name="routeTable">An existing route table to associate.</param>
 /// <return>The next stage of the update.</return>
 Subnet.Update.IUpdate Subnet.Update.IWithRouteTable.WithExistingRouteTable(IRouteTable routeTable)
 {
     return(this.WithExistingRouteTable(routeTable));
 }
 /// <summary>
 /// Specifies an existing route table to associate with the subnet.
 /// </summary>
 /// <param name="routeTable">An existing route table to associate.</param>
 /// <return>The next stage of the definition.</return>
 Subnet.Definition.IWithAttach <Network.Definition.IWithCreateAndSubnet> Subnet.Definition.IWithRouteTable <Network.Definition.IWithCreateAndSubnet> .WithExistingRouteTable(IRouteTable routeTable)
 {
     return(this.WithExistingRouteTable(routeTable));
 }
 /// <summary>
 /// Specifies an existing route table to associate with the subnet.
 /// </summary>
 /// <param name="routeTable">An existing route table to associate.</param>
 /// <return>The next stage of the definition.</return>
 Subnet.UpdateDefinition.IWithAttach <Network.Update.IUpdate> Subnet.UpdateDefinition.IWithRouteTable <Network.Update.IUpdate> .WithExistingRouteTable(IRouteTable routeTable)
 {
     return(this.WithExistingRouteTable(routeTable));
 }
 private void WriteRouteTable(IRouteTable networkSecurityGroup)
 {
     WriteObject(networkSecurityGroup, true);
 }
Beispiel #32
0
 public RouteTable(IRouteTable source, TargetSettings targetSettings)
 {
     _SourceRouteTable = source;
     this.SetTargetName(source.Name, targetSettings);
 }
Beispiel #33
0
 public RouteTable(IRouteTable source, TargetSettings targetSettings) : base(ArmConst.MicrosoftNetwork, ArmConst.RouteTables)
 {
     _SourceRouteTable = source;
     this.SetTargetName(source.Name, targetSettings);
 }
Beispiel #34
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DefaultModulesRegistration" /> class.
        /// </summary>
        /// <param name="assemblyLoader">The assembly loader.</param>
        /// <param name="cmsConfiguration">The CMS configuration.</param>
        /// <param name="controllerExtensions">The controller extensions.</param>
        /// <param name="routeTable">The route table.</param>
        public DefaultModulesRegistration(IAssemblyLoader assemblyLoader, ICmsConfiguration cmsConfiguration, IControllerExtensions controllerExtensions, IRouteTable routeTable)
        {
            this.assemblyLoader       = assemblyLoader;
            this.cmsConfiguration     = cmsConfiguration;
            this.controllerExtensions = controllerExtensions;

            knownModuleDescriptorTypes = new Dictionary <string, Type>();
            knownModules                 = new Dictionary <string, ModuleRegistrationContext>();
            knownJavaScriptModules       = new Dictionary <string, JsIncludeDescriptor>();
            knownSidebarHeadContentItems = new List <IPageActionProjection>();
            knownSidebarContentItems     = new List <IPageActionProjection>();
            knownSidebarBodyContentItems = new List <IPageActionProjection>();
            knownSiteSettingsItems       = new List <IPageActionProjection>();
            knownStyleSheetIncludes      = new List <CssIncludeDescriptor>();
        }
        private void GetByName()
        {
            IRouteTable routeTable = Client.GetRouteTable(Name, this.Detailed);

            WriteRouteTable(routeTable);
        }