Inheritance: System.Web.UI.Page
Exemplo n.º 1
0
        internal override void OnPreRenderComplete(Hosting.IDotvvmRequestContext context)
        {
            var dep = Dependencies?.Split(',') ?? new string[] { ResourceConstants.DotvvmResourceName };
            context.ResourceManager.AddStartupScript("inlinescript_" + (ClientID ?? (string)GetDotvvmUniqueId()), Script, dep);

            base.OnPreRenderComplete(context);
        }
        protected override Task OnReceivedAsync(Hosting.IRequest request, string connectionId, string data)
        {
            Connection.Send(connectionId, "OnReceivedAsync1");
            Connection.Send(connectionId, "OnReceivedAsync2");

            return base.OnReceivedAsync(request, connectionId, data);
        }
Exemplo n.º 3
0
        protected override Task OnConnectedAsync(Hosting.IRequest request, string connectionId)
        {
            Send("OnConnectedAsync1");
            Send("OnConnectedAsync2");

            return base.OnConnectedAsync(request, connectionId);
        }
Exemplo n.º 4
0
        public RootActor(Hosting.Engine _engine)
        {
            engine = _engine;
            actorName = "Root";

            if (instance == null)
            {
                instance = this;
            }
        }
Exemplo n.º 5
0
        public void HandleNewProxy_NotMyNamespace_should_filter_proxy()
        {
            var vcall = new Mock<IVcallSubsystem>();
            var peer = new Mock<ICommPeer>();

            var hosting = new Hosting(peer.Object, vcall.Object, new HostingConfiguration {NameSpace = "Vcall.Testing"});
            hosting.HandleNewProxy(new ProxyInfo {NameSpace = "Other.Testing"});

            var counters = _countersDb.SumAll();
            Assert.That(counters.Hosting_Event_NotMyNamespace, Is.EqualTo(1));
        }
Exemplo n.º 6
0
        public MyAppUsingUriLookups()
        {
            Hosting.ConfigureAppConfiguration((context, config) =>
            {
                config.AddInMemoryCollection(new Dictionary <string, string> {
                    { "incoming", "tcp://server3:2000" }
                });
            });


            // This usage assumes that there is a value in the configuration
            // with the key "incoming" that corresponds to a Uri
            Transports.ListenForMessagesFrom("config://incoming");
        }
Exemplo n.º 7
0
        public RabbitReceiver()
        {
            Handlers.DisableConventionalDiscovery().IncludeType <RabbitedMessageReceiver>();

            Hosting.ConfigureLogging(x =>
            {
                x.AddConsole();
                x.AddDebug();
            });

            Transports.ListenForMessagesFrom("rabbitmq://localhost:5672/numbers");

            Settings.PersistMessagesWithSqlServer(Servers.SqlServerConnectionString, "rabbit_receiver");
        }
Exemplo n.º 8
0
        async Task StartProtocolHead()
        {
            string certificateValue = await SecretsHelper.GetSecret("IotHubMqttHeadCert");

            byte[] cert        = Convert.FromBase64String(certificateValue);
            var    certificate = new X509Certificate2(cert);

            // TODO for now this is empty as will suffice for SAS X.509 thumbprint auth but we will need other CA certs for X.509 CA validation
            var trustBundle = new List <X509Certificate2>();

            string edgeDeviceConnectionString = await SecretsHelper.GetSecretFromConfigKey("edgeCapableDeviceConnStrKey");

            // TODO - After IoTHub supports MQTT, remove this and move to using MQTT for upstream connections
            await ConnectToIotHub(edgeDeviceConnectionString);

            ConfigHelper.TestConfig[EdgeHubConstants.ConfigKey.IotHubConnectionString] = edgeDeviceConnectionString;

            IDependencyManager dependencyManager = new DependencyManager(ConfigHelper.TestConfig, certificate, trustBundle, this.sslProtocols);
            Hosting            hosting           = Hosting.Initialize(ConfigHelper.TestConfig, certificate, dependencyManager, true, this.sslProtocols);

            this.hosting = hosting;
            IContainer container = hosting.Container;

            // CloudConnectionProvider and RoutingEdgeHub have a circular dependency. So set the
            // EdgeHub on the CloudConnectionProvider before any other operation
            ICloudConnectionProvider cloudConnectionProvider = await container.Resolve <Task <ICloudConnectionProvider> >();

            IEdgeHub edgeHub = await container.Resolve <Task <IEdgeHub> >();

            cloudConnectionProvider.BindEdgeHub(edgeHub);

            IConfigSource configSource = await container.Resolve <Task <IConfigSource> >();

            ConfigUpdater configUpdater = await container.Resolve <Task <ConfigUpdater> >();

            await configUpdater.Init(configSource);

            ILogger          logger           = container.Resolve <ILoggerFactory>().CreateLogger("EdgeHub");
            MqttProtocolHead mqttProtocolHead = await container.Resolve <Task <MqttProtocolHead> >();

            AmqpProtocolHead amqpProtocolHead = await container.Resolve <Task <AmqpProtocolHead> >();

            var httpProtocolHead = new HttpProtocolHead(hosting.WebHost);

            this.protocolHead = new EdgeHubProtocolHead(new List <IProtocolHead> {
                mqttProtocolHead, amqpProtocolHead, httpProtocolHead
            }, logger);
            await this.protocolHead.StartAsync();
        }
Exemplo n.º 9
0
        public AppUsingMessageTracking()
        {
            // TODO -- need to change this when GH-346 is done
            Hosting.ConfigureAppConfiguration((context, config) =>
            {
                var environment = context.HostingEnvironment.EnvironmentName;

                if (environment == "Development" || environment == "Testing")
                {
                    // Don't use this in production because it'd
                    // cause a memory leak issue
                    Include <MessageTrackingExtension>();
                }
            });
        }
Exemplo n.º 10
0
            public UsingConfigApp()
            {
                // Ignore this please;)
                Handlers.DisableConventionalDiscovery();


                Hosting.ConfigureAppConfiguration((_, config) =>
                {
                    config.AddInMemoryCollection(new Dictionary <string, string> {
                        { "AppName", "WocketInMyPocket" }
                    });
                });


                Settings.Alter <JasperOptions>((c, options) => options.ServiceName = c.Configuration["AppName"]);
            }
Exemplo n.º 11
0
        public RabbitSender()
        {
            Handlers.DisableConventionalDiscovery();

            Hosting.ConfigureLogging(x =>
            {
                x.AddConsole();
                x.AddDebug();
            });

            Publish.AllMessagesTo("rabbitmq://localhost:5672/numbers");

            Settings.PersistMessagesWithSqlServer(Servers.SqlServerConnectionString, "rabbit_sender");

            Services.AddSingleton <IHostedService, TimedSender>();
        }
Exemplo n.º 12
0
        void ReceiveHostTarget(IrcMessage message)
        {
            HostInformation hostinformation = CreateHostInformation(message);

            if (hostinformation.Channel != "-")
            {
                if (hostinformation.Host == name)
                {
                    Hosting?.Invoke(hostinformation);
                }
                else
                {
                    Host?.Invoke(hostinformation);
                }
            }
        }
        private void HandleLanguage(FileUploader fileUploader)
        {
            var context          = Hosting.GetHttpContext();
            var selectedLanguage = context.Request["languageSelector"];

            if (selectedLanguage != null)
            {
                fileUploader.DisplayLanguage = selectedLanguage;
            }
            else
            {
                selectedLanguage = fileUploader.DisplayLanguage;
            }

            PopulateLanguageSelector(selectedLanguage);
        }
Exemplo n.º 14
0
        protected void Application_Start(object sender, EventArgs e)
        {
            var gleamTechConfig = Hosting.ResolvePhysicalPath("~/App_Data/GleamTech.config");

            if (File.Exists(gleamTechConfig))
            {
                GleamTechConfiguration.Current.Load(gleamTechConfig);
            }

            var documentUltimateConfig = Hosting.ResolvePhysicalPath("~/App_Data/DocumentUltimate.config");

            if (File.Exists(documentUltimateConfig))
            {
                DocumentUltimateConfiguration.Current.Load(documentUltimateConfig);
            }
        }
Exemplo n.º 15
0
        protected internal override void OnInit(Hosting.IDotvvmRequestContext context)
        {
            GetRoot().SetValue(Internal.IsSpaPageProperty, true);

            Attributes["name"] = HostingConstants.SpaContentPlaceHolderID;
            Attributes[HostingConstants.SpaContentPlaceHolderDataAttributeName] = GetSpaContentPlaceHolderUniqueId();

            var correctSpaUrlPrefix = GetCorrectSpaUrlPrefix(context);
            if (correctSpaUrlPrefix != null)
            {
                Attributes[HostingConstants.SpaUrlPrefixAttributeName] = correctSpaUrlPrefix;
            }

            AddDotvvmUniqueIdAttribute();

            base.OnInit(context);
        }
Exemplo n.º 16
0
 public async Task Download(string from, string to = null)
 {
     to = to ?? from;
     Console.WriteLine($"download '{from}' -> '{to}'");
     if (await Hosting.IsFileAsync(from))
     {
         await Hosting.DownloadFileAsync(from, new FileInfo(to), new ConsoleProgressProvider());
     }
     else if (await Hosting.IsDirectoryAsync(from))
     {
         await Hosting.DownloadDirectoryAsync(from, new DirectoryInfo(to), failures, successes);
     }
     else
     {
         throw new ItemNotFound();
     }
 }
Exemplo n.º 17
0
        public RabbitMqUsingApp()
        {
            Hosting.ConfigureLogging(x =>
            {
                x.AddConsole();
                x.AddDebug();
            });

            Transports.ListenForMessagesFrom("rabbitmq://localhost:5672/messages3");

            Services.AddSingleton <ColorHistory>();
            Services.AddSingleton <MessageTracker>();

            Publish.AllMessagesTo("rabbitmq://localhost:5672/messages3");

            Include <MessageTrackingExtension>();
        }
Exemplo n.º 18
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var videoPath         = exampleFileSelector.SelectedFile;
            var fileInfo          = new FileInfo(videoPath);
            var thumbnailCacheKey = new FileCacheKey(new FileCacheSourceKey(fileInfo.Name, fileInfo.Length, fileInfo.LastWriteTimeUtc), "jpg");
            var cacheItem         = ThumbnailCache.GetOrAdd(
                thumbnailCacheKey,
                thumbnailStream => GetAndSaveThumbnail(videoPath, thumbnailStream)
                );

            ThumbnailUrl = ExamplesConfiguration.GetDownloadUrl(
                Hosting.ResolvePhysicalPath(ThumbnailCachePath.Append(cacheItem.RelativeName)),
                thumbnailCacheKey.FullValue
                );

            VideoInfo = GetVideoInfo(videoPath);
        }
        public IActionResult Dynamic()
        {
            var fileManager = new FileManager
            {
                Width     = 800,
                Height    = 600,
                Resizable = true
            };

            var context      = Hosting.GetHttpContext();
            var selectedUser = context.Request["userSelector"] ?? "User1";

            SetDynamicFolderAndPermissions(fileManager, selectedUser);

            PopulateUserSelector(selectedUser);

            return(View(fileManager));
        }
