public static string GetNamespace(TypeReference type) { if (type.GetElementType().IsNested) { type = type.GetElementType(); } while (type != null && type.IsNested) { type = type.DeclaringType; } if (type == null) { return(string.Empty); } string typeNS = type.Namespace; // first, make sure this isn't a type reference to another assembly/module bool isInAssembly = MDocUpdater.IsInAssemblies(type.Module.Name); if (isInAssembly && !typeNS.StartsWith("System") && MDocUpdater.HasDroppedNamespace(type)) { typeNS = string.Format("{0}.{1}", MDocUpdater.droppedNamespace, typeNS); } return(typeNS); }
public static string GetTranslatedName(TypeReference t) { string typename = t.FullName; bool isInAssembly = MDocUpdater.IsInAssemblies(t.Module.Name); if (isInAssembly && !typename.StartsWith("System") && MDocUpdater.HasDroppedNamespace(t)) { string nameWithDropped = string.Format("{0}.{1}", MDocUpdater.droppedNamespace, typename); return(nameWithDropped); } return(typename); }
public static string GetNamespace(TypeReference type, string delimeter = null) { if (type == null) { return(string.Empty); } if (type.GetElementType().IsNested) { type = type.GetElementType(); } while (type != null && type.IsNested && !type.IsGenericParameter) { type = type.DeclaringType; } if (type == null) { return(string.Empty); } string typeNS = type.Namespace; if (!string.IsNullOrEmpty(delimeter)) { typeNS = typeNS.Replace(".", delimeter); } // first, make sure this isn't a type reference to another assembly/module bool isInAssembly = MDocUpdater.IsInAssemblies(type.Module.Name); if (isInAssembly && !typeNS.StartsWith("System") && MDocUpdater.HasDroppedNamespace(type)) { typeNS = string.Format("{0}{1}{2}", MDocUpdater.droppedNamespace, delimeter ?? ".", typeNS); } return(typeNS); }