當前位置: 首頁>>代碼示例>>C#>>正文


C# CSharp.Indexer類代碼示例

本文整理匯總了C#中Mono.CSharp.Indexer的典型用法代碼示例。如果您正苦於以下問題:C# Indexer類的具體用法?C# Indexer怎麽用?C# Indexer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Indexer類屬於Mono.CSharp命名空間,在下文中一共展示了Indexer類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Visit

			public override void Visit (Indexer indexer)
			{
				IndexerDeclaration newIndexer = new IndexerDeclaration ();
				
				var location = LocationsBag.GetMemberLocation (indexer);
				AddModifiers (newIndexer, location);
				
				newIndexer.AddChild ((INode)indexer.TypeName.Accept (this), AbstractNode.Roles.ReturnType);
				
				if (location != null)
					newIndexer.AddChild (new CSharpTokenNode (Convert (location[0]), 1), IndexerDeclaration.Roles.LBracket);
				AddParameter (newIndexer, indexer.Parameters);
				if (location != null)
					newIndexer.AddChild (new CSharpTokenNode (Convert (location[1]), 1), IndexerDeclaration.Roles.RBracket);
				
				if (location != null)
					newIndexer.AddChild (new CSharpTokenNode (Convert (location[2]), 1), IndexerDeclaration.Roles.LBrace);
				if (indexer.Get != null) {
					MonoDevelop.CSharp.Dom.Accessor getAccessor = new MonoDevelop.CSharp.Dom.Accessor ();
					var getLocation = LocationsBag.GetMemberLocation (indexer.Get);
					AddModifiers (getAccessor, getLocation);
					if (getLocation != null)
						getAccessor.AddChild (new CSharpTokenNode (Convert (indexer.Get.Location), "get".Length), PropertyDeclaration.Roles.Keyword);
					if (indexer.Get.Block != null) {
						getAccessor.AddChild ((INode)indexer.Get.Block.Accept (this), MethodDeclaration.Roles.Body);
					} else {
						if (getLocation != null && getLocation.Count > 0)
							newIndexer.AddChild (new CSharpTokenNode (Convert (getLocation[0]), 1), MethodDeclaration.Roles.Semicolon);
					}
					newIndexer.AddChild (getAccessor, PropertyDeclaration.PropertyGetRole);
				}
				
				if (indexer.Set != null) {
					MonoDevelop.CSharp.Dom.Accessor setAccessor = new MonoDevelop.CSharp.Dom.Accessor ();
					var setLocation = LocationsBag.GetMemberLocation (indexer.Set);
					AddModifiers (setAccessor, setLocation);
					if (setLocation != null)
						setAccessor.AddChild (new CSharpTokenNode (Convert (indexer.Set.Location), "set".Length), PropertyDeclaration.Roles.Keyword);
					
					if (indexer.Set.Block != null) {
						setAccessor.AddChild ((INode)indexer.Set.Block.Accept (this), MethodDeclaration.Roles.Body);
					} else {
						if (setLocation != null && setLocation.Count > 0)
							newIndexer.AddChild (new CSharpTokenNode (Convert (setLocation[0]), 1), MethodDeclaration.Roles.Semicolon);
					}
					newIndexer.AddChild (setAccessor, PropertyDeclaration.PropertySetRole);
				}
				
				if (location != null)
					newIndexer.AddChild (new CSharpTokenNode (Convert (location[3]), 1), IndexerDeclaration.Roles.RBrace);
				
				typeStack.Peek ().AddChild (newIndexer, TypeDeclaration.Roles.Member);
			}
開發者ID:pgoron,項目名稱:monodevelop,代碼行數:53,代碼來源:CSharpParser.cs