Exemplo n.º 20
0
        public void HandleNewProxy()
        {
            var vcall = VcallSubsystem.New();
            var config = new HostingConfiguration();

            var peer = new HostingPeer(config, vcall);

            var info = new ProxyInfo
            {
                Tag = Guid.NewGuid().ToString(),
                ListeningUri = "/tests",
                NameSpace = "Vcall.Testing",
                HostName = "localhost"
            };

            var hosting = new Hosting(peer, vcall, config);
            hosting.HandleNewProxy(info);
        }
Exemplo n.º 21
0
        public async Task ShouldGetHostingById()
        {
            var originalHosting = new Hosting
            {
                PublicCloud = new PublicCloud
                {
                    Summary      = "Some Summary",
                    Link         = "www.somelink.com",
                    RequiresHSCN = "This Solution requires a HSCN/N3 connection"
                },
                PrivateCloud = new PrivateCloud
                {
                    Summary      = "Private Summary",
                    Link         = "www.privatelink.com",
                    HostingModel = "Hosting Model",
                    RequiresHSCN = "How much wood would a woodchuck chuck if a woodchuck could chuck wood?"
                },
                HybridHostingType = new HybridHostingType
                {
                    Summary      = "Private Summary",
                    Link         = "www.privatelink.com",
                    HostingModel = "Hosting Model",
                    RequiresHSCN = "This Solution requires a HSCN/N3 connection"
                },
                OnPremise = new OnPremise
                {
                    Summary      = "Private Summary",
                    Link         = "www.privatelink.com",
                    HostingModel = "Hosting Model",
                    RequiresHSCN = "This Solution requires a HSCN/N3 connection"
                }
            };

            _hostingResult = Mock.Of <IHostingResult>(r =>
                                                      r.Id == _solutionId &&
                                                      r.Hosting == JsonConvert.SerializeObject(originalHosting)
                                                      );

            var newHosting = await _context.GetHostingBySolutionIdHandler.Handle(
                new GetHostingBySolutionIdQuery(_solutionId), _cancellationToken).ConfigureAwait(false);

            newHosting.Should().BeEquivalentTo(originalHosting);
        }
Exemplo n.º 22
0
        public SampleApp()
        {
            // SAMPLE: alter-settings
            Settings.Alter <MyFakeSettings>(_ => { _.SomeSetting = 5; });

            // or additionally use IConfiguration
            Settings.Alter <MyFakeSettings>((context, settings) =>
            {
                settings.SomeSetting = int.Parse(context.Configuration["SomeKey"]);
            });


            // ENDSAMPLE

            // SAMPLE: replace-settings
            Settings.Replace(new MyFakeSettings
            {
                SomeSetting  = 3,
                OtherSetting = "blue"
            });
            // ENDSAMPLE

            // SAMPLE: build-configuration
            Hosting.ConfigureAppConfiguration((context, config) =>
            {
                config.SetBasePath(context.HostingEnvironment.WebRootPath)
                .AddJsonFile("myconfig.json")
                .AddJsonFile("myotherconfig.json.config")
                .AddEnvironmentVariables();
            });



            // ENDSAMPLE

            // SAMPLE: configure-settings
            Settings.Require <Colors>();
            // ENDSAMPLE

            // SAMPLE: configure-settings2
            Settings.Configure <MySettings>(_ => _.GetSection("subsection"));
            // ENDSAMPLE
        }
Exemplo n.º 23
0
        public AppUsingHttpTransport()
        {
            // While *sending* by the HTTP transport is enabled by default,
            // you have to explicitly enable the HTTP transport listening
            Transports.Http.EnableListening(true)

            // The default is 10 seconds
            .ConnectionTimeout(2.Seconds())

            // Override the releative Url of the message
            // listening routes. The default is _messages
            .RelativeUrl("_jasper");

            // You'll have to have Kestrel or some other
            // web server for this to function
            Hosting
            .UseUrls("http://*:5000")
            .UseKestrel();
        }
Exemplo n.º 24
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            RouteConfig.RegisterRoutes(RouteTable.Routes);

            var gleamTechConfig = Hosting.ResolvePhysicalPath("~/App_Data/GleamTech.config");

            if (File.Exists(gleamTechConfig))
            {
                GleamTechConfiguration.Current.Load(gleamTechConfig);
            }

            var fileUltimateConfig = Hosting.ResolvePhysicalPath("~/App_Data/FileUltimate.config");

            if (File.Exists(fileUltimateConfig))
            {
                FileUltimateConfiguration.Current.Load(fileUltimateConfig);
            }
        }
Exemplo n.º 25
0
        public async Task Info(string path)
        {
            var o    = Console.ForegroundColor;
            var r    = ConsoleColor.Red;
            var g    = ConsoleColor.Green;
            var b    = ConsoleColor.Cyan;
            var info = await Hosting.GetItemInfoAsync(path);

            ColoredConsole.WriteLine(b, info.IsDirectory ? "DIRECTORY" : "FILE");
            ColoredConsole.WriteLine("Name:\t", b, info.Name);
            ColoredConsole.WriteLine("Size:\t", b, info.Size);
            ColoredConsole.WriteLine("  bytes:", b, info.Size.TotalBytes, " B");
            ColoredConsole.WriteLine("LW time:", b, info.LastWriteTime);
            ColoredConsole.WriteLine("On hostings: ");
            foreach (var hosting in info.Hostings)
            {
                ColoredConsole.WriteLine("\t", b, hosting.Name);
            }
        }
