当前位置: 首页>>代码示例>>C#>>正文


C# DocumentStateTracker.Dispose方法代码示例

本文整理汇总了C#中DocumentStateTracker.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# DocumentStateTracker.Dispose方法的具体用法?C# DocumentStateTracker.Dispose怎么用?C# DocumentStateTracker.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DocumentStateTracker的用法示例。


在下文中一共展示了DocumentStateTracker.Dispose方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CorrectIndenting

		public override void CorrectIndenting (PolicyContainer policyParent, IEnumerable<string> mimeTypeChain, 
			TextEditorData data, int line)
		{
			LineSegment lineSegment = data.Document.GetLine (line);
			if (lineSegment == null)
				return;

			var policy = policyParent.Get<CFormattingPolicy> (mimeTypeChain);
			var tracker = new DocumentStateTracker<CIndentEngine> (new CIndentEngine (policy), data);
			tracker.UpdateEngine (lineSegment.Offset);
			for (int i = lineSegment.Offset; i < lineSegment.Offset + lineSegment.EditableLength; i++) {
				tracker.Engine.Push (data.Document.GetCharAt (i));
			}

			string curIndent = lineSegment.GetIndentation (data.Document);

			int nlwsp = curIndent.Length;
			if (!tracker.Engine.LineBeganInsideMultiLineComment || (nlwsp < lineSegment.Length && data.Document.GetCharAt (lineSegment.Offset + nlwsp) == '*')) {
				// Possibly replace the indent
				string newIndent = tracker.Engine.ThisLineIndent;
				if (newIndent != curIndent) 
					data.Replace (lineSegment.Offset, nlwsp, newIndent);
			}
			tracker.Dispose ();
		}
开发者ID:famousthom,项目名称:monodevelop,代码行数:25,代码来源:CFormatter.cs

示例2: CorrectIndenting

		public override void CorrectIndenting (object textEditorData, int line)
		{
			TextEditorData data = (TextEditorData)textEditorData;
			LineSegment lineSegment = data.Document.GetLine (line);
			if (lineSegment == null)
				return;
			IEnumerable<string> types = MonoDevelop.Ide.DesktopService.GetMimeTypeInheritanceChain (CSharpFormatter.MimeType);
			var policy = MonoDevelop.Projects.Policies.PolicyService.GetDefaultPolicy<CSharpFormattingPolicy> (types);
			DocumentStateTracker<CSharpIndentEngine> tracker = new DocumentStateTracker<CSharpIndentEngine> (new CSharpIndentEngine (policy), data);
			tracker.UpdateEngine (lineSegment.Offset);
			for (int i = lineSegment.Offset; i < lineSegment.Offset + lineSegment.EditableLength; i++) {
				tracker.Engine.Push (data.Document.GetCharAt (i));
			}
			
			string curIndent = lineSegment.GetIndentation (data.Document);
			
			int nlwsp = curIndent.Length;
//			int cursor = data.Caret.Offset;
//			int pos = lineSegment.Offset;
//			int offset = cursor > pos + nlwsp ? cursor - (pos + nlwsp) : 0;
			if (!tracker.Engine.LineBeganInsideMultiLineComment || (nlwsp < lineSegment.Length && data.Document.GetCharAt (lineSegment.Offset + nlwsp) == '*')) {
				// Possibly replace the indent
				string newIndent = tracker.Engine.ThisLineIndent;
//				int newIndentLength = newIndent.Length;
				if (newIndent != curIndent) 
					data.Replace (lineSegment.Offset, nlwsp, newIndent);
			}
			
/*			
			string endIndent = tracker.Engine.ThisLineIndent;
			string indent = endIndent.Length < beginIndent.Length ? endIndent : beginIndent;
			if (indent != curIndent)
				data.Replace (lineSegment.Offset, curIndent.Length, indent);
						 */
			tracker.Dispose ();
		}
开发者ID:pgoron,项目名称:monodevelop,代码行数:36,代码来源:CSharpFormatter.cs


注:本文中的DocumentStateTracker.Dispose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。