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

C# UsingStatement类代码示例

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

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



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

示例1: VisitUsingStatement

			public override void VisitUsingStatement(UsingStatement usingStatement)
			{
				inUsingStatementResourceAcquisition = true;
				usingStatement.ResourceAcquisition.AcceptVisitor (this);
				inUsingStatementResourceAcquisition = false;
				usingStatement.EmbeddedStatement.AcceptVisitor (this);
			}
开发者ID:RainsSoft,项目名称:playscript-monodevelop,代码行数:7,代码来源:RedundantAssignmentIssue.cs


示例2: EmbeddedStatement


//.........这里部分代码省略.........
				lexer.NextToken();

#line  1585 "cs.ATG" 
				statement = new YieldStatement(new BreakStatement()); 
			} else SynErr(198);
			Expect(11);
		} else if (la.kind == 101) {
			lexer.NextToken();
			if (StartOf(6)) {
				Expr(
#line  1588 "cs.ATG" 
out expr);
			}
			Expect(11);

#line  1588 "cs.ATG" 
			statement = new ReturnStatement(expr); 
		} else if (la.kind == 112) {
			lexer.NextToken();
			if (StartOf(6)) {
				Expr(
#line  1589 "cs.ATG" 
out expr);
			}
			Expect(11);

#line  1589 "cs.ATG" 
			statement = new ThrowStatement(expr); 
		} else if (StartOf(6)) {
			StatementExpr(
#line  1592 "cs.ATG" 
out statement);
			while (!(la.kind == 0 || la.kind == 11)) {SynErr(199); lexer.NextToken(); }
			Expect(11);
		} else if (la.kind == 114) {
			TryStatement(
#line  1595 "cs.ATG" 
out statement);
		} else if (la.kind == 86) {
			lexer.NextToken();
			Expect(20);
			Expr(
#line  1598 "cs.ATG" 
out expr);
			Expect(21);
			EmbeddedStatement(
#line  1599 "cs.ATG" 
out embeddedStatement);

#line  1599 "cs.ATG" 
			statement = new LockStatement(expr, embeddedStatement); 
		} else if (la.kind == 121) {

#line  1602 "cs.ATG" 
			Statement resourceAcquisitionStmt = null; 
			lexer.NextToken();
			Expect(20);
			ResourceAcquisition(
#line  1604 "cs.ATG" 
out resourceAcquisitionStmt);
			Expect(21);
			EmbeddedStatement(
#line  1605 "cs.ATG" 
out embeddedStatement);

#line  1605 "cs.ATG" 
			statement = new UsingStatement(resourceAcquisitionStmt, embeddedStatement); 
		} else if (la.kind == 119) {
			lexer.NextToken();
			Block(
#line  1608 "cs.ATG" 
out embeddedStatement);

#line  1608 "cs.ATG" 
			statement = new UnsafeStatement(embeddedStatement); 
		} else if (la.kind == 74) {

#line  1610 "cs.ATG" 
			Statement pointerDeclarationStmt = null; 
			lexer.NextToken();
			Expect(20);
			ResourceAcquisition(
#line  1612 "cs.ATG" 
out pointerDeclarationStmt);
			Expect(21);
			EmbeddedStatement(
#line  1613 "cs.ATG" 
out embeddedStatement);

#line  1613 "cs.ATG" 
			statement = new FixedStatement(pointerDeclarationStmt, embeddedStatement); 
		} else SynErr(200);

#line  1615 "cs.ATG" 
		if (statement != null) {
		statement.StartLocation = startLocation;
		statement.EndLocation = t.EndLocation;
		}
		
	}
开发者ID:mgagne-atman,项目名称:Projects,代码行数:101,代码来源:Parser.cs


示例3: CreateUsingStatement

			public UsingStatement CreateUsingStatement (Block blockStatement)
			{
				var usingResult = new UsingStatement ();
				var location = LocationsBag.GetLocations (blockStatement);
				if (location != null)
					usingResult.AddChild (new CSharpTokenNode (Convert (location[0]), "using".Length), UsingStatement.Roles.Keyword);
				if (location != null)
					usingResult.AddChild (new CSharpTokenNode (Convert (location[1]), 1), UsingStatement.Roles.LPar);
				Statement cur = blockStatement.Statements[0];
				while (cur is Using) {
					Using u = (Using)cur;
					if (u.Var != null)
						usingResult.AddChild ((INode)u.Var.Accept (this), UsingStatement.Roles.Identifier);
					
					if (u.Init != null)
						usingResult.AddChild ((INode)u.Init.Accept (this), UsingStatement.Roles.Initializer);
					
					cur = u.EmbeddedStatement;
				}
				if (location != null)
					usingResult.AddChild (new CSharpTokenNode (Convert (location[2]), 1), UsingStatement.Roles.RPar);
				usingResult.AddChild ((INode)cur.Accept (this), UsingStatement.Roles.EmbeddedStatement);
				return usingResult;
			}