示例2: Visit

			public override void Visit (Indexer i)
			{
				DomProperty indexer = new DomProperty ();
				indexer.PropertyModifier |= PropertyModifier.IsIndexer;
				indexer.Name = "this";
				indexer.Documentation = RetrieveDocumentation (i.Location.Row);
				indexer.Location = Convert (i.Location);
				indexer.GetterModifier = indexer.SetterModifier = ConvertModifiers (i.ModFlags);
				var location = LocationsBag.GetMemberLocation (i);
				if (location != null && location.Count >= 1) {
					var endLoc = location.Count == 1 ? location[0] : location[location.Count - 1];
					indexer.BodyRegion = ConvertRegion (location[0], endLoc);
				} else {
					indexer.BodyRegion = DomRegion.Empty;
				}
				
				indexer.ReturnType = ConvertReturnType (i.TypeName);
				AddParameter (indexer, i.ParameterInfo);
				
				AddAttributes (indexer, i.OptAttributes, i);
				AddExplicitInterfaces (indexer, i);
				
				if (i.Get != null) {
					indexer.PropertyModifier |= PropertyModifier.HasGet;
					if ((i.Get.ModFlags & Mono.CSharp.Modifiers.AccessibilityMask) != 0)
						indexer.GetterModifier = ConvertModifiers (i.Get.ModFlags);
					if (i.Get.Block != null) {
						indexer.GetRegion = ConvertRegion (i.Get.Location, i.Get.Block.EndLocation);
					} else {
						var getLocation = LocationsBag.GetMemberLocation (i.Get);
						indexer.GetRegion = ConvertRegion (i.Get.Location, getLocation.Count > 0 ? getLocation[0] : i.Get.Location);
					}
				}
				
				if (i.Set != null) {
					indexer.PropertyModifier |= PropertyModifier.HasSet;
					if ((i.Set.ModFlags & Mono.CSharp.Modifiers.AccessibilityMask) != 0)
						indexer.SetterModifier = ConvertModifiers (i.Set.ModFlags);
					if (i.Set.Block != null) {
						indexer.SetRegion = ConvertRegion (i.Set.Location, i.Set.Block.EndLocation);
					} else {
						var setLocation = LocationsBag.GetMemberLocation (i.Set);
						indexer.SetRegion = ConvertRegion (i.Set.Location, setLocation.Count > 0 ? setLocation[0] : i.Set.Location);
					}
				}
				indexer.DeclaringType = typeStack.Peek ();
				typeStack.Peek ().Add (indexer);
			}
開發者ID:RainsSoft,項目名稱:playscript-monodevelop,代碼行數:48,代碼來源:McsParser.cs

示例3: Visit

			public override void Visit(Indexer i)
			{
				var newIndexer = new IndexerDeclaration();
				AddAttributeSection(newIndexer, i);
				var location = LocationsBag.GetMemberLocation(i);
				AddModifiers(newIndexer, location);
				newIndexer.AddChild(ConvertToType(i.TypeExpression), Roles.Type);
				AddExplicitInterface(newIndexer, i.MemberName);
				var name = i.MemberName;
				newIndexer.AddChild(new CSharpTokenNode(Convert(name.Location), IndexerDeclaration.ThisKeywordRole), IndexerDeclaration.ThisKeywordRole);
				
				if (location != null && location.Count > 0)
					newIndexer.AddChild(new CSharpTokenNode(Convert(location [0]), Roles.LBracket), Roles.LBracket);
				AddParameter(newIndexer, i.ParameterInfo);
				if (location != null && location.Count > 1)
					newIndexer.AddChild(new CSharpTokenNode(Convert(location [1]), Roles.RBracket), Roles.RBracket);
				
				if (location != null && location.Count > 2)
					newIndexer.AddChild(new CSharpTokenNode(Convert(location [2]), Roles.LBrace), Roles.LBrace);
				if (i.Get != null) {
					var getAccessor = new Accessor();
					var getLocation = LocationsBag.GetMemberLocation(i.Get);
					AddAttributeSection(getAccessor, i.Get);
					AddModifiers(getAccessor, getLocation);
					if (getLocation != null)
						getAccessor.AddChild(new CSharpTokenNode(Convert(i.Get.Location), PropertyDeclaration.GetKeywordRole), PropertyDeclaration.GetKeywordRole);
					if (i.Get.Block != null) {
						getAccessor.AddChild((BlockStatement)i.Get.Block.Accept(this), Roles.Body);
					} else {
						if (getLocation != null && getLocation.Count > 0)
							newIndexer.AddChild(new CSharpTokenNode(Convert(getLocation [0]), Roles.Semicolon), Roles.Semicolon);
					}
					newIndexer.AddChild(getAccessor, PropertyDeclaration.GetterRole);
				}
				
				if (i.Set != null) {
					var setAccessor = new Accessor();
					var setLocation = LocationsBag.GetMemberLocation(i.Set);
					AddAttributeSection(setAccessor, i.Set);
					AddModifiers(setAccessor, setLocation);
					if (setLocation != null)
						setAccessor.AddChild(new CSharpTokenNode(Convert(i.Set.Location), PropertyDeclaration.SetKeywordRole), PropertyDeclaration.SetKeywordRole);
					
					if (i.Set.Block != null) {
						setAccessor.AddChild((BlockStatement)i.Set.Block.Accept(this), Roles.Body);
					} else {
						if (setLocation != null && setLocation.Count > 0)
							newIndexer.AddChild(new CSharpTokenNode(Convert(setLocation [0]), Roles.Semicolon), Roles.Semicolon);
					}
					newIndexer.AddChild(setAccessor, PropertyDeclaration.SetterRole);
				}
				
				if (location != null) {
					if (location.Count > 3)
						newIndexer.AddChild(new CSharpTokenNode(Convert(location [3]), Roles.RBrace), Roles.RBrace);
				} else {
					// parser error, set end node to max value.
					newIndexer.AddChild(new ErrorNode(), Roles.Error);
				}
				typeStack.Peek().AddChild(newIndexer, Roles.TypeMemberRole);
			}