Exemplo n.º 26
0
        public AppWithMiddleware()
        {
            Hosting.Configure(app =>
            {
                app.UseMiddleware <CustomMiddleware>();

                app.UseJasper();

                // Just to show how you can configure ASP.Net Core
                // middleware that runs after Jasper's RequestDelegate,
                // but do note that Jasper has its own default "not found"
                // behavior
                app.Run(c =>
                {
                    c.Response.StatusCode = 404;

                    return(c.Response.WriteAsync("Not found"));
                });
            });
        }
Exemplo n.º 27
0
        public UsingEnvironmentName()
        {
            // Idiomatic Jasper way
            Settings.Configure(context =>
            {
                if (context.HostingEnvironment.IsDevelopment())
                {
                    Services.AddSingleton <IThirdPartyService, StubThirdPartyService>();
                }
            });

            // ASP.Net Core idiomatic way
            Hosting.ConfigureServices((context, services) =>
            {
                if (context.HostingEnvironment.IsDevelopment())
                {
                    services.AddSingleton <IThirdPartyService, StubThirdPartyService>();
                }
            });
        }
Exemplo n.º 28
0
        public async Task Info()
        {
            var o     = Console.ForegroundColor;
            var r     = ConsoleColor.Red;
            var g     = ConsoleColor.Green;
            var b     = ConsoleColor.Cyan;
            var sizes = await Hosting.GetSpaceInfoAsync();

            var total       = sizes.TotalSpace.TotalBytes;
            var usedPercent = total == 0 ? 0 : 100 * sizes.UsedSpace.TotalBytes / total;
            var freePercent = total == 0 ? 0 : 100 * sizes.FreeSpace.TotalBytes / total;

            ColoredConsole.WriteLine(o, "Used ", r, sizes.UsedSpace, o, " from ", b, sizes.TotalSpace, o, " - ", r, usedPercent, "%");
            ColoredConsole.WriteLine(o, "Free ", g, sizes.FreeSpace, o, " from ", b, sizes.TotalSpace, o, " - ", g, freePercent, "%");

            var maxCells  = Console.WindowWidth - 1;
            var usedCells = maxCells * usedPercent / 100;

            ColoredConsole.Write(r, string.Join("", Enumerable.Repeat("|", (int)usedCells)));
            ColoredConsole.WriteLine(g, string.Join("", Enumerable.Repeat(".", maxCells - (int)usedCells)));
        }
Exemplo n.º 29
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseGleamTech();

            var gleamTechConfig = Hosting.ResolvePhysicalPath("~/App_Data/GleamTech.config");

            if (File.Exists(gleamTechConfig))
            {
                GleamTechConfiguration.Current.Load(gleamTechConfig);
            }

            var fileUltimateConfig = Hosting.ResolvePhysicalPath("~/App_Data/FileUltimate.config");

            if (File.Exists(fileUltimateConfig))
            {
                FileUltimateConfiguration.Current.Load(fileUltimateConfig);
            }

            app.UseStaticFiles();

            app.UseRouting();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=Home}/{action=Index}/{id?}");
            });
        }
Exemplo n.º 30
0
        public IActionResult Overview()
        {
            var fileUploader = new FileUploader
            {
                Width          = 600, //Default unit is pixels. Percentage can be specified as CssLength.Percentage(100)
                Height         = 300,
                Resizable      = true,
                UploadLocation = "~/App_Data/Uploads"
            };

            var context          = Hosting.GetHttpContext();
            var selectedLanguage = context.Request["languageSelector"];

            if (selectedLanguage != null)
            {
                fileUploader.DisplayLanguage = selectedLanguage;
            }

            PopulateLanguageSelector(selectedLanguage);

            return(View(fileUploader));
        }
Exemplo n.º 31
0
        public void Setup()
        {
            _summary      = "A Summary";
            _url          = "A URL";
            _requiresHscn = "Requires HSCN";

            _dataMock = new Mock <IUpdatePublicCloudData>();
            _dataMock.Setup(x => x.Summary).Returns(() => _summary);
            _dataMock.Setup(x => x.Link).Returns(() => _url);
            _dataMock.Setup(x => x.RequiresHSCN).Returns(() => _requiresHscn);

            _hosting = new Hosting
            {
                PublicCloud = new PublicCloud()
                {
                    Summary      = _summary,
                    Link         = _url,
                    RequiresHSCN = _requiresHscn
                }
            };

            _hostingJson = JsonConvert.SerializeObject(_hosting);
        }
Exemplo n.º 32
0
        public BootstrappingApp()
        {
            Services.For <BootstrappingToken>().Use(new BootstrappingToken(Id));

            Configuration.AddInMemoryCollection(new Dictionary <string, string> {
                { "foo", "bar" }
            });

            Hosting.ConfigureAppConfiguration(c =>
                                              c.AddInMemoryCollection(new Dictionary <string, string> {
                { "team", "chiefs" }
            }));

            Hosting.ConfigureServices(s => s.AddTransient <IService, ServiceFromJasperRegistryConfigure>());

            Hosting.ConfigureServices((c, services) =>
            {
                if (c.HostingEnvironment.EnvironmentName == "Green")
                {
                    services.AddTransient <IService, GreenService>();
                }
            });

            Hosting.Configure(app =>
            {
                app.MapWhen(
                    c => c.Request.Path.Value.Contains("host"),
                    b => b.Run(c => c.Response.WriteAsync("from jasperregistry host")));
            });

            Settings.Alter <BootstrappingSetting>((context, settings) =>
            {
                settings.Environment = context.HostingEnvironment.EnvironmentName;
                settings.Team        = context.Configuration["team"];
                settings.City        = context.Configuration["city"];
            });
        }
