当前位置: 首页>>代码示例>>C#>>正文


C# CSharp.AnonymousTypeParameter类代码示例

本文整理汇总了C#中Mono.CSharp.AnonymousTypeParameter的典型用法代码示例。如果您正苦于以下问题:C# AnonymousTypeParameter类的具体用法?C# AnonymousTypeParameter怎么用?C# AnonymousTypeParameter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


AnonymousTypeParameter类属于Mono.CSharp命名空间,在下文中一共展示了AnonymousTypeParameter类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: case_513

void case_513()
#line 3733 "cs-parser.jay"
{
	  	MemberAccess ma = (MemberAccess) yyVals[0+yyTop];
	  	yyVal = new AnonymousTypeParameter (ma, ma.Name, ma.Location);
	  }
开发者ID:segaman,项目名称:NRefactory,代码行数:6,代码来源:cs-parser.cs

示例2: Create

		public static AnonymousTypeClass Create (TypeContainer parent, IList<AnonymousTypeParameter> parameters, Location loc)
		{
			string name = ClassNamePrefix + parent.Module.CounterAnonymousTypes++;

			ParametersCompiled all_parameters;
			TypeParameters tparams = null;
			SimpleName[] t_args;

			if (parameters.Count == 0) {
				all_parameters = ParametersCompiled.EmptyReadOnlyParameters;
				t_args = null;
			} else {
				t_args = new SimpleName[parameters.Count];
				tparams = new TypeParameters ();
				Parameter[] ctor_params = new Parameter[parameters.Count];
				for (int i = 0; i < parameters.Count; ++i) {
					AnonymousTypeParameter p = parameters[i];
					for (int ii = 0; ii < i; ++ii) {
						if (parameters[ii].Name == p.Name) {
							parent.Compiler.Report.Error (833, parameters[ii].Location,
								"`{0}': An anonymous type cannot have multiple properties with the same name",
									p.Name);

							p = new AnonymousTypeParameter (null, "$" + i.ToString (), p.Location);
							parameters[i] = p;
							break;
						}
					}

					t_args[i] = new SimpleName ("<" + p.Name + ">__T", p.Location);
					tparams.Add (new TypeParameter (i, new MemberName (t_args[i].Name, p.Location), null, null, Variance.None));
					ctor_params[i] = new Parameter (t_args[i], p.Name, Parameter.Modifier.NONE, null, p.Location);
				}

				all_parameters = new ParametersCompiled (ctor_params);
			}

			//
			// Create generic anonymous type host with generic arguments
			// named upon properties names
			//
			AnonymousTypeClass a_type = new AnonymousTypeClass (parent.Module, new MemberName (name, tparams, loc), parameters, loc);

			Constructor c = new Constructor (a_type, name, Modifiers.PUBLIC | Modifiers.DEBUGGER_HIDDEN,
				null, all_parameters, loc);
			c.Block = new ToplevelBlock (parent.Module.Compiler, c.ParameterInfo, loc);

			// 
			// Create fields and constructor body with field initialization
			//
			bool error = false;
			for (int i = 0; i < parameters.Count; ++i) {
				AnonymousTypeParameter p = parameters [i];

				Field f = new Field (a_type, t_args [i], Modifiers.PRIVATE | Modifiers.READONLY | Modifiers.DEBUGGER_HIDDEN,
					new MemberName ("<" + p.Name + ">", p.Location), null);

				if (!a_type.AddField (f)) {
					error = true;
					continue;
				}

				c.Block.AddStatement (new StatementExpression (
					new SimpleAssign (new MemberAccess (new This (p.Location), f.Name),
						c.Block.GetParameterReference (i, p.Location))));

				ToplevelBlock get_block = new ToplevelBlock (parent.Module.Compiler, p.Location);
				get_block.AddStatement (new Return (
					new MemberAccess (new This (p.Location), f.Name), p.Location));

				Property prop = new Property (a_type, t_args [i], Modifiers.PUBLIC,
					new MemberName (p.Name, p.Location), null);
				prop.Get = new Property.GetMethod (prop, 0, null, p.Location);
				prop.Get.Block = get_block;
				a_type.AddMember (prop);
			}

			if (error)
				return null;

			a_type.AddConstructor (c);
			return a_type;
		}
开发者ID:rabink,项目名称:mono,代码行数:83,代码来源:anonymous.cs

示例3: case_511

void case_511()
#line 3721 "cs-parser.jay"
{
		var lt = (LocatedToken)yyVals[-2+yyTop];
	  	yyVal = new AnonymousTypeParameter ((Expression)yyVals[0+yyTop], lt.Value, lt.Location);
	  	lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop]));
	  }
