Esempio n. 1
0
        /// <summary>
        /// Lists the methods.
        /// </summary>
        /// <param name="assemblyLocation">The assembly location.</param>
        /// <param name="assemblyName">Name of the assembly.</param>
        /// <param name="fullName">The full name.</param>
        /// <returns></returns>
        public ServiceConstructorList ListConstructors(string assemblyLocation, string assemblyName, string fullName)
        {
            var serviceMethodList = new ServiceConstructorList();

            if (_assemblyLoader.TryLoadAssembly(assemblyLocation, assemblyName, out Assembly assembly))
            {
                var type         = assembly.GetType(fullName);
                var constructors = type.GetConstructors();
                constructors.ToList().ForEach(info =>
                {
                    var serviceConstructor = new ServiceConstructor();
                    var parameterInfos     = info.GetParameters().ToList();
                    parameterInfos.ForEach(parameterInfo =>
                    {
                        var constructorParameter = new ConstructorParameter
                        {
                            DefaultValue  = parameterInfo.DefaultValue?.ToString() ?? string.Empty,
                            EmptyToNull   = false,
                            IsRequired    = !parameterInfo.IsOptional,
                            Name          = parameterInfo.Name,
                            TypeName      = parameterInfo.ParameterType.AssemblyQualifiedName,
                            ShortTypeName = parameterInfo.ParameterType.FullName,
                        };
                        var returnType = parameterInfo.ParameterType;
                        BuildParameter(returnType, constructorParameter);
                        serviceConstructor.Parameters.Add(constructorParameter);
                    });
                    serviceMethodList.Add(serviceConstructor);
                });
            }

            return(serviceMethodList);
        }
        static PluginService CreatePluginService(List <IDev2MethodInfo> method, Type type, ServiceConstructor constructor = null)
        {
            var source  = CreatePluginSource(typeof(DummyClassForPluginTest));
            var service = new PluginService
            {
                ResourceID   = Guid.NewGuid(),
                ResourceName = "DummyPluginService",
                ResourceType = "PluginService",
                Namespace    = type.FullName,
                MethodsToRun = method,
                Source       = source,
                Constructor  = constructor,
            };

            return(service);
        }
Esempio n. 3
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="exportRegistry">Required.</param>
 /// <param name="serviceProvider">NOTICE: is optional.</param>
 /// <exception cref="ArgumentNullException"></exception>
 public ExportFactory(IExportRegistry <TExport> exportRegistry, IServiceProvider serviceProvider)
 {
     ExportRegistry     = exportRegistry ?? throw new ArgumentNullException(nameof(exportRegistry));
     ServiceProvider    = serviceProvider ?? ServiceProviderHelper.AsServiceProvider(EmptyProvider);
     ServiceConstructor = new ServiceConstructor(serviceProvider);