本文整理汇总了C#中Mono.CSharp.CollectionOrObjectInitializers类的典型用法代码示例。如果您正苦于以下问题:C# CollectionOrObjectInitializers类的具体用法?C# CollectionOrObjectInitializers怎么用?C# CollectionOrObjectInitializers使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CollectionOrObjectInitializers类属于Mono.CSharp命名空间,在下文中一共展示了CollectionOrObjectInitializers类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ConvertCollectionOrObjectInitializers
ArrayInitializerExpression ConvertCollectionOrObjectInitializers(CollectionOrObjectInitializers minit)
{
if (minit == null)
return null;
var init = new ArrayInitializerExpression();
AddConvertCollectionOrObjectInitializers(init, minit);
return init;
}
开发者ID:0xb1dd1e,项目名称:NRefactory,代码行数:8,代码来源:CSharpParser.cs
示例2: AddConvertCollectionOrObjectInitializers
void AddConvertCollectionOrObjectInitializers(Expression init, CollectionOrObjectInitializers minit)
{
var initLoc = LocationsBag.GetLocations(minit);
var commaLoc = LocationsBag.GetLocations(minit.Initializers);
int curComma = 0;
init.AddChild(new CSharpTokenNode(Convert(minit.Location), Roles.LBrace), Roles.LBrace);
foreach (var expr in minit.Initializers) {
var collectionInit = expr as CollectionElementInitializer;
if (collectionInit != null) {
AstNode parent;
// For ease of use purposes in the resolver the ast representation
// of { a, b, c } is { {a}, {b}, {c} } - but the generated ArrayInitializerExpression
// can be identified by expr.IsSingleElement.
if (!collectionInit.IsSingle) {
parent = new ArrayInitializerExpression();
parent.AddChild(new CSharpTokenNode(Convert(collectionInit.Location), Roles.LBrace), Roles.LBrace);
} else {
parent = ArrayInitializerExpression.CreateSingleElementInitializer();
}
if (collectionInit.Arguments != null) {
for (int i = 0; i < collectionInit.Arguments.Count; i++) {
var arg = collectionInit.Arguments [i] as CollectionElementInitializer.ElementInitializerArgument;
if (arg == null || arg.Expr == null)
continue;
parent.AddChild(
(Expression)arg.Expr.Accept(this),
Roles.Expression
);
}
}
if (!collectionInit.IsSingle) {
var braceLocs = LocationsBag.GetLocations(expr);
if (braceLocs != null)
parent.AddChild(new CSharpTokenNode(Convert(braceLocs [0]), Roles.RBrace), Roles.RBrace);
}
init.AddChild((ArrayInitializerExpression)parent, Roles.Expression);
} else {
var eleInit = expr as ElementInitializer;
if (eleInit != null) {
var nexpr = new NamedExpression();
nexpr.AddChild(
Identifier.Create(eleInit.Name, Convert(eleInit.Location)),
Roles.Identifier
);
var assignLoc = LocationsBag.GetLocations(eleInit);
if (assignLoc != null)
nexpr.AddChild(new CSharpTokenNode(Convert(assignLoc [0]), Roles.Assign), Roles.Assign);
if (eleInit.Source != null) {
var colInit = eleInit.Source as CollectionOrObjectInitializers;
if (colInit != null) {
var arrInit = new ArrayInitializerExpression();
AddConvertCollectionOrObjectInitializers(
arrInit,
colInit
);
nexpr.AddChild(arrInit, Roles.Expression);
} else {
nexpr.AddChild((Expression)eleInit.Source.Accept(this), Roles.Expression);
}
}
init.AddChild(nexpr, Roles.Expression);
}
}
if (commaLoc != null && curComma < commaLoc.Count)
init.AddChild(new CSharpTokenNode(Convert(commaLoc [curComma++]), Roles.Comma), Roles.Comma);
}
if (initLoc != null) {
if (initLoc.Count == 2) // optional comma
init.AddChild(new CSharpTokenNode(Convert(initLoc [0]), Roles.Comma), Roles.Comma);
init.AddChild(new CSharpTokenNode(Convert(initLoc [initLoc.Count - 1]), Roles.RBrace), Roles.RBrace);
}
}
开发者ID:0xb1dd1e,项目名称:NRefactory,代码行数:76,代码来源:CSharpParser.cs
示例3: case_451
void case_451()
#line 3341 "cs-parser.jay"
{
yyVal = new CollectionOrObjectInitializers ((List<Expression>) yyVals[-2+yyTop], GetLocation (yyVals[-3+yyTop]));
lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop]), GetLocation (yyVals[0+yyTop]));
}
开发者ID:segaman,项目名称:NRefactory,代码行数:6,代码来源:cs-parser.cs
示例4: AddConvertCollectionOrObjectInitializers
void AddConvertCollectionOrObjectInitializers (Expression init, CollectionOrObjectInitializers minit)
{
var initLoc = LocationsBag.GetLocations (minit);
var commaLoc = LocationsBag.GetLocations (minit.Initializers);
int curComma = 0;
if (initLoc != null)
init.AddChild (new CSharpTokenNode (Convert (initLoc [0]), 1), ArrayInitializerExpression.Roles.LBrace);
foreach (var expr in minit.Initializers) {
var collectionInit = expr as CollectionElementInitializer;
if (collectionInit != null) {
var parent = new ArrayInitializerExpression ();
var braceLocs = LocationsBag.GetLocations (expr);
if (braceLocs != null)
parent.AddChild (new CSharpTokenNode (Convert (braceLocs [0]), 1), ArrayInitializerExpression.Roles.LBrace);
for (int i = 0; i < collectionInit.Arguments.Count; i++) {
var arg = collectionInit.Arguments [i] as CollectionElementInitializer.ElementInitializerArgument;
if (arg == null)
continue;
parent.AddChild ((ICSharpCode.NRefactory.CSharp.Expression)arg.Expr.Accept (this), ArrayInitializerExpression.Roles.Expression);
}
if (braceLocs != null)
parent.AddChild (new CSharpTokenNode (Convert (braceLocs [1]), 1), ArrayInitializerExpression.Roles.RBrace);
init.AddChild (parent, ArrayInitializerExpression.Roles.Expression);
} else {
var eleInit = expr as ElementInitializer;
if (eleInit != null) {
var nexpr = new NamedExpression ();
nexpr.AddChild (Identifier.Create (eleInit.Name, Convert (eleInit.Location)), NamedArgumentExpression.Roles.Identifier);
var assignLoc = LocationsBag.GetLocations (eleInit);
if (assignLoc != null)
nexpr.AddChild (new CSharpTokenNode (Convert (assignLoc [0]), 1), NamedArgumentExpression.Roles.Assign);
if (eleInit.Source != null) {
if (eleInit.Source is CollectionOrObjectInitializers) {
var arrInit = new ArrayInitializerExpression ();
AddConvertCollectionOrObjectInitializers (arrInit, eleInit.Source as CollectionOrObjectInitializers);
nexpr.AddChild (arrInit, NamedArgumentExpression.Roles.Expression);
} else {
nexpr.AddChild ((Expression)eleInit.Source.Accept (this), NamedArgumentExpression.Roles.Expression);
}
}
init.AddChild (nexpr, ArrayInitializerExpression.Roles.Expression);
}
}
if (commaLoc != null && curComma < commaLoc.Count)
init.AddChild (new CSharpTokenNode (Convert (commaLoc [curComma++]), 1), ArrayInitializerExpression.Roles.Comma);
}
if (initLoc != null) {
if (initLoc.Count == 3) // optional comma
init.AddChild (new CSharpTokenNode (Convert (initLoc [1]), 1), ArrayInitializerExpression.Roles.Comma);
init.AddChild (new CSharpTokenNode (Convert (initLoc [initLoc.Count - 1]), 1), ArrayInitializerExpression.Roles.RBrace);
}
}
开发者ID:N3X15,项目名称:ILSpy,代码行数:58,代码来源:CSharpParser.cs
示例5: case_452
void case_452()
#line 3151 "cs-parser.jay"
{
if (yyVals[-1+yyTop] == null) {
yyVal = CollectionOrObjectInitializers.Empty;
/* TODO: lbag*/
} else {
yyVal = new CollectionOrObjectInitializers ((List<Expression>) yyVals[-1+yyTop], GetLocation (yyVals[-2+yyTop]));
lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop]));
}
}
开发者ID:Ein,项目名称:monodevelop,代码行数:11,代码来源:cs-parser.cs
示例6: case_450
void case_450()
#line 3332 "cs-parser.jay"
{
if (yyVals[-1+yyTop] == null) {
yyVal = new CollectionOrObjectInitializers (GetLocation (yyVals[-2+yyTop]));
} else {
yyVal = new CollectionOrObjectInitializers ((List<Expression>) yyVals[-1+yyTop], GetLocation (yyVals[-2+yyTop]));
}
lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop]));
}
开发者ID:segaman,项目名称:NRefactory,代码行数:10,代码来源:cs-parser.cs
示例7: yyparse
//.........这里部分代码省略.........
{
var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop];
yyVal = new CompletionMemberAccess ((Expression) yyVals[-3+yyTop], lt.Value, lt.Location);
}
break;
case 436:
#line 3106 "cs-parser.jay"
{
/* TODO: Location is wrong as some predefined types doesn't hold a location*/
yyVal = new CompletionMemberAccess ((Expression) yyVals[-2+yyTop], null, lexer.Location);
}
break;
case 437:
#line 3110 "cs-parser.jay"
{
var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop];
yyVal = new CompletionMemberAccess ((Expression) yyVals[-3+yyTop], lt.Value, lt.Location);
}
break;
case 438:
#line 3118 "cs-parser.jay"
{
yyVal = new Invocation ((Expression) yyVals[-3+yyTop], (Arguments) yyVals[-1+yyTop]);
}
break;
case 439:
#line 3124 "cs-parser.jay"
{ yyVal = null; }
break;
case 441:
#line 3130 "cs-parser.jay"
{
if (yyVals[-1+yyTop] == null)
yyVal = CollectionOrObjectInitializers.Empty;
else
yyVal = new CollectionOrObjectInitializers ((List<Expression>) yyVals[-1+yyTop], GetLocation (yyVals[-2+yyTop]));
}
break;
case 442:
#line 3137 "cs-parser.jay"
{
yyVal = new CollectionOrObjectInitializers ((List<Expression>) yyVals[-2+yyTop], GetLocation (yyVals[-3+yyTop]));
}
break;
case 443:
#line 3143 "cs-parser.jay"
{ yyVal = null; }
break;
case 444:
#line 3145 "cs-parser.jay"
{
yyVal = yyVals[0+yyTop];
}
break;
case 445:
#line 3152 "cs-parser.jay"
{
var a = new List<Expression> ();
a.Add ((Expression) yyVals[0+yyTop]);
yyVal = a;
}
break;
case 446:
#line 3158 "cs-parser.jay"
{
var a = (List<Expression>)yyVals[-2+yyTop];
开发者ID:speier,项目名称:shake,代码行数:67,代码来源:cs-parser.cs
示例8: ConvertCollectionOrObjectInitializers
ArrayInitializerExpression ConvertCollectionOrObjectInitializers (CollectionOrObjectInitializers minit)
{
if (minit == null)
return null;
var init = new ArrayInitializerExpression ();
var braceLocs = LocationsBag.GetLocations (minit);
if (braceLocs != null)
init.AddChild (new CSharpTokenNode (Convert (braceLocs[0]), 1), ArrayInitializerExpression.Roles.LBrace);
AddConvertCollectionOrObjectInitializers (init, minit);
if (braceLocs != null)
init.AddChild (new CSharpTokenNode (Convert (braceLocs[1]), 1), ArrayInitializerExpression.Roles.RBrace);
return init;
}
开发者ID:aleksandersumowski,项目名称:monodevelop,代码行数:13,代码来源:CSharpParser.cs
示例9: NewInitialize
public NewInitialize (Expression requested_type, Arguments arguments, CollectionOrObjectInitializers initializers, Location l)
: base (requested_type, arguments, l)
{
this.initializers = initializers;
}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:5,代码来源:expression.cs
示例10: case_443
void case_443()
{
yyVal = new CollectionOrObjectInitializers ((List<Expression>) yyVals[-2+yyTop], GetLocation (yyVals[-3+yyTop]));
lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop]), GetLocation (yyVals[0+yyTop]));
}
开发者ID:animaonline,项目名称:Portable-Mono.CSharp,代码行数:5,代码来源:cs-parser.cs
示例11: yyparse
//.........这里部分代码省略.........
yyVal = new CompletionMemberAccess ((Expression) yyVals[-3+yyTop], lt.Value, lt.Location);
}
break;
case 461:
#line 3482 "D:\GitHub\M\Marvin\mcs\cs-parser.jay"
{
isInteractionArgumentList = isInteraction;
}
break;
case 462:
#line 3486 "D:\GitHub\M\Marvin\mcs\cs-parser.jay"
{
isInteractionArgumentList = false;
}
break;
case 463:
#line 3490 "D:\GitHub\M\Marvin\mcs\cs-parser.jay"
{
var instance = (Expression) yyVals[-5+yyTop];
var arguments = (Arguments) yyVals[-2+yyTop];
yyVal = new Invocation (instance,arguments);
lbag.AddLocation (yyVal, GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[-1+yyTop]));
}
break;
case 464:
#line 3500 "D:\GitHub\M\Marvin\mcs\cs-parser.jay"
{ yyVal = null; }
break;
case 466:
#line 3506 "D:\GitHub\M\Marvin\mcs\cs-parser.jay"
{
if (yyVals[-1+yyTop] == null) {
yyVal = CollectionOrObjectInitializers.Empty;
/* TODO: lbag*/
} else {
yyVal = new CollectionOrObjectInitializers ((List<Expression>) yyVals[-1+yyTop], GetLocation (yyVals[-2+yyTop]));
lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop]));
}
}
break;
case 467:
#line 3516 "D:\GitHub\M\Marvin\mcs\cs-parser.jay"
{
yyVal = new CollectionOrObjectInitializers ((List<Expression>) yyVals[-2+yyTop], GetLocation (yyVals[-3+yyTop]));
lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop]), GetLocation (yyVals[0+yyTop]));
}
break;
case 468:
#line 3523 "D:\GitHub\M\Marvin\mcs\cs-parser.jay"
{ yyVal = null; }
break;
case 469:
#line 3525 "D:\GitHub\M\Marvin\mcs\cs-parser.jay"
{
yyVal = yyVals[0+yyTop];
}
break;
case 470:
#line 3532 "D:\GitHub\M\Marvin\mcs\cs-parser.jay"
{
var a = new List<Expression> ();
a.Add ((Expression) yyVals[0+yyTop]);
yyVal = a;
}
break;
开发者ID:runefs,项目名称:Marvin,代码行数:67,代码来源:cs-parser.cs
示例12: case_451
void case_451()
#line 3137 "C:\Projects\Junk\mono\mcs\class\Mono.CSharp\..\..\mcs\cs-parser.jay"
{
yyVal = new CollectionOrObjectInitializers ((List<Expression>) yyVals[-2+yyTop], GetLocation (yyVals[-3+yyTop]));
lbag.AddLocation (yyVal, GetLocation (yyVals[-1+yyTop]), GetLocation (yyVals[0+yyTop]));
}
开发者ID:RainsSoft,项目名称:MonoCompilerAsAService,代码行数:6,代码来源:cs-parser.cs
示例13: case_450
void case_450()
#line 3127 "C:\Projects\Junk\mono\mcs\class\Mono.CSharp\..\..\mcs\cs-parser.jay"
{
if (yyVals[-1+yyTop] == null) {
yyVal = CollectionOrObjectInitializers.Empty;
/* TODO: lbag*/
} else {
yyVal = new CollectionOrObjectInitializers ((List<Expression>) yyVals[-1+yyTop], GetLocation (yyVals[-2+yyTop]));
lbag.AddLocation (yyVal, GetLocation (yyVals[0+yyTop]));
}
}
开发者ID:RainsSoft,项目名称:MonoCompilerAsAService,代码行数:11,代码来源:cs-parser.cs
注:本文中的Mono.CSharp.CollectionOrObjectInitializers类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论