本文整理汇总了C#中dnlib.DotNet.PropertyDef.IsIndexer方法的典型用法代码示例。如果您正苦于以下问题:C# PropertyDef.IsIndexer方法的具体用法?C# PropertyDef.IsIndexer怎么用?C# PropertyDef.IsIndexer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dnlib.DotNet.PropertyDef
的用法示例。
在下文中一共展示了PropertyDef.IsIndexer方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PropertyNode
public PropertyNode(PropertyDef analyzedProperty, bool hidesParent = false) {
if (analyzedProperty == null)
throw new ArgumentNullException(nameof(analyzedProperty));
isIndexer = analyzedProperty.IsIndexer();
this.analyzedProperty = analyzedProperty;
this.hidesParent = hidesParent;
}
示例2: AnalyzedPropertyTreeNode
public AnalyzedPropertyTreeNode(PropertyDef analyzedProperty, bool hidesParent = false) {
if (analyzedProperty == null)
throw new ArgumentNullException("analyzedProperty");
this.isIndexer = analyzedProperty.IsIndexer();
this.analyzedProperty = analyzedProperty;
this.hidesParent = hidesParent;
this.LazyLoading = true;
}
示例3: AnalyzedPropertyTreeNode
public AnalyzedPropertyTreeNode(PropertyDef analyzedProperty, string prefix = "")
{
if (analyzedProperty == null)
throw new ArgumentNullException("analyzedProperty");
this.isIndexer = analyzedProperty.IsIndexer();
this.analyzedProperty = analyzedProperty;
this.prefix = prefix;
this.LazyLoading = true;
}
示例4: PropertyTreeNode
public PropertyTreeNode(PropertyDef 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));
}
}
示例5: PropertyTreeNode
public PropertyTreeNode(PropertyDef property, ILSpyTreeNode owner) {
if (property == null)
throw new ArgumentNullException("property");
this.property = property;
var list = GetDnSpyFileList(owner ?? this);
using (list == null ? null : list.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));
}
}
示例6: FindBaseProperties
/// <summary>
/// Finds all properties from base types overridden or hidden by the specified property.
/// </summary>
/// <param name="property">The property which overrides or hides properties from base types.</param>
/// <returns>Properties overriden or hidden by the specified property.</returns>
public static IEnumerable<PropertyDef> FindBaseProperties(PropertyDef property)
{
if (property == null)
yield break;
var accMeth = property.GetMethod ?? property.SetMethod;
if (accMeth != null && accMeth.HasOverrides)
yield break;
bool isIndexer = property.IsIndexer();
foreach (var baseType in BaseTypes(property.DeclaringType)) {
var baseTypeDef = baseType.Resolve();
if (baseTypeDef == null)
continue;
foreach (var baseProperty in baseTypeDef.Properties) {
if (MatchProperty(baseProperty, Resolve(baseProperty.PropertySig, baseType), property)
&& IsVisibleFromDerived(baseProperty, property.DeclaringType)) {
if (isIndexer != baseProperty.IsIndexer())
continue;
yield return baseProperty;
var anyPropertyAccessor = baseProperty.GetMethod ?? baseProperty.SetMethod;
if (anyPropertyAccessor != null && anyPropertyAccessor.IsNewSlot == anyPropertyAccessor.IsVirtual)
yield break;
}
}
}
}
示例7: FormatPropertyName
public override string FormatPropertyName(PropertyDef 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().MethodDeclaration.DeclaringType;
buffer.Append(TypeToString(declaringType, includeNamespace: true));
buffer.Append(@".");
}
buffer.Append(@"this[");
bool addSeparator = false;
foreach (var p in property.PropertySig.GetParameters()) {
if (addSeparator)
buffer.Append(@", ");
else
addSeparator = true;
buffer.Append(TypeToString(p.ToTypeDefOrRef(), includeNamespace: true));
}
buffer.Append(@"]");
return buffer.ToString();
} else
return property.Name;
}
示例8: WriteToolTip
void WriteToolTip(ITextOutput output, PropertyDef prop)
{
var sig = prop.PropertySig;
var md = prop.GetMethods.FirstOrDefault() ??
prop.SetMethods.FirstOrDefault() ??
prop.OtherMethods.FirstOrDefault();
var writer = new MethodWriter(this, output, md);
writer.WriteReturnType();
WriteToolTip(output, prop.DeclaringType);
output.Write('.', TextTokenType.Operator);
var ovrMeth = md == null || md.Overrides.Count == 0 ? null : md.Overrides[0].MethodDeclaration;
if (prop.IsIndexer()) {
if (ovrMeth != null) {
WriteToolTipType(output, ovrMeth.DeclaringType, false);
output.Write('.', TextTokenType.Operator);
}
output.Write("this", TextTokenType.Keyword);
writer.WriteGenericArguments();
writer.WriteMethodParameterList('[', ']');
}
else if (ovrMeth != null && GetPropName(ovrMeth) != null) {
WriteToolTipType(output, ovrMeth.DeclaringType, false);
output.Write('.', TextTokenType.Operator);
output.Write(IdentifierEscaper.Escape(GetPropName(ovrMeth)), TextTokenHelper.GetTextTokenType(prop));
}
else
output.Write(IdentifierEscaper.Escape(prop.Name), TextTokenHelper.GetTextTokenType(prop));
output.WriteSpace();
output.WriteLeftBrace();
if (prop.GetMethods.Count > 0) {
output.WriteSpace();
output.Write("get", TextTokenType.Keyword);
output.Write(';', TextTokenType.Operator);
}
if (prop.SetMethods.Count > 0) {
output.WriteSpace();
output.Write("set", TextTokenType.Keyword);
output.Write(';', TextTokenType.Operator);
}
output.WriteSpace();
output.WriteRightBrace();
}
示例9: FormatPropertyName
public override void FormatPropertyName(ITextOutput output, PropertyDef property, bool? isIndexer)
{
if (property == null)
throw new ArgumentNullException("property");
if (!isIndexer.HasValue) {
isIndexer = property.IsIndexer();
}
if (isIndexer.Value) {
var accessor = property.GetMethod ?? property.SetMethod;
if (accessor != null && accessor.HasOverrides) {
var methDecl = accessor.Overrides.First().MethodDeclaration;
var declaringType = methDecl == null ? null : methDecl.DeclaringType;
TypeToString(output, declaringType, includeNamespace: true);
output.Write('.', TextTokenType.Operator);
}
output.Write("this", TextTokenType.Keyword);
output.Write('[', TextTokenType.Operator);
bool addSeparator = false;
foreach (var p in property.PropertySig.GetParameters()) {
if (addSeparator) {
output.Write(',', TextTokenType.Operator);
output.WriteSpace();
}
else
addSeparator = true;
TypeToString(output, p.ToTypeDefOrRef(), includeNamespace: true);
}
output.Write(']', TextTokenType.Operator);
} else
output.Write(IdentifierEscaper.Escape(property.Name), TextTokenHelper.GetTextTokenType(property));
}
示例10: Write
void Write(PropertyDef prop) {
if (prop == null) {
WriteError();
return;
}
var getMethod = prop.GetMethods.FirstOrDefault();
var setMethod = prop.SetMethods.FirstOrDefault();
var md = getMethod ?? setMethod;
if (md == null) {
WriteError();
return;
}
var info = new MethodInfo(md, md == setMethod);
WriteModuleName(info);
WriteReturnType(info);
if (ShowOwnerTypes) {
Write(prop.DeclaringType);
OutputWrite(".", TextTokenKind.Operator);
}
var ovrMeth = md == null || md.Overrides.Count == 0 ? null : md.Overrides[0].MethodDeclaration;
if (prop.IsIndexer()) {
if (ovrMeth != null) {
WriteType(ovrMeth.DeclaringType, false, ShowTypeKeywords);
OutputWrite(".", TextTokenKind.Operator);
}
OutputWrite("this", TextTokenKind.Keyword);
WriteGenericArguments(info);
WriteMethodParameterList(info, "[", "]");
}
else if (ovrMeth != null && GetPropName(ovrMeth) != null) {
WriteType(ovrMeth.DeclaringType, false, ShowTypeKeywords);
OutputWrite(".", TextTokenKind.Operator);
WriteIdentifier(GetPropName(ovrMeth), TextTokenKindUtils.GetTextTokenType(prop));
}
else
WriteIdentifier(prop.Name, TextTokenKindUtils.GetTextTokenType(prop));
WriteToken(prop);
WriteSpace();
OutputWrite("{", TextTokenKind.Operator);
if (prop.GetMethods.Count > 0) {
WriteSpace();
OutputWrite("get", TextTokenKind.Keyword);
OutputWrite(";", TextTokenKind.Operator);
}
if (prop.SetMethods.Count > 0) {
WriteSpace();
OutputWrite("set", TextTokenKind.Keyword);
OutputWrite(";", TextTokenKind.Operator);
}
WriteSpace();
OutputWrite("}", TextTokenKind.Operator);
}
示例11: FormatPropertyName
protected override void FormatPropertyName(IDecompilerOutput output, PropertyDef property, bool? isIndexer) {
if (property == null)
throw new ArgumentNullException(nameof(property));
if (!isIndexer.HasValue) {
isIndexer = property.IsIndexer();
}
if (isIndexer.Value) {
var accessor = property.GetMethod ?? property.SetMethod;
if (accessor != null && accessor.HasOverrides) {
var methDecl = accessor.Overrides.First().MethodDeclaration;
var declaringType = methDecl == null ? null : methDecl.DeclaringType;
TypeToString(output, declaringType, includeNamespace: true);
output.Write(".", BoxedTextColor.Operator);
}
output.Write("this", BoxedTextColor.Keyword);
output.Write("[", BoxedTextColor.Punctuation);
bool addSeparator = false;
foreach (var p in property.PropertySig.GetParams()) {
if (addSeparator) {
output.Write(",", BoxedTextColor.Punctuation);
output.Write(" ", BoxedTextColor.Text);
}
else
addSeparator = true;
TypeToString(output, p.ToTypeDefOrRef(), includeNamespace: true);
}
output.Write("]", BoxedTextColor.Punctuation);
}
else
WriteIdentifier(output, property.Name, MetadataTextColorProvider.GetColor(property));
}