public void ApplyChanges(TargetProjectComparisonResult comparison, string outputProjectPath)
		{
			foreach(var newClass in comparison.ClassesToAdd)
			{
				string userFilePath = Path.Combine(Path.GetDirectoryName(outputProjectPath), newClass.UserFileRelativePath);
				if (!File.Exists(userFilePath))
				{
					this.CreateUserFile(newClass, userFilePath);
				}
				string designerFilePath = Path.Combine(Path.GetDirectoryName(outputProjectPath), newClass.DesignerFileRelativePath);
				//if (!File.Exists(designerFilePath))
				//{
					switch (newClass.SourceObjectType)
					{
						case EnumSourceObjectType.MasterPage:
							this.CreateDesignerMasterPageFile(newClass, designerFilePath);
							break;
						case EnumSourceObjectType.WebPage:
							this.CreateDesignerWebPageFile(newClass, designerFilePath);
							break;
						default:
							throw new UnknownEnumValueException(newClass.SourceObjectType);
					}
				//}
				ProjectParser parser = new ProjectParser();
				parser.EnsureFileInclude(outputProjectPath, newClass.UserFileRelativePath, null);
				parser.EnsureFileInclude(outputProjectPath, newClass.DesignerFileRelativePath, newClass.UserFileRelativePath);
			}
			foreach(var updatedClass in comparison.ClassesToUpdate)
			{
				string designerFilePath = Path.Combine(Path.GetDirectoryName(outputProjectPath), updatedClass.DesignerFileRelativePath);
				//if (!File.Exists(designerFilePath))
				//{
				switch (updatedClass.SourceObjectType)
				{
					case EnumSourceObjectType.MasterPage:
						this.CreateDesignerMasterPageFile(updatedClass, designerFilePath);
						break;
					case EnumSourceObjectType.WebPage:
						this.CreateDesignerWebPageFile(updatedClass, designerFilePath);
						break;
					default:
						throw new UnknownEnumValueException(updatedClass.SourceObjectType);
				}
				//}
				ProjectParser parser = new ProjectParser();
				parser.EnsureFileInclude(outputProjectPath, updatedClass.DesignerFileRelativePath, updatedClass.DesignerFileRelativePath);
			}
		}
Exemple #2
0
		static void Main()
		{
			//string inputProject = @"C:\Users\admin\Dropbox\Code\screwturn-screwturn-wiki-4-cf9155b27d4c\WebApplication\WebApplication.csproj";
			string inputProjectPath = @"..\..\..\..\BugNet\src\BugNET_WAP\BugNET_WAP.csproj";
			//string outputProjectPath = @"C:\Users\admin\Dropbox\Code\MMDB.UITest\ScrewturnWikiProxySample\ScrewturnWikiProxySample.csproj";
			string outputProjectPath = @"..\..\..\BugNetProxySample\BugNetProxySample.csproj";
			var sourceProjectFile = new ProjectParser().ParseFile(inputProjectPath);
			var sourceModel = new SourceWebModelParser().LoadFromProjectFile(sourceProjectFile, inputProjectPath);

			var targetProjectFile = new ProjectParser().ParseFile(outputProjectPath);
			var targetModel = new TargetModelParser().LoadFromProjectFile(targetProjectFile, outputProjectPath);

			var comparison = new TargetModelGenerator().CompareProject(targetModel, sourceModel);
			new TargetModelWriter().ApplyChanges(comparison, outputProjectPath);

			//ProxyGenerator.UpdateProxyProject(outputProjectPath, sourceProject);
			Application.EnableVisualStyles();
			Application.SetCompatibleTextRenderingDefault(false);
			Application.Run(new Form1());

		}
Exemple #3
0
        public void EnsureFiles(string targetProjectPath)
		{
			string userFilePath = Path.Combine(Path.GetDirectoryName(targetProjectPath), this.UserFileRelativePath);
			if (!File.Exists(userFilePath))
			{
				this.CreateUserFile(userFilePath);
			}

			string designerFilePath = Path.Combine(Path.GetDirectoryName(targetProjectPath), this.DesignerFileRelativePath);
			if (!File.Exists(designerFilePath))
			{
				switch(this.SourceObjectType)
				{
					case EnumSourceObjectType.MasterPage:
						this.CreateDesignerMasterPageFile(designerFilePath);
						break;
					case EnumSourceObjectType.WebPage:
						this.CreateWebPageFile(designerFilePath);
						break;
					default:
						throw new UnknownEnumValueException(this.SourceObjectType);
				}
			}
			
			ProjectParser parser = new ProjectParser();
			parser.EnsureFileInclude(targetProjectPath, this.UserFileRelativePath, null);
			parser.EnsureFileInclude(targetProjectPath, this.DesignerFileRelativePath, this.UserFileRelativePath);
		}
		public TargetProject LoadFromProjectFile(string targetProjectPath)
		{
			ProjectParser parser = new ProjectParser();
			var csProject = parser.ParseFile(targetProjectPath);
			return LoadFromProjectFile(csProject, targetProjectPath);
		}