コード例 #1
0
        private void LoadAssembly()
        {
            actionComponent.TryExecute(() =>
            {
                string assemblyPath = textBoxAssemblyPath.Text;
                bool execute        = false;
                string errorMessage = null;

                if (string.IsNullOrWhiteSpace(assemblyPath))
                {
                    errorMessage = "Path cannot be empty";
                }
                else if (!assemblyExtensions.Contains(Path.GetExtension(assemblyPath)))
                {
                    errorMessage = "Path must end with an assembly extension";
                }
                else if (!File.Exists(assemblyPath))
                {
                    errorMessage = "Path must point towards an existing file";
                }
                else
                {
                    execute = true;
                }

                if (execute)
                {
                    assembly = Assembly.LoadFrom(assemblyPath);

                    allAssemblyTypes = assembly.ExportedTypes.Select(
                        type => typesStaticDataCache.Get(type)).Where(
                        type => !type.Data.IsAbstract && type.AllConstructors.Value.Any(
                            c => c.Data.IsPublic && !c.Data.IsStatic && c.Parameters.Value.None())).Select(
                        type => type.Data).ToList();

                    allAssemblyTypes.Sort((t1, t2) => t1.FullName.CompareTo(t2.FullName));
                    filteredAssemblyTypes = allAssemblyTypes.ToList();

                    RefreshDataGridViewAssemblyTypesRowsCore();
                }

                return(new Tuple <bool, string>(
                           execute, errorMessage));
            }, nameof(LoadAssembly));
        }
コード例 #2
0
 protected ProgramArgsParserBase(
     ITypesStaticDataCache typesStaticDataCache)
 {
     this.TypesStaticDataCache = typesStaticDataCache ?? throw new ArgumentNullException(nameof(typesStaticDataCache));
     this.ArgsTypeWrapper      = typesStaticDataCache.Get(typeof(TProgramArgs));
 }