C# CSharp.CSharpFormattingOptions类代码示例

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


C# CSharp.CSharpFormattingOptions类代码示例

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

本文标签属性:

示例:示例英文

代码:代码大全可复制

CSharp:csharp是什么

上一篇:C++ twindow::register_hotkey方法代码示例
下一篇:Java HtmlAnchor类代码示例

为您推荐