本文整理汇总了C#中IMemberDefinition类的典型用法代码示例。如果您正苦于以下问题:C# IMemberDefinition类的具体用法?C# IMemberDefinition怎么用?C# IMemberDefinition使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IMemberDefinition类属于命名空间,在下文中一共展示了IMemberDefinition类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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();
}
示例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;
}
示例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;
}
示例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();
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
示例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();
}
示例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();
}
示例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);
}
}
示例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
}