本文整理汇总了C#中Mono.Cecil.PropertyDefinition.IsIndexer方法的典型用法代码示例。如果您正苦于以下问题:C# PropertyDefinition.IsIndexer方法的具体用法?C# PropertyDefinition.IsIndexer怎么用?C# PropertyDefinition.IsIndexer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mono.Cecil.PropertyDefinition
的用法示例。
在下文中一共展示了PropertyDefinition.IsIndexer方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AnalyzedPropertyTreeNode
public AnalyzedPropertyTreeNode(PropertyDefinition analyzedProperty, string prefix = "")
{
if (analyzedProperty == null)
throw new ArgumentNullException("analyzedProperty");
this.isIndexer = analyzedProperty.IsIndexer();
this.analyzedProperty = analyzedProperty;
this.prefix = prefix;
this.LazyLoading = true;
}
示例2: PropertyTreeNode
public PropertyTreeNode(PropertyDefinition property)
{
if (property == null)
throw new ArgumentNullException("property");
this.property = property;
using (LoadedAssembly.DisableAssemblyLoad()) {
this.isIndexer = property.IsIndexer();
}
if (property.GetMethod != null)
this.Children.Add(new MethodTreeNode(property.GetMethod));
if (property.SetMethod != null)
this.Children.Add(new MethodTreeNode(property.SetMethod));
if (property.HasOtherMethods) {
foreach (var m in property.OtherMethods)
this.Children.Add(new MethodTreeNode(m));
}
}
示例3: WritePropertyDeclaration
protected override void WritePropertyDeclaration(PropertyDefinition property)
{
MethodDefinition moreVisibleMethod = property.GetMethod.GetMoreVisibleMethod(property.SetMethod);
if (property.IsIndexer())
{
WriteIndexerKeywords();
}
if (this.ModuleContext.RenamedMembers.Contains(property.MetadataToken.ToUInt32()))
{
WriteComment(property.Name);
WriteLine();
}
if (!property.IsExplicitImplementation())
{
WriteMethodVisibilityAndSpace(moreVisibleMethod);
}
if (!(property.IsVirtual() && !property.IsNewSlot()))
{
bool isIndexerProperty = property.IsIndexer();
if ((isIndexerProperty && IsIndexerPropertyHiding(property)) || (!isIndexerProperty && IsPropertyHiding(property)))
{
WriteKeyword(KeyWordWriter.Hiding);
WriteSpace();
}
}
if (property.IsVirtual() && !property.DeclaringType.IsInterface)
{
if (WritePropertyKeywords(property))
{
WriteSpace();
}
}
//covers the case of properties with only one of the get/set methods in VB
WriteReadOnlyWriteOnlyProperty(property);
if (property.IsStatic())
{
WriteKeyword(KeyWordWriter.Static);
WriteSpace();
}
if (KeyWordWriter.Property != null)
{
WriteKeyword(KeyWordWriter.Property);
WriteSpace();
}
if (property.IsIndexer())
{
if (WritePropertyAsIndexer(property))
{
return;
}
}
WritePropertyTypeAndNameWithArguments(property);
WritePropertyInterfaceImplementations(property);
}
示例4: FormatPropertyName
public override string FormatPropertyName(PropertyDefinition property, bool? isIndexer)
{
if (property == null)
throw new ArgumentNullException("property");
if (!isIndexer.HasValue) {
isIndexer = property.IsIndexer();
}
if (isIndexer.Value) {
var buffer = new System.Text.StringBuilder();
var accessor = property.GetMethod ?? property.SetMethod;
if (accessor.HasOverrides) {
var declaringType = accessor.Overrides.First().DeclaringType;
buffer.Append(TypeToString(declaringType, includeNamespace: true));
buffer.Append(@".");
}
buffer.Append(@"this[");
bool addSeparator = false;
foreach (var p in property.Parameters) {
if (addSeparator)
buffer.Append(@", ");
else
addSeparator = true;
buffer.Append(TypeToString(p.ParameterType, includeNamespace: true));
}
buffer.Append(@"]");
return buffer.ToString();
} else
return property.Name;
}
示例5: GetOverlayedImage
ImageSource GetOverlayedImage(PropertyDefinition propDef, MemberIcon icon)
{
bool isStatic = false;
AccessOverlayIcon overlayIcon = AccessOverlayIcon.Public;
return Images.GetIcon(propDef.IsIndexer() ? MemberIcon.Indexer : icon, overlayIcon, isStatic);
}
示例6: CreateProperty
MemberDeclaration CreateProperty(PropertyDefinition propDef)
{
PropertyDeclaration astProp = new PropertyDeclaration();
astProp.AddAnnotation(propDef);
var accessor = propDef.GetMethod ?? propDef.SetMethod;
Modifiers getterModifiers = Modifiers.None;
Modifiers setterModifiers = Modifiers.None;
if (accessor.HasOverrides) {
astProp.PrivateImplementationType = ConvertType(accessor.Overrides.First().DeclaringType);
} else if (!propDef.DeclaringType.IsInterface) {
getterModifiers = ConvertModifiers(propDef.GetMethod);
setterModifiers = ConvertModifiers(propDef.SetMethod);
astProp.Modifiers = FixUpVisibility(getterModifiers | setterModifiers);
try {
if (accessor.IsVirtual && !accessor.IsNewSlot && (propDef.GetMethod == null || propDef.SetMethod == null)) {
foreach (var basePropDef in TypesHierarchyHelpers.FindBaseProperties(propDef)) {
if (basePropDef.GetMethod != null && basePropDef.SetMethod != null) {
var propVisibilityModifiers = ConvertModifiers(basePropDef.GetMethod) | ConvertModifiers(basePropDef.SetMethod);
astProp.Modifiers = FixUpVisibility((astProp.Modifiers & ~Modifiers.VisibilityMask) | (propVisibilityModifiers & Modifiers.VisibilityMask));
break;
} else if ((basePropDef.GetMethod ?? basePropDef.SetMethod).IsNewSlot) {
break;
}
}
}
if (accessor.IsVirtual ^ !accessor.IsNewSlot) {
if (TypesHierarchyHelpers.FindBaseProperties(propDef).Any())
astProp.Modifiers |= Modifiers.New;
}
} catch (ReferenceResolvingException) {
// TODO: add some kind of notification (a comment?) about possible problems with decompiled code due to unresolved references.
}
}
astProp.Name = CleanName(propDef.Name);
astProp.ReturnType = ConvertType(propDef.PropertyType, propDef);
if (propDef.GetMethod != null) {
// Create mapping - used in debugger
MemberMapping methodMapping = propDef.GetMethod.CreateCodeMapping(this.CodeMappings);
astProp.Getter = new Accessor();
astProp.Getter.Body = CreateMethodBody(propDef.GetMethod);
astProp.AddAnnotation(propDef.GetMethod);
ConvertAttributes(astProp.Getter, propDef.GetMethod);
if ((getterModifiers & Modifiers.VisibilityMask) != (astProp.Modifiers & Modifiers.VisibilityMask))
astProp.Getter.Modifiers = getterModifiers & Modifiers.VisibilityMask;
astProp.Getter.WithAnnotation(methodMapping);
}
if (propDef.SetMethod != null) {
// Create mapping - used in debugger
MemberMapping methodMapping = propDef.SetMethod.CreateCodeMapping(this.CodeMappings);
astProp.Setter = new Accessor();
astProp.Setter.Body = CreateMethodBody(propDef.SetMethod);
astProp.Setter.AddAnnotation(propDef.SetMethod);
ConvertAttributes(astProp.Setter, propDef.SetMethod);
ConvertCustomAttributes(astProp.Setter, propDef.SetMethod.Parameters.Last(), "param");
if ((setterModifiers & Modifiers.VisibilityMask) != (astProp.Modifiers & Modifiers.VisibilityMask))
astProp.Setter.Modifiers = setterModifiers & Modifiers.VisibilityMask;
astProp.Setter.WithAnnotation(methodMapping);
}
ConvertCustomAttributes(astProp, propDef);
if(propDef.IsIndexer())
return ConvertPropertyToIndexer(astProp, propDef);
else
return astProp;
}