Exemplo n.º 33
0
        public IActionResult Processing()
        {
            var context = Hosting.GetHttpContext();
            int selectedValue;

            int.TryParse(context.Request["taskSelector"], out selectedValue);

            var model = new ProcessingViewModel
            {
                ExampleFileSelector = new ExampleFileSelector
                {
                    Id          = "exampleFileSelector",
                    InitialFile = "JPG Image.jpg",
                    FormWrapped = false
                },
                TaskSelectList = PopulateTaskSelector(selectedValue)
            };

            model.ImagePath = model.ExampleFileSelector.SelectedFile;

            var expression = TaskExpressions[selectedValue];
            var lambda     = expression.Compile();

            model.TaskAction = task =>
            {
                task.ResizeWidth(400);
                lambda(task);
            };

            model.CodeString = string.Format(
                "@this.ImageTag(\"{0}\", {1})",
                model.ExampleFileSelector.SelectedFile.FileName,
                ExpressionStringBuilder.ToString(expression)
                );

            return(View(model));
        }
        public MainWindow()
        {
            SyncContext = SynchronizationContext.Current;
            InitializeComponent();
            MainWindowViewModel = new MainWindowViewModel(MainTextBox)
            {
                BookmarkImage = Resources["WhiteBookmarkImage"] as ImageSource
            };


            DataContext = MainWindowViewModel;
            // MainWindowViewModel.ToolsVisible = true;

            MainTextBox.TextChanged += new System.Windows.Controls.TextChangedEventHandler(MainTextBox_TextChanged);

            PreviewKeyDown  += MainWindow_PreviewKeyDown;
            PreviewKeyUp    += MainWindow_PreviewKeyUp;
            LocationChanged += MainWindow_LocationChanged;
            SizeChanged     += MainWindow_SizeChanged;
            Loaded          += MainWindow_Loaded;

            MouseDoubleClick += new MouseButtonEventHandler(MainWindow_MouseDoubleClick);

            MouseLeftButtonDown += MainWindow_MouseLeftButtonDown;


            Closing += MainWindow_Closing;

            PromptView = LayoutRoot;

            SharedMainWindow = this;
            if (Properties.Settings.Default.StartWebController)
            {
                Hosting.Start();
            }
        }
Exemplo n.º 35
0
        public ReceiverApp()
        {
            Configuration.AddJsonFile("appsettings.json").AddEnvironmentVariables();

            Hosting.UseUrls("http://*:5061").UseKestrel();

            Hosting.ConfigureLogging(x =>
            {
                x.SetMinimumLevel(LogLevel.Information);
                x.AddConsole();
            });

            Settings.PersistMessagesWithSqlServer((context, settings) =>
            {
                settings.SchemaName       = "receiver";
                settings.ConnectionString = context.Configuration["mssql"];
            });


            Settings.Configure(c =>
            {
                Transports.ListenForMessagesFrom(c.Configuration["listener"]);
            });
        }
Exemplo n.º 36
0
 protected internal override void OnLoad(Hosting.IDotvvmRequestContext context)
 {
     DataBind(context);
     base.OnLoad(context);
 }
Exemplo n.º 37
0
 protected override Task OnConnectedAsync(Hosting.IRequest request, string connectionId)
 {
     return SendToGroup("test", "hey");
 }
Exemplo n.º 38
0
        public SubscriberApp()
        {
            Hosting.UseUrls("http://localhost:5004");

            Transports.LightweightListenerAt(22222);
        }
Exemplo n.º 39
0
 protected override Task OnConnectedAsync(Hosting.IRequest request, string connectionId)
 {
     _connectWh.Set();
     return base.OnConnectedAsync(request, connectionId);
 }
Exemplo n.º 40
0
 protected override Task OnReceivedAsync(Hosting.IRequest request, string connectionId, string data)
 {
     return Connection.Broadcast(data);
 }
Exemplo n.º 41
0
        protected internal override void OnPreRender(Hosting.IDotvvmRequestContext context)
        {
            if (context.IsSpaRequest)
            {
                // we need to render the HTML on postback when SPA request arrives
                SetValue(PostBack.UpdateProperty, true);
            }

            base.OnPreRender(context);
        }
