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

C# UsingDeclaration类代码示例

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

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



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

示例1: VisitUsingDeclaration

		public override object VisitUsingDeclaration(UsingDeclaration usingDeclaration, object data)
		{
			base.VisitUsingDeclaration(usingDeclaration, data);
			if (usingDeclaration.Parent is NamespaceDeclaration) {
				nodesToMoveToCompilationUnit.Add(usingDeclaration);
				RemoveCurrentNode();
			}
			return null;
		}
开发者ID:mgagne-atman,项目名称:Projects,代码行数:9,代码来源:ToVBNetConvertVisitor.cs


示例2: HandleVisitorUsingDeclarationVisited

		void HandleVisitorUsingDeclarationVisited (UsingDeclaration node, InspectionData data)
		{
			if (!data.Graph.UsedUsings.Contains (node.Namespace)) {
				AddResult (data,
					new DomRegion (node.StartLocation.Line, node.StartLocation.Column, node.EndLocation.Line, node.EndLocation.Column),
					GettextCatalog.GetString ("Remove unused usings"),
					delegate {
						RefactoringOptions options = new RefactoringOptions () { Document = data.Document, Dom = data.Document.Dom};
						new RemoveUnusedImportsRefactoring ().Run (options);
					}
				);
			}
		}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:13,代码来源:UnusedUsingInspector.cs


示例3: VisitUsingDeclaration

 public override void VisitUsingDeclaration(UsingDeclaration usingDeclaration)
 {
     if (usingDeclaration.PrevSibling != null && !(usingDeclaration.PrevSibling is UsingDeclaration || usingDeclaration.PrevSibling is UsingAliasDeclaration)) {
         FixIndentationForceNewLine(usingDeclaration.StartLocation);
         EnsureBlankLinesBefore(usingDeclaration, policy.BlankLinesBeforeUsings);
     } else if (!(usingDeclaration.NextSibling is UsingDeclaration || usingDeclaration.NextSibling  is UsingAliasDeclaration)) {
         FixIndentationForceNewLine(usingDeclaration.StartLocation);
         EnsureBlankLinesAfter(usingDeclaration, policy.BlankLinesAfterUsings);
     } else {
         FixIndentationForceNewLine(usingDeclaration.StartLocation);
     }
 }
开发者ID:artifexor,项目名称:NRefactory,代码行数:12,代码来源:AstFormattingVisitor.cs


示例4: TrackedVisitUsingDeclaration

		public virtual object TrackedVisitUsingDeclaration(UsingDeclaration usingDeclaration, object data) {
			return base.VisitUsingDeclaration(usingDeclaration, data);
		}
开发者ID:mgagne-atman,项目名称:Projects,代码行数:3,代码来源:NodeTrackingAstVisitor.cs


示例5: Visit

			public override void Visit (UsingsBag.Using u)
			{
				UsingDeclaration ud = new UsingDeclaration ();
				ud.AddChild (new CSharpTokenNode (Convert (u.UsingLocation), "using".Length), UsingDeclaration.Roles.Keyword);
				ud.AddChild (new Identifier (u.NSpace.Name, Convert (u.NSpace.Location)), UsingDeclaration.Roles.Identifier);
				ud.AddChild (new CSharpTokenNode (Convert (u.SemicolonLocation), 1), UsingDeclaration.Roles.Semicolon);
				AddToNamespace (ud);
			}
开发者ID:pgoron,项目名称:monodevelop,代码行数:8,代码来源:CSharpParser.cs


示例6: Visit

			public override void Visit(UsingNamespace un)
			{
				var ud = new UsingDeclaration();
				var loc = LocationsBag.GetLocations(un);
				ud.AddChild(new CSharpTokenNode(Convert(un.Location), UsingDeclaration.UsingKeywordRole), UsingDeclaration.UsingKeywordRole);
				if (un.NamespaceExpression != null)
					ud.AddChild(ConvertToType(un.NamespaceExpression), UsingDeclaration.ImportRole);
				if (loc != null)
					ud.AddChild(new CSharpTokenNode(Convert(loc [0]), Roles.Semicolon), Roles.Semicolon);
				AddToNamespace(ud);
			}
