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


C# TypeContainer.AddEvent方法代碼示例

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


在下文中一共展示了TypeContainer.AddEvent方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: yyparse


//.........這裏部分代碼省略.........
			Report.Error (575, lt.Location, "Only class types can contain destructor");
		} else {
			Destructor d = new Destructor (current_class, (Modifiers) yyVals[-6+yyTop],
				ParametersCompiled.EmptyReadOnlyParameters, (Attributes) yyVals[-7+yyTop], lt.Location);
			if (RootContext.Documentation != null)
				d.DocComment = ConsumeStoredComment ();
		  
			d.Block = (ToplevelBlock) yyVals[0+yyTop];
			current_container.AddMethod (d);
		}

		current_local_parameters = null;
	  }
  break;
case 291:
#line 2248 "cs-parser.jay"
  {
		foreach (VariableMemberDeclaration var in (List<object>) yyVals[-1+yyTop]) {

			EventField e = new EventField (
				current_class, (FullNamedExpression) yyVals[-2+yyTop], (Modifiers) yyVals[-4+yyTop], var.MemberName, (Attributes) yyVals[-5+yyTop]);
				
			e.Initializer = var.GetInitializer ((FullNamedExpression) yyVals[-2+yyTop]);
			if (current_container.Kind == MemberKind.Interface && e.Initializer != null) {
				Report.Error (68, e.Location, "`{0}': event in interface cannot have initializer", e.GetSignatureForError ());
			}
			
			if (var.MemberName.Left != null) {
				Report.Error (71, e.Location,
					"`{0}': An explicit interface implementation of an event must use property syntax",
					e.GetSignatureForError ());
			}

			current_container.AddEvent (e);

			if (RootContext.Documentation != null) {
				e.DocComment = Lexer.consume_doc_comment ();
				Lexer.doc_state = XmlCommentState.Allowed;
			}
		}
	  }
  break;
case 292:
#line 2277 "cs-parser.jay"
  {
		implicit_value_parameter_type = (FullNamedExpression) yyVals[-2+yyTop];  
		current_local_parameters = new ParametersCompiled (compiler,
			new Parameter (implicit_value_parameter_type, "value", 
			Parameter.Modifier.NONE, null, GetLocation (yyVals[-3+yyTop])));

		lexer.EventParsing = true;
	  }
  break;
case 293:
#line 2286 "cs-parser.jay"
  {
		lexer.EventParsing = false;  
	  }
  break;
case 294:
#line 2290 "cs-parser.jay"
  {
		MemberName name = (MemberName) yyVals[-5+yyTop];
		
		if (current_container.Kind == MemberKind.Interface) {
			Report.Error (69, GetLocation (yyVals[-7+yyTop]), "Event in interface cannot have add or remove accessors");
開發者ID:speier,項目名稱:shake,代碼行數:67,代碼來源:cs-parser.cs


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