コード例 #1
0
        void OnProcessCreated(WebProjectProperties properties, bool withDebugging)
        {
            string processName = WebProjectService.GetWorkerProcessName(properties);

            Process[] processes = Process.GetProcesses();
            int       index     = processes.FindIndex(p => p.ProcessName.Equals(processName, StringComparison.OrdinalIgnoreCase));

            if (index == -1)
            {
                return;
            }
            if (withDebugging)
            {
                DebuggerService.CurrentDebugger.Attach(processes[index]);

                if (!DebuggerService.CurrentDebugger.IsAttached)
                {
                    if (properties.UseIIS)
                    {
                        string format = ResourceService.GetString("ICSharpCode.WebProjectOptionsPanel.NoIISWP");
                        MessageService.ShowMessage(string.Format(format, processName));
                    }
                }
            }
        }
コード例 #2
0
		void CreateMSBuildProjectWithWebProjectProperties()
		{
			CreateMSBuildProject();
			var properties = new WebProjectProperties();
			var extension = new VisualStudioProjectExtension(properties);
			extension.Save(msbuildProject);
		}
コード例 #3
0
		public static string GetWorkerProcessName(WebProjectProperties properties)
		{
			if (properties.UseIISExpress) {
				return GetIISExpressWorkerProcessName();
			}
			return GetIISWorkerProcessName();
		}
コード例 #4
0
        public void UpdateWebProjectProperties(WebProjectProperties properties)
        {
            var projectExtension = new VisualStudioProjectExtension(properties);

            projectExtension.Save(msbuildProject);
            SetMSBuildProperty("UseIISExpress", properties.UseIISExpress);
        }
コード例 #5
0
 public static string GetWorkerProcessName(WebProjectProperties properties)
 {
     if (properties.UseIISExpress)
     {
         return(GetIISExpressWorkerProcessName());
     }
     return(GetIISWorkerProcessName());
 }
コード例 #6
0
 public WebProjectProperties GetWebProjectProperties()
 {
     if (HasWebProjectProperties())
     {
         var projectExtension            = new VisualStudioProjectExtension(msbuildProject);
         WebProjectProperties properties = projectExtension.GetWebProjectProperties();
         properties.UseIISExpress = UseIISExpress;
         return(properties);
     }
     return(DefaultProperties);
 }
コード例 #7
0
		bool Equals(WebProjectProperties properties)
		{
			return
				(AutoAssignPort == properties.AutoAssignPort) &&
				(UseIIS == properties.UseIIS) &&
				(DevelopmentServerVPath == properties.DevelopmentServerVPath) &&
				(DevelopmentServerPort == properties.DevelopmentServerPort) &&
				(CustomServerUrl == properties.CustomServerUrl) &&
				(UseCustomServer == properties.UseCustomServer) &&
				(SaveServerSettingsInUserFile == properties.SaveServerSettingsInUserFile) &&
				(UseIISExpress == properties.UseIISExpress) &&
				(NTLMAuthentication == properties.NTLMAuthentication) &&
				(IISUrl == properties.IISUrl);
		}
コード例 #8
0
 bool Equals(WebProjectProperties properties)
 {
     return
         ((AutoAssignPort == properties.AutoAssignPort) &&
          (UseIIS == properties.UseIIS) &&
          (DevelopmentServerVPath == properties.DevelopmentServerVPath) &&
          (DevelopmentServerPort == properties.DevelopmentServerPort) &&
          (CustomServerUrl == properties.CustomServerUrl) &&
          (UseCustomServer == properties.UseCustomServer) &&
          (SaveServerSettingsInUserFile == properties.SaveServerSettingsInUserFile) &&
          (UseIISExpress == properties.UseIISExpress) &&
          (NTLMAuthentication == properties.NTLMAuthentication) &&
          (IISUrl == properties.IISUrl));
 }