开发者ID:0xb1dd1e,项目名称:NRefactory,代码行数:11,代码来源:CSharpParser.cs


示例7: VisitUsingDeclaration

 public virtual void VisitUsingDeclaration(UsingDeclaration usingDeclaration)
 {
     if (this.ThrowException)
     {
         throw (Exception)this.CreateException(usingDeclaration);
     }
 }
开发者ID:fabriciomurta,项目名称:BridgeUnified,代码行数:7,代码来源:Visitor.Exception.cs


示例8: VisitUsingDeclaration

		public override void VisitUsingDeclaration(UsingDeclaration usingDeclaration)
		{
			if (!(usingDeclaration.PrevSibling is UsingDeclaration || usingDeclaration.PrevSibling  is UsingAliasDeclaration)) {
				EnsureBlankLinesBefore(usingDeclaration, policy.BlankLinesBeforeUsings);
			}
			if (!(usingDeclaration.NextSibling is UsingDeclaration || usingDeclaration.NextSibling  is UsingAliasDeclaration)) {
				EnsureBlankLinesAfter(usingDeclaration, policy.BlankLinesAfterUsings);
			}
		}
开发者ID:txdv,项目名称:monodevelop,代码行数:9,代码来源:AstFormattingVisitor.cs


示例9: VisitUsingDeclaration

 public override void VisitUsingDeclaration(UsingDeclaration usingDeclaration)
 {
     imports.Add(usingDeclaration.GetText().Replace("using ", "").Replace(";\n", ""));
     base.VisitUsingDeclaration (usingDeclaration);
 }
开发者ID:renanalan,项目名称:101repo,代码行数:5,代码来源:Fact.cs


示例10: VisitUsingDeclaration

        public void VisitUsingDeclaration(UsingDeclaration usingDeclaration)
        {


            JsonObject declaration = new JsonObject();
            declaration.Comment = "VisitUsingDeclaration";
            AddKeyword(declaration, UsingDeclaration.UsingKeywordRole);
            declaration.AddJsonValue("import", GenerateNamespaceString(usingDeclaration.Import));

            Push(declaration);
        }
开发者ID:CompilerKit,项目名称:CodeWalk,代码行数:11,代码来源:AstCsToJson.cs


示例11: VisitDeclareDeclaration

		public override object VisitDeclareDeclaration(DeclareDeclaration declareDeclaration, object data)
		{
			if (usings != null && !usings.ContainsKey("System.Runtime.InteropServices")) {
				UsingDeclaration @using = new UsingDeclaration("System.Runtime.InteropServices");
				addedUsings.Add(@using);
				base.VisitUsingDeclaration(@using, data);
			}
			
			MethodDeclaration method = new MethodDeclaration {
				Name = declareDeclaration.Name,
				Modifier = declareDeclaration.Modifier,
				TypeReference = declareDeclaration.TypeReference,
				Parameters = declareDeclaration.Parameters,
				Attributes = declareDeclaration.Attributes
			};
			
			if ((method.Modifier & Modifiers.Visibility) == 0)
				method.Modifier |= Modifiers.Public;
			method.Modifier |= Modifiers.Extern | Modifiers.Static;
			
			if (method.TypeReference.IsNull) {
				method.TypeReference = new TypeReference("System.Void", true);
			}
			
			Attribute att = new Attribute("DllImport", null, null);
			att.PositionalArguments.Add(CreateStringLiteral(declareDeclaration.Library));
			if (declareDeclaration.Alias.Length > 0) {
				att.NamedArguments.Add(new NamedArgumentExpression("EntryPoint", CreateStringLiteral(declareDeclaration.Alias)));
			}
			switch (declareDeclaration.Charset) {
				case CharsetModifier.Auto:
					att.NamedArguments.Add(new NamedArgumentExpression("CharSet",
					                                                   new MemberReferenceExpression(new IdentifierExpression("CharSet"),
					                                                                                 "Auto")));
					break;
				case CharsetModifier.Unicode:
					att.NamedArguments.Add(new NamedArgumentExpression("CharSet",
					                                                   new MemberReferenceExpression(new IdentifierExpression("CharSet"),
					                                                                                 "Unicode")));
					break;
				default:
					att.NamedArguments.Add(new NamedArgumentExpression("CharSet",
					                                                   new MemberReferenceExpression(new IdentifierExpression("CharSet"),
					                                                                                 "Ansi")));
					break;
			}
			att.NamedArguments.Add(new NamedArgumentExpression("SetLastError", new PrimitiveExpression(true, true.ToString())));
			att.NamedArguments.Add(new NamedArgumentExpression("ExactSpelling", new PrimitiveExpression(true, true.ToString())));
			method.Attributes.Add(new AttributeSection { Attributes = { att } });
			ReplaceCurrentNode(method);
			return base.VisitMethodDeclaration(method, data);
		}
