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


C# UsingStatement类代码示例

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


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


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