本文整理汇总了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);
}
示例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;
}
}
示例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;
}
示例4: VisitUsingStatement
public virtual void VisitUsingStatement (UsingStatement usingStatement)
{
VisitChildren (usingStatement);
}
示例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;
}
示例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);
}
示例7: AddUsingStatementToClassAction
public AddUsingStatementToClassAction(Class classToAddTo, UsingStatement usingStatementToAdd)
{
ClassToAddTo = classToAddTo;
UsingStatementToAdd = usingStatementToAdd;
}
示例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;
}
}
示例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] );
}
示例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(";");
}
示例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);
}
示例12: VisitUsingStatement
public override void VisitUsingStatement(UsingStatement usingStatement)
{
VisitNewDeclarationSpace(usingStatement);
}
示例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);
}
示例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;
}
示例15: VBUsingStatementPrinter
public VBUsingStatementPrinter(UsingStatement obj)
{
this.obj = obj;
}