public void TestTransformerType(string testName, RazorRuntime runtime)
        {
            string workingDirectory = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
            try
            {
                using (var razorGenerator = new HostManager(workingDirectory, loadExtensions: false, defaultRuntime: runtime, assemblyDirectory: Environment.CurrentDirectory))
                {
                    string inputFile = SaveInputFile(workingDirectory, testName);
                    var host = razorGenerator.CreateHost(inputFile, testName + ".cshtml", string.Empty);
                    host.DefaultNamespace = GetType().Namespace;
                    host.EnableLinePragmas = false;

                    var output = host.GenerateCode();
                    AssertOutput(testName, output, runtime);
                }
            }
            finally
            {
                try
                {
                    Directory.Delete(workingDirectory);
                }
                catch
                {
                }
            }

        }
Beispiel #2
0
 public void SetUp()
 {
     try
     {
         File.Delete(DbConstants.DatabaseFile);
     }
     catch { }
     HostManager.InitializeCore();
 }
Beispiel #3
0
        public void HostManagerHieruisticForMvcViews(string path)
        {
            // Act
            RazorRuntime runtime;
            var          guess = HostManager.GuessHost(Directory.GetCurrentDirectory(), path, out runtime);

            // Assert
            Assert.Equal("MvcView", guess);
        }
Beispiel #4
0
        public void HostManagerHieruisticForMvcHelperInViewsFolder(string path, string expected, RazorRuntime expectedRuntime)
        {
            // Act
            RazorRuntime runtime;
            var          guess = HostManager.GuessHost(Directory.GetCurrentDirectory(), path, out runtime);

            // Assert
            Assert.Equal(expected, guess);
            Assert.Equal(expectedRuntime, runtime);
        }
Beispiel #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ddlMName.DataSource    = ModuleManager.getAllModule();
                ddlMName.DataTextField = "ModuleName";
                ddlMName.DataBind();
            }
            string strName = "";

            if (Session["Name"] == null)
            {
                strName           = "匿名";
                labName.Text      = strName;
                labEmail.Text     = "无";
                labQQ.Text        = "无";
                labIndex.Text     = "无";
                imgPhoto.ImageUrl = "../Images/Visiter.jpg";
            }
            else
            {
                strName = Session["Name"].ToString();
                if (Session["Pop"].ToString() == "用户")
                {
                    user.UserName     = strName;
                    user              = UserManager.findUserByUserName(user);
                    labName.Text      = strName;
                    labEmail.Text     = user.Email;
                    labQQ.Text        = user.QQ.ToString();
                    labIndex.Text     = user.Index;
                    imgPhoto.ImageUrl = user.Photo;
                    return;
                }
                if (Session["Pop"].ToString() == "版主")
                {
                    host.HostName     = strName;
                    host              = HostManager.FindHostByHostName(host);
                    labName.Text      = strName;
                    labEmail.Text     = host.Email;
                    labQQ.Text        = host.QQ.ToString();
                    labIndex.Text     = host.Index;
                    imgPhoto.ImageUrl = host.Photo;
                    return;
                }
                if (Session["Pop"].ToString() == "管理员")
                {
                    labName.Text      = strName;
                    labEmail.Text     = "无";
                    labQQ.Text        = "无";
                    labIndex.Text     = "无";
                    imgPhoto.ImageUrl = "../Images/Admin.jpg";
                    return;
                }
            }
        }