开发者ID:mgagne-atman,项目名称:Projects,代码行数:52,代码来源:VBNetConstructsConvertVisitor.cs


示例12: VisitUsingDeclaration

 public void VisitUsingDeclaration(UsingDeclaration node)
 {
     VisitChildren(node);
 }
开发者ID:evanw,项目名称:minisharp,代码行数:4,代码来源:Lower.cs


示例13: VisitUsingDeclaration

		public virtual object VisitUsingDeclaration(UsingDeclaration usingDeclaration, object data) {
			throw new global::System.NotImplementedException("UsingDeclaration");
		}
开发者ID:mgagne-atman,项目名称:Projects,代码行数:3,代码来源:NotImplementedAstVisitor.cs


示例14: UsingDirective

 private void UsingDirective()
 {
     string qualident = null;
     TypeReference type = null;
     base.Expect(120);
     Point location = this.t.Location;
     this.Qualident(out qualident);
     if (this.la.kind == 3)
     {
         base.lexer.NextToken();
         this.NonArrayType(out type);
     }
     base.Expect(11);
     if ((qualident != null) && (qualident.Length > 0))
     {
         INode node;
         if (type != null)
         {
             node = new UsingDeclaration(qualident, type);
         }
         else
         {
             node = new UsingDeclaration(qualident);
         }
         node.StartLocation = location;
         node.EndLocation = this.t.EndLocation;
         base.compilationUnit.AddChild(node);
     }
 }
开发者ID:KnowNo,项目名称:test-code-backup,代码行数:29,代码来源:Parser.cs


示例15: VisitUsingDeclaration

		public virtual object VisitUsingDeclaration(UsingDeclaration usingDeclaration, object data) {
			Debug.Assert((usingDeclaration != null));
			Debug.Assert((usingDeclaration.Usings != null));
			for (int i = 0; i < usingDeclaration.Usings.Count; i++) {
				Using o = usingDeclaration.Usings[i];
				Debug.Assert(o != null);
				nodeStack.Push(o);
				o.AcceptVisitor(this, data);
				o = (Using)nodeStack.Pop();
				if (o == null)
					usingDeclaration.Usings.RemoveAt(i--);
				else
					usingDeclaration.Usings[i] = o;
			}
			return null;
		}
开发者ID:mgagne-atman,项目名称:Projects,代码行数:16,代码来源:AbstractAstTransformer.cs


示例16: VisitUsingDeclaration

		public sealed override object VisitUsingDeclaration(UsingDeclaration usingDeclaration, object data) {
			BeginVisit(usingDeclaration);
			object result = TrackedVisitUsingDeclaration(usingDeclaration, data);
			EndVisit(usingDeclaration);
			return result;
		}
开发者ID:mgagne-atman,项目名称:Projects,代码行数:6,代码来源:NodeTrackingAstVisitor.cs


示例17: VisitUsingDeclaration

 public override void VisitUsingDeclaration(UsingDeclaration usingDeclaration)
 {
 }
