Esempio n. 1
0
 public static void SaveElement(XmlSerializer serializer, string fileName, object element)
 {
     using (var memoryStream = new MemoryStream())
         using (var writer = XmlnsIndentedWriter.Create(memoryStream, DefaultWriterSettings))
         {
             serializer.Serialize(writer, element);
             using (var fileStream = new FileStream(fileName, FileMode.Create, FileAccess.Write))
             {
                 memoryStream.WriteTo(fileStream);
             }
         }
 }
Esempio n. 2
0
        public static string StoreWorkflowElements(WorkflowBuilder builder)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            if (builder.Workflow.Count > 0)
            {
                var stringBuilder = new StringBuilder();
                using (var writer = XmlnsIndentedWriter.Create(stringBuilder, DefaultWriterSettings))
                {
                    WorkflowBuilder.Serializer.Serialize(writer, builder);
                }

                return(stringBuilder.ToString());
            }

            return(string.Empty);
        }