Inline ConvertReference(IEntity referencedEntity) { var h = new Hyperlink(new Run(ambience.ConvertSymbol(referencedEntity))); h.Click += CreateNavigateOnClickHandler(referencedEntity); return(h); }
public EntityItem(IMember member, IAmbience ambience) { this.IsInSamePart = true; this.entity = member.UnresolvedMember; ambience.ConversionFlags = ConversionFlags.ShowTypeParameterList | ConversionFlags.ShowParameterList | ConversionFlags.ShowParameterNames; text = ambience.ConvertSymbol(member); image = CompletionImage.GetImage(member); }
Inline ConvertReference(IEntity referencedEntity) { var h = new Hyperlink(new Run(ambience.ConvertSymbol(referencedEntity))); h.Click += (sender, e) => { MainWindow.Instance.JumpToReference(referencedEntity); }; return(h); }
object GetText() { var member = model.Resolve(); if (member == null) { return(model.Name); } IAmbience ambience = AmbienceService.GetCurrentAmbience(); ambience.ConversionFlags = ConversionFlags.ShowTypeParameterList | ConversionFlags.ShowParameterList | ConversionFlags.ShowParameterNames; return(ambience.ConvertSymbol(member)); }
public FieldWrapper(IField member) { if (member == null) { throw new ArgumentNullException("member"); } this.field = member; addSetter = true; IAmbience ambience = AmbienceService.GetCurrentAmbience(); ambience.ConversionFlags |= ConversionFlags.ShowReturnType | ConversionFlags.ShowModifiers | ConversionFlags.ShowAccessibility; this.text = ambience.ConvertSymbol(member); }
protected IMember GetMemberFromName(ITypeDefinition c, string name, ReadOnlyCollection<string> parameters) { if (name == null || c == null) return null; if (name.StartsWith("get_", StringComparison.Ordinal) || name.StartsWith("set_", StringComparison.Ordinal)) { // Property Getter or Setter name = name.Substring(4); IProperty prop = c.Properties.FirstOrDefault(p => p.Name == name); if (prop != null) return prop; } else if (name.StartsWith("add_", StringComparison.Ordinal) || name.StartsWith("remove_", StringComparison.Ordinal)) { name = name.Substring(4); IEvent ev = c.Events.FirstOrDefault(e => e.Name == name); if (ev != null) return ev; } ambience.ConversionFlags = ConversionFlags.UseFullyQualifiedTypeNames | ConversionFlags.ShowParameterNames | ConversionFlags.StandardConversionFlags; IMethod matchWithSameName = null; IMethod matchWithSameParameterCount = null; foreach (IMethod method in c.Methods) { if (method.Name != name) continue; matchWithSameName = method; if (method.Parameters.Count != ((parameters == null) ? 0 : parameters.Count)) continue; matchWithSameParameterCount = method; bool isCorrect = true; for (int i = 0; i < method.Parameters.Count; i++) { if (parameters[i] != ambience.ConvertSymbol(method.Parameters[i])) { isCorrect = false; break; } } if (isCorrect) return method; } return matchWithSameParameterCount ?? matchWithSameName; }
public PropertyOrFieldWrapper(IMember member) { isIncluded = false; if (member == null) { throw new ArgumentNullException("member"); } if (!(member is IField || member is IProperty)) { throw new ArgumentException("member must be IField or IProperty"); } this.Member = member; IAmbience ambience = AmbienceService.GetCurrentAmbience(); ambience.ConversionFlags |= ConversionFlags.ShowReturnType | ConversionFlags.ShowModifiers | ConversionFlags.ShowAccessibility; this.text = ambience.ConvertSymbol(member); }
/// <summary> /// Converts a member to text. /// Returns the declaration of the member as C# or VB code, e.g. /// "public void MemberName(string parameter)" /// </summary> private static string GetText(IEntity entity) { IAmbience ambience = CsharpAmbience; ambience.ConversionFlags = ConversionFlags.StandardConversionFlags; if (entity is ITypeDefinition) { // Show fully qualified Type name ambience.ConversionFlags |= ConversionFlags.UseFullyQualifiedTypeNames; } if (entity is IMethod) { //if the method is an extension method we wanna see the whole method for the description //the original method (not reduced) can be obtained by calling ReducedFrom var reducedFromMethod = ((IMethod)entity).ReducedFrom; if (reducedFromMethod != null) { entity = reducedFromMethod; } } return(ambience.ConvertSymbol(entity)); }
public static string PrintFullName(this IEntity entity) { return(amb.ConvertSymbol(entity)); }
protected IMember GetMemberFromName(ITypeDefinition c, string name, ReadOnlyCollection <string> parameters) { if (name == null || c == null) { return(null); } if (name == ".ctor" || name == ".cctor") // Constructor { name = name.Replace('.', '#'); } if (name.StartsWith("get_") || name.StartsWith("set_")) { // Property Getter or Setter name = name.Substring(4); IProperty prop = c.Properties.FirstOrDefault(p => p.Name == name); if (prop != null) { return(prop); } } else if (name.StartsWith("add_") || name.StartsWith("remove_")) { name = name.Substring(4); IEvent ev = c.Events.FirstOrDefault(e => e.Name == name); if (ev != null) { return(ev); } } ambience.ConversionFlags = ConversionFlags.UseFullyQualifiedTypeNames | ConversionFlags.ShowParameterNames | ConversionFlags.StandardConversionFlags; IMethod matchWithSameName = null; IMethod matchWithSameParameterCount = null; foreach (IMethod method in c.Methods) { if (method.Name != name) { continue; } matchWithSameName = method; if (method.Parameters.Count != ((parameters == null) ? 0 : parameters.Count)) { continue; } matchWithSameParameterCount = method; bool isCorrect = true; for (int i = 0; i < method.Parameters.Count; i++) { if (parameters[i] != ambience.ConvertSymbol(method.Parameters[i])) { isCorrect = false; break; } } if (isCorrect) { return(method); } } return(matchWithSameParameterCount ?? matchWithSameName); }