開發者ID:0xb1dd1e,項目名稱:NRefactory,代碼行數:61,代碼來源:CSharpParser.cs

示例4: Visit

			public override void Visit (Indexer indexer)
			{
				IndexerDeclaration newIndexer = new IndexerDeclaration ();
				AddAttributeSection (newIndexer, indexer);
				var location = LocationsBag.GetMemberLocation (indexer);
				AddModifiers (newIndexer, location);
				newIndexer.AddChild (ConvertToType (indexer.TypeName), IndexerDeclaration.Roles.Type);
				var name = indexer.MemberName;
				if (name.Left != null) {
					newIndexer.AddChild (ConvertToType (name.Left), IndexerDeclaration.PrivateImplementationTypeRole);
					var privateImplTypeLoc = LocationsBag.GetLocations (name.Left);
					if (privateImplTypeLoc != null)
						newIndexer.AddChild (new CSharpTokenNode (Convert (privateImplTypeLoc[0]), 1), MethodDeclaration.Roles.Dot);
				}
				newIndexer.AddChild (Identifier.Create ("this", Convert (name.Location)), IndexerDeclaration.Roles.Identifier);
				
				if (location != null)
					newIndexer.AddChild (new CSharpTokenNode (Convert (location [0]), 1), IndexerDeclaration.Roles.LBracket);
				AddParameter (newIndexer, indexer.ParameterInfo);
				if (location != null)
					newIndexer.AddChild (new CSharpTokenNode (Convert (location[1]), 1), IndexerDeclaration.Roles.RBracket);
				
				if (location != null)
					newIndexer.AddChild (new CSharpTokenNode (Convert (location[2]), 1), IndexerDeclaration.Roles.LBrace);
				if (indexer.Get != null) {
					Accessor getAccessor = new Accessor ();
					var getLocation = LocationsBag.GetMemberLocation (indexer.Get);
					AddAttributeSection (getAccessor, indexer.Get);
					AddModifiers (getAccessor, getLocation);
					if (getLocation != null)
						getAccessor.AddChild (new CSharpTokenNode (Convert (indexer.Get.Location), "get".Length), PropertyDeclaration.Roles.Keyword);
					if (indexer.Get.Block != null) {
						getAccessor.AddChild ((BlockStatement)indexer.Get.Block.Accept (this), MethodDeclaration.Roles.Body);
					} else {
						if (getLocation != null && getLocation.Count > 0)
							newIndexer.AddChild (new CSharpTokenNode (Convert (getLocation[0]), 1), MethodDeclaration.Roles.Semicolon);
					}
					newIndexer.AddChild (getAccessor, PropertyDeclaration.GetterRole);
				}
				
				if (indexer.Set != null) {
					Accessor setAccessor = new Accessor ();
					var setLocation = LocationsBag.GetMemberLocation (indexer.Set);
					AddAttributeSection (setAccessor, indexer.Set);
					AddModifiers (setAccessor, setLocation);
					if (setLocation != null)
						setAccessor.AddChild (new CSharpTokenNode (Convert (indexer.Set.Location), "set".Length), PropertyDeclaration.Roles.Keyword);
					
					if (indexer.Set.Block != null) {
						setAccessor.AddChild ((BlockStatement)indexer.Set.Block.Accept (this), MethodDeclaration.Roles.Body);
					} else {
						if (setLocation != null && setLocation.Count > 0)
							newIndexer.AddChild (new CSharpTokenNode (Convert (setLocation[0]), 1), MethodDeclaration.Roles.Semicolon);
					}
					newIndexer.AddChild (setAccessor, PropertyDeclaration.SetterRole);
				}
				
				if (location != null) {
					newIndexer.AddChild (new CSharpTokenNode (Convert (location[3]), 1), IndexerDeclaration.Roles.RBrace);
				} else {
					// parser error, set end node to max value.
					newIndexer.AddChild (new ErrorNode (), AstNode.Roles.Error);
				}
				typeStack.Peek ().AddChild (newIndexer, TypeDeclaration.MemberRole);
			}