コード例 #9
0
		public static IISAdministrator CreateAdministrator(WebProjectProperties properties)
		{
			if (properties.UseIISExpress) {
				return new IISExpressAdministrator(properties);
			}
			switch (WebProjectService.IISVersion) {
				case IISVersion.IIS5:
				case IISVersion.IIS6:
					return new IIS6Administrator(properties);
				case IISVersion.None:
					return new NullIISAdministrator();
				default:
					return new IIS7Administrator(properties);
			}
		}
コード例 #10
0
        void AttachToWebWorkerProcessOrStartIISExpress(WebProjectProperties properties, bool withDebugging)
        {
            string processName = WebProjectService.GetWorkerProcessName(properties);

            // try find the worker process directly or using the process monitor callback
            Process[] processes = System.Diagnostics.Process.GetProcesses();
            int       index     = Array.FindIndex(processes, p => properties.UseIISExpress ? p.Id == LastStartedIISExpressProcessId : p.ProcessName.Equals(processName, StringComparison.OrdinalIgnoreCase));

            if (index > -1)
            {
                if (withDebugging)
                {
                    SD.Debugger.Attach(processes[index]);
                }
            }
            else
            {
                if (properties.UseIISExpress)
                {
                    // start IIS express and attach to it
                    if (WebProjectService.IsIISExpressInstalled)
                    {
                        ProcessStartInfo processInfo = IISExpressProcessStartInfo.Create(WebProject);
                        if (withDebugging)
                        {
                            SD.Debugger.Start(processInfo);
                        }
                        else
                        {
                            var process = Process.Start(processInfo);
                            LastStartedIISExpressProcessId = process.Id;
                        }
                    }
                }
                else
                {
                    DisposeProcessMonitor();
                    this.monitor = new ProcessMonitor(processName);
                    this.monitor.ProcessCreated += delegate {
                        SD.MainThread.InvokeAsyncAndForget(() => OnProcessCreated(properties, withDebugging));
                    };
                    this.monitor.Start();
                }
            }
        }
コード例 #11
0
        void AttachToWebWorkerProcessOrStartIISExpress(WebProjectProperties properties, bool withDebugging)
        {
            string processName = WebProjectService.GetWorkerProcessName(properties);

            // try find the worker process directly or using the process monitor callback
            Process[] processes = System.Diagnostics.Process.GetProcesses();
            int       index     = processes.FindIndex(p => p.ProcessName.Equals(processName, StringComparison.OrdinalIgnoreCase));

            if (index > -1)
            {
                if (withDebugging)
                {
                    DebuggerService.CurrentDebugger.Attach(processes[index]);
                }
            }
            else
            {
                if (properties.UseIISExpress)
                {
                    // start IIS express and attach to it
                    if (WebProjectService.IsIISExpressInstalled)
                    {
                        ProcessStartInfo processInfo = IISExpressProcessStartInfo.Create(WebProject);
                        if (withDebugging)
                        {
                            DebuggerService.CurrentDebugger.Start(processInfo);
                        }
                        else
                        {
                            Process.Start(processInfo);
                        }
                    }
                }
                else
                {
                    DisposeProcessMonitor();
                    this.monitor = new ProcessMonitor(processName);
                    this.monitor.ProcessCreated += delegate {
                        WorkbenchSingleton.SafeThreadCall((Action)(() => OnProcessCreated(properties, withDebugging)));
                    };
                    this.monitor.Start();
                }
            }
        }
コード例 #12
0
        public static IISAdministrator CreateAdministrator(WebProjectProperties properties)
        {
            if (properties.UseIISExpress)
            {
                return(new IISExpressAdministrator(properties));
            }
            switch (WebProjectService.IISVersion)
            {
            case IISVersion.IIS5:
            case IISVersion.IIS6:
                return(new IIS6Administrator(properties));

            case IISVersion.None:
                return(new NullIISAdministrator());

            default:
                return(new IIS7Administrator(properties));
            }
        }
コード例 #13
0
		public void Constructor_XElementHasCustomServerUrl_CustomServerUrlPropertyPopulated()
		{
			var properties = new WebProjectProperties() { CustomServerUrl = "/Test" };
			properties = new WebProjectProperties(properties.ToXElement());
			
			Assert.AreEqual("/Test", properties.CustomServerUrl);
		}
