예제 #1
0
        private void LoadApplicationAssemblies()
        {
            var exeRoot     = Path.GetDirectoryName(typeof(SiloAssemblyLoader).GetTypeInfo().Assembly.Location);
            var appRoot     = Path.Combine(exeRoot, "Applications");
            var cwd         = Directory.GetCurrentDirectory();
            var directories = new Dictionary <string, SearchOption>
            {
                { exeRoot, SearchOption.TopDirectoryOnly },
                { appRoot, SearchOption.AllDirectories }
            };

            if (!directories.ContainsKey(cwd))
            {
                directories.Add(cwd, SearchOption.TopDirectoryOnly);
            }

            AssemblyLoaderPathNameCriterion[] excludeCriteria =
            {
                AssemblyLoaderCriteria.ExcludeResourceAssemblies,
                AssemblyLoaderCriteria.ExcludeSystemBinaries()
            };
            AssemblyLoaderReflectionCriterion[] loadCriteria =
            {
                AssemblyLoaderReflectionCriterion.NewCriterion(
                    TypeUtils.IsConcreteGrainClass,
                    "Assembly does not contain any acceptable grain types."),
                AssemblyLoaderCriteria.LoadTypesAssignableFrom(
                    typeof(IProvider))
            };

            discoveredAssemblyLocations = AssemblyLoader.LoadAssemblies(directories, excludeCriteria, loadCriteria, logger);
        }
예제 #2
0
        internal static AssemblyLoaderReflectionCriterion LoadTypesAssignableFrom(Type[] requiredTypes)
        {
            // any types provided must be converted to reflection-only
            // types, or they aren't comparable with other reflection-only
            // types.
            requiredTypes = requiredTypes.Select(TypeUtils.ToReflectionOnlyType).ToArray();
            string[] complaints = new string[requiredTypes.Length];
            for (var i = 0; i < requiredTypes.Length; ++i)
            {
                complaints[i] = String.Format("Assembly contains no types assignable from {0}.", requiredTypes[i].FullName);
            }

            return
                (AssemblyLoaderReflectionCriterion.NewCriterion(
                     (Type type, out IEnumerable <string> ignored) =>
            {
                ignored = null;
                foreach (var requiredType in requiredTypes)
                {
                    if (requiredType.IsAssignableFrom(type))
                    {
                        //  we found a match! load the assembly.
                        return true;
                    }
                }
                return false;
            },
                     complaints));
        }
예제 #3
0
        private void LoadApplicationAssemblies()
        {
            var exeRoot     = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            var appRoot     = Path.Combine(exeRoot, "Applications");
            var directories = new Dictionary <string, SearchOption>
            {
                { exeRoot, SearchOption.TopDirectoryOnly },
                { appRoot, SearchOption.AllDirectories }
            };

            AssemblyLoaderPathNameCriterion[] excludeCriteria =
            {
                AssemblyLoaderCriteria.ExcludeResourceAssemblies,
                AssemblyLoaderCriteria.ExcludeSystemBinaries()
            };
            AssemblyLoaderReflectionCriterion[] loadCriteria =
            {
                AssemblyLoaderReflectionCriterion.NewCriterion(
                    TypeUtils.IsConcreteGrainClass,
                    "Assembly does not contain any acceptable grain types."),
                AssemblyLoaderCriteria.LoadTypesAssignableFrom(
                    typeof(IProvider))
            };

            AssemblyLoader.LoadAssemblies(directories, excludeCriteria, loadCriteria, logger);
        }
예제 #4
0
        private void LoadApplicationAssemblies()
        {
            AssemblyLoaderPathNameCriterion[] excludeCriteria =
            {
                AssemblyLoaderCriteria.ExcludeResourceAssemblies,
                AssemblyLoaderCriteria.ExcludeSystemBinaries()
            };
            AssemblyLoaderReflectionCriterion[] loadCriteria =
            {
                AssemblyLoaderReflectionCriterion.NewCriterion(
                    TypeUtils.IsConcreteGrainClass,
                    "Assembly does not contain any acceptable grain types."),
                AssemblyLoaderCriteria.LoadTypesAssignableFrom(
                    typeof(IProvider))
            };

            discoveredAssemblyLocations = AssemblyLoader.LoadAssemblies(directories, excludeCriteria, loadCriteria, logger);
        }
예제 #5
0
        private static void LoadAdditionalAssemblies()
        {
            var logger = TraceLogger.GetLogger("AssemblyLoader.Client", TraceLogger.LoggerType.Runtime);

            var directories =
                new Dictionary<string, SearchOption>
                    {
                        {
                            Path.GetDirectoryName(typeof(OutsideRuntimeClient).GetTypeInfo().Assembly.Location), 
                            SearchOption.AllDirectories
                        }
                    };
            var excludeCriteria =
                new AssemblyLoaderPathNameCriterion[]
                    {
                        AssemblyLoaderCriteria.ExcludeResourceAssemblies,
                        AssemblyLoaderCriteria.ExcludeSystemBinaries()
                    };
            var loadProvidersCriteria =
                new AssemblyLoaderReflectionCriterion[]
                    {
                        AssemblyLoaderCriteria.LoadTypesAssignableFrom(typeof(IProvider))
                    };

            AssemblyLoader.LoadAssemblies(directories, excludeCriteria, loadProvidersCriteria, logger);
        }
예제 #6
0
        private void LoadAdditionalAssemblies()
        {
#if !NETSTANDARD_TODO
            var logger = LogManager.GetLogger("AssemblyLoader.Client", LoggerType.Runtime);

            var directories =
                new Dictionary<string, SearchOption>
                    {
                        {
                            Path.GetDirectoryName(typeof(OutsideRuntimeClient).GetTypeInfo().Assembly.Location),
                            SearchOption.AllDirectories
                        }
                    };
            var excludeCriteria =
                new AssemblyLoaderPathNameCriterion[]
                    {
                        AssemblyLoaderCriteria.ExcludeResourceAssemblies,
                        AssemblyLoaderCriteria.ExcludeSystemBinaries()
                    };
            var loadProvidersCriteria =
                new AssemblyLoaderReflectionCriterion[]
                    {
                        AssemblyLoaderCriteria.LoadTypesAssignableFrom(typeof(IProvider))
                    };

            this.assemblyProcessor.Initialize();
            AssemblyLoader.LoadAssemblies(directories, excludeCriteria, loadProvidersCriteria, logger);
#endif
        }
예제 #7
0
        private AssemblyLoader NewAssemblyLoader(List<string> exclusionList)
        {
            var directories =
                new Dictionary<string, SearchOption>
                    {
                        {Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), 
                            SearchOption.AllDirectories}
                    };
            var excludeCriteria =
                new AssemblyLoaderPathNameCriterion[]
                    {
                        AssemblyLoaderCriteria.ExcludeResourceAssemblies,
                        AssemblyLoaderCriteria.ExcludeFileNames(exclusionList)
                    };
            var loadProvidersCriteria =
                new AssemblyLoaderReflectionCriterion[]
                    {
                        AssemblyLoaderCriteria.LoadTypesAssignableFrom(typeof(IProvider))
                    };

            return AssemblyLoader.NewAssemblyLoader(directories, excludeCriteria, loadProvidersCriteria, logger);
        }