Beispiel #6
0
        public override void SendScreenshot(Boolean fullscreen)
        {
            SwitchToInputDesktop();
            byte[] image = new byte[] { };

            var bmpScreenshot = new Bitmap(System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width,
                                           System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height,
                                           PixelFormat.Format32bppArgb);

            // Create a graphics object from the bitmap.
            //var img = _ScreenCapture.GetScreen(new Size(System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width, System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height));

            var gfxScreenshot = Graphics.FromImage(bmpScreenshot);

            // Take the screenshot from the upper left corner to the right bottom corner.
            gfxScreenshot.CopyFromScreen(System.Windows.Forms.Screen.PrimaryScreen.Bounds.X,
                                         System.Windows.Forms.Screen.PrimaryScreen.Bounds.Y,
                                         0,
                                         0,
                                         System.Windows.Forms.Screen.PrimaryScreen.Bounds.Size,
                                         CopyPixelOperation.SourceCopy);

            var stream = new MemoryStream();

            bmpScreenshot.Save(stream, ImageFormat.Png);

            ResponseScreenshotMessage rs = new ResponseScreenshotMessage();

            rs.Bounds       = System.Windows.Forms.Screen.PrimaryScreen.Bounds;
            rs.Fullscreen   = true;
            rs.HostSystemId = HostManager.SystemId;

            /*using (var msout = new MemoryStream())
             * {
             *  unsafe
             *  {
             *      fixed (byte* datb = img.Data)
             *      {
             *          using (Bitmap image = new Bitmap(System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width, System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height, System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width * 4, PixelFormat.Format32bppRgb, new IntPtr(datb)))
             *          {
             *              image.Save(msout, ImageFormat.Png);
             *              rs.Image = msout.ToArray();
             *
             *          }
             *      }
             *  }
             * }*/
            rs.Image = stream.ToArray();

            foreach (var ID in ConnectedClients)
            {
                rs.ClientSystemId = ID;
                HostManager.sendMessage(rs);
            }
        }
Beispiel #7
0
        public static void InitService()
        {
            HostManager.WebApiBLLHostOpen(
                SysConstVar.LocalIP,
                SysConstVar.LocalAddrPortWebApiBLL.ToString());

            HostManager.HttpFileHostStart(
                SysConstVar.LocalAddrPortHttpFile,
                "/",
                SysConstVar.LocalIISPath);
        }
 public InMemoryHost(
     IConfigurationSource configuration,
     IDependencyResolver dependencyResolver = null,
     StartupProperties startup = null)
 {
     Resolver               = dependencyResolver ?? (configuration as IDependencyResolverAccessor)?.Resolver ?? new InternalDependencyResolver();
     _configuration         = configuration ?? new DelegateConfigurationSource(null);
     ApplicationVirtualPath = "/";
     HostManager            = HostManager.RegisterHost(this);
     RaiseStart(startup ?? new StartupProperties());
 }
Beispiel #9
0
 void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
     else if (Instance != this)
     {
         Destroy(gameObject);
     }
 }
Beispiel #10
0
        public AppDomainHost(string assemblyPath, string configPath)
        {
            _assemblyPath   = assemblyPath;
            _assemblyConfig = configPath;

            var assemblyFullPath = Path.GetFullPath(assemblyPath);
            var appDomain        = CreateAppDomain(Path.GetDirectoryName(assemblyFullPath), configPath);

            _hostManager = CreateInstanceAndUnwrap <HostManager>(appDomain);
            _hostManager.LoadServiceAssemblyAndServices(assemblyPath);
        }
        public async static Task <IActionResult> Initialize(
            [HttpTrigger(AuthorizationLevel.Function, "post", Route = null)]
            HttpRequest req,
            ExecutionContext executionContext,
            ILogger logger
            )
        {
            var deploymentId = await HostManager <ApplicationInfo> .InitializeService(executionContext, logger);

            return(new OkObjectResult(new { DeploymentId = deploymentId }));
        }
        public ActionResult Index()
        {
            var hostResponse = new HostManager(Wrapper).GetHostListing();

            if (hostResponse.HasError)
            {
                return(ErrorView(hostResponse.ErrorString));
            }

            return(hostResponse.HasError ? ErrorView(hostResponse.ErrorString) : View("Index", hostResponse.ObjectValue));
        }
        private static void createHostClient(out HostManager host, out ClientManager client)
        {
            UnityLogger logger = new UnityLogger();

            host        = new GameObject(nameof(HostManager)).AddComponent <HostManager>();
            host.logger = logger;
            host.start();

            client        = new GameObject(nameof(ClientManager)).AddComponent <ClientManager>();
            client.logger = logger;
            client.start();
        }
Beispiel #14
0
 private void ToolStripMenuItem_Restart_Click(object sender, EventArgs e)
 {
     HostManager.Stop();
     Task.Run(async() =>
     {
         this.TextBox.Clear();
         this.TextBox.AppendText($"WebHost restarting……{Environment.NewLine}");
         await Task.Delay(3000);
         this.TextBox.AppendText($"WebHost restarts success.{Environment.NewLine}{Environment.NewLine}");
         HostManager.Start();
     });
 }