开发者ID:segaman,项目名称:NRefactory,代码行数:7,代码来源:cs-parser.cs

示例4: case_512

void case_512()
#line 3727 "cs-parser.jay"
{
		var lt = (LocatedToken)yyVals[0+yyTop];
	  	yyVal = new AnonymousTypeParameter (new SimpleName (lt.Value, lt.Location),
	  		lt.Value, lt.Location);
	  }
开发者ID:segaman,项目名称:NRefactory,代码行数:7,代码来源:cs-parser.cs

示例5: yyparse


//.........这里部分代码省略.........
			Report.FeatureIsNotAvailable (GetLocation (yyVals[-2+yyTop]), "implicitly typed arrays");
	  
		yyVal = new ImplicitlyTypedArrayCreation ((string) yyVals[-1+yyTop], (ArrayInitializer) yyVals[0+yyTop], GetLocation (yyVals[-2+yyTop]));
	  }
  break;
case 493:
#line 3450 "cs-parser.jay"
  {
		Report.Error (1526, GetLocation (yyVals[-1+yyTop]), "A new expression requires () or [] after type");
		yyVal = new ArrayCreation ((FullNamedExpression) yyVals[-1+yyTop], "[]", null, GetLocation (yyVals[-1+yyTop]));
	  }
  break;
case 494:
#line 3458 "cs-parser.jay"
  {
		++lexer.parsing_type;
	  }
  break;
case 495:
#line 3462 "cs-parser.jay"
  {
		--lexer.parsing_type;
		yyVal = yyVals[0+yyTop];
	  }
  break;
case 496:
#line 3470 "cs-parser.jay"
  {
		if (RootContext.MetadataCompatibilityVersion < MetadataVersion.v2)	  
	  		Report.FeatureIsNotSupported (GetLocation (yyVals[-3+yyTop]), "anonymous types");
	  	else if (RootContext.Version <= LanguageVersion.ISO_2)
	  		Report.FeatureIsNotAvailable (GetLocation (yyVals[-3+yyTop]), "anonymous types");

		yyVal = new NewAnonymousType ((List<AnonymousTypeParameter>) yyVals[-1+yyTop], current_container, GetLocation (yyVals[-3+yyTop]));
	  }
  break;
case 499:
#line 3486 "cs-parser.jay"
  { yyVal = null; }
  break;
case 501:
#line 3492 "cs-parser.jay"
  {
	  	var a = new List<AnonymousTypeParameter> (4);
	  	a.Add ((AnonymousTypeParameter) yyVals[0+yyTop]);
	  	yyVal = a;
	  }
  break;
case 502:
#line 3498 "cs-parser.jay"
  {
	  	var a = (List<AnonymousTypeParameter>) yyVals[-2+yyTop];
	  	a.Add ((AnonymousTypeParameter) yyVals[0+yyTop]);
	  	yyVal = a;
	  }
  break;
case 503:
#line 3507 "cs-parser.jay"
  {
		var lt = (Tokenizer.LocatedToken)yyVals[-2+yyTop];
	  	yyVal = new AnonymousTypeParameter ((Expression)yyVals[0+yyTop], lt.Value, lt.Location);
	  }
  break;
case 504:
#line 3512 "cs-parser.jay"
  {
开发者ID:speier,项目名称:shake,代码行数:67,代码来源:cs-parser.cs

示例6: GeneratedParameter

			public GeneratedParameter (FullNamedExpression type, AnonymousTypeParameter p)
				: base (type, p.Name, Modifier.NONE, null, p.Location)
			{
			}
开发者ID:silk,项目名称:monodevelop,代码行数:4,代码来源:anonymous.cs

示例7: case_504

void case_504()
{
		var lt = (Tokenizer.LocatedToken)yyVals[0+yyTop];
	  	yyVal = new AnonymousTypeParameter (new SimpleName (lt.Value, lt.Location),
	  		lt.Value, lt.Location);
	  }
开发者ID:animaonline,项目名称:Portable-Mono.CSharp,代码行数:6,代码来源:cs-parser.cs

示例8: case_505

void case_505()
{
	  	MemberAccess ma = (MemberAccess) yyVals[0+yyTop];
	  	yyVal = new AnonymousTypeParameter (ma, ma.Name, ma.Location);
	  }
开发者ID:animaonline,项目名称:Portable-Mono.CSharp,代码行数:5,代码来源:cs-parser.cs

示例9: case_503

void case_503()
{
		var lt = (Tokenizer.LocatedToken)yyVals[-2+yyTop];
	  	yyVal = new AnonymousTypeParameter ((Expression)yyVals[0+yyTop], lt.Value, lt.Location);
	  	lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop]));
	  }
开发者ID:animaonline,项目名称:Portable-Mono.CSharp,代码行数:6,代码来源:cs-parser.cs