開發者ID:N3X15,項目名稱:ILSpy,代碼行數:65,代碼來源:CSharpParser.cs

示例5: AddIndexer

		/// <summary>
		/// Indexer has special handling in constrast to other AddXXX because the name can be driven by IndexerNameAttribute
		/// </summary>
		public void AddIndexer (Indexer i)
		{
			orderedAllMembers.Add (i);
			if (indexers == null)
				indexers = new List<MemberCore> ();
			if (i.IsExplicitImpl)
				AddMemberToList (i, indexers, true);
			else 
				AddMemberToList (i, indexers, false);
		}
開發者ID:famousthom,項目名稱:monodevelop,代碼行數:13,代碼來源:class.cs

示例6: AddIndexer

		/// <summary>
		/// Indexer has special handling in constrast to other AddXXX because the name can be driven by IndexerNameAttribute
		/// </summary>
		public void AddIndexer (Indexer i)
		{
			if (indexers == null)
				indexers = new ArrayList ();

			if (i.IsExplicitImpl)
				AddMemberToList (i, indexers, true);
			else 
				AddMemberToList (i, indexers, false);
		}
開發者ID:calumjiao,項目名稱:Mono-Class-Libraries,代碼行數:13,代碼來源:class.cs

示例7: case_201

void case_201()
#line 1801 "cs-parser.jay"
{
		valid_param_mod = 0;
		var type = (FullNamedExpression) yyVals[-5+yyTop];
		Indexer indexer = new Indexer (current_type, type, (MemberName) yyVals[-4+yyTop], (Modifiers) yyVals[-6+yyTop], (ParametersCompiled) yyVals[-1+yyTop], (Attributes) yyVals[-7+yyTop]);
			
		current_property = indexer;

  		current_type.AddIndexer (indexer);
		lbag.AddMember (current_property, GetModifierLocations (), GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[0+yyTop]));
  		
		if (type.Type != null && type.Type.Kind == MemberKind.Void)
			report.Error (620, GetLocation (yyVals[-5+yyTop]), "`{0}': indexer return type cannot be `void'", indexer.GetSignatureForError ());  		

		if (indexer.ParameterInfo.IsEmpty) {
			report.Error (1551, GetLocation (yyVals[-3+yyTop]), "Indexers must have at least one parameter");
		}

		if (doc_support) {
			tmpComment = Lexer.consume_doc_comment ();
			Lexer.doc_state = XmlCommentState.Allowed;
		}

		lexer.PropertyParsing = true;
	  }
開發者ID:segaman,項目名稱:NRefactory,代碼行數:26,代碼來源:cs-parser.cs

示例8: yyparse


//.........這裏部分代碼省略.........
  {
		yyVal = new Accessor ((ToplevelBlock) yyVals[0+yyTop], 0, (Attributes) yyVals[-3+yyTop], null, GetLocation (yyVals[-2+yyTop]));
		lexer.EventParsing = true;
	  }
  break;
case 308:
#line 2387 "cs-parser.jay"
  {
		Report.Error (73, GetLocation (yyVals[-1+yyTop]), "An add or remove accessor must have a body");
		yyVal = null;
	  }
  break;
case 309:
#line 2391 "cs-parser.jay"
  {
		Report.Error (1609, GetLocation (yyVals[0+yyTop]), "Modifiers cannot be placed on event accessor declarations");
		yyVal = null;
	  }
  break;
case 310:
#line 2400 "cs-parser.jay"
  {
	  	valid_param_mod = ParameterModifierType.Params | ParameterModifierType.DefaultValue;
	  }
  break;
case 311:
#line 2405 "cs-parser.jay"
  {
		valid_param_mod = 0;
		implicit_value_parameter_type = (FullNamedExpression) yyVals[-6+yyTop];
		indexer_parameters = (ParametersCompiled) yyVals[-2+yyTop];
		
		if (indexer_parameters.IsEmpty) {
			Report.Error (1551, GetLocation (yyVals[-4+yyTop]), "Indexers must have at least one parameter");
		}

		if (RootContext.Documentation != null) {
			tmpComment = Lexer.consume_doc_comment ();
			Lexer.doc_state = XmlCommentState.Allowed;
		}

		lexer.PropertyParsing = true;
		parsing_indexer  = true;
		
	  }
  break;
case 312:
#line 2424 "cs-parser.jay"
  {
		  lexer.PropertyParsing = false;
		  has_get = has_set = false;
		  parsing_indexer  = false;
	  }
  break;
