本文整理汇总了C#中UsingDeclaration类的典型用法代码示例。如果您正苦于以下问题:C# UsingDeclaration类的具体用法?C# UsingDeclaration怎么用?C# UsingDeclaration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UsingDeclaration类属于命名空间,在下文中一共展示了UsingDeclaration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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);
}
);
}
}
示例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);
}
}
示例4: TrackedVisitUsingDeclaration
public virtual object TrackedVisitUsingDeclaration(UsingDeclaration usingDeclaration, object data) {
return base.VisitUsingDeclaration(usingDeclaration, data);
}
示例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);
}
示例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);
}
示例7: VisitUsingDeclaration
public virtual void VisitUsingDeclaration(UsingDeclaration usingDeclaration)
{
if (this.ThrowException)
{
throw (Exception)this.CreateException(usingDeclaration);
}
}
示例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);
}
}
示例9: VisitUsingDeclaration
public override void VisitUsingDeclaration(UsingDeclaration usingDeclaration)
{
imports.Add(usingDeclaration.GetText().Replace("using ", "").Replace(";\n", ""));
base.VisitUsingDeclaration (usingDeclaration);
}
示例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);
}
示例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);
}
示例12: VisitUsingDeclaration
public void VisitUsingDeclaration(UsingDeclaration node)
{
VisitChildren(node);
}
示例13: VisitUsingDeclaration
public virtual object VisitUsingDeclaration(UsingDeclaration usingDeclaration, object data) {
throw new global::System.NotImplementedException("UsingDeclaration");
}
示例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);
}
}
示例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;
}