コード例 #14
0
		public void IsConfigured_UseIISExpressIsTrueAndIISUrlIsValidUrl_ReturnsTrue()
		{
			var properties = new WebProjectProperties
			{
				UseIISExpress = true,
				IISUrl = "http://localhost:8080/"
			};
			
			bool configured = properties.IsConfigured();
			
			Assert.IsTrue(configured);
		}
コード例 #15
0
ファイル: WebProjectTests.cs プロジェクト: Paccc/SharpDevelop
		void CreateWebProjectFromMSBuildProjectWithWebProjectProperties(WebProjectProperties properties)
		{
			CreateWebProject();
			webProject.UpdateWebProjectProperties(properties);
			CreateWebProject(msbuildProject);
		}
コード例 #16
0
ファイル: WebProjectTests.cs プロジェクト: Paccc/SharpDevelop
		public void GetWebProjectProperties_MSBuildHasUseIISExpressPropertySetToTrue_UseIISExpressPropertyIsTrue()
		{
			CreateWebProjectFromMSBuildProjectWithWebProjectProperties();
			SetUseIISExpressInMSBuildProjectToTrue();
			
			var properties = webProject.GetWebProjectProperties();
			
			var expectedProperties = new WebProjectProperties { UseIISExpress = true };
			
			Assert.AreEqual(expectedProperties, properties);
		}
コード例 #17
0
		public void Constructor_WebPropertyPropertiesXElementHasNoChildElements_ExceptionNotThrown()
		{
			var element = new XElement("WebPropertyProperties");
			var properties = new WebProjectProperties(element);
			
			Assert.AreEqual(String.Empty, properties.IISUrl);
			Assert.AreEqual(String.Empty, properties.CustomServerUrl);
		}
コード例 #18
0
		public void Constructor_XElementHasUseIIS_UseIISPropertyPopulated()
		{
			var properties = new WebProjectProperties() { UseIIS = true };
			properties = new WebProjectProperties(properties.ToXElement());
			
			Assert.IsTrue(properties.UseIIS);
		}
コード例 #19
0
		void CreateWebProject(MSBuildBasedProject project)
		{
			webProject = new WebProject(project);
			properties = webProject.GetWebProjectProperties();
		}
コード例 #20
0
		public void Constructor_XElementHasDevelopmentServerVPath_DevelopmentServerVPathPropertyPopulated()
		{
			var properties = new WebProjectProperties() { DevelopmentServerVPath = "Test" };
			properties = new WebProjectProperties(properties.ToXElement());
			
			Assert.AreEqual("Test", properties.DevelopmentServerVPath);
		}
