}//end

        //从[xaml]字串得到[ActivityBuilder]对象
        public static string xamlFromActivityBuilder(ActivityBuilder activityBuilder)
        {
            string xamlString = "";

            StringBuilder stringBuilder = new StringBuilder();

            System.IO.StringWriter stringWriter = new System.IO.StringWriter(stringBuilder);

            XamlSchemaContext xamlSchemaContext = new XamlSchemaContext();
            XamlXmlWriter     xamlXmlWriter     = new XamlXmlWriter(stringWriter, xamlSchemaContext);
            XamlWriter        xamlWriter        = ActivityXamlServices.CreateBuilderWriter(xamlXmlWriter);

            XamlServices.Save(xamlWriter, activityBuilder);
            xamlString = stringBuilder.ToString();

            return(xamlString);
        }
Esempio n. 2
0
        //从[ActivityBuilder]对象得到[xaml]字串
        public static ActivityBuilder activityBuilderFromXaml(string xaml)
        {
            ActivityBuilder activityBuilder = null;

            System.IO.StringReader    stringReader  = new System.IO.StringReader(xaml);
            System.Xaml.XamlXmlReader xamlXmlReader = new System.Xaml.XamlXmlReader(stringReader);
            System.Xaml.XamlReader    xamlReader    = ActivityXamlServices.CreateBuilderReader(xamlXmlReader);

            activityBuilder = System.Xaml.XamlServices.Load(xamlReader) as ActivityBuilder;

            if (activityBuilder != null)
            {
                return(activityBuilder);
            }
            else
            {
                return(null);
            }
        }