我正在寻找.Net 4常用名称空间海报,例如{3.5}可用于.NET 3.5。到目前为止,我只能找到.NET Framework 4.0 this海报,但有更详细的内容吗?
答案 0 :(得分:3)
还有这个,但我相信它更古老:http://brad_abrams.members.winisp.net/Projects/PDC2008/PDC2008-NETFX4.pdf
指向同一文件的另一个链接:http://download.microsoft.com/download/9/2/3/923d72fb-0076-49b6-96c4-aac1c255a60e/PDC2008-NETFX4.pdf
答案 1 :(得分:2)
必须有一整套这样的海报。在ASP.NET电子商务应用程序中“常用”的命名空间和类可能永远不会出现在XNA游戏开发中。
答案 2 :(得分:0)
我编写了一个快速应用程序,用于在文件夹(及其子文件夹)中搜索程序集,并使用反射来捕获其名称空间和类。该应用程序输出命名空间及其类的排序列表。我将应用程序定位于包含.Net 4.0程序集(C:\ Program Files(x86)\ Reference Assemblies \ Microsoft \ Framework.NETFramework \ v4.0)的文件夹,以获取所有.Net 4.0命名空间和类的列表。这不是一个漂亮的海报,只是一个清单。
该列表太长,无法在此处发布。因此,我将发布我的应用程序的代码,并让您在喜欢的任何文件上单独运行它。请注意,它目前处理.Net 4.0文件-您将需要修改所需的任何文件。
internal class ClassInfo
{
public ClassInfo(string namespaceName, string className)
{
NamespaceName = namespaceName;
ClassName = className;
}
public string NamespaceName { get; private set; }
public string ClassName { get; private set; }
}
class Program
{
static void Main(string[] args)
{
IList<ClassInfo> _classes = new List<ClassInfo>();
//DirectoryInfo folder = new DirectoryInfo(Directory.GetCurrentDirectory());
DirectoryInfo folder = new DirectoryInfo(@"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0");
ProcessFolder(folder, _classes);
Console.WriteLine();
Console.WriteLine("*************** NAMESPACES ***************");
Console.WriteLine();
PrintNamespaces(_classes);
Console.WriteLine();
Console.WriteLine("*************** NAMESPACES/CLASSES ***************");
Console.WriteLine();
PrintClassesByNamespaces(_classes);
}
private static void PrintNamespaces(IList<ClassInfo> classes)
{
var namespaces = (from c in classes
orderby c.NamespaceName
select c.NamespaceName).Distinct();
foreach (string s in namespaces)
{
Console.WriteLine(s);
}
}
private static void PrintClassesByNamespaces(IList<ClassInfo> classes)
{
var namespaces = (from c in classes
orderby c.NamespaceName
select c.NamespaceName).Distinct();
foreach (string s in namespaces)
{
Console.WriteLine(s);
var namespaceClasses = (from c in classes
where c.NamespaceName == s
orderby c.ClassName
select c.ClassName).Distinct();
foreach (string className in namespaceClasses)
{
Console.WriteLine($" {className}");
}
}
}
public static void ProcessFolder(DirectoryInfo directory, IList<ClassInfo> classes)
{
Console.WriteLine($"folder: {directory.FullName}");
foreach (FileInfo f in directory.GetFiles("*.dll"))
{
ProcessAssembly(directory, f.FullName, classes);
}
foreach (DirectoryInfo d in directory.GetDirectories())
{
ProcessFolder(d, classes);
}
}
private static void ProcessAssembly(DirectoryInfo directory, string fileName, IList<ClassInfo> classes)
{
Assembly assembly;
try
{
assembly = Assembly.LoadFile(fileName);
foreach (var t in assembly.DefinedTypes)
{
classes.Add(new ClassInfo(t.Namespace, t.Name));
Console.WriteLine($"{t.Namespace} - {t.Name}");
}
}
catch (Exception ex)
{
Console.WriteLine($"something wrong loading {fileName} - {ex.Message}");
}
}
}