开发者ID:pgoron,项目名称:monodevelop,代码行数:24,代码来源:CSharpParser.cs


示例4: VisitUsingStatement

		public virtual void VisitUsingStatement (UsingStatement usingStatement)
		{
			VisitChildren (usingStatement);
		}
开发者ID:modulexcite,项目名称:ICSharpCode.Decompiler-retired,代码行数:4,代码来源:DepthFirstAstVisitor.cs


示例5: CreateUsingStatement

			public UsingStatement CreateUsingStatement(Block blockStatement)
			{
				var usingResult = new UsingStatement();
				Mono.CSharp.Statement cur = blockStatement.Statements [0];
				var u = cur as Using;
				if (u != null) {
					usingResult.AddChild(new CSharpTokenNode(Convert(u.loc), UsingStatement.UsingKeywordRole), UsingStatement.UsingKeywordRole);
					usingResult.AddChild(new CSharpTokenNode(Convert(blockStatement.StartLocation), Roles.LPar), Roles.LPar);
					if (u.Variables != null) {
						var initializer = new VariableInitializer {
							NameToken = Identifier.Create(u.Variables.Variable.Name, Convert(u.Variables.Variable.Location)),
						};
						
						var loc = LocationsBag.GetLocations(u.Variables);
						if (loc != null)
							initializer.AddChild(new CSharpTokenNode(Convert(loc [0]), Roles.Assign), Roles.Assign);
						if (u.Variables.Initializer != null)
							initializer.Initializer = u.Variables.Initializer.Accept(this) as Expression;
						
						
						var varDec = new VariableDeclarationStatement {
							Type = ConvertToType(u.Variables.TypeExpression),
							Variables = { initializer }
						};
						
						if (u.Variables.Declarators != null) {
							foreach (var decl in u.Variables.Declarators) {
								var declLoc = LocationsBag.GetLocations(decl);
								var init = new VariableInitializer();
								if (declLoc != null && declLoc.Count > 0)
									varDec.AddChild(new CSharpTokenNode(Convert(declLoc [0]), Roles.Comma), Roles.Comma);
								init.AddChild(Identifier.Create(decl.Variable.Name, Convert(decl.Variable.Location)), Roles.Identifier);
								if (decl.Initializer != null) {
									if (declLoc != null && declLoc.Count > 1)
										init.AddChild(new CSharpTokenNode(Convert(declLoc [1]), Roles.Assign), Roles.Assign);
									init.AddChild((Expression)decl.Initializer.Accept(this), Roles.Expression);
								}
								varDec.AddChild(init, Roles.Variable);
							}
						}
						usingResult.AddChild(varDec, UsingStatement.ResourceAcquisitionRole);
					}
					cur = u.Statement;
					usingResult.AddChild(new CSharpTokenNode(Convert(blockStatement.EndLocation), Roles.RPar), Roles.RPar);
					if (cur != null)
						usingResult.AddChild((Statement)cur.Accept(this), Roles.EmbeddedStatement);
				}
				return usingResult;
			}
开发者ID:0xb1dd1e,项目名称:NRefactory,代码行数:49,代码来源:CSharpParser.cs


示例6: VisitUsingStatement

		public override void VisitUsingStatement(UsingStatement usingStatement) {
			var stmt = CreateInnerCompiler().Compile(usingStatement.EmbeddedStatement);

			var vds = usingStatement.ResourceAcquisition as VariableDeclarationStatement;
			if (vds != null) {
				foreach (var resource in vds.Variables.Reverse()) {
					stmt = GenerateUsingBlock(((LocalResolveResult)_resolver.Resolve(resource)), resource.Initializer, usingStatement.GetRegion(), stmt);
				}
			}
			else {
				var resource = CreateTemporaryVariable(_resolver.Resolve((Expression)usingStatement.ResourceAcquisition).Type, usingStatement.GetRegion());
				stmt = GenerateUsingBlock(new LocalResolveResult(resource), (Expression)usingStatement.ResourceAcquisition, usingStatement.GetRegion(), stmt);
			}

			_result.Add(stmt);
		}