Beispiel #15
0
 private void initHost()
 {
     if (_host == null)
     {
         _host = this.findInstance <HostManager>();
         if (_host == null)
         {
             throw new Exception("没有找到HostManager");
         }
         host.onClientConnected += Host_onClientConnected;
     }
 }
Beispiel #16
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var textValue = value as string;
            if (string.IsNullOrEmpty(textValue))
                return null;
            var content = DBFactory.GetData().Read(textValue).GetAttributeValue(Constants.CONTENT);
            if (string.IsNullOrEmpty(content))
                return null;
            var steps = XElement.Parse(content).GetAttributeValue("Steps");
            var ret = Utilities.GetStepsList(steps, _options, HostManager.GetInstance().GetHost());

            return ret;
        }
Beispiel #17
0
 public string getHost(string str)
 {
     host.ModuleID = str;
     if (HostManager.FindHostByModuleID(host) != null)
     {
         string hostname = HostManager.FindHostByModuleID(host).HostName;
         return(hostname);
     }
     else
     {
         return(null);
     }
 }
Beispiel #18
0
        public void Initialize(IEnumerable <string> prefixes, string appPathVDir, Type dependencyResolverFactory)
        {
            CheckNotDisposed();
            ApplicationVirtualPath = appPathVDir;

            _resolverFactory = dependencyResolverFactory;
            _listener        = new System.Net.HttpListener();
            foreach (string prefix in prefixes)
            {
                _listener.Prefixes.Add(prefix);
            }
            HostManager.RegisterHost(this);
        }
Beispiel #19
0
 protected void gvHostInfo_RowDeleting(object sender, GridViewDeleteEventArgs e)
 {
     host.HostName = gvHostInfo.DataKeys[e.RowIndex].Value.ToString();
     if (HostManager.deleteHost(host) != 0)
     {
         Response.Write("<script language=javascript>alert('删除成功!')</script>");
     }
     else
     {
         Response.Write("<script language=javascript>alert('删除失败!')</script>");
     }
     gvBind();
 }
        private static void createHostClient12(out HostManager host, out ClientManager client1, out ClientManager client2)
        {
            UnityLogger logger = new UnityLogger();

            host        = new GameObject(nameof(HostManager) + "1").AddComponent <HostManager>();
            host.logger = logger;
            host.start();
            client1        = new GameObject(nameof(ClientManager) + "1").AddComponent <ClientManager>();
            client1.logger = logger;
            client1.start();
            client2        = new GameObject(nameof(ClientManager) + "2").AddComponent <ClientManager>();
            client2.logger = logger;
            client2.start();
        }
Beispiel #21
0
        public static void Start()
        {
            HostCore.Log.Message("Starting wizard to create a new application package.");
            PreConfigurationState preConfigurationState;
            ApplicationData       applicationData;

            do
            {
                if (!RunPreWizard(out preConfigurationState))
                {
                    return;
                }
                if (PrepareApplicationData(preConfigurationState, out applicationData))
                {
                    break; // Successfully extracted ApplicationData from the data specified in the wizard
                }
                if (
                    MessageBox.Show("Failed to start a packaging process from the data specified. Please retry.",
                                    "Packaging Initialization Failed", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error)
                    != DialogResult.Retry)
                {
                    return;
                }
            } while (true);
            PackagedApplication packagedApplication;

            if (!RunPackagingSequence(preConfigurationState, applicationData, out packagedApplication))
            {
                return;
            }
            HostCore.Log.Message("Successfully constructed a package for: " + preConfigurationState.InstallerExecutable);
            var applicationDataFile = System.IO.Path.Combine(preConfigurationState.InstallerOutputDestination,
                                                             HostCore.Configuration.Application.DefaultApplicationDataFile);

            if (!RunPostWizard(packagedApplication, applicationDataFile))
            {
                MessageBox.Show("Failed to create an application data file for the packaged application.",
                                "Unable to create application data file", MessageBoxButtons.OK, MessageBoxIcon.Error);
                // ToDo:
                //  Ask user whether or not he wants to start the ApplicationConfigurationUtility
                //  or create a recovery utility based on ApplicationConfigurationUtility
                return;
            }
            // Start the application, if requested.
            if (preConfigurationState.Autostart)
            {
                HostManager.StartProcess(applicationDataFile);
            }
        }