コード例 #21
0
        public override void Start(bool withDebugging)
        {
            if (!CheckWebProjectStartInfo())
            {
                return;
            }

            try {
                WebProjectProperties properties = WebProject.GetWebProjectProperties();
                string processName = WebProjectService.GetWorkerProcessName(properties);

                // try find the worker process directly or using the process monitor callback
                Process[] processes = System.Diagnostics.Process.GetProcesses();
                int       index     = processes.FindIndex(p => p.ProcessName.Equals(processName, StringComparison.OrdinalIgnoreCase));
                if (index > -1)
                {
                    if (withDebugging)
                    {
                        DebuggerService.CurrentDebugger.Attach(processes[index]);
                    }
                }
                else
                {
                    if (properties.UseIISExpress)
                    {
                        // start IIS express and attach to it
                        if (WebProjectService.IsIISExpressInstalled)
                        {
                            ProcessStartInfo processInfo = IISExpressProcessStartInfo.Create(WebProject);
                            DebuggerService.CurrentDebugger.Start(processInfo);
                        }
                        else
                        {
                            DisposeProcessMonitor();
                            MessageService.ShowError("${res:ICSharpCode.WebProjectOptionsPanel.NoProjectUrlOrProgramAction}");
                            return;
                        }
                    }
                    else
                    {
                        DisposeProcessMonitor();
                        this.monitor = new ProcessMonitor(processName);
                        this.monitor.ProcessCreated += delegate {
                            WorkbenchSingleton.SafeThreadCall((Action)(() => OnProcessCreated(properties, withDebugging)));
                        };
                        this.monitor.Start();
                    }
                }

                // start default application(e.g. browser) or the one specified
                switch (CompilableProject.StartAction)
                {
                case StartAction.Project:
                    if (FileUtility.IsUrl(properties.IISUrl))
                    {
                        Process.Start(properties.IISUrl);
                    }
                    else
                    {
                        MessageService.ShowError("${res:ICSharpCode.WebProjectOptionsPanel.NoProjectUrlOrProgramAction}");
                        DisposeProcessMonitor();
                    }
                    break;

                case StartAction.Program:
                    Process.Start(StartProgram);
                    break;

                case StartAction.StartURL:
                    if (FileUtility.IsUrl(StartUrl))
                    {
                        Process.Start(StartUrl);
                    }
                    else
                    {
                        string url = string.Concat(properties.IISUrl, StartUrl);
                        if (FileUtility.IsUrl(url))
                        {
                            Process.Start(url);
                        }
                        else
                        {
                            MessageService.ShowError("${res:ICSharpCode.WebProjectOptionsPanel.NoProjectUrlOrProgramAction}");
                            DisposeProcessMonitor();
                            return;
                        }
                    }
                    break;

                default:
                    throw new Exception("Invalid value for StartAction");
                }
            } catch (Exception ex) {
                MessageService.ShowError(ex.Message);
                LoggingService.Error(ex.ToString());
                DisposeProcessMonitor();
            }
        }
コード例 #22
0
 protected IISAdministrator(WebProjectProperties properties)
 {
     this.Properties = properties;
 }
コード例 #23
0
		void CreateTwoWebProjectProperties()
		{
			lhs = new WebProjectProperties();
			rhs = new WebProjectProperties();
		}
コード例 #24
0
		public void IsConfigured_UseIISIsTrueAndIISUrlIsNull_ReturnsFalse()
		{
			var properties = new WebProjectProperties
			{
				UseIISExpress = true,
				IISUrl = null
			};
			
			bool configured = properties.IsConfigured();
			
			Assert.IsFalse(configured);
		}
コード例 #25
0
		public void IsConfigured_UseIISExpressIsTrueAndIISUrlIsEmptyString_ReturnsFalse()
		{
			var properties = new WebProjectProperties
			{
				UseIISExpress = true,
				IISUrl = String.Empty
			};
			
			bool configured = properties.IsConfigured();
			
			Assert.IsFalse(configured);
		}
コード例 #26
0
		void AttachToWebWorkerProcessOrStartIISExpress(WebProjectProperties properties, bool withDebugging)
		{
			string processName = WebProjectService.GetWorkerProcessName(properties);
			
			// try find the worker process directly or using the process monitor callback
			Process[] processes = System.Diagnostics.Process.GetProcesses();
			int index = Array.FindIndex(processes, p => properties.UseIISExpress ? p.Id == LastStartedIISExpressProcessId : p.ProcessName.Equals(processName, StringComparison.OrdinalIgnoreCase));
			if (index > -1) {
				if (withDebugging)
					SD.Debugger.Attach(processes[index]);
			} else {
				if (properties.UseIISExpress) {
					// start IIS express and attach to it
					if (WebProjectService.IsIISExpressInstalled) {
						ProcessStartInfo processInfo = IISExpressProcessStartInfo.Create(WebProject);
						if (withDebugging) {
							SD.Debugger.Start(processInfo);
						} else {
							var process = Process.Start(processInfo);
							LastStartedIISExpressProcessId = process.Id;
						}
					}
				} else {
					DisposeProcessMonitor();
					this.monitor = new ProcessMonitor(processName);
					this.monitor.ProcessCreated += delegate {
						SD.MainThread.InvokeAsyncAndForget(() => OnProcessCreated(properties, withDebugging));
					};
					this.monitor.Start();
				}
			}
		}
コード例 #27
0
		public IISExpressAdministrator(WebProjectProperties properties)
			: base(properties)
		{
		}
