public static AssemblyInfo TryCreate(string assemblyFullname) { if(AssemblyInfos.Count == 0) { Refresh(); } string rightName, rightVersion; AssemblyInfo.BuilderNameVersion(assemblyFullname, out rightName, out rightVersion); AssemblyInfo topLeft = null; foreach(var left in AssemblyInfos) { if(left.Fullname == assemblyFullname) { topLeft = left; break; } else if(left.Name == rightName) { if(topLeft != null && string.Compare(topLeft.Version, left.Version) > 0) { continue; } topLeft = left; } } if(topLeft == null) { topLeft = new AssemblyInfo(assemblyFullname); AssemblyInfos.Add(topLeft); } return topLeft; }
static AssemblyInfoCollection() { var assems = AppDomain.CurrentDomain.GetAssemblies(); AssemblyInfos = new List<AssemblyInfo>(assems.Length); var ms = Types.String.Assembly; foreach(var assembly in assems) { var info = new AssemblyInfo(assembly); if(ms == assembly) { mscorlib = info; } AssemblyInfos.Add(info); } }