Beispiel #22
0
        public void TestTransformerType(string testName, RazorRuntime runtime)
        {
            string workingDirectory = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());

            using (var razorGenerator = new HostManager(workingDirectory, loadExtensions: false, defaultRuntime: runtime, assemblyDirectory: Environment.CurrentDirectory))
            {
                string inputFile = SaveInputFile(workingDirectory, testName);
                var    host      = razorGenerator.CreateHost(inputFile, testName + ".cshtml");
                host.DefaultNamespace  = GetType().Namespace;
                host.EnableLinePragmas = false;

                var output = host.GenerateCode();
                AssertOutput(testName, output, runtime);
            }
        }
Beispiel #23
0
        public static void AbortAll()
        {
            HTTPManager.Logger.Information("HTTPManager", "AbortAll called!");

            // This is an immediate shutdown request!

            RequestEventHelper.Clear();
            ConnectionEventHelper.Clear();
            PluginEventHelper.Clear();
            ProtocolEventHelper.Clear();

            HostManager.Shutdown();

            ProtocolEventHelper.CancelActiveProtocols();
        }
Beispiel #24
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         gvHostInfo.DataSource   = HostManager.getAllHost();
         gvHostInfo.DataKeyNames = new string[] { "版主" };
         gvHostInfo.DataBind();
         List <Host> listOfHost = HostManager.getAllHost();
         for (int i = 0; i < listOfHost.Count; i++)
         {
             module.ModuleID = listOfHost[i].ModuleID;
             gvHostInfo.Rows[i].Cells[1].Text = ModuleManager.findModuleByName(module).ModuleName;
             gvHostInfo.Rows[i].Cells[3].Text = listOfHost[i].Birthday.ToLongDateString();
         }
     }
 }
Beispiel #25
0
 protected virtual void Dispose(bool fromDisposeMethod)
 {
     if (!_isDisposed)
     {
         if (fromDisposeMethod)
         {
             if (_listener.IsListening)
             {
                 StopListening();
             }
             HostManager.UnregisterHost(this);
         }
         _listener.Abort();
         _isDisposed = true;
     }
 }
Beispiel #26
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (Session["Name"] == null)
         {
             Response.Redirect("../Common/LimitPop.aspx");
         }
         else
         {
             card.CardID   = Page.Request.QueryString["CardID"].ToString();
             labCName.Text = CardManager.FindCardByCardID(card).CardName;
             string strName = Session["Name"].ToString();
             if (Session["Pop"].ToString() == "用户")
             {
                 user.UserName     = strName;
                 user              = UserManager.findUserByUserName(user);
                 labName.Text      = strName;
                 labEmail.Text     = user.Email;
                 labQQ.Text        = user.QQ.ToString();
                 labIndex.Text     = user.Index;
                 imgPhoto.ImageUrl = user.Photo;
                 return;
             }
             if (Session["Pop"].ToString() == "版主")
             {
                 host.HostName     = strName;
                 host              = HostManager.FindHostByHostName(host);
                 labName.Text      = strName;
                 labEmail.Text     = host.Email;
                 labQQ.Text        = host.QQ.ToString();
                 labIndex.Text     = host.Index;
                 imgPhoto.ImageUrl = host.Photo;
                 return;
             }
             if (Session["Pop"].ToString() == "管理员")
             {
                 labName.Text      = strName;
                 labEmail.Text     = "无";
                 labQQ.Text        = "无";
                 labIndex.Text     = "无";
                 imgPhoto.ImageUrl = "../Images/Admin.jpg";
                 return;
             }
         }
     }
 }
        private static void createRoomPlayer12(HostManager host, out RoomPlayerInfo playerInfo1, out RoomPlayerInfo playerInfo2, out RoomInfo roomInfo)
        {
            playerInfo1 = new RoomPlayerInfo()
            {
                name = "测试名字1"
            };
            playerInfo2 = new RoomPlayerInfo()
            {
                name = "测试名字2"
            };
            playerInfo2.PlayerID = playerInfo1.PlayerID + 1;

            roomInfo = new RoomInfo()
            {
                ip = "127.0.0.1", port = host.port, OwnerID = playerInfo1.PlayerID
            };
        }
