public static Activity Load(XamlReader xamlReader, ActivityXamlServicesSettings settings) { if (xamlReader == null) { throw CoreWf.Internals.FxTrace.Exception.ArgumentNull("xamlReader"); } if (settings == null) { throw CoreWf.Internals.FxTrace.Exception.ArgumentNull("settings"); } DynamicActivityXamlReader dynamicActivityReader = new DynamicActivityXamlReader(xamlReader); object xamlObject = XamlServices.Load(dynamicActivityReader); Activity result = xamlObject as Activity; if (result == null) { throw CoreWf.Internals.FxTrace.Exception.Argument("reader", SR.ActivityXamlServicesRequiresActivity( xamlObject != null ? xamlObject.GetType().FullName : string.Empty)); } IDynamicActivity dynamicActivity = result as IDynamicActivity; if (dynamicActivity != null && settings.CompileExpressions) { Compile(dynamicActivity, settings.LocationReferenceEnvironment); } return(result); }
public static Activity Load(TextReader textReader, ActivityXamlServicesSettings settings) { if (textReader == null) { throw CoreWf.Internals.FxTrace.Exception.ArgumentNull("textReader"); } if (settings == null) { throw CoreWf.Internals.FxTrace.Exception.ArgumentNull("settings"); } using (XmlReader xmlReader = XmlReader.Create(textReader)) { return(Load(xmlReader, settings)); } }
public static Activity Load(string fileName, ActivityXamlServicesSettings settings) { if (fileName == null) { throw CoreWf.Internals.FxTrace.Exception.ArgumentNull("fileName"); } if (settings == null) { throw CoreWf.Internals.FxTrace.Exception.ArgumentNull("settings"); } using (XmlReader xmlReader = XmlReader.Create(fileName)) { return(Load(xmlReader, settings)); } }
public static Activity Load(XmlReader xmlReader, ActivityXamlServicesSettings settings) { if (xmlReader == null) { throw CoreWf.Internals.FxTrace.Exception.ArgumentNull("xmlReader"); } if (settings == null) { throw CoreWf.Internals.FxTrace.Exception.ArgumentNull("settings"); } using (XamlXmlReader xamlReader = new XamlXmlReader(xmlReader, dynamicActivityReaderSchemaContext)) { return(Load(xamlReader, settings)); } }
public static Activity Load(Stream stream, ActivityXamlServicesSettings settings) { if (stream == null) { throw FxTrace.Exception.ArgumentNull(nameof(stream)); } if (settings == null) { throw FxTrace.Exception.ArgumentNull(nameof(settings)); } using (XmlReader xmlReader = XmlReader.Create(stream)) { return(Load(xmlReader, settings)); } }
static void Main(string[] args) { ActivityXamlServicesSettings settings = new CoreWf.XamlIntegration.ActivityXamlServicesSettings { CompileExpressions = false }; try { string InWriteActivity = @" <Activity x:Class=""WFTemplate"" xmlns=""http://schemas.microsoft.com/netfx/2009/xaml/activities"" xmlns:s=""clr-namespace:System;assembly=mscorlib"" xmlns:s1=""clr-namespace:System;assembly=System"" xmlns:sa=""clr-namespace:CoreWf;assembly=CoreWf"" xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml""> </Activity>";//<HelloWorldConsole></HelloWorldConsole> <Sequence></Sequence> var act = CoreWf.XamlIntegration.ActivityXamlServices.Load(GenerateStreamFromString(InWriteActivity), settings); WorkflowInvoker.Invoke(act); } catch (Exception ex) { Console.WriteLine(ex.Message.ToString()); } try { string InWriteActivity = @" <Activity x:Class=""WFTemplate"" xmlns=""http://schemas.microsoft.com/netfx/2009/xaml/activities"" xmlns:s=""clr-namespace:System;assembly=mscorlib"" xmlns:s1=""clr-namespace:System;assembly=System"" xmlns:sa=""clr-namespace:CoreWf;assembly=CoreWf"" xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml""> <x:Members> <x:Property Name=""myInput"" Type=""InArgument(x:String)"" /> </x:Members> <HelloWorldConsole Text=""[myInput]"" /> </Activity>"; var act = CoreWf.XamlIntegration.ActivityXamlServices.Load(GenerateStreamFromString(InWriteActivity), settings); Dictionary <string, object> dic = new Dictionary <string, object>(); dic.Add("myInput", "HelloWorld"); WorkflowInvoker.Invoke(act, dic); } catch (Exception ex) { Console.WriteLine(ex.Message.ToString()); } try { string InWriteActivity = @" <Activity x:Class=""WFTemplate"" xmlns=""http://schemas.microsoft.com/netfx/2009/xaml/activities"" xmlns:s=""clr-namespace:System;assembly=mscorlib"" xmlns:s1=""clr-namespace:System;assembly=System"" xmlns:sa=""clr-namespace:CoreWf;assembly=CoreWf"" xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml""> <x:Members> <x:Property Name=""myInput"" Type=""InArgument(x:String)"" /> </x:Members> <WriteLine Text=""[myInput]"" /> </Activity>"; var act = CoreWf.XamlIntegration.ActivityXamlServices.Load(GenerateStreamFromString(InWriteActivity), settings); Dictionary <string, object> dic = new Dictionary <string, object>(); dic.Add("myInput", "HelloWorld"); WorkflowInvoker.Invoke(act, dic); } catch (Exception ex) { Console.WriteLine(ex.Message.ToString()); } try { string ActivityWriteLine = @" <Activity x:Class=""WFTemplate"" xmlns=""http://schemas.microsoft.com/netfx/2009/xaml/activities"" xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml""> <Sequence> <WriteLine Text=""HelloWorld"" /> </Sequence> </Activity>"; var act = CoreWf.XamlIntegration.ActivityXamlServices.Load(GenerateStreamFromString(ActivityWriteLine), settings); WorkflowInvoker.Invoke(act); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } try { string ActivityWriteLine = @" <Activity x:Class=""WFTemplate"" xmlns=""http://schemas.microsoft.com/netfx/2009/xaml/activities"" xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml""> <Sequence> <WriteLine><Content><Text>""HelloWorld""</Text></Content> </WriteLine> </Sequence> </Activity>"; var act = CoreWf.XamlIntegration.ActivityXamlServices.Load(GenerateStreamFromString(ActivityWriteLine), settings); WorkflowInvoker.Invoke(act); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } try { string ActivityAlone = @" <Activity x:Class=""WFTemplate"" xmlns=""http://schemas.microsoft.com/netfx/2009/xaml/activities"" xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml""> </Activity>"; var act = CoreWf.XamlIntegration.ActivityXamlServices.Load(GenerateStreamFromString(ActivityAlone), settings); WorkflowInvoker.Invoke(act); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } try { string ActivityWriteLine = @" <Activity x:Class=""WFTemplate"" xmlns=""http://schemas.microsoft.com/netfx/2009/xaml/activities"" xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml""> <WriteLine Text=""HelloWorld"" /> </Activity>"; var act = CoreWf.XamlIntegration.ActivityXamlServices.Load(GenerateStreamFromString(ActivityWriteLine), settings); WorkflowInvoker.Invoke(act); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } try { string InOutActivityOnly = @" <Activity x:Class=""WFTemplate"" xmlns=""http://schemas.microsoft.com/netfx/2009/xaml/activities"" xmlns:s=""clr-namespace:System;assembly=mscorlib"" xmlns:s1=""clr-namespace:System;assembly=System"" xmlns:sa=""clr-namespace:CoreWf;assembly=CoreWf"" xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml""> <x:Members> <x:Property Name=""myOutput"" Type=""OutArgument(x:Int32)"" /> <x:Property Name=""myInput"" Type=""InArgument(x:Int32)"" /> </x:Members> </Activity>"; var act = CoreWf.XamlIntegration.ActivityXamlServices.Load(GenerateStreamFromString(InOutActivityOnly), settings); Dictionary <string, object> dic = new Dictionary <string, object>(); dic.Add("myInput", 1); Dictionary <string, object> outputDict = WorkflowInvoker.Invoke(act, dic) as Dictionary <string, object>; foreach (var kvp in outputDict.ToList()) { Console.WriteLine(kvp.Key.ToString() + " " + kvp.Value.ToString()); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } try { string InOutActivity = @" <Activity x:Class=""WFTemplate"" xmlns=""http://schemas.microsoft.com/netfx/2009/xaml/activities"" xmlns:s=""clr-namespace:System;assembly=mscorlib"" xmlns:s1=""clr-namespace:System;assembly=System"" xmlns:sa=""clr-namespace:CoreWf;assembly=CoreWf"" xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml""> <x:Members> <x:Property Name=""myOutput"" Type=""OutArgument(x:Int32)"" /> <x:Property Name=""myInput"" Type=""InArgument(x:Int32)"" /> </x:Members> <Assign> <Assign.To> <OutArgument x:TypeArguments=""x:Int32"">[myOutput]</OutArgument> </Assign.To> <Assign.Value> <InArgument x:TypeArguments=""x:Int32"">[myInput]</InArgument> </Assign.Value> </Assign> </Activity>"; var act = CoreWf.XamlIntegration.ActivityXamlServices.Load(GenerateStreamFromString(InOutActivity), settings); var outputDict = WorkflowInvoker.Invoke(act) as Dictionary <string, object>; foreach (var kvp in outputDict) { Console.WriteLine(kvp.Key.ToString() + " " + kvp.Value.ToString()); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } try { string XamlText = @" <Activity x:Class=""WFTemplate"" xmlns=""http://schemas.microsoft.com/netfx/2009/xaml/activities"" xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml""> <Sequence> <WriteLine Text=""HelloWorld"" /> </Sequence> </Activity>"; var act = CoreWf.XamlIntegration.ActivityXamlServices.Load(GenerateStreamFromString(XamlText), settings); WorkflowInvoker.Invoke(act); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }