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


C# CSharpFormattingPolicy类代码示例

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


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

示例1: TestNamespaceBraceStyle

		public void TestNamespaceBraceStyle ()
		{
			TextEditorData data = new TextEditorData ();
			data.Document.FileName = "a.cs";
			data.Document.Text = @"namespace A
{
namespace B {
	class Test {}
}
}";
			
			CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
			policy.NamespaceBraceStyle = BraceStyle.EndOfLine;
			policy.ClassBraceStyle = BraceStyle.DoNotChange;
			
			CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data);
			compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null);
			Assert.AreEqual (@"namespace A {
	namespace B {
		class Test {}
	}
}", data.Document.Text);
			
			policy.NamespaceBraceStyle = BraceStyle.NextLineShifted;
			compilationUnit = new CSharpParser ().Parse (data);
			compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null);
			Assert.AreEqual (@"namespace A
	{
	namespace B
		{
		class Test {}
		}
	}", data.Document.Text);
		}
开发者ID:stewartwhaley,项目名称:monodevelop,代码行数:34,代码来源:TestBraceStlye.cs

示例2: TestIndentClassBody

		public void TestIndentClassBody ()
		{
			TextEditorData data = new TextEditorData ();
			data.Document.FileName = "a.cs";
			data.Document.Text = 
@"class Test
{
				Test a;
}";
			
			CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
			policy.IndentClassBody = true;
			
			CSharp.Dom.CompilationUnit compilationUnit = new CSharpParser ().Parse (data);
			compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null);
			Assert.AreEqual (@"class Test
{
	Test a;
}", data.Document.Text);
			policy.IndentClassBody = false;
			compilationUnit = new CSharpParser ().Parse (data);
			compilationUnit.AcceptVisitor (new DomIndentationVisitor (policy, data), null);
			Assert.AreEqual (@"class Test
{
Test a;
}", data.Document.Text);
		}
开发者ID:pgoron,项目名称:monodevelop,代码行数:27,代码来源:TestTypeLevelIndentation.cs

示例3: TestBlankLinesAfterUsings

		public void TestBlankLinesAfterUsings ()
		{
			TextEditorData data = new TextEditorData ();
			data.Document.FileName = "a.cs";
			data.Document.Text = @"using System;
using System.Text;
namespace Test
{
}";
			
			CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
			policy.BlankLinesAfterUsings = 2;
			var compilationUnit = new CSharpParser ().Parse (data);
			compilationUnit.AcceptVisitor (new AstIndentationVisitor (policy, data), null);
			Assert.AreEqual (@"using System;
using System.Text;


namespace Test
{
}", data.Document.Text);
			
		policy.BlankLinesAfterUsings = 0;
		compilationUnit = new CSharpParser ().Parse (data);
		compilationUnit.AcceptVisitor (new AstIndentationVisitor (policy, data), null);
		Assert.AreEqual (@"using System;
using System.Text;
namespace Test
{
}", data.Document.Text);
		}
开发者ID:sandyarmstrong,项目名称:monodevelop,代码行数:31,代码来源:TestBlankLineFormatting.cs

示例4: AddProfile

		public static void AddProfile (CSharpFormattingPolicy profile)
		{
			profiles.Add (profile);
			if (!Directory.Exists (ProfilePath))
				Directory.CreateDirectory (ProfilePath);
			string fileName = Path.Combine (ProfilePath, profile.Name + ".xml");
			profile.Save (fileName);
		}
开发者ID:nickname100,项目名称:monodevelop,代码行数:8,代码来源:FormattingProfileService.cs

示例5: CSharpIndentEngine

		// Constructors
		public CSharpIndentEngine (CSharpFormattingPolicy policy)
		{
			if (policy == null)
				throw new ArgumentNullException ("policy");
			this.policy = policy;
			stack = new IndentStack (this);
			linebuf = new StringBuilder ();
			Reset ();
		}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:10,代码来源:CSharpIndentEngine.cs

示例6: CSharpFormattingPolicies

		public CSharpFormattingPolicies()
		{
			// Load global settings
			GlobalOptions = new CSharpFormattingPolicy(
				SD.PropertyService.MainPropertiesContainer, new CSharpFormattingOptionsContainer() {
					DefaultText = StringParser.Parse("${res:CSharpBinding.Formatting.GlobalOptionReference}")
				});
			GlobalOptions.FormattingPolicyUpdated += OnFormattingPolicyUpdated;
			GlobalOptions.Load();
		}
开发者ID:2594636985,项目名称:SharpDevelop,代码行数:10,代码来源:CSharpFormattingPolicies.cs

示例7: CSharpFormattingOptionPanel

		public CSharpFormattingOptionPanel(CSharpFormattingPolicy persistenceHelper, bool allowPresets, bool overrideGlobalIndentation)
		{
			if (persistenceHelper == null)
				throw new ArgumentNullException("persistenceHelper");
			
			this.formattingPolicy = persistenceHelper;
			this.isDirty = false;
			InitializeComponent();			
			
			formattingEditor.AllowPresets = allowPresets;
			formattingEditor.OverrideGlobalIndentation = overrideGlobalIndentation;
		}
开发者ID:2594636985,项目名称:SharpDevelop,代码行数:12,代码来源:CSharpFormattingOptionPanel.xaml.cs

示例8: CSharpFormattingPolicyPanelWidget

		public CSharpFormattingPolicyPanelWidget ()
		{
			// ReSharper disable once DoNotCallOverridableMethodsInConstructor
			this.Build ();
			policy = new CSharpFormattingPolicy ();
			buttonEdit.Clicked += HandleButtonEditClicked;
			
			texteditor.Options = DefaultSourceEditorOptions.PlainEditor;
			texteditor.IsReadOnly = true;
			texteditor.MimeType = CSharpFormatter.MimeType;
			scrolledwindow1.AddWithViewport (texteditor);
			ShowAll ();
		}
开发者ID:kdubau,项目名称:monodevelop,代码行数:13,代码来源:CSharpFormattingPolicyPanelWidget.cs

示例9: TestClassIndentation

		public void TestClassIndentation ()
		{
			TextEditorData data = new TextEditorData ();
			data.Document.FileName = "a.cs";
			data.Document.Text = 
@"			class Test {}";
			
			CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
			policy.ClassBraceStyle = BraceStyle.DoNotChange;
			
			var compilationUnit = new CSharpParser ().Parse (data);
			compilationUnit.AcceptVisitor (new AstIndentationVisitor (policy, data), null);
			Assert.AreEqual (@"class Test {}", data.Document.Text);
		}
开发者ID:sandyarmstrong,项目名称:monodevelop,代码行数:14,代码来源:TestTypeLevelIndentation.cs

示例10: TestBug325187

		public void TestBug325187 ()
		{
			CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
			policy.PlaceElseOnNewLine = true;
			
			TestStatementFormatting (policy,
@"foreach (int i in myints)
if (i == 6)
Console.WriteLine (""Yeah"");
else
Console.WriteLine (""Bad indent"");",
@"foreach (int i in myints)
	if (i == 6)
		Console.WriteLine (""Yeah"");
	else
		Console.WriteLine (""Bad indent"");");
		}
开发者ID:sandyarmstrong,项目名称:monodevelop,代码行数:17,代码来源:TestFormattingBugs.cs

示例11: CSharpFormattingPolicyPanelWidget

		public CSharpFormattingPolicyPanelWidget ()
		{
			this.Build ();
			policy = new CSharpFormattingPolicy ();
			buttonEdit.Clicked += HandleButtonEditClicked;
			
			var options = MonoDevelop.SourceEditor.DefaultSourceEditorOptions.Instance;
			texteditor.Options.FontName = options.FontName;
			texteditor.Options.ColorScheme = options.ColorScheme;
			texteditor.Options.ShowFoldMargin = false;
			texteditor.Options.ShowIconMargin = false;
			texteditor.Options.ShowLineNumberMargin = false;
			texteditor.Document.ReadOnly = true;
			texteditor.Document.MimeType = CSharpFormatter.MimeType;
			scrolledwindow1.Child = texteditor;
			ShowAll ();
		}
开发者ID:jrhtcg,项目名称:monodevelop,代码行数:17,代码来源:CSharpFormattingPolicyPanelWidget.cs

示例12: TestFieldSpacesBeforeComma2

		public void TestFieldSpacesBeforeComma2 ()
		{
			TextEditorData data = new TextEditorData ();
			data.Document.FileName = "a.cs";
			data.Document.Text = @"class Test {
	int a           ,                   b,          c;
}";
			
			CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
			policy.ClassBraceStyle =  BraceStyle.EndOfLine;
			policy.BeforeFieldDeclarationComma = true;
			policy.AfterFieldDeclarationComma = true;
			
			var compilationUnit = new CSharpParser ().Parse (data);
			compilationUnit.AcceptVisitor (new AstSpacingVisitor (policy, data), null);
			Assert.AreEqual (@"class Test {
	int a , b , c;
}", data.Document.Text);
		}
开发者ID:sandyarmstrong,项目名称:monodevelop,代码行数:19,代码来源:TestSpacingVisitor.cs

示例13: TestBug415469

		public void TestBug415469 () 
		{
			CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
			
			TestStatementFormatting (policy,
@"switch (condition) {
case CONDITION1:
return foo != null ? foo.Bar : null;
case CONDITION2:
string goo = foo != null ? foo.Bar : null;
return ""Should be indented like this"";
}", @"switch (condition) {
case CONDITION1:
	return foo != null ? foo.Bar : null;
case CONDITION2:
	string goo = foo != null ? foo.Bar : null;
	return ""Should be indented like this"";
}");
		}
开发者ID:sandyarmstrong,项目名称:monodevelop,代码行数:19,代码来源:TestFormattingBugs.cs

示例14: TestIndentBlocks

		public void TestIndentBlocks ()
		{
			TextEditorData data = new TextEditorData ();
			data.Document.FileName = "a.cs";
			data.Document.Text = @"class Test {
	Test TestMethod ()
	{
{
{}
}
	}
}";
			
			CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
			
			policy.IndentBlocks = true;
			var compilationUnit = new CSharpParser ().Parse (data);
			compilationUnit.AcceptVisitor (new AstIndentationVisitor (policy, data), null);
			Assert.AreEqual (@"class Test
{
	Test TestMethod ()
	{
		{
			{}
		}
	}
}", data.Document.Text);
			policy.IndentBlocks = false;
			compilationUnit = new CSharpParser ().Parse (data);
			compilationUnit.AcceptVisitor (new AstIndentationVisitor (policy, data), null);
			
			Assert.AreEqual (@"class Test
{
	Test TestMethod ()
	{
		{
		{}
		}
	}
}", data.Document.Text);
			policy.IndentBlocks = false;
		}
开发者ID:okrmartin,项目名称:monodevelop,代码行数:42,代码来源:TestStatementIndentation.cs

示例15: TestInvocationIndentation

		public void TestInvocationIndentation ()
		{
			TextEditorData data = new TextEditorData ();
			data.Document.FileName = "a.cs";
			data.Document.Text = @"class Test {
	Test TestMethod ()
	{
this.TestMethod ();
	}
}";
			
			CSharpFormattingPolicy policy = new CSharpFormattingPolicy ();
			
			policy.ClassBraceStyle = BraceStyle.EndOfLine;
			var compilationUnit = new CSharpParser ().Parse (data);
			compilationUnit.AcceptVisitor (new AstFormattingVisitor (policy, data), null);
			Assert.AreEqual (@"class Test {
	Test TestMethod ()
	{
		this.TestMethod ();
	}
}", data.Document.Text);
		}
开发者ID:raufbutt,项目名称:monodevelop-old,代码行数:23,代码来源:TestStatementIndentation.cs


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