private static void DiscoverPages <IPageType>(Assembly asm = null) { try { if (asm == null) { asm = Assembly.GetEntryAssembly(); } foreach (var t in asm.GetTypes()) { if (!t.IsAbstract) { var iface = t.GetInterfaces().FirstOrDefault(i => i == typeof(IPageType));// i.FullName == "W.WPF.Framework.IPage"); if (iface != null) { //var page = Activator.CreateInstance(t) as IPage; var pw = new PageWrapper() { //Name = t.Name, Type = t, //PageXaml = t.FullName, //Page = new Lazy<IPage>(() => Activator.CreateInstance(t) as IPage) FrameworkElement = (FrameworkElement)Activator.CreateInstance(t) }; AllPages.Add(pw); } } } foreach (AssemblyName assemblyName in asm.GetReferencedAssemblies()) { try { if (assemblyName.CodeBase?.Trim('/', '\\') == AppDomain.CurrentDomain.BaseDirectory.Trim('/', '\\')) //if (!assemblyName.Name.StartsWith("System") && !(assemblyName.Name.StartsWith("mscorlib"))) { Log.i("Loading {0}", assemblyName); var assembly = Assembly.Load(assemblyName.Name); if (assembly != null) { DiscoverPages <IPageType>(assembly); } } } catch (Exception e) { Log.e(e); } } } catch (Exception e) { Log.e(e); } }
//public static string LinesToString( ICollection<string> lines ) //{ // var b = new StringBuilder(); // bool first = true; // foreach( var line in lines ) // { // if( !first ) // b.Append( "\r\n" ); // b.Append( line ); // first = false; // } // return b.ToString(); //} static DebugInfoPage() { AllPages.Add(new DebugInfoPage_Memory()); AllPages.Add(new DebugInfoPage_RenderResources()); AllPages.Add(new DebugInfoPage_RenderStatistics()); AllPages.Add(new DebugInfoPage_Sound()); //AllPages.Add( new DebugInfoPage_Scene() ); //ломает звук. странно //AllPages.Add( new DebugInfoPage_Assemblies() ); //AllPages.Add( new DebugInfoPage_DLLs() ); }