Exemplo n.º 42
0
        private void CreateHeaderRow(Hosting.IDotvvmRequestContext context, Action<string> sortCommand)
        {
            head = new HtmlGenericControl("thead");
            Children.Add(head);

            var gridViewDataSet = DataSource as IGridViewDataSet;

            // workaroud: header template must have to be one level nested, because it is in the Columns property which nests the dataContext to the item type
            // on server we need null, to be Convertible to Item type and on client the best is empty object, because with will hide the inner content when it is null
            var headerRow = new HtmlGenericControl("tr");
            //headerRow.SetBinding(DataContextProperty, new ValueBindingExpression(h => null, "{}"));
            head.Children.Add(headerRow);
            foreach (var column in Columns)
            {
                var cell = new HtmlGenericControl("th");
                SetCellAttributes(column, cell, true);
                headerRow.Children.Add(cell);

                column.CreateHeaderControls(context, this, sortCommand, cell, gridViewDataSet);
                if (FilterPlacement == GridViewFilterPlacement.HeaderRow)
                {
                    column.CreateFilterControls(context, this, cell, gridViewDataSet);
                }
            }

            if (FilterPlacement == GridViewFilterPlacement.ExtraRow)
            {
                headerRow = new HtmlGenericControl("tr");
                headerRow.SetBinding(DataContextProperty, new ValueBindingExpression(h => null, "{}"));
                head.Children.Add(headerRow);
                foreach (var column in Columns)
                {
                    var cell = new HtmlGenericControl("th");
                    SetCellAttributes(column, cell, true);
                    headerRow.Children.Add(cell);
                    column.CreateFilterControls(context, this, cell, gridViewDataSet);
                }
            }
        }
Exemplo n.º 43
0
 private void CreateTemplates(Hosting.IDotvvmRequestContext context, DataItemContainer placeholder, bool isInEditMode = false)
 {
     var row = CreateRow(placeholder, isInEditMode);
     
     // create cells
     foreach (var column in Columns)
     {
         var cell = new HtmlGenericControl("td");
         row.Children.Add(cell);
         if (isInEditMode && column.IsEditable)
         {
             column.CreateEditControls(context, cell);
         }
         else
         {
             column.CreateControls(context, cell);
         }
     }
 }
Exemplo n.º 44
0
        // Assumption is that application, if present, is in curly Guids form
        static List<EndpointConfigContainer> GetContainersForQueryOrRemove(Hosting hosting, string application, string webServer, string webDirectory)
        {
            List<EndpointConfigContainer> containers = new List<EndpointConfigContainer>();

            // first, get any complus-hosted endpointConfigs
            if (hosting == Hosting.Complus || hosting == Hosting.NotSpecified)
            {
                if (!string.IsNullOrEmpty(application))
                {
                    EndpointConfigContainer container = ComplusEndpointConfigContainer.Get(application);
                    if (container == null)
                    {
                        throw CreateArgumentException(Cmd.Application, options.Application, SR.GetString(SR.ApplicationNotFound, options.Application), null);
                    }

                    containers.Add(container);
                }
                else
                {
                    // query for all complus-hosted apps
                    List<ComplusEndpointConfigContainer> comContainers = ComplusEndpointConfigContainer.Get();
                    if (comContainers != null)
                    {
                        foreach (ComplusEndpointConfigContainer comContainer in comContainers)
                        {
                            containers.Add(comContainer);
                        }
                    }
                }
            }

            // then, get any was-hosted endpointConfigs
            if (hosting == Hosting.Was || hosting == Hosting.NotSpecified)
            {
                // specific webDirectory
                if (!string.IsNullOrEmpty(webDirectory))
                {
                    if (string.IsNullOrEmpty(webServer))
                    {
                        webServer = WasEndpointConfigContainer.DefaultWebServer;
                    }

                    EndpointConfigContainer container = WasEndpointConfigContainer.Get(webServer, webDirectory, application);
                    if (container == null)
                    {
                        throw CreateArgumentException(Cmd.WebDirectory, options.WebDirectory, SR.GetString(SR.WebDirectoryNotFound, options.WebDirectory), null);
                    }

                    if (string.IsNullOrEmpty(application))
                    {
                        containers.Add(container);
                    }
                    else
                    {
                        if (container.HasEndpointsForApplication(new Guid(application)))
                        {
                            containers.Add(container);
                        }
                    }
                }
                else
                {
                    // no webDirectory specified.
                    // we will therefore look in all webDirs, in all webServers (unless one is specified)

                    List<WasEndpointConfigContainer> wasContainers = null;

                    if (!string.IsNullOrEmpty(webServer))
                    {
                        wasContainers = WasEndpointConfigContainer.Get(webServer, application); // all webDirs in a specific server
                    }
                    else
                    {
                        wasContainers = WasEndpointConfigContainer.Get(application);  // all webDirs in all servers
                    }

                    if (wasContainers != null)
                    {
                        foreach (WasEndpointConfigContainer container in wasContainers)
                        {
                            if (string.IsNullOrEmpty(application))
                            {
                                containers.Add(container);
                            }
                            else
                            {
                                if (container.HasEndpointsForApplication(new Guid(application)))
                                {
                                    containers.Add(container);
                                }
                            }
                        }
                    }
                }
            }

            return containers;
        }
Exemplo n.º 45
0
 protected internal override void OnPreRender(Hosting.IDotvvmRequestContext context)
 {
     DataBind(context);     // TODO: support for observable collection
     base.OnPreRender(context);
 }
Exemplo n.º 46
0
        static void ValidateApplication(ComAdminAppInfo appInfo, Hosting hosting)
        {
            if (appInfo.IsSystemApplication)
            {
                throw CreateArgumentException(Cmd.Application, appInfo.Name, SR.GetString(SR.SystemApplicationsNotSupported), null);
            }

            if (hosting == Hosting.Complus)
            {
                if (!appInfo.IsServerActivated)
                {
                    throw CreateArgumentException(Cmd.Application, appInfo.Name, SR.GetString(SR.LibraryApplicationsNotSupported), null);
                }

                if (appInfo.IsAutomaticRecycling)
                {
                    throw CreateArgumentException(Cmd.Application, appInfo.Name, SR.GetString(SR.ProcessRecyclingNotSupported), null);
                }

                if (appInfo.IsProcessPooled)
                {
                    throw CreateArgumentException(Cmd.Application, appInfo.Name, SR.GetString(SR.ProcessPoolingNotSupported), null);
                }
            }
        }