开发者ID:Cestbienmoi,项目名称:Bridge,代码行数:3,代码来源:Inspector.Visitor.cs


示例18: VisitUsingDeclaration

		public virtual object VisitUsingDeclaration(UsingDeclaration usingDeclaration, object data) {
			Debug.Assert((usingDeclaration != null));
			Debug.Assert((usingDeclaration.Usings != null));
			foreach (Using o in usingDeclaration.Usings) {
				Debug.Assert(o != null);
				o.AcceptVisitor(this, data);
			}
			return null;
		}
开发者ID:mgagne-atman,项目名称:Projects,代码行数:9,代码来源:AbstractASTVisitor.cs


示例19: PerformChanges

		public override List<Change> PerformChanges (RefactoringOptions options, object properties)
		{
			List<Change> result = new List<Change> ();
			ICompilationUnit compilationUnit = options.ParseDocument ().CompilationUnit;
			Mono.TextEditor.TextEditorData textEditorData = options.GetTextEditorData ();
			int minOffset = int.MaxValue;
			foreach (IUsing u in compilationUnit.Usings) {
				if (u.IsFromNamespace)
					continue;
				int offset = textEditorData.Document.LocationToOffset (u.Region.Start.Line, u.Region.Start.Column);
				TextReplaceChange change = new TextReplaceChange () {
					FileName = options.Document.FileName,
					Offset = offset,
					RemovedChars = textEditorData.Document.LocationToOffset (u.Region.End.Line, u.Region.End.Column) - offset
				};
				Mono.TextEditor.LineSegment line = textEditorData.Document.GetLineByOffset (change.Offset);
				if (line != null && line.EditableLength == change.RemovedChars)
					change.RemovedChars += line.DelimiterLength;
				result.Add (change);
				minOffset = Math.Min (minOffset, offset);
			}
			StringBuilder output = new StringBuilder ();
			List<IUsing> usings = new List<IUsing> (compilationUnit.Usings);
			usings.Sort (UsingComparer);
			INRefactoryASTProvider astProvider = options.GetASTProvider ();
			foreach (IUsing u in usings) {
				AstNode declaration;
				if (u.IsFromNamespace)
					continue;
				if (u.Aliases.Any ()) {
					KeyValuePair<string, IReturnType> alias = u.Aliases.First ();
					declaration = new UsingAliasDeclaration (alias.Key, alias.Value.ConvertToTypeReference ());
				} else {
					declaration = new UsingDeclaration (u.Namespaces.First ());
				}
				output.Append (astProvider.OutputNode (options.Dom, declaration));
			}
			TextReplaceChange insertSortedUsings = new TextReplaceChange () {
				FileName = options.Document.FileName,
				Offset = minOffset,
				InsertedText = output.ToString ()
			};
			result.Add (insertSortedUsings);
			return result;
		}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:45,代码来源:SortImportsRefactoring.cs


示例20: UsingDirective

	void UsingDirective() {

#line  190 "cs.ATG" 
		string qualident = null; TypeReference aliasedType = null;
		
		Expect(121);

#line  193 "cs.ATG" 
		Location startPos = t.Location; 
		Qualident(
#line  194 "cs.ATG" 
out qualident);
		if (la.kind == 3) {
			lexer.NextToken();
			NonArrayType(
#line  195 "cs.ATG" 
out aliasedType);
		}
		Expect(11);

#line  197 "cs.ATG" 
		if (qualident != null && qualident.Length > 0) {
		 INode node;
		 if (aliasedType != null) {
		     node = new UsingDeclaration(qualident, aliasedType);
		 } else {
		     node = new UsingDeclaration(qualident);
		 }
		 node.StartLocation = startPos;
		 node.EndLocation   = t.EndLocation;
		 compilationUnit.AddChild(node);
		}
		
	}
开发者ID:mgagne-atman,项目名称:Projects,代码行数:34,代码来源:Parser.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# UsingDirectiveSyntax类代码示例发布时间:2022-05-24
下一篇:
C# UsersContext类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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