本文整理汇总了C#中IMemberDefinition类的典型用法代码示例。如果您正苦于以下问题:C# IMemberDefinition类的具体用法?C# IMemberDefinition怎么用?C# IMemberDefinition使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IMemberDefinition类属于命名空间,在下文中一共展示了IMemberDefinition类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: GetWriterContext
public override WriterContext GetWriterContext(IMemberDefinition member, ILanguage language)
{
TypeDefinition type = Utilities.GetDeclaringTypeOrSelf(member);
Dictionary<FieldDefinition, PropertyDefinition> fieldToPropertyMap = type.GetFieldToPropertyMap(language);
IEnumerable<FieldDefinition> propertyFields = fieldToPropertyMap.Keys;
HashSet<PropertyDefinition> autoImplementedProperties = new HashSet<PropertyDefinition>(fieldToPropertyMap.Values);
HashSet<EventDefinition> autoImplementedEvents = GetAutoImplementedEvents(type);
TypeSpecificContext typeContext = new TypeSpecificContext(type) { AutoImplementedProperties = autoImplementedProperties, AutoImplementedEvents = autoImplementedEvents };
TypeDefinition declaringType = Utilities.GetDeclaringTypeOrSelf(member);
Dictionary<string, string> renamedNamespacesMap = new Dictionary<string, string>();
MemberRenamingData memberReanmingData = GetMemberRenamingData(declaringType.Module, language);
ModuleSpecificContext moduleContext =
new ModuleSpecificContext(declaringType.Module, new List<string>(), new Dictionary<string, List<string>>(), new Dictionary<string, HashSet<string>>(),
renamedNamespacesMap, memberReanmingData.RenamedMembers, memberReanmingData.RenamedMembersMap);
return new WriterContext(
new AssemblySpecificContext(),
moduleContext,
typeContext,
new Dictionary<string, MethodSpecificContext>(),
GetDecompiledStatements(member, language, propertyFields));
}
开发者ID:juancarlosbaezpozos,项目名称:JustDecompileEngine,代码行数:27,代码来源:TypeDeclarationsWriterContextService.cs
示例2: RenameMemberDefinition
/// <summary>
/// Rename a member definition
/// </summary>
/// <param name="imdef">Member definition</param>
/// <param name="name">new name</param>
public static void RenameMemberDefinition(IMemberDefinition imdef, string name)
{
if (imdef is TypeDefinition)
RenameTypeDefinition(imdef as TypeDefinition, name);
else
imdef.Name = name;
}
开发者ID:XQuantumForceX,项目名称:Reflexil,代码行数:12,代码来源:RenameHelper.cs
示例3: GetMemberFullName
/// <summary>
/// Creates the part of the member's ID string representation, following the prefix showing the kind of the member, according to ECMA-334 standart.
/// See chapter E: Documentation Comments.
/// </summary>
/// <param name="member"></param>
/// <returns></returns>
private string GetMemberFullName(IMemberDefinition member)
{
StringBuilder result = new StringBuilder();
if (member is TypeDefinition)
{
return GetTypeFullName(member as TypeDefinition);
}
else
{
// Every member, that is not a type, is supposed to have declaring type.
// As the specification is for the C# language, which does not allow methods to be declared outside of classes,
// global methods can't be documented using this format.
result.Append(GetTypeFullName(member.DeclaringType));
result.Append('.');
}
string memberName = member.Name.Replace('.', '#'); // according to the standart, '.' should be replaced with '#'
result.Append(memberName);
// Methods are the only members that can be generic (types are already handled).
if (member is MethodDefinition)
{
string genericMarker = GetMethodGenericParametersMarker(member as MethodDefinition);
result.Append(genericMarker);
}
if (member is MethodDefinition || member is PropertyDefinition)
{
string arguments = GetArgumentsString(member);
result.Append(arguments);
}
return result.ToString();
}
开发者ID:juancarlosbaezpozos,项目名称:JustDecompileEngine,代码行数:38,代码来源:DocumentationCache.cs
示例4: TypeMember
/// <summary>
/// Creates a new instance of this class.
/// </summary>
/// <param name="class">The member type.</param>
/// <param name="definition">The member definition.</param>
public TypeMember(TypeReference type, IMemberDefinition definition)
{
if (type == null) throw new ArgumentNullException("type");
if (definition == null) throw new ArgumentNullException("definition");
Type = type;
Definition = definition;
}
开发者ID:cessationoftime,项目名称:nroles,代码行数:12,代码来源:TypeMember.cs
示例5: GetObjectsToRename
public IEnumerable<KeyValuePair<IMemberDefinition, string>> GetObjectsToRename(IMemberDefinition member)
{
//Returns ths given intem
yield return new KeyValuePair<IMemberDefinition, string>(member, "{0}");
//Checks if the member is a property or an event
if (member is PropertyDefinition)
{
var prop = (PropertyDefinition)member;
if (prop.GetMethod != null)
yield return new KeyValuePair<IMemberDefinition, string>(prop.GetMethod, "get_{0}");
if (prop.SetMethod != null)
yield return new KeyValuePair<IMemberDefinition, string>(prop.SetMethod, "set_{0}");
if (prop.HasOtherMethods)
foreach (var m in prop.OtherMethods)
yield return new KeyValuePair<IMemberDefinition, string>(m, "{0}");
}
else if (member is EventDefinition)
{
var evt = (EventDefinition)member;
if (evt.AddMethod != null)
yield return new KeyValuePair<IMemberDefinition, string>(evt.AddMethod, "add_{0}");
if (evt.RemoveMethod != null)
yield return new KeyValuePair<IMemberDefinition, string>(evt.RemoveMethod, "remove_{0}");
if (evt.InvokeMethod != null)
yield return new KeyValuePair<IMemberDefinition, string>(evt.InvokeMethod, "raise_{0}");
if (evt.HasOtherMethods)
foreach (var m in evt.OtherMethods)
yield return new KeyValuePair<IMemberDefinition, string>(m, "{0}");
}
yield break;
}
开发者ID:95ulisse,项目名称:ILEdit,代码行数:32,代码来源:RenameEntry.cs
示例6: IsVisibleInSubclass
private static bool IsVisibleInSubclass(IMemberDefinition member)
{
//TODO! internal and in another assembly are also not visible!
// also take into account the InternalsVisibleTo attribute!
// and ProtectedANDInternal
if (member == null) return false;
var method = member as MethodDefinition;
if (method != null) {
return !method.IsPrivate;
}
var property = member as PropertyDefinition;
if (property != null) {
var getterIsVisible = IsVisibleInSubclass(property.GetMethod);
var setterIsVisible = IsVisibleInSubclass(property.SetMethod);
return getterIsVisible || setterIsVisible;
}
var @event = member as EventDefinition;
if (@event != null) {
var adderIsVisible = IsVisibleInSubclass(@event.AddMethod);
var removerIsVisible = IsVisibleInSubclass(@event.RemoveMethod);
var invokerIsVisible = IsVisibleInSubclass(@event.InvokeMethod);
return adderIsVisible || removerIsVisible || invokerIsVisible;
}
var field = member as FieldDefinition;
if (field != null) {
return !field.IsPrivate;
}
throw new InvalidOperationException();
}
开发者ID:cessationoftime,项目名称:nroles,代码行数:35,代码来源:ClassMemberContainer.cs
示例7: GetMemberName
// LOOKUP Path.GetRandomFileName BaseBMethod
public string GetMemberName(IMemberDefinition member)
{
if (member.DeclaringType == null)
return GetTypeName((TypeDefinition)member);
var scopeId = GetMemberScope(member);
return GetNextName(scopeId);
}
开发者ID:Cadla,项目名称:OBFSCTR,代码行数:9,代码来源:CTSNameGenerator.cs
示例8: GetDocumentationForMember
/// <summary>
/// Gets the documentation related to <paramref name="member"/>. If no documentation is found for this particular member,
/// an empty string is returned.
/// </summary>
/// <param name="member"></param>
/// <returns>String containing the XML-formated documentation for <paramref name="member">.</returns>
public string GetDocumentationForMember(IMemberDefinition member)
{
string memberName = GetDocumentationMemberName(member);
if (documentationMap.ContainsKey(memberName))
{
return documentationMap[memberName];
}
return string.Empty;
}
开发者ID:juancarlosbaezpozos,项目名称:JustDecompileEngine,代码行数:15,代码来源:DocumentationCache.cs
示例9: FormatMemberName
public static string FormatMemberName(IMemberDefinition member)
{
var typePrefix = member.DeclaringType.Name + "_";
if (member.Name.Contains(typePrefix))
return EscapeIdentifier(member.Name);
else
return EscapeIdentifier(typePrefix + member.Name);
}
开发者ID:WebAssembly,项目名称:ilwasm,代码行数:9,代码来源:Util.cs
示例10: AddDecompiledMemberToCache
protected CachedDecompiledMember AddDecompiledMemberToCache(IMemberDefinition member, DecompiledMember decompiledMember, TypeSpecificContext typeContext, ILanguage language)
{
CachedDecompiledMember cachedMember = new CachedDecompiledMember(decompiledMember, typeContext);
if (!this.cacheService.IsDecompiledMemberInCache(member, language, this.renameInvalidMembers))
{
this.cacheService.AddDecompiledMemberToCache(member, language, this.renameInvalidMembers, cachedMember);
}
return cachedMember;
}
开发者ID:Feng2012,项目名称:JustDecompileEngine,代码行数:10,代码来源:BaseWriterContextService.cs
示例11: WriteBody
public override void WriteBody(IMemberDefinition member, IWriterContextService writerContextService)
{
this.writerContextService = writerContextService;
this.writerContext = writerContextService.GetWriterContext(member, Language);
this.currentWritingInfo = new WritingInfo(member);
UpdateWritingInfo(this.writerContext, this.currentWritingInfo);
this.writingInfos = new List<WritingInfo>();
this.writingInfos.Add(this.currentWritingInfo);
WriteBodyInternal(member);
}
开发者ID:Feng2012,项目名称:JustDecompileEngine,代码行数:10,代码来源:NamespaceImperativeLanguageWriter.cs
示例12: StateInterceptor
/// <summary>
/// Initializes a new instance of the <see cref="StateInterceptor" /> class.
/// </summary>
/// <param name="memberDefinition">The method signature.</param>
/// <param name="callbacks">The callbacks.</param>
/// <exception cref="ArgumentNullException">The <paramref name="memberDefinition" /> is <c>null</c>.</exception>
/// <exception cref="ArgumentNullException">The <paramref name="callbacks" /> is <c>null</c>.</exception>
public StateInterceptor(IMemberDefinition memberDefinition, CallbackCollection callbacks)
{
Argument.IsNotNull("methodDefinition", memberDefinition);
Argument.IsNotNull("callbacks", callbacks);
MemberDefinition = memberDefinition;
CallbackCollection = callbacks;
_visitor = new SelectCallbackVisitor();
}
开发者ID:matthijskoopman,项目名称:Catel,代码行数:17,代码来源:StateInterceptor.cs
示例13: GetDocumentationMemberName
/// <summary>
/// Generates the name, used to specify <paramref name="member"/> according to ECMA-334 standart.
/// </summary>
/// <param name="member">The member who's name is about to be generated.</param>
/// <returns>Returns the string used as ID in the documentation to refer to <paramref name="member">.</returns>
private string GetDocumentationMemberName(IMemberDefinition member)
{
StringBuilder sb = new StringBuilder();
string prefix = GetMemberPrefix(member);
sb.Append(prefix);
string memberFullname = GetMemberFullName(member);
sb.Append(memberFullname);
return sb.ToString();
}
开发者ID:juancarlosbaezpozos,项目名称:JustDecompileEngine,代码行数:16,代码来源:DocumentationCache.cs
示例14: ProcessField
static void ProcessField(IMemberDefinition m)
{
foreach (CustomAttribute att in m.CustomAttributes)
if (att.Constructor.DeclaringType.Name == "ProcessingStandardFieldAttribute") {
var f = m as FieldDefinition;
if (f != null && f.IsLiteral)
Console.WriteLine ("Const " + m.Name);
else
Console.WriteLine ("Field " + m.Name);
}
}
开发者ID:atsushieno,项目名称:tsukimi,代码行数:11,代码来源:ProcessingApiGenerator.cs
示例15: MapMemberDefinition
//TODO Same fully-qualified type names in two assemblies http://msdn.microsoft.com/en-us/library/ms173212.aspx
private string MapMemberDefinition(IMemberDefinition member)
{
string newName = _codeProvider.CreateValidIdentifier(_nameGenerator.GetMemberName(member));
#if APPEND
DefinitionsMap[member] = member.Name + newName;
return member.Name + newName;
#else
DefinitionsMap[member] = newName;
return newName;
#endif
}
开发者ID:Cadla,项目名称:OBFSCTR,代码行数:12,代码来源:Renamer.cs
示例16: CollectSecurityAttributes
public virtual List<ICustomAttribute> CollectSecurityAttributes(IMemberDefinition member)
{
List<ICustomAttribute> attributes = new List<ICustomAttribute>();
if (member is ISecurityDeclarationMemberDefinition)
{
foreach (SecurityDeclaration securityDeclaration in (member as ISecurityDeclarationMemberDefinition).SecurityDeclarations)
{
attributes.AddRange(GetSecurityDeclaration(securityDeclaration));
}
}
return attributes;
}
开发者ID:saravanaram,项目名称:JustDecompileEngine,代码行数:12,代码来源:AttributeWriter.cs
示例17: CheckForNormalAttribute
public void CheckForNormalAttribute(IMemberDefinition memberDefinition)
{
var obsoleteExAttribute = memberDefinition
.CustomAttributes
.FirstOrDefault(x => x.AttributeType.Name == "ObsoleteAttribute");
if (obsoleteExAttribute == null)
{
return;
}
var warning = $"The member `{memberDefinition.FullName}` has an ObsoleteAttribute. You should consider replacing it with an ObsoleteExAttribute.";
LogWarning(warning);
}
开发者ID:Fody,项目名称:Obsolete,代码行数:12,代码来源:ObsoleteAttributeWarner.cs
示例18: InnerProcess
void InnerProcess(IMemberDefinition memberDefinition)
{
var customAttributes = memberDefinition.CustomAttributes;
var obsoleteExAttribute = customAttributes.FirstOrDefault(x => x.AttributeType.Name == "ObsoleteExAttribute");
if (obsoleteExAttribute == null)
{
return;
}
var throwsNotImplemented = false;
var methodDefinition = memberDefinition as MethodDefinition;
if (methodDefinition != null)
{
throwsNotImplemented = ThrowsNotImplemented(methodDefinition);
if (methodDefinition.IsGetter || methodDefinition.IsSetter)
{
var error = $"ObsoleteExAttribute is not valid on property gets or sets. Member: `{memberDefinition.FullName}`.";
LogError(error);
}
}
else
{
var propertyDefinition = memberDefinition as PropertyDefinition;
if (propertyDefinition != null)
{
throwsNotImplemented = ThrowsNotImplemented(propertyDefinition);
}
}
customAttributes.Remove(obsoleteExAttribute);
var attributeData = DataReader.ReadAttributeData(obsoleteExAttribute, throwsNotImplemented);
try
{
ApplyVersionConvention(attributeData);
}
catch (WeavingException exception)
{
throw new WeavingException($"Could not process {memberDefinition.FullName}. {exception.Message}");
}
ValidateVersion(memberDefinition, attributeData);
AddObsoleteAttribute(attributeData, customAttributes);
if (HideObsoleteMembers)
{
AddEditorBrowsableAttribute(customAttributes);
}
}
开发者ID:Fody,项目名称:Obsolete,代码行数:49,代码来源:AttributeFixer.cs
示例19: GetMemberName
// LOOKUP Path.GetRandomFileName BaseBMethod
public string GetMemberName(IMemberDefinition member)
{
if (member.DeclaringType == null)
return GetTypeName((TypeDefinition)member);
var declaringTypeName = GetDeclaringTypeName(member.DeclaringType);
string newName;
do{
newName = NewMethod(member);
}
while(newName == declaringTypeName);
//_scopedMemberNames[declaringTypeScope] = newName;
return newName;
}
开发者ID:Cadla,项目名称:OBFSCTR,代码行数:16,代码来源:CLSNameGenerator.cs
示例20: WriteMemberAttributesAndNewLine
public virtual void WriteMemberAttributesAndNewLine(IMemberDefinition member, IEnumerable<string> ignored = null, bool isWinRTImplementation = false)
{
//TODO Handle attributes that take arrays as arguments
//TODO write tests for all possible types of attribute values and targets
if (ignored != null)
{
foreach (string ignoredAttributeType in ignored)
{
attributesNotToShow.Add(ignoredAttributeType);
}
}
securityAttributeToDeclaration = new Dictionary<SecurityAttribute,SecurityDeclaration>();
List<ICustomAttribute> attributes = CollectSecurityAttributes(member);
foreach (CustomAttribute attribute in member.CustomAttributes)
{
attribute.Resolve();
if (!isWinRTImplementation || !IsWinRTActivatableAttribute(attribute))
{
attributes.Add(attribute);
}
}
attributes.AddRange(WritePropertiesAsAttributes(member));
attributes.Sort((x, y) => { return CompareAttributes(x, y); });
foreach (ICustomAttribute attribute in attributes)
{
if (attribute is CustomAttribute)
{
WriteAttribute(attribute as CustomAttribute);
}
else if (attribute is SecurityAttribute)
{
bool b;
WriteSecurityAttribute(GetModuleDefinition(member), false, attribute as SecurityAttribute, securityAttributeToDeclaration[attribute as SecurityAttribute], out b);
}
}
if (ignored!= null)
{
foreach (string ignoredAttributeType in ignored)
{
attributesNotToShow.Remove(ignoredAttributeType);
}
}
}
开发者ID:juancarlosbaezpozos,项目名称:JustDecompileEngine,代码行数:47,代码来源:AttributeWriter.cs
注:本文中的IMemberDefinition类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论