Exemplo n.º 47
0
 public string GetMarkupFileVirtualPath(Hosting.IDotvvmRequestContext context)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 48
0
 private void PartHost_Faulted(object sender, Hosting.Isolation.Runtime.Activation.ActivationHostEventArgs e)
 {
     foreach (var movieProvider in Providers)
     {
         var objectReferenceAware = (IObjectReferenceAware) movieProvider;
         if (e.Description.Id == objectReferenceAware.Reference.Description.Id)
         {
             // we have a problem - one of the host hosting our plugin has died, disable this tab
             Execute.OnUIThread(() => IsFaulted = true);
             break;
         }
     }
 }
Exemplo n.º 49
0
 protected internal override void OnPreRender(Hosting.IDotvvmRequestContext context)
 {
     isFormattingRequired = !string.IsNullOrEmpty(FormatString) || ValueType != FormatValueType.Text;
     if (isFormattingRequired)
     {
         context.ResourceManager.AddCurrentCultureGlobalizationResource();
     }
     base.OnPreRender(context);
 }
Exemplo n.º 50
0
        private void DataBind(Hosting.IDotvvmRequestContext context)
        {
            Children.Clear();

            content = new HtmlGenericControl("ul");
            content.SetBinding(DataContextProperty, GetDataSetBinding());
            Children.Add(content);


            var dataSet = DataSet;
            if (dataSet != null)
            {
                object enabledValue = HasValueBinding(EnabledProperty) ? (object)new ValueBindingExpression(h => GetValueBinding(EnabledProperty).Evaluate(this, EnabledProperty), "$pagerEnabled") : Enabled;

                // first button
                firstLi = new HtmlGenericControl("li");
                var firstLink = new LinkButton();
                SetButtonContent(context, firstLink, "««", FirstPageTemplate);
                firstLink.SetBinding(ButtonBase.ClickProperty, GoToFirstPageCommand);
                if (!true.Equals(enabledValue)) firstLink.SetValue(LinkButton.EnabledProperty, enabledValue);
                firstLi.Children.Add(firstLink);
                content.Children.Add(firstLi);

                // previous button
                previousLi = new HtmlGenericControl("li");
                var previousLink = new LinkButton();
                SetButtonContent(context, previousLink, "«", PreviousPageTemplate);
                previousLink.SetBinding(ButtonBase.ClickProperty, GoToPrevPageCommand);
                if (!true.Equals(enabledValue)) previousLink.SetValue(LinkButton.EnabledProperty, enabledValue);
                previousLi.Children.Add(previousLink);
                content.Children.Add(previousLi);
                
                // number fields
                numbersPlaceHolder = new PlaceHolder();
                content.Children.Add(numbersPlaceHolder);

                var i = 0;
                foreach (var number in dataSet.NearPageIndexes)
                {
                    var li = new HtmlGenericControl("li");
                    li.SetBinding(DataContextProperty, GetNearIndexesBinding(i));
                    if (number == dataSet.PageIndex)
                    {
                        li.Attributes["class"] = "active";
                    }
                    var link = new LinkButton() { Text = (number + 1).ToString() };
                    link.SetBinding(ButtonBase.ClickProperty, GoToThisPageCommand);
                    if (!true.Equals(enabledValue)) link.SetValue(LinkButton.EnabledProperty, enabledValue);
                    li.Children.Add(link);
                    numbersPlaceHolder.Children.Add(li);

                    i++;
                }
                
                // next button
                nextLi = new HtmlGenericControl("li");
                var nextLink = new LinkButton();
                SetButtonContent(context, nextLink, "»", NextPageTemplate);
                nextLink.SetBinding(ButtonBase.ClickProperty, GoToNextPageCommand);
                if (!true.Equals(enabledValue)) nextLink.SetValue(LinkButton.EnabledProperty, enabledValue);
                nextLi.Children.Add(nextLink);
                content.Children.Add(nextLi);

                // last button
                lastLi = new HtmlGenericControl("li");
                var lastLink = new LinkButton();
                SetButtonContent(context, lastLink, "»»", LastPageTemplate);
                if (!true.Equals(enabledValue)) lastLink.SetValue(LinkButton.EnabledProperty, enabledValue);
                lastLink.SetBinding(ButtonBase.ClickProperty, GoToLastPageCommand);
                lastLi.Children.Add(lastLink);
                content.Children.Add(lastLi);
            }
        }