示例10: yyparse


//.........这里部分代码省略.........
case 514:
#line 3813 "D:\GitHub\M\Marvin\mcs\cs-parser.jay"
  {
		report.Error (178, GetLocation (yyVals[-1+yyTop]), "Invalid rank specifier, expecting `,' or `]'");
		yyVal = new ArrayCreation ((FullNamedExpression) yyVals[-5+yyTop], null, GetLocation (yyVals[-6+yyTop]));
	  }
  break;
case 515:
#line 3818 "D:\GitHub\M\Marvin\mcs\cs-parser.jay"
  {
		Error_SyntaxError (1526, yyToken, "Unexpected symbol");
		yyVal = new ArrayCreation ((FullNamedExpression) yyVals[-1+yyTop], null, GetLocation (yyVals[-2+yyTop]));
	  }
  break;
case 516:
#line 3825 "D:\GitHub\M\Marvin\mcs\cs-parser.jay"
  {
		++lexer.parsing_type;
	  }
  break;
case 517:
#line 3829 "D:\GitHub\M\Marvin\mcs\cs-parser.jay"
  {
		--lexer.parsing_type;
		yyVal = yyVals[0+yyTop];
	  }
  break;
case 518:
#line 3837 "D:\GitHub\M\Marvin\mcs\cs-parser.jay"
  {
		if (lang_version <= LanguageVersion.ISO_2)
	  		FeatureIsNotAvailable (GetLocation (yyVals[-3+yyTop]), "anonymous types");

		yyVal = new NewAnonymousType ((List<AnonymousTypeParameter>) yyVals[-1+yyTop], current_container, GetLocation (yyVals[-3+yyTop]));
		
		/* TODO: lbag comma location*/
		lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop]));
	  }
  break;
case 521:
#line 3854 "D:\GitHub\M\Marvin\mcs\cs-parser.jay"
  { yyVal = null; }
  break;
case 523:
#line 3860 "D:\GitHub\M\Marvin\mcs\cs-parser.jay"
  {
	  	var a = new List<AnonymousTypeParameter> (4);
	  	a.Add ((AnonymousTypeParameter) yyVals[0+yyTop]);
	  	yyVal = a;
	  }
  break;
case 524:
#line 3866 "D:\GitHub\M\Marvin\mcs\cs-parser.jay"
  {
	  	var a = (List<AnonymousTypeParameter>) yyVals[-2+yyTop];
	  	a.Add ((AnonymousTypeParameter) yyVals[0+yyTop]);
	  	yyVal = a;
	  }
  break;
case 525:
#line 3875 "D:\GitHub\M\Marvin\mcs\cs-parser.jay"
  {
		var lt = (Tokenizer.LocatedToken)yyVals[-2+yyTop];
	  	yyVal = new AnonymousTypeParameter ((Expression)yyVals[0+yyTop], lt.Value, lt.Location);
	  	lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop]));
	  }
开发者ID:runefs,项目名称:Marvin,代码行数:67,代码来源:cs-parser.cs

示例11: case_511

void case_511()
#line 3504 "C:\Projects\Junk\mono\mcs\class\Mono.CSharp\..\..\mcs\cs-parser.jay"
{
	  	MemberAccess ma = (MemberAccess) yyVals[0+yyTop];
	  	yyVal = new AnonymousTypeParameter (ma, ma.Name, ma.Location);
	  }
开发者ID:RainsSoft,项目名称:MonoCompilerAsAService,代码行数:6,代码来源:cs-parser.cs

示例12: case_510

void case_510()
#line 3498 "C:\Projects\Junk\mono\mcs\class\Mono.CSharp\..\..\mcs\cs-parser.jay"
{
		var lt = (Tokenizer.LocatedToken)yyVals[0+yyTop];
	  	yyVal = new AnonymousTypeParameter (new SimpleName (lt.Value, lt.Location),
	  		lt.Value, lt.Location);
	  }
开发者ID:RainsSoft,项目名称:MonoCompilerAsAService,代码行数:7,代码来源:cs-parser.cs

示例13: case_509

void case_509()
#line 3492 "C:\Projects\Junk\mono\mcs\class\Mono.CSharp\..\..\mcs\cs-parser.jay"
{
		var lt = (Tokenizer.LocatedToken)yyVals[-2+yyTop];
	  	yyVal = new AnonymousTypeParameter ((Expression)yyVals[0+yyTop], lt.Value, lt.Location);
	  	lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop]));
	  }
开发者ID:RainsSoft,项目名称:MonoCompilerAsAService,代码行数:7,代码来源:cs-parser.cs


注:本文中的Mono.CSharp.AnonymousTypeParameter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。