Beispiel #28
0
        public AgrServerApplication()
        {
            LogManager.LogEmit += LogManager_LogEmit;

            var binding = new NetTcpBinding();

            binding.Name = "my_binding";
            binding.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard;
            binding.Security.Mode          = SecurityMode.None;
            binding.MaxConnections         = (int)AppConfig.MaxClients;

            // лимит на соединения
            var throttling = new ServiceThrottlingBehavior();

            throttling.MaxConcurrentSessions = (int)AppConfig.MaxClients;

            host = new ServiceHost(typeof(RLTTaskManagerService));
            host.Description.Behaviors.Add(throttling);
            host.AddServiceEndpoint(typeof(IRLTTaskManagerService), binding, HostManager.GetServerHost());
            host.Open();

            LogManager.LogInfo(unit, string.Format("Запуск сервера. Максимальное количество клиентов: {0}", AppConfig.MaxClients));

            _mNotifyIcon.MouseClick        += MNotifyIconMouseClick;
            _mNotifyIcon.BalloonTipClicked += MNotifyIconClick;
            var menu = new ContextMenuStrip();

            ToolStripItem item = menu.Items.Add("Настройка", AgrServer.Properties.Resources.users_1);

            item.Click += MNotifyIconClick;

            item        = menu.Items.Add("Сообщения", AgrServer.Properties.Resources.info);
            item.Click += InfoIconClick;

            menu.Items.Add("-");

            item        = menu.Items.Add("Выход", AgrServer.Properties.Resources.Turn2);
            item.Click += ItemClick;
            _mNotifyIcon.ContextMenuStrip = menu;
            _mNotifyIcon.Icon             = AgrServer.Properties.Resources.user_green1;

            _mNotifyIcon.Visible = true;

            ShutdownMode = ShutdownMode.OnExplicitShutdown;
        }
 public void setup()
 {
     Host = new InMemoryHost(startup: new StartupProperties
     {
         OpenRasta =
         {
             Errors                           =
             {
                 HandleAllExceptions          = false,
                 HandleCatastrophicExceptions = false
             }
         }
     });
     HostManager            = Host.HostManager;
     AmbientContext.Current = new AmbientContext();
     RequestScope           = Host.Resolver.CreateRequestScope();
     HostManager.SetupCommunicationContext(Context = new InMemoryCommunicationContext());
 }
 public void Init(HttpApplication context)
 {
     context.PostResolveRequestCache += HandleHttpApplicationPostResolveRequestCacheEvent;
     context.EndRequest += HandleHttpApplicationEndRequestEvent;
     if (HostManager == null)
     {
         lock (SyncRoot)
         {
             Thread.MemoryBarrier();
             if (HostManager == null)
             {
                 HostManager = HostManager.RegisterHost(Host);
                 Host.RaiseStart();
                 Log = HostManager.Resolver.Resolve<ILogger<AspNetLogSource>>();
             }
         }
     }
 }
Beispiel #31
0
 public void Init(HttpApplication context)
 {
     context.PostResolveRequestCache += HandleHttpApplicationPostResolveRequestCacheEvent;
     context.EndRequest += HandleHttpApplicationEndRequestEvent;
     if (HostManager == null)
     {
         lock (_syncRoot)
         {
             Thread.MemoryBarrier();
             if (HostManager == null)
             {
                 HostManager = HostManager.RegisterHost(Host);
                 Host.RaiseStart();
                 Log = HostManager.Resolver.Resolve <ILogger <AspNetLogSource> >();
             }
         }
     }
 }
        protected virtual void Dispose(bool fromDisposeMethod)
        {
            if (_isDisposed || _listener == null)
            {
                return;
            }

            if (fromDisposeMethod)
            {
                if (_listener.IsListening)
                {
                    StopListening();
                }
                HostManager.UnregisterHost(this);
            }
            _listener.Abort();
            _listener.Close();
            _isDisposed = true;
        }
 static void TryInitializeHosting()
 {
     if (HostManager == null)
     {
         lock (_syncRoot)
         {
             Thread.MemoryBarrier();
             if (HostManager == null)
             {
                 var hostManager = HostManager.RegisterHost(Host);
                 Thread.MemoryBarrier();
                 HostManager = hostManager;
                 try
                 {
                     Host.RaiseStart();
                     Log = HostManager.Resolver.Resolve<ILogger<AspNetLogSource>>();
                 }
                 catch
                 {
                     HostManager.UnregisterHost(Host);
                     HostManager = null;
                 }
             }
         }
     }
 }