コード例 #28
0
		void OnProcessCreated(WebProjectProperties properties, bool withDebugging)
		{
			string processName = WebProjectService.GetWorkerProcessName(properties);
			Process[] processes = Process.GetProcesses();
			int index = Array.FindIndex(processes, p => p.ProcessName.Equals(processName, StringComparison.OrdinalIgnoreCase));
			if (index == -1)
				return;
			if (withDebugging) {
				SD.Debugger.Attach(processes[index]);
				
				if (!SD.Debugger.IsAttached) {
					if(properties.UseIIS) {
						string format = ResourceService.GetString("ICSharpCode.WebProjectOptionsPanel.NoIISWP");
						MessageService.ShowMessage(string.Format(format, processName));
					}
				}
			}
		}
コード例 #29
0
		public void Constructor_XElementHasUseCustomServer_UseCustomServerPropertyPopulated()
		{
			var properties = new WebProjectProperties() { UseCustomServer = true };
			properties = new WebProjectProperties(properties.ToXElement());
			
			Assert.IsTrue(properties.UseCustomServer);
		}
コード例 #30
0
		protected IISAdministrator(WebProjectProperties properties)
		{
			this.Properties = properties;
		}
コード例 #31
0
 public VisualStudioProjectExtension(WebProjectProperties properties)
 {
     this.webProjectProperties = properties;
 }
コード例 #32
0
		public VisualStudioProjectExtension(WebProjectProperties properties)
		{
			this.webProjectProperties = properties;
		}
コード例 #33
0
ファイル: WebBehavior.cs プロジェクト: Netring/SharpDevelop
		void AttachToWebWorkerProcessOrStartIISExpress(WebProjectProperties properties, bool withDebugging)
		{
			string processName = WebProjectService.GetWorkerProcessName(properties);
			
			// try find the worker process directly or using the process monitor callback
			Process[] processes = System.Diagnostics.Process.GetProcesses();
			int index = processes.FindIndex(p => p.ProcessName.Equals(processName, StringComparison.OrdinalIgnoreCase));
			if (index > -1) {
				if (withDebugging)
					DebuggerService.CurrentDebugger.Attach(processes[index]);
			} else {
				if (properties.UseIISExpress) {
					// start IIS express and attach to it
					if (WebProjectService.IsIISExpressInstalled) {
						ProcessStartInfo processInfo = IISExpressProcessStartInfo.Create(WebProject);
						if (withDebugging)
							DebuggerService.CurrentDebugger.Start(processInfo);
						else
							Process.Start(processInfo);
					}
				} else {
					DisposeProcessMonitor();
					this.monitor = new ProcessMonitor(processName);
					this.monitor.ProcessCreated += delegate {
						WorkbenchSingleton.SafeThreadCall((Action)(() => OnProcessCreated(properties, withDebugging)));
					};
					this.monitor.Start();
				}
			}
		}
コード例 #34
0
ファイル: WebProjectTests.cs プロジェクト: Paccc/SharpDevelop
		public void GetWebProjectProperties_MSBuildHasWebProjectProperties_ReadsWebProjectPropertiesFromMSBuildProject()
		{
			var expectedProperties = new WebProjectProperties
			{
				DevelopmentServerPort = 8989,
				IISUrl = "http://localhost:8989/test"
			};
			CreateWebProjectFromMSBuildProjectWithWebProjectProperties(expectedProperties);
			
			WebProjectProperties properties = webProject.GetWebProjectProperties();
			
			Assert.AreEqual(expectedProperties, properties);
		}
コード例 #35
0
		public void Constructor_XElementHasSaveServerSettingsInUserFile_SaveServerSettingsInUserFilePropertyPopulated()
		{
			var properties = new WebProjectProperties() { SaveServerSettingsInUserFile = true };
			properties = new WebProjectProperties(properties.ToXElement());
			
			Assert.IsTrue(properties.SaveServerSettingsInUserFile);
		}
