コード例 #1
0
ファイル: AspNetTesting.cs プロジェクト: Kalnor/monodevelop
		static AspNetTestingEditorExtension CreateEditor (string text, string extension, out string editorText, out TestViewContent sev)
		{
			string parsedText;
			int cursorPosition = text.IndexOf ('$');
			int endPos = text.IndexOf ('$', cursorPosition + 1);
			if (endPos == -1)
				parsedText = editorText = text.Substring (0, cursorPosition) + text.Substring (cursorPosition + 1);
			else {
				parsedText = text.Substring (0, cursorPosition) + new string (' ', endPos - cursorPosition) + text.Substring (endPos + 1);
				editorText = text.Substring (0, cursorPosition) + text.Substring (cursorPosition + 1, endPos - cursorPosition - 1) + text.Substring (endPos + 1);
				cursorPosition = endPos - 1;
			}

			var project = new AspNetAppProject ("C#");
			project.References.Add (new ProjectReference (ReferenceType.Package, "System"));
			project.References.Add (new ProjectReference (ReferenceType.Package, "System.Web"));
			project.FileName = UnitTests.TestBase.GetTempFile (".csproj");
			string file = UnitTests.TestBase.GetTempFile (extension);
			project.AddFile (file);

			var pcw = TypeSystemService.LoadProject (project);
			TypeSystemService.ForceUpdate (pcw);
			pcw.ReconnectAssemblyReferences ();

			sev = new TestViewContent ();
			sev.Project = project;
			sev.ContentName = file;
			sev.Text = editorText;
			sev.CursorPosition = cursorPosition;

			var tww = new TestWorkbenchWindow ();
			tww.ViewContent = sev;

			var doc = new TestDocument (tww);
			doc.Editor.Document.FileName = sev.ContentName;
			var parser = new AspNetParser ();
			var parsedDoc = (AspNetParsedDocument) parser.Parse (false, sev.ContentName, new StringReader (parsedText), project);
			doc.HiddenParsedDocument = parsedDoc;

			return new AspNetTestingEditorExtension (doc);
		}
コード例 #2
0
ファイル: Document.cs プロジェクト: segaman/monodevelop
		/// <summary>
		/// Parses a given string
		/// </summary>
		/// <param name='doc'>
		/// ASP.NET document
		/// </param>
		/// <param name='fileName'>
		/// File name.
		/// </param>
		AspNetParsedDocument Parse (string doc, string fileName)
		{
			AspNetParsedDocument parsedDoc = null;
			AspNetParser parser = new AspNetParser ();
			using (StringReader strRd = new StringReader (doc)) {
				parsedDoc = parser.Parse (true, fileName, strRd, textEditor.Project) as AspNetParsedDocument;
			}
			return parsedDoc;
		}