예제 #1
0
        internal void LoadAssembly()
        {
            var pluginLocation = AssemblyFile.ExistsOrThrow().FullName;

            AssemblyObj = Assembly.LoadFrom(AssemblyFile.ExistsOrThrow().FullName);

            ControllerType = AssemblyObj.GetType(ControllerName);

            if (ControllerType == null) // Maybe no namespace?
            {
                ControllerType = AssemblyObj.GetTypes().FirstOrDefault(x => x.Name == ControllerName)
                                 ?? throw new Exception(ControllerName + " was not found.");
            }

            ControllerName = ControllerType.FullName; // Ensure it has full namespace

            ActionMethods = ControllerType
                            .GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public)
                            .Select(x => new MethodGenerator(x, ControllerType))
                            .ToArray();

            if (ActionMethods.Length == 0)
            {
                throw new Exception("This controller has no action method.");
            }
        }
예제 #2
0
        internal void LoadAssembly()
        {
            var pluginLocation = AssemblyFile.ExistsOrThrow().FullName;

            AssemblyObj = Assembly.LoadFrom(AssemblyFile.ExistsOrThrow().FullName);

            CommandType = AssemblyObj.GetType(CommandName) ??
                          AssemblyObj.GetTypes().FirstOrDefault(x => x.Name == CommandName && x.BaseType == typeof(EventBusCommandMessage)) ??
                          throw new Exception($"No type in the assembly {AssemblyFile.FullName} is named: {CommandName}.");

            CommandName = CommandType.FullName; // Ensure it has full namespace
        }