Esempio n. 1
0
        public void Save(string themeFilePath)
        {
            if ((themeFilePath == null) || (themeFilePath.Length == 0))
            {
                throw new ArgumentException(DR.GetString("ThemePathNotValid", new object[0]), "themeFilePath");
            }
            DesignerSerializationManager manager = new DesignerSerializationManager();

            using (manager.CreateSession())
            {
                WorkflowMarkupSerializationManager serializationManager = new WorkflowMarkupSerializationManager(manager);
                XmlWriter writer = null;
                ThemeSerializationProvider provider = new ThemeSerializationProvider();
                try
                {
                    string directoryName = Path.GetDirectoryName(themeFilePath);
                    if ((directoryName.Length > 0) && !Directory.Exists(directoryName))
                    {
                        Directory.CreateDirectory(directoryName);
                    }
                    writer = Helpers.CreateXmlWriter(themeFilePath);
                    serializationManager.AddSerializationProvider(provider);
                    new WorkflowMarkupSerializer().Serialize(serializationManager, writer, this);
                }
                finally
                {
                    serializationManager.RemoveSerializationProvider(provider);
                    if (writer != null)
                    {
                        writer.Close();
                    }
                }
                this.filePath = themeFilePath;
            }
        }
Esempio n. 2
0
        private void SaveDesignerLayout()
        {
            string           layoutFileName = DesignerLayoutFileName;
            ActivityDesigner rootDesigner   = ActivityDesigner.GetSafeRootDesigner(LoaderHost);

            if (String.IsNullOrEmpty(layoutFileName) || rootDesigner == null || !rootDesigner.SupportsLayoutPersistence)
            {
                return;
            }

            using (TextWriter layoutWriter = GetFileWriter(layoutFileName))
            {
                if (layoutWriter != null)
                {
                    IList layoutErrors = null;
                    using (XmlWriter xmlWriter = Helpers.CreateXmlWriter(layoutWriter))
                        SaveDesignerLayout(xmlWriter, rootDesigner, out layoutErrors);
                }
            }
        }
Esempio n. 3
0
        private void SaveDesignerLayout()
        {
            string           designerLayoutFileName = this.DesignerLayoutFileName;
            ActivityDesigner safeRootDesigner       = ActivityDesigner.GetSafeRootDesigner(base.LoaderHost);

            if ((!string.IsNullOrEmpty(designerLayoutFileName) && (safeRootDesigner != null)) && safeRootDesigner.SupportsLayoutPersistence)
            {
                using (TextWriter writer = this.GetFileWriter(designerLayoutFileName))
                {
                    if (writer != null)
                    {
                        IList layoutSaveErrors = null;
                        using (XmlWriter writer2 = Helpers.CreateXmlWriter(writer))
                        {
                            this.SaveDesignerLayout(writer2, safeRootDesigner, out layoutSaveErrors);
                        }
                    }
                }
            }
        }
Esempio n. 4
0
        public WorkflowTheme Clone()
        {
            WorkflowTheme theme = null;
            DesignerSerializationManager serializationManager = new DesignerSerializationManager();

            using (serializationManager.CreateSession())
            {
                ThemeSerializationProvider provider = new ThemeSerializationProvider();
                StringWriter output = new StringWriter(new StringBuilder(), CultureInfo.InvariantCulture);
                StringReader input  = null;
                try
                {
                    ((IDesignerSerializationManager)serializationManager).AddSerializationProvider(provider);
                    WorkflowMarkupSerializer serializer = new WorkflowMarkupSerializer();
                    using (XmlWriter writer2 = Helpers.CreateXmlWriter(output))
                    {
                        serializer.Serialize(serializationManager, writer2, this);
                    }
                    input = new StringReader(output.ToString());
                    using (XmlReader reader2 = XmlReader.Create(input))
                    {
                        theme = serializer.Deserialize(serializationManager, reader2) as WorkflowTheme;
                    }
                }
                finally
                {
                    ((IDesignerSerializationManager)serializationManager).RemoveSerializationProvider(provider);
                    input.Close();
                    output.Close();
                }
            }
            if (theme != null)
            {
                theme.filePath = this.filePath;
                foreach (DesignerTheme theme2 in theme.DesignerThemes)
                {
                    theme2.Initialize();
                }
            }
            return(theme);
        }