Esempio n. 1
0
        public void PluginServicesMethodsWithReturnsWithInvalidArgsExpectedReturnsEmptyList()
        {
            var services = new PluginServices();
            var result   = services.MethodsWithReturns(new PluginService(), Guid.Empty, Guid.Empty);

            Assert.AreEqual(0, result.Count);
        }
        public void PluginServicesMethodsWithReturnsNullArgsExpectedReturnsEmptyList()
        {
            var services = new PluginServices();
            var result   = services.MethodsWithReturns(null);

            Assert.AreEqual(0, result.Count);
        }
Esempio n. 3
0
        public void PluginServicesMethodsWithReturnsWithValidArgsExpectedReturnsList()
        {
            var service     = CreatePluginService();
            var workspaceID = Guid.NewGuid();

            EnvironmentVariables.GetWorkspacePath(workspaceID);

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

            Assert.AreEqual(7, result.Count);
        }
        public StringBuilder Execute(Dictionary <string, StringBuilder> values, IWorkspace theWorkspace)
        {
            var serializer = new Dev2JsonSerializer();

            try
            {
                var pluginSource = serializer.Deserialize <PluginSourceDefinition>(values["source"]);
                var ns           = serializer.Deserialize <INamespaceItem>(values["namespace"]);
                // ReSharper disable MaximumChainedReferences
                PluginServices services = new PluginServices();
                var            src      = Resources.GetResource <PluginSource>(GlobalConstants.ServerWorkspaceID, pluginSource.Id);
                //src.AssemblyName = ns.FullName;
                if (ns != null)
                {
                    PluginService svc = new PluginService {
                        Namespace = ns.FullName, Source = src
                    };

                    var serviceMethodList        = services.MethodsWithReturns(svc, Guid.Empty, Guid.Empty);
                    List <IPluginAction> methods = serviceMethodList.Select(a => new PluginAction
                    {
                        FullName = ns.FullName,
                        Inputs   = a.Parameters.Select(x => new ServiceInput(x.Name, x.DefaultValue ?? "")
                        {
                            Name = x.Name
                            ,
                            EmptyIsNull = x.EmptyToNull
                            ,
                            RequiredField = x.IsRequired
                            ,
                            TypeName = x.TypeName
                            ,
                            ShortTypeName = x.ShortTypeName
                            ,
                            IsObject = x.IsObject
                            ,
                            Dev2ReturnType = x.Dev2ReturnType,

                            IntellisenseFilter = x.IsObject ? enIntellisensePartType.JsonObject : enIntellisensePartType.All
                        } as IServiceInput).ToList(),
                        Method    = a.Name,
                        Variables = a.Parameters.Select(x => new NameValue {
                            Name = x.Name + " (" + x.TypeName + ")", Value = ""
                        } as INameValue).ToList(),
                        Dev2ReturnType = a.Dev2ReturnType,
                        IsObject       = a.IsObject,
                        IsVoid         = a.IsVoid,
                        IsProperty     = a.IsProperty
                    } as IPluginAction).ToList();
                    return(serializer.SerializeToBuilder(new ExecuteMessage
                    {
                        HasError = false,
                        Message = serializer.SerializeToBuilder(methods)
                    }));
                }
                // ReSharper disable once RedundantIfElseBlock
                else
                {
                    return(serializer.SerializeToBuilder(new ExecuteMessage
                    {
                        HasError = false,
                        Message = serializer.SerializeToBuilder(new List <IPluginAction>())
                    }));
                }

                // ReSharper restore MaximumChainedReferences
            }
            catch (Exception e)
            {
                return(serializer.SerializeToBuilder(new ExecuteMessage
                {
                    HasError = true,
                    Message = new StringBuilder(e.Message)
                }));
            }
        }