• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# CSharp.CSharpFormattingOptions类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中ICSharpCode.NRefactory.CSharp.CSharpFormattingOptions的典型用法代码示例。如果您正苦于以下问题:C# CSharpFormattingOptions类的具体用法?C# CSharpFormattingOptions怎么用?C# CSharpFormattingOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



CSharpFormattingOptions类属于ICSharpCode.NRefactory.CSharp命名空间,在下文中一共展示了CSharpFormattingOptions类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: TestClassIndentationInNamespacesCase2

		public void TestClassIndentationInNamespacesCase2 ()
		{
			CSharpFormattingOptions policy = new CSharpFormattingOptions ();
			policy.NamespaceBraceStyle = BraceStyle.NextLine;
			policy.ClassBraceStyle = BraceStyle.NextLine;
			policy.ConstructorBraceStyle = BraceStyle.NextLine;
			
			Test (policy,
@"using System;

namespace MonoDevelop.CSharp.Formatting {
	public class FormattingProfileService {
		public FormattingProfileService () {
		}
	}
}",
@"using System;

namespace MonoDevelop.CSharp.Formatting
{
	public class FormattingProfileService
	{
		public FormattingProfileService ()
		{
		}
	}
}");
		}
开发者ID:rmattuschka,项目名称:ILSpy,代码行数:28,代码来源:TestTypeLevelIndentation.cs


示例2: Test

		protected static IDocument Test (CSharpFormattingOptions policy, string input, string expectedOutput, FormattingMode mode = FormattingMode.Intrusive, TextEditorOptions options = null)
		{
			expectedOutput = NormalizeNewlines(expectedOutput);

			IDocument doc = GetResult(policy, input, mode, options);
			if (expectedOutput != doc.Text) {
				Console.WriteLine ("expected:");
				Console.WriteLine (expectedOutput);
				Console.WriteLine ("got:");
				Console.WriteLine (doc.Text);
				for (int i = 0; i < expectedOutput.Length && i < doc.TextLength; i++) {
					if (expectedOutput [i] != doc.GetCharAt(i)) {
						Console.WriteLine (
							"i:"+i+" differ:"+ 
							expectedOutput[i].ToString ().Replace ("\n", "\\n").Replace ("\r", "\\r").Replace ("\t", "\\t") +
							" !=" + 
							doc.GetCharAt(i).ToString ().Replace ("\n", "\\n").Replace ("\r", "\\r").Replace ("\t", "\\t")
						);
						Console.WriteLine(">"+expectedOutput.Substring (i).Replace ("\n", "\\n").Replace ("\r", "\\r").Replace ("\t", "\\t"));
						Console.WriteLine(">"+doc.Text.Substring (i).Replace ("\n", "\\n").Replace ("\r", "\\r").Replace ("\t", "\\t"));
						break;
					}
				}
			}
			Assert.AreEqual (expectedOutput, doc.Text);
			return doc;
		}
开发者ID:0xb1dd1e,项目名称:NRefactory,代码行数:27,代码来源:TextEditorTestAdapter.cs


示例3: TestNamespaceBraceStyle

		public void TestNamespaceBraceStyle ()
		{
			CSharpFormattingOptions policy = new CSharpFormattingOptions ();
			policy.NamespaceBraceStyle = BraceStyle.EndOfLine;
			policy.ClassBraceStyle = BraceStyle.DoNotChange;
			
			var adapter = Test (policy, @"namespace A
{
namespace B {
	class Test {}
}
}",
@"namespace A {
	namespace B {
		class Test {}
	}
}");
			
			policy.NamespaceBraceStyle = BraceStyle.NextLineShifted;
			Continue (policy, adapter,
@"namespace A
	{
	namespace B
		{
		class Test {}
		}
	}");
		}
开发者ID:awatertree,项目名称:NRefactory,代码行数:28,代码来源:TestBraceStlye.cs


示例4: TestBlankLinesBeforeUsings

		public void TestBlankLinesBeforeUsings ()
		{
			CSharpFormattingOptions policy = new CSharpFormattingOptions ();
			policy.BlankLinesAfterUsings = 0;
			policy.BlankLinesBeforeUsings = 2;
			
			var adapter = Test (policy, @"using System;
using System.Text;
namespace Test
{
}",
@"

using System;
using System.Text;
namespace Test
{
}", FormattingMode.Intrusive);
			
			policy.BlankLinesBeforeUsings = 0;
			Continue (policy, adapter, 
@"using System;
using System.Text;
namespace Test
{
}", FormattingMode.Intrusive);
		}
开发者ID:awatertree,项目名称:NRefactory,代码行数:27,代码来源:TestBlankLineFormatting.cs


示例5: Format

		/// <summary>
		/// Formats the specified part of the document.
		/// </summary>
		public static void Format(ITextEditor editor, int offset, int length, CSharpFormattingOptions options)
		{
			var formatter = new CSharpFormatter(options, editor.ToEditorOptions());
			formatter.AddFormattingRegion(new DomRegion(editor.Document.GetLocation(offset), editor.Document.GetLocation(offset + length)));
			var changes = formatter.AnalyzeFormatting(editor.Document, SyntaxTree.Parse(editor.Document));
			changes.ApplyChanges(offset, length);
		}
开发者ID:Paccc,项目名称:SharpDevelop,代码行数:10,代码来源:CSharpFormatter.cs


示例6: TestIndentBlocks

		public void TestIndentBlocks ()
		{
			CSharpFormattingOptions policy = new CSharpFormattingOptions ();
			policy.IndentBlocks = true;
			
			var adapter = Test (policy,
@"class Test {
	Test TestMethod ()
	{
{
{}
}
	}
}",
@"class Test
{
	Test TestMethod ()
	{
		{
			{}
		}
	}
}");
			policy.IndentBlocks = false;
			Continue (policy, adapter, @"class Test
{
	Test TestMethod ()
	{
		{
		{}
		}
	}
}");
		}
开发者ID:95ulisse,项目名称:ILEdit,代码行数:34,代码来源:TestStatementIndentation.cs


示例7: TestBlankLinesBeforeFirstDeclaration

        public void TestBlankLinesBeforeFirstDeclaration()
        {
            CSharpFormattingOptions policy = new CSharpFormattingOptions ();
            policy.BlankLinesBeforeFirstDeclaration = 2;

            var adapter = Test (policy, @"namespace Test
            {
            class Test
            {
            }
            }",
            @"namespace Test
            {

            class Test
            {
            }
            }");

            policy.BlankLinesBeforeFirstDeclaration = 0;
            Continue (policy, adapter,
            @"namespace Test
            {
            class Test
            {
            }
            }");
        }
开发者ID:tapenjoyGame,项目名称:ILSpy,代码行数:28,代码来源:TestBlankLineFormatting.cs


示例8: EditorScript

		public EditorScript(ITextEditor editor, SDRefactoringContext context, CSharpFormattingOptions formattingOptions)
			: base(editor.Document, formattingOptions, context.TextEditorOptions)
		{
			this.editor = editor;
			this.context = context;
			this.textSegmentCollection = new TextSegmentCollection<TextSegment>((TextDocument)editor.Document);
		}
开发者ID:kristjan84,项目名称:SharpDevelop,代码行数:7,代码来源:EditorScript.cs


示例9: RandomTests

		public static void RandomTests(string filePath, int count, CSharpFormattingOptions policy = null, TextEditorOptions options = null)
		{
			if (File.Exists(filePath))
			{
				var code = File.ReadAllText(filePath);
				var document = new ReadOnlyDocument(code);
				policy = policy ?? FormattingOptionsFactory.CreateMono();
				options = options ?? new TextEditorOptions { IndentBlankLines = false };

				var engine = new CacheIndentEngine(new CSharpIndentEngine(document, options, policy) { EnableCustomIndentLevels = true });
				Random rnd = new Random();

				for (int i = 0; i < count; i++) {
					int offset = rnd.Next(document.TextLength);
					engine.Update(offset);
					if (engine.CurrentIndent.Length == 0)
						continue;
				}

			}
			else
			{
				Assert.Fail("File " + filePath + " doesn't exist.");
			}
		}
开发者ID:scemino,项目名称:NRefactory,代码行数:25,代码来源:Helper.cs


示例10: MDRefactoringScript

		public MDRefactoringScript (MDRefactoringContext context, CSharpFormattingOptions formattingOptions) : base(context.TextEditor.Document, formattingOptions, context.TextEditor.CreateNRefactoryTextEditorOptions ())
		{
			this.context = context;
			undoGroup  = this.context.TextEditor.OpenUndoGroup ();
			this.startVersion = this.context.TextEditor.Version;

		}
开发者ID:sturmrutsturm,项目名称:monodevelop,代码行数:7,代码来源:MDRefactoringScript.cs


示例11: CreateEngine

		public static CacheIndentEngine CreateEngine(string text, CSharpFormattingOptions formatOptions = null, TextEditorOptions options = null)
		{
			if (formatOptions == null) {
				formatOptions = FormattingOptionsFactory.CreateMono();
				formatOptions.AlignToFirstIndexerArgument = formatOptions.AlignToFirstMethodCallArgument = true;
			}
			
			var sb = new StringBuilder();
			int offset = 0;
			for (int i = 0; i < text.Length; i++) {
				var ch = text [i];
				if (ch == '$') {
					offset = i;
					continue;
				}
				sb.Append(ch);
			}
			
			var document = new ReadOnlyDocument(sb.ToString());
			options = options ?? new TextEditorOptions { EolMarker = "\n" };
			
			var result = new CacheIndentEngine(new CSharpIndentEngine(document, options, formatOptions));
			result.Update(offset);
			return result;
		}
开发者ID:asiazhang,项目名称:SharpDevelop,代码行数:25,代码来源:TextPasteIndentEngineTests.cs


示例12: CSharpFormatter

 /// <summary>
 /// Initializes a new instance of the <see cref="ICSharpCode.NRefactory.CSharp.CSharpFormatter"/> class.
 /// </summary>
 /// <param name="policy">The formatting policy to use.</param>
 /// <param name="document">The text document to work upon.</param>
 /// <param name="options">The text editor options (optional). Default is: TextEditorOptions.Default</param>
 public CSharpFormatter(CSharpFormattingOptions policy, TextEditorOptions options = null)
 {
     if (policy == null)
         throw new ArgumentNullException("policy");
     this.policy = policy;
     this.options = options ?? TextEditorOptions.Default;
 }
开发者ID:CSRedRat,项目名称:NRefactory,代码行数:13,代码来源:CSharpFormatter.cs


示例13: TextPasteIndentEngine

		/// <summary>
		///     Creates a new TextPasteIndentEngine instance.
		/// </summary>
		/// <param name="decoratedEngine">
		///     An instance of <see cref="IStateMachineIndentEngine"/> to which the
		///     logic for indentation will be delegated.
		/// </param>
		/// <param name="textEditorOptions">
		///    Text editor options for indentation.
		/// </param>
		/// <param name="formattingOptions">
		///     C# formatting options.
		/// </param>
		public TextPasteIndentEngine(IStateMachineIndentEngine decoratedEngine, TextEditorOptions textEditorOptions, CSharpFormattingOptions formattingOptions)
		{
			this.engine = decoratedEngine;
			this.textEditorOptions = textEditorOptions;
			this.formattingOptions = formattingOptions;

			this.engine.EnableCustomIndentLevels = false;
		}
开发者ID:asiazhang,项目名称:SharpDevelop,代码行数:21,代码来源:TextPasteIndentEngine.cs


示例14: Format

 /// <summary>
 /// Formats the specified part of the document.
 /// </summary>
 public static void Format(IDocument document, int offset, int length, CSharpFormattingOptions options)
 {
     var syntaxTree = new CSharpParser().Parse(document);
     var fv = new AstFormattingVisitor(options, document);
     fv.FormattingRegion = new DomRegion(document.GetLocation(offset), document.GetLocation(offset + length));
     syntaxTree.AcceptVisitor(fv);
     fv.ApplyChanges(offset, length);
 }
开发者ID:sentientpc,项目名称:SharpSnippetCompiler-v5,代码行数:11,代码来源:CSharpFormatter.cs


示例15: WriteNode

 public static IDictionary<AstNode, ISegment> WriteNode(StringWriter writer, AstNode node, CSharpFormattingOptions policy, ICSharpCode.AvalonEdit.TextEditorOptions options)
 {
     var formatter = new SegmentTrackingOutputFormatter(writer);
     formatter.IndentationString = options.IndentationString;
     var visitor = new CSharpOutputVisitor(formatter, policy);
     node.AcceptVisitor(visitor);
     return formatter.Segments;
 }
开发者ID:sentientpc,项目名称:SharpSnippetCompiler-v5,代码行数:8,代码来源:SegmentTrackingOutputFormatter.cs


示例16: GetResult

		protected static IDocument GetResult(CSharpFormattingOptions policy, string input, FormattingMode mode = FormattingMode.Intrusive, TextEditorOptions options = null)
		{
			StringBuilderDocument document;
			var changes = GetChanges(policy, input, out document, mode, options);
			
			changes.ApplyChanges();
			return document;
		}
开发者ID:0xb1dd1e,项目名称:NRefactory,代码行数:8,代码来源:TextEditorTestAdapter.cs


示例17: CSharpIndentEngine

 public CSharpIndentEngine(IDocument document, TextEditorOptions textEditorOptions, CSharpFormattingOptions formattingOptions)
 {
     this.document = document;
     this.options = formattingOptions;
     this.textEditorOptions = textEditorOptions;
     this.indent = new Indent(textEditorOptions);
     this.thisLineindent = new Indent(textEditorOptions);
 }
开发者ID:artifexor,项目名称:NRefactory,代码行数:8,代码来源:CSharpIndentEngine.cs


示例18: AssertOutput

		void AssertOutput(string expected, Expression expr, CSharpFormattingOptions policy = null)
		{
			if (policy == null)
				policy = new CSharpFormattingOptions();;
			StringWriter w = new StringWriter();
			w.NewLine = "\n";
			expr.AcceptVisitor(new CSharpOutputVisitor(new TextWriterOutputFormatter(w) { IndentationString = "\t" }, policy), null);
			Assert.AreEqual(expected.Replace("\r", ""), w.ToString());
		}
开发者ID:sbeparey,项目名称:ILSpy,代码行数:9,代码来源:CSharpOutputVisitorTests.cs


示例19: PatchTask

 public PatchTask(ITaskInterface taskInterface, string baseDir, string srcDir, string patchDir,
         CSharpFormattingOptions format = null)
     : base(taskInterface)
 {
     this.baseDir = baseDir;
     this.srcDir = srcDir;
     this.patchDir = patchDir;
     this.format = format;
 }
开发者ID:Evarenis,项目名称:tModLoader,代码行数:9,代码来源:PatchTask.cs


示例20: AssertOutput

		void AssertOutput(string expected, AstNode node, CSharpFormattingOptions policy = null)
		{
			if (policy == null)
				policy = FormattingOptionsFactory.CreateMono();
			StringWriter w = new StringWriter();
			w.NewLine = "\n";
			node.AcceptVisitor(new CSharpOutputVisitor(new TextWriterOutputFormatter(w) { IndentationString = "$" }, policy));
			Assert.AreEqual(expected.Replace("\r", ""), w.ToString());
		}
开发者ID:Gobiner,项目名称:ILSpy,代码行数:9,代码来源:CSharpOutputVisitorTests.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# CSharp.CSharpFormattingPolicy类代码示例发布时间:2022-05-26
下一篇:
C# Ast.VariableDeclaration类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap