Пример #1
0
        public void PluginServicesConstuctorsWithInvalidArgsExpectedReturnsEmptyList()
        {
            var services = new PluginServices();
            var result   = services.Constructors(new PluginService(), Guid.Empty, Guid.Empty);

            Assert.AreEqual(0, result.Count);
        }
Пример #2
0
        public void PluginServicesConstructorsWithValidArgsExpectedReturnsList()
        {
            var service     = CreatePluginService();
            var workspaceID = Guid.NewGuid();

            EnvironmentVariables.GetWorkspacePath(workspaceID);

            var services = new PluginServices();
            var result   = services.Constructors(service, workspaceID, Guid.Empty);

            Assert.AreEqual(2, result.Count);
        }
Пример #3
0
        public override StringBuilder Execute(Dictionary <string, StringBuilder> values, IWorkspace theWorkspace)
        {
            var serializer = new Dev2JsonSerializer();

            try
            {
                var pluginSource = values["source"].DeserializeToObject <PluginSourceDefinition>();
                var ns           = values["namespace"].DeserializeToObject <INamespaceItem>();

                var services = new PluginServices();
                var src      = Resources.GetResource <PluginSource>(GlobalConstants.ServerWorkspaceID, pluginSource.Id);
                var svc      = new PluginService();
                if (ns != null)
                {
                    svc.Namespace = ns.FullName;
                    svc.Source    = src;
                }
                else
                {
                    svc.Source = src;
                }
                var serviceConstructorList = services.Constructors(svc, Guid.Empty, Guid.Empty);
                var constructors           = serviceConstructorList.Select(a => new PluginConstructor
                {
                    ConstructorName = BuildConstructorName(a.Parameters.Select(parameter => parameter.ShortTypeName)),
                    Inputs          = a.Parameters.Cast <IConstructorParameter>().ToList(),
                } as IPluginConstructor).ToList();
                var executeMessage = new ExecuteMessage {
                    HasError = false, Message = constructors.SerializeToJsonStringBuilder()
                };
                return(executeMessage.SerializeToJsonStringBuilder());
            }
            catch (Exception e)
            {
                return(serializer.SerializeToBuilder(new ExecuteMessage
                {
                    HasError = true,
                    Message = new StringBuilder(e.Message)
                }));
            }
        }