예제 #1
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)
                }));
            }
        }