コード例 #36
0
ファイル: WebProjectTests.cs プロジェクト: Paccc/SharpDevelop
		public void UpdateWebProjectProperties_UseIISExpressIsTrue_MSBuildProjectIISExpressPropertySetToTrue()
		{
			CreateWebProject();
			var properties = new WebProjectProperties { UseIISExpress = true };
			
			webProject.UpdateWebProjectProperties(properties);
			
			string value = msbuildProject.GetEvaluatedProperty("UseIISExpress");
			
			Assert.AreEqual("True", value);
		}
コード例 #37
0
        public override void Start(bool withDebugging)
        {
            try {
                WebProjectProperties properties = WebProject.GetWebProjectProperties();
                if (CheckWebProjectStartInfo())
                {
                    AttachToWebWorkerProcessOrStartIISExpress(properties, withDebugging);
                }

                // start default application(e.g. browser) or the one specified
                switch (CompilableProject.StartAction)
                {
                case StartAction.Project:
                    if (FileUtility.IsUrl(properties.IISUrl))
                    {
                        Process.Start(properties.IISUrl);
                    }
                    else
                    {
                        MessageService.ShowError("${res:ICSharpCode.WebProjectOptionsPanel.NoProjectUrlOrProgramAction}");
                        DisposeProcessMonitor();
                    }
                    break;

                case StartAction.Program:
                    ProcessStartInfo processInfo = DotNetStartBehavior.CreateStartInfo(StartProgram, Project.Directory, StartWorkingDirectory, StartArguments);
                    if (withDebugging)
                    {
                        DebuggerService.CurrentDebugger.Start(processInfo);
                    }
                    else
                    {
                        Process.Start(processInfo);
                    }
                    break;

                case StartAction.StartURL:
                    if (FileUtility.IsUrl(StartUrl))
                    {
                        Process.Start(StartUrl);
                    }
                    else
                    {
                        string url = string.Concat(properties.IISUrl, StartUrl);
                        if (FileUtility.IsUrl(url))
                        {
                            Process.Start(url);
                        }
                        else
                        {
                            MessageService.ShowError("${res:ICSharpCode.WebProjectOptionsPanel.NoProjectUrlOrProgramAction}");
                            DisposeProcessMonitor();
                            return;
                        }
                    }
                    break;

                default:
                    throw new Exception("Invalid value for StartAction");
                }
            } catch (Exception ex) {
                MessageService.ShowError(ex.Message);
                LoggingService.Error(ex.ToString());
                DisposeProcessMonitor();
            }
        }
コード例 #38
0
 public IISExpressAdministrator(WebProjectProperties properties)
     : base(properties)
 {
 }
コード例 #39
0
		public void IsConfigured_UseIISAndUseIISExpressAreBothFalse_ReturnsFalse()
		{
			var properties = new WebProjectProperties() { UseIISExpress = false, UseIIS = false };
			
			bool configured = properties.IsConfigured();
			
			Assert.IsFalse(configured);
		}
コード例 #40
0
		public void Constructor_XElementHasAutoAssignPort_AutoAssignPortPropertyPopulated()
		{
			var properties = new WebProjectProperties() { AutoAssignPort = true };
			properties = new WebProjectProperties(properties.ToXElement());
			
			Assert.IsTrue(properties.AutoAssignPort);
		}
コード例 #41
0
		public void Constructor_XElementHasNTLMAuthentication_NTLMAuthenticationPropertyPopulated()
		{
			var properties = new WebProjectProperties() { NTLMAuthentication = true };
			properties = new WebProjectProperties(properties.ToXElement());
			
			Assert.IsTrue(properties.NTLMAuthentication);
		}
コード例 #42
0
ファイル: WebProject.cs プロジェクト: hefnerliu/SharpDevelop
		public void UpdateWebProjectProperties(WebProjectProperties properties)
		{
			var projectExtension = new VisualStudioProjectExtension(properties);
			projectExtension.Save(msbuildProject);
			SetMSBuildProperty("UseIISExpress", properties.UseIISExpress);
		}
コード例 #43
0
 void CreateWebProject(MSBuildBasedProject project)
 {
     webProject = new WebProject(project);
     properties = webProject.GetWebProjectProperties();
 }