Пример #1
0
        /// <inheritdoc/>
        public virtual void Write(WorkflowDefinition workflow, Stream stream, WorkflowDefinitionFormat format = WorkflowDefinitionFormat.Yaml)
        {
            if (workflow == null)
            {
                throw new ArgumentNullException(nameof(workflow));
            }
            if (stream == null)
            {
                throw new ArgumentNullException(nameof(stream));
            }
            ISerializer serializer;

            switch (format)
            {
            case WorkflowDefinitionFormat.Json:
                serializer = this.JsonSerializer;
                break;

            case WorkflowDefinitionFormat.Yaml:
                serializer = this.YamlSerializer;
                break;

            default:
                throw new NotSupportedException($"The specified workflow definition format '{format}' is not supported");
            }
            serializer.Serialize(workflow, stream);
        }
Пример #2
0
        /// <inheritdoc/>
        public virtual void Write(WorkflowDefinition workflow, Stream stream, WorkflowDefinitionFormat format = WorkflowDefinitionFormat.Yaml)
        {
            if (workflow == null)
            {
                throw new ArgumentNullException(nameof(workflow));
            }
            if (stream == null)
            {
                throw new ArgumentNullException(nameof(stream));
            }
            ISerializer serializer = format switch
            {
                WorkflowDefinitionFormat.Json => this.JsonSerializer,
                WorkflowDefinitionFormat.Yaml => this.YamlSerializer,
                _ => throw new NotSupportedException($"The specified workflow definition format '{format}' is not supported"),
            };

            serializer.Serialize(workflow, stream);
        }
Пример #3
0
        /// <inheritdoc/>
        public virtual WorkflowDefinition Read(Stream stream, WorkflowDefinitionFormat format = WorkflowDefinitionFormat.Yaml)
        {
            if (stream == null)
            {
                throw new ArgumentNullException(nameof(stream));
            }
            ISerializer serializer;

            switch (format)
            {
            case WorkflowDefinitionFormat.Json:
                serializer = this.JsonSerializer;
                break;

            case WorkflowDefinitionFormat.Yaml:
                serializer = this.YamlSerializer;
                break;

            default:
                throw new NotSupportedException($"The specified workflow definition format '{format}' is not supported");
            }
            return(serializer.Deserialize <WorkflowDefinition>(stream));
        }