Exemplo n.º 51
0
        private void DataBind(Hosting.IDotvvmRequestContext context)
        {
            Children.Clear();
            emptyDataContainer = null;
            head = null;

            var dataSourceBinding = GetDataSourceBinding();
            var dataSource = DataSource;

            Action<string> sortCommand = null;
            var set = dataSource as IGridViewDataSet;
            if (set != null)
            {
                sortCommand = set.SetSortExpression;
            }
            else
            {
                sortCommand = SortChanged;
            }

            // WORKAROUND: DataSource is null => don't throw exception
            if (sortCommand == null && dataSource == null)
            {
                sortCommand = s =>
                {
                    throw new DotvvmControlException(this, "Cannot sort when DataSource is null.");
                };
            }

            CreateHeaderRow(context, sortCommand);
            var index = 0;
            if (dataSource != null)
            {
                // create header row
                var items = GetIEnumerableFromDataSource(dataSource);
                var javascriptDataSourceExpression = dataSourceBinding.GetKnockoutBindingExpression();

                foreach (var item in items)
                {
                    // create row
                    var placeholder = new DataItemContainer { DataItemIndex = index };
                    placeholder.SetBinding(DataContextProperty, GetItemBinding((IList)items, javascriptDataSourceExpression, index));
                    placeholder.SetValue(Internal.PathFragmentProperty, JavascriptCompilationHelper.AddIndexerToViewModel(GetPathFragmentExpression(), index));
                    placeholder.ID = index.ToString();
                    CreateRowWithCells(context, placeholder);
                    Children.Add(placeholder);

                    index++;
                }
                numberOfRows = index;
            }
            else
            {
                numberOfRows = 0;
            }

            // add empty item
            if (EmptyDataTemplate != null)
            {
                emptyDataContainer = new EmptyData();
                emptyDataContainer.SetBinding(DataSourceProperty, dataSourceBinding);
                EmptyDataTemplate.BuildContent(context, emptyDataContainer);
                Children.Add(emptyDataContainer);
            }
        }
Exemplo n.º 52
0
 protected override Task OnReconnectedAsync(Hosting.IRequest request, IEnumerable<string> groups, string connectionId)
 {
     Reconnects++;
     return base.OnReconnectedAsync(request, groups, connectionId);
 }
Exemplo n.º 53
0
        private void CreateRowWithCells(Hosting.IDotvvmRequestContext context, DataItemContainer placeholder)
        {
            var isInEditMode = false;
            if (InlineEditing)
            {
                // if gridviewdataset is missing throw exception
                if (!(DataSource is IGridViewDataSet))
                {
                    throw new ArgumentException("You have to use GridViewDataSet with InlineEditing enabled.");
                }

                //checks if row is being edited
                isInEditMode = IsEditedRow(placeholder);
            }

            var row = CreateRow(placeholder, isInEditMode);

            // create cells
            foreach (var column in Columns)
            {
                var cell = new HtmlGenericControl("td");
                SetCellAttributes(column, cell, false);
                row.Children.Add(cell);

                if (isInEditMode && column.IsEditable)
                {
                    column.CreateEditControls(context, cell);
                }
                else
                {
                    column.CreateControls(context, cell);
                }
            }
        }
Exemplo n.º 54
0
 protected override Task OnReconnectedAsync(Hosting.IRequest request, System.Collections.Generic.IEnumerable<string> groups, string connectionId)
 {
     Console.WriteLine("{0} Reconnected", connectionId);
     return base.OnReconnectedAsync(request, groups, connectionId);
 }
Exemplo n.º 55
0
 public EnvironmentNameRegistry()
 {
     // which is just a shortcut for:
     Hosting.UseEnvironment("Production");
 }
Exemplo n.º 56
0
        /// <summary>
        /// Performs the data-binding and builds the controls inside the <see cref="Repeater"/>.
        /// </summary>
        private void DataBind(Hosting.IDotvvmRequestContext context)
        {
            Children.Clear();
            emptyDataContainer = null;

            var dataSourceBinding = GetDataSourceBinding();
            var index = 0;
            var dataSource = DataSource;
            if (dataSource != null)
            {
                var items = GetIEnumerableFromDataSource(dataSource).Cast<object>().ToArray();
                var javascriptDataSourceExpression = dataSourceBinding.GetKnockoutBindingExpression();
                foreach (var item in items)
                {
                    var placeholder = new DataItemContainer { DataItemIndex = index };
                    ItemTemplate.BuildContent(context, placeholder);
                    placeholder.SetBinding(DataContextProperty, GetItemBinding((IList)items, javascriptDataSourceExpression, index));
                    placeholder.SetValue(Internal.PathFragmentProperty, JavascriptCompilationHelper.AddIndexerToViewModel(GetPathFragmentExpression(), index));
                    placeholder.ID = index.ToString();
                    Children.Add(placeholder);
                    index++;
                }
                numberOfRows = index;
            }
            else
            {
                numberOfRows = 0;
            }

            // add empty item
            if (EmptyDataTemplate != null)
            {
                emptyDataContainer = new EmptyData();
                emptyDataContainer.SetBinding(DataSourceProperty, dataSourceBinding);
                EmptyDataTemplate.BuildContent(context, emptyDataContainer);
                Children.Add(emptyDataContainer);
            }
        }
Exemplo n.º 57
0
 protected override Task OnConnectedAsync(Hosting.IRequest request, string connectionId)
 {
     Console.WriteLine("{0} Connected", connectionId);
     return base.OnConnectedAsync(request, connectionId);
 }
Exemplo n.º 58
0
 /// <summary>
 /// Occurs after the page commands are executed.
 /// </summary>
 protected internal override void OnPreRender(Hosting.IDotvvmRequestContext context)
 {
     DataBind(context);     // TODO: we should handle observable collection operations to persist controlstate of controls inside the Repeater
     base.OnPreRender(context);
 }
Exemplo n.º 59
0
 private void SetButtonContent(Hosting.IDotvvmRequestContext context, LinkButton button, string text, ITemplate contentTemplate)
 {
     if (contentTemplate != null)
     {
         contentTemplate.BuildContent(context, button);
     }
     else
     {
         button.Text = text;
     }
 }
Exemplo n.º 60
0
        internal override void OnPreRenderComplete(Hosting.IDotvvmRequestContext context)
        {
            context.ResourceManager.AddRequiredResource(ResourceConstants.DotvvmFileUploadCssResourceName);

            base.OnPreRenderComplete(context);
        }