case 313:
#line 2430 "cs-parser.jay"
  { 
		Accessors accessors = (Accessors) yyVals[-2+yyTop];
		Accessor get_block = accessors != null ? accessors.get_or_add : null;
		Accessor set_block = accessors != null ? accessors.set_or_remove : null;
		bool order = accessors != null ? accessors.declared_in_reverse : false;

		Indexer indexer = new Indexer (current_class, (FullNamedExpression) yyVals[-10+yyTop],
			(MemberName)yyVals[-9+yyTop], (Modifiers) yyVals[-11+yyTop], (ParametersCompiled) yyVals[-6+yyTop], (Attributes) yyVals[-12+yyTop],
			get_block, set_block, order);
				       
開發者ID:speier,項目名稱:shake,代碼行數:66,代碼來源:cs-parser.cs

示例9: case_211

void case_211()
#line 1738 "cs-parser.jay"
{
		valid_param_mod = 0;
	  
		Indexer indexer = new Indexer (current_class, (FullNamedExpression) yyVals[-6+yyTop],
			(MemberName)yyVals[-5+yyTop], (Modifiers) yyVals[-7+yyTop], (ParametersCompiled) yyVals[-2+yyTop], (Attributes) yyVals[-8+yyTop]);
			
		current_property = indexer;

  		current_container.AddIndexer (indexer);
		lbag.AddMember (current_property, GetModifierLocations (), GetLocation (yyVals[-4+yyTop]), GetLocation (yyVals[-1+yyTop]), GetLocation (yyVals[0+yyTop]));
  		
		if (indexer.TypeExpression.Type == TypeManager.void_type)
			Report.Error (620, GetLocation (yyVals[-6+yyTop]), "`{0}': indexer return type cannot be `void'", indexer.GetSignatureForError ());  		

		if (indexer.Parameters.IsEmpty) {
			Report.Error (1551, GetLocation (yyVals[-4+yyTop]), "Indexers must have at least one parameter");
		}

		if (RootContext.Documentation != null) {
			tmpComment = Lexer.consume_doc_comment ();
			Lexer.doc_state = XmlCommentState.Allowed;
		}

		lexer.PropertyParsing = true;
	  }
開發者ID:Ein,項目名稱:monodevelop,代碼行數:27,代碼來源:cs-parser.cs

示例10: AddIndexer

		public AdditionResult AddIndexer (Indexer i)
		{
			if (indexers == null)
				indexers = new ArrayList ();

			if (i.InterfaceType != null)
				indexers.Insert (0, i);
			else
				indexers.Add (i);

			return AdditionResult.Success;
		}
開發者ID:emtees,項目名稱:old-code,代碼行數:12,代碼來源:class.cs

示例11: Visit

			public override void Visit (Indexer i)
			{
				VisitProperty(i);
			}
開發者ID:johnv315,項目名稱:playscript-mono,代碼行數:4,代碼來源:module.cs

示例12: AddIndexer

		/// <summary>
		/// Indexer has special handling in constrast to other AddXXX because the name can be driven by IndexerNameAttribute
		/// </summary>
		public void AddIndexer (Indexer i)
		{
			orderedAllMembers.Add (i);
			if (indexers == null)
				indexers = new List<MemberCore> ();

			AddMemberToList (i, indexers);
		}
開發者ID:nylen,項目名稱:SharpDevelop,代碼行數:11,代碼來源:class.cs

示例13: SetIndexerMethod

 public SetIndexerMethod(Indexer method)
     : base(method)
 {
     parameters = ParametersCompiled.MergeGenerated (Compiler, method.parameters, false, parameters [0], null);
 }
開發者ID:speier,項目名稱:shake,代碼行數:5,代碼來源:property.cs

示例14: GetIndexerMethod

 public GetIndexerMethod(Indexer method)
     : base(method)
 {
     this.parameters = method.parameters;
 }
開發者ID:speier,項目名稱:shake,代碼行數:5,代碼來源:property.cs

示例15: AddIndexer

		/// <summary>
		/// Indexer has special handling in constrast to other AddXXX because the name can be driven by IndexerNameAttribute
		/// </summary>
		public void AddIndexer (Indexer i)
		{
			if (indexers == null)
				indexers = new List<MemberCore> ();

			AddMemberToList (i, indexers);
		}
開發者ID:jordanbtucker,項目名稱:mono,代碼行數:10,代碼來源:class.cs


注:本文中的Mono.CSharp.Indexer類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。