本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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);
示例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;
}
示例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;
}
示例11: Visit
public override void Visit (Indexer i)
{
VisitProperty(i);
}
示例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);
}
示例13: SetIndexerMethod
public SetIndexerMethod(Indexer method)
: base(method)
{
parameters = ParametersCompiled.MergeGenerated (Compiler, method.parameters, false, parameters [0], null);
}
示例14: GetIndexerMethod
public GetIndexerMethod(Indexer method)
: base(method)
{
this.parameters = method.parameters;
}
示例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);
}