private static int CompareMemberNames(NetBrowserSettings settings, MemberInfo a, MemberInfo b) { // Compare the names with case-insensitive comparison first (for ordering purposes) string nameA = GetMemberName(settings, a); string nameB = GetMemberName(settings, b); int result = string.Compare(nameA, nameB, true); if (result != 0) { return(result); } // Now try case-sensitive comparison result = string.Compare(nameA, nameB, false); if (result != 0) { return(result); } // Names are the same - must be methods or properties with different signatures Debug.Assert(a.MemberType == MemberTypes.Method || a.MemberType == MemberTypes.Constructor || a.MemberType == MemberTypes.Property, "a.MemberType == MemberTypes.Method" + " || a.MemberType == MemberTypes.Constructor || a.MemberType == MemberTypes.Property"); return(string.Compare(a.ToString(), b.ToString(), true)); }
public override object Clone() { NetBrowserSettings cloned = new NetBrowserSettings(); cloned.CloneFrom(this); return(cloned); }
internal void AppendCustomAttributes(DescriptionBuilder sb, ICustomAttributeProvider provider) { const string attributeSuffix = "Attribute"; Debug.Assert(sb != null && provider != null, "sb != null && provider != null"); NetBrowserSettings settings = (NetBrowserSettings)Settings; foreach (Attribute attr in provider.GetCustomAttributes(false)) { Type attrType = attr.GetType(); // Remove the "Attribute" suffix from the name. string name = attrType.Name; if (name.EndsWith(attributeSuffix)) { name = name.Substring(0, name.Length - attributeSuffix.Length); } sb.Append(settings.GetKeyword(NetBrowserSettings.KeywordAttributeStart)); sb.AppendLink(name, GetTypeInfoForLink( attrType.Assembly.Location, attrType.FullName)); sb.Append(settings.GetKeyword(NetBrowserSettings.KeywordAttributeEnd)); sb.EndLine(); } }
protected override void CloneFrom(ObjectBrowserSettings source) { base.CloneFrom(source); RemoteNetBrowserSettings sourceSettings = (RemoteNetBrowserSettings)source; m_remoteDomain = sourceSettings.m_remoteDomain; m_settings = (sourceSettings.m_settings == null ? null : (NetBrowserSettings)sourceSettings.m_settings.Clone()); }
private void CreateRemoteSettingsObject() { m_settings = (NetBrowserSettings)m_remoteDomain.CreateInstanceAndUnwrap( typeof(NetBrowserSettings).Assembly.FullName, typeof(NetBrowserSettings).FullName, false, BindingFlags.Instance | BindingFlags.Public, null, new object[] { ShowMembers, ShowTypeCheckBoxes, Language }, null, null); Debug.Assert(m_settings != null, "m_settings != null"); m_settings.ShowMembers = ShowMembers; m_settings.TypeOrder = TypeOrder; m_settings.MemberOrder = MemberOrder; m_settings.ShowNonPublic = ShowNonPublic; }
private static string GetMemberName(NetBrowserSettings settings, MemberInfo member) { if (member.MemberType == MemberTypes.Constructor) { return(member.DeclaringType.Name); } else if (member.MemberType == MemberTypes.Method && MethodIsOperator((MethodInfo)member)) { return(GetOperatorName(settings, member.Name)); } else { return(member.Name); } }
public override bool SettingsEqual(ISettingsObject obj) { if (!base.SettingsEqual(obj)) { return(false); } NetBrowserSettings other = obj as NetBrowserSettings; if (other == null) { return(false); } return(Language == other.Language); }
internal static string GetOperatorName(NetBrowserSettings settings, string methodName) { // Replace the method name with the operator declaration, like VS.NET does. string opName = settings.GetKeyword(methodName); if (opName == null) { Debug.Fail("Unexpected operator name: '" + methodName + "'."); return(methodName); } else { return(opName); } }
internal static void WriteParameterType(NetBrowserManager manager, DescriptionBuilder sb, ParameterInfo parameter, bool link) { NetBrowserSettings settings = (NetBrowserSettings)manager.Settings; if (parameter.IsOut) { sb.Append(settings.GetKeyword(ParameterAttributes.Out)); sb.Append(" "); AppendParameterTypeDisplayName(manager, sb, parameter.ParameterType, true, link); } else { if (parameter.IsDefined(typeof(ParamArrayAttribute), false)) { sb.Append(settings.GetKeyword(typeof(ParamArrayAttribute))); sb.Append(" "); } AppendParameterTypeDisplayName(manager, sb, parameter.ParameterType, false, link); } }
internal static void AppendParameterTypeDisplayName(NetBrowserManager manager, DescriptionBuilder sb, Type type, bool ignoreRef, bool link) { NetBrowserSettings settings = (NetBrowserSettings)manager.Settings; if (type.HasElementType) { if (type.IsByRef) { if (!ignoreRef) { sb.Append(settings.GetKeyword("Type.IsByRef")); sb.Append(" "); } AppendParameterTypeDisplayName(manager, sb, type.GetElementType(), ignoreRef, link); } else if (type.IsArray) { AppendParameterTypeDisplayName(manager, sb, type.GetElementType(), ignoreRef, link); sb.Append(settings.GetKeyword(NetBrowserSettings.KeywordArrayStart)); int dimensions = type.GetArrayRank(); for (int index = 1; index < dimensions; index++) { sb.Append(","); } sb.Append(settings.GetKeyword(NetBrowserSettings.KeywordArrayEnd)); } else if (type.IsPointer) { AppendParameterTypeDisplayName(manager, sb, type.GetElementType(), ignoreRef, link); sb.Append(" *"); } else { throw new ApplicationException("Type '" + type.Name + "' has element type, but is not a" + " reference type, array or pointer."); } } else { string keyword = ((NetBrowserSettings)manager.Settings).GetKeyword(type.AssemblyQualifiedName); if (keyword == null) { if (link) { sb.AppendLink(GetTypeDisplayFullName(type), manager.GetTypeInfoForLink( type.Assembly.Location, type.FullName)); } else { sb.Append(GetTypeDisplayFullName(type)); } } else { sb.Append(keyword); // We don't want to make keywords into links } } }