开发者ID:chenxustu1,项目名称:SaltarelleCompiler,代码行数:16,代码来源:StatementCompiler.cs


示例7: AddUsingStatementToClassAction

 public AddUsingStatementToClassAction(Class classToAddTo, UsingStatement usingStatementToAdd)
 {
     ClassToAddTo = classToAddTo;
     UsingStatementToAdd = usingStatementToAdd;
 }
开发者ID:uQr,项目名称:Visual-NHibernate,代码行数:5,代码来源:AddUsingStatementToClassAction.cs


示例8: VisitUsingStatement

		public override object VisitUsingStatement(UsingStatement usingStatement, object data)
		{
			// uses LocalVariableDeclaration, we just have to put the end location on the stack
			if (usingStatement.EmbeddedStatement.EndLocation.IsEmpty) {
				return base.VisitUsingStatement(usingStatement, data);
			} else {
				endLocationStack.Push(usingStatement.EmbeddedStatement.EndLocation);
				base.VisitUsingStatement(usingStatement, data);
				endLocationStack.Pop();
				return null;
			}
		}
开发者ID:mgagne-atman,项目名称:Projects,代码行数:12,代码来源:LookupTableVisitor.cs


示例9: Equals

 public bool Equals( UsingStatement obj )
 {
     if (ReferenceEquals( null, obj )) return false;
     if (ReferenceEquals( this, obj )) return true;
     return Equals( [email protected], [email protected] );
 }
开发者ID:werwolfby,项目名称:wolfgenerator,代码行数:6,代码来源:UsingStatement.cs


示例10: Visit

 /// <summary>
 /// Visits the specified using statement.
 /// </summary>
 /// <param name="usingStatement">The using statement.</param>
 public override void Visit(UsingStatement usingStatement)
 {
     WriteLinkLine(usingStatement);
     Write("using ").Write(usingStatement.Name).WriteLine(";");
 }
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:9,代码来源:ShaderMixinCodeGen.cs


示例11: UsingStatement_Change_Value

        public void UsingStatement_Change_Value()
        {
            UsingStatement merged1 = new UsingStatement(controller);
            UsingStatement merged2 = new UsingStatement(controller);
            UsingStatement merged3 = new UsingStatement(controller);

            const string Alias = "MyAlias1";
            const string Value1 = "MyValue1";
            const string Value2 = "MyValue2";

            UsingStatement unchanging = new UsingStatement(controller, Alias, Value1);
            UsingStatement changing = new UsingStatement(controller, Alias, Value2);

            const string expectedResult = "using " + Alias + " = " + Value2;

            Merge_And_Assert(merged1, merged2, merged3, changing, unchanging, expectedResult);
        }
开发者ID:uQr,项目名称:Visual-NHibernate,代码行数:17,代码来源:Specs_For_CodeRootMapNode_GetMergedBaseConstruct.cs


示例12: VisitUsingStatement

		public override void VisitUsingStatement(UsingStatement usingStatement)
		{
			VisitNewDeclarationSpace(usingStatement);
		}
开发者ID:0xb1dd1e,项目名称:NRefactory,代码行数:4,代码来源:LocalDeclarationSpaceVisitor.cs


示例13: VisitUsingStatement

		public virtual void VisitUsingStatement(UsingStatement usingStatement)
		{
			StartNode(usingStatement);
			WriteKeywordReference(UsingStatement.UsingKeywordRole);
			Space(policy.SpaceBeforeUsingParentheses);
			var braceHelper = BraceHelper.LeftParen(this, CodeBracesRangeFlags.Parentheses);
			Space(policy.SpacesWithinUsingParentheses);
			
			DebugStart(usingStatement);
			usingStatement.ResourceAcquisition.AcceptVisitor(this);
			DebugEnd(usingStatement);
			
			Space(policy.SpacesWithinUsingParentheses);
			braceHelper.RightParen();
			
			WriteEmbeddedStatement(usingStatement.EmbeddedStatement);
			
			EndNode(usingStatement);
		}
开发者ID:0xd4d,项目名称:NRefactory,代码行数:19,代码来源:CSharpOutputVisitor.cs


