public SorterControlViewModel(SorterModel sorter) { ChangeStateClickCommand = new Command(arg => ChangeStateClickMethod()); MinimizeClickCommand = new Command(arg => MinimizeClickMethod()); Sorter = sorter; }
private void LoadSorters() { try { string[] dllFileNames = null; if (Directory.Exists(@"Plugins")) { dllFileNames = Directory.GetFiles(@"Plugins", "*.dll"); } foreach (string dllFile in dllFileNames) { Assembly assembly = Assembly.LoadFrom(dllFile); var sorterTypes = from t in assembly.GetTypes() where (t.GetCustomAttribute(typeof(SorterAttribute)) != null) select t.MakeGenericType(new Type[] { typeof(int) }); foreach (Type sorterType in sorterTypes) { ASorter<int> aSorter = assembly.CreateInstance(sorterType.FullName, true) as ASorter<int>; string sorterName = (sorterType.GetCustomAttribute(typeof(SorterAttribute)) as SorterAttribute).SorterName; SorterModel sorter = new SorterModel(aSorter, sorterName); SorterControlViewModels.Add(new SorterControlViewModel(sorter)); } } } catch (ReflectionTypeLoadException ex) { StringBuilder sb = new StringBuilder(); foreach (Exception exSub in ex.LoaderExceptions) { sb.AppendLine(exSub.Message); FileNotFoundException exFileNotFound = exSub as FileNotFoundException; if (exFileNotFound != null) { if (!string.IsNullOrEmpty(exFileNotFound.FusionLog)) { sb.AppendLine("Fusion Log:"); sb.AppendLine(exFileNotFound.FusionLog); } } sb.AppendLine(); } string errorMessage = sb.ToString(); } }