attributesection.cs

来自「全功能c#编译器」· CS 代码 · 共 150 行

CS
150
字号
// AttributeDeclaration.cs
// Copyright (C) 2003 Mike Krueger (mike@icsharpcode.net)
// 
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
// 
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// 
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

using System;
using System.Diagnostics;
using System.Collections.Generic;

namespace ICSharpCode.CsVbRefactory.Parser.AST
{
	public class NamedArgument : AbstractNode
	{
		string name = "";
		Expression expr = Expression.Null;
		
		public string Name {
			get {
				return name;
			}
		}
		public Expression Expr {
			get {
				return expr;
			}
		}
		
		public NamedArgument(string name, Expression expr)
		{
			Debug.Assert(name != null);
			this.name = name;
			Debug.Assert(expr != null);
			this.expr = expr;
		}
		public override object AcceptVisitor(IASTVisitor visitor, object data)
		{
			return visitor.Visit(this, data);
		}
		public override string ToString()
		{
			return String.Format("[NamedArgument: Name = {0}, Expr = {1}]",
			                     Name,
			                     Expr);
		}
	}
	
	public class Attribute : AbstractNode
	{
		string name = "";
		List<Expression> positionalArguments;
		List<NamedArgument> namedArguments;
		
		public Attribute(string name, List<Expression> positionalArguments, List<NamedArgument> namedArguments)
		{
			Debug.Assert(name != null);
			Debug.Assert(positionalArguments != null);
			Debug.Assert(namedArguments != null);
			
			this.name = name;
			this.positionalArguments = positionalArguments;
			this.namedArguments      = namedArguments;
		}
		
		public string Name {
			get {
				return name;
			}
		}
		
		public List<Expression> PositionalArguments {
			get {
				return positionalArguments;
			}
		}
		public List<NamedArgument> NamedArguments {
			get {
				return namedArguments;
			}
		}
		public override object AcceptVisitor(IASTVisitor visitor, object data)
		{
			return visitor.Visit(this, data);
		}
		public override string ToString()
		{
			return String.Format("[Attribute: Name = {0}, PositionalArguments = {1}, NamedArguments = {2}]",
			                     Name,
			                     PositionalArguments,
			                     NamedArguments);
		}
	}
	
	public class AttributeSection : AbstractNode
	{
		string    attributeTarget = "";
		List<Attribute> attributes;
		
		public string AttributeTarget {
			get {
				return attributeTarget;
			}
			set {
				Debug.Assert(value != null);
				attributeTarget = value;
			}
		}
		
		public List<Attribute> Attributes {
			get {
				return attributes;
			}
			set {
				Debug.Assert(value != null);
				attributes = value;
			}
		}
		
		public AttributeSection(string attributeTarget, List<Attribute> attributes)
		{
			Debug.Assert(attributeTarget != null);
			this.attributeTarget = attributeTarget;
			Debug.Assert(attributes != null);
			this.attributes = attributes;
		}
		
		public override object AcceptVisitor(IASTVisitor visitor, object data)
		{
			return visitor.Visit(this, data);
		}
		public override string ToString()
		{
			return String.Format("[AttributeSection: AttributeTarget={0}, Attributes={1}]",
			                     AttributeTarget,
			                     Attributes);
		}
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?