示例14: CreateUsingStatement

			public UsingStatement CreateUsingStatement (Block blockStatement)
			{
				var usingResult = new UsingStatement ();
				Statement cur = blockStatement.Statements[0];
				if (cur is Using) {
					Using u = (Using)cur;
					usingResult.AddChild (new CSharpTokenNode (Convert (u.loc), "using".Length), UsingStatement.Roles.Keyword);
					usingResult.AddChild (new CSharpTokenNode (Convert (blockStatement.StartLocation), 1), UsingStatement.Roles.LPar);
					if (u.Variables != null) {
						usingResult.AddChild ((INode)u.Variables.TypeExpression.Accept (this), UsingStatement.Roles.ReturnType);
						usingResult.AddChild (new Identifier (u.Variables.Variable.Name, Convert (u.Variables.Variable.Location)), UsingStatement.Roles.Identifier);
						var loc = LocationsBag.GetLocations (u.Variables);
						if (loc != null)
							usingResult.AddChild (new CSharpTokenNode (Convert (loc[1]), 1), ContinueStatement.Roles.Assign);
						if (u.Variables.Initializer != null)
							usingResult.AddChild ((INode)u.Variables.Initializer.Accept (this), UsingStatement.Roles.Initializer);
						
					}
					cur = u.Statement;
					usingResult.AddChild (new CSharpTokenNode (Convert (blockStatement.EndLocation), 1), UsingStatement.Roles.RPar);
					usingResult.AddChild ((INode)cur.Accept (this), UsingStatement.Roles.EmbeddedStatement);
				}
				return usingResult;
			}
开发者ID:silk,项目名称:monodevelop,代码行数:24,代码来源:CSharpParser.cs


示例15: VBUsingStatementPrinter

 public VBUsingStatementPrinter(UsingStatement obj)
 {
     this.obj = obj;
 }
开发者ID:uQr,项目名称:Visual-NHibernate,代码行数:4,代码来源:VBUsingStatementPrinter.cs


示例16: VisitUsingStatement

            public override object VisitUsingStatement(UsingStatement usingStatement, object data)
            {
                UnlockWith(usingStatement);

                return base.VisitUsingStatement(usingStatement, data);
            }
开发者ID:clausjoergensen,项目名称:strokes,代码行数:6,代码来源:UsingStatementAchievement.cs


示例17: VisitUsingStatement

 public override void VisitUsingStatement(UsingStatement usingStatement)
 {
     new UsingBlock(this, usingStatement).Emit();
 }
开发者ID:yindongfei,项目名称:bridge.lua,代码行数:4,代码来源:Emitter.Visitor.cs


示例18: VisitUsingStatement

		public override void VisitUsingStatement(UsingStatement usingStatement)
		{
			ForceSpacesBefore(usingStatement.LParToken, policy.SpaceBeforeUsingParentheses);

			ForceSpacesAfter(usingStatement.LParToken, policy.SpacesWithinUsingParentheses);
			ForceSpacesBefore(usingStatement.RParToken, policy.SpacesWithinUsingParentheses);

			FixEmbeddedStatment(policy.StatementBraceStyle, policy.UsingBraceForcement, usingStatement.EmbeddedStatement);
		}
开发者ID:txdv,项目名称:monodevelop,代码行数:9,代码来源:AstFormattingVisitor.cs


示例19: Visit

			public override object Visit (Using usingStatement)
			{
				var result = new UsingStatement ();
				var location = LocationsBag.GetLocations (usingStatement);
				
				result.AddChild (new CSharpTokenNode (Convert (usingStatement.loc), "using".Length), UsingStatement.Roles.Keyword);
				if (location != null)
					result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), UsingStatement.Roles.LPar);
				
				result.AddChild ((AstNode)usingStatement.Expression.Accept (this), UsingStatement.ResourceAcquisitionRole);
				
				if (location != null)
					result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), UsingStatement.Roles.RPar);
				
				result.AddChild ((MonoDevelop.CSharp.Ast.Statement)usingStatement.Statement.Accept (this), UsingStatement.Roles.EmbeddedStatement);
				return result;
			}
开发者ID:sandyarmstrong,项目名称:monodevelop,代码行数:17,代码来源:CSharpParser.cs


示例20: VisitUsingStatement

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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# UsingStatementSyntax类代码示例发布时间:2022-05-24
下一篇:
C# UsingDirectiveSyntax类代码示例发布时间: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