我希望能够在以XamlInjector
编程方式创建的单个自定义活动上使用它来动态模拟它。目前我有以下抛出System.ArgumentException: Illegal characters in path
. 从注射器。任何想法如何使这项工作?
string serializedActivity = CreateXaml(new MyActivity()); //(Activator.CreateInstance(activityType));
var xamlInjector = new XamlInjector(serializedActivity);
private static string CreateXaml(object activity) {
StringBuilder builder = new StringBuilder();
StringWriter writer = new StringWriter(builder);
XamlWriter xamlWriter = ActivityXamlServices.CreateBuilderWriter(new XamlXmlWriter(writer, new XamlSchemaContext()));
XamlServices.Save(xamlWriter, activity);
return builder.ToString();
}
以下是创建的 xaml 示例:
<?xml version="1.0" encoding="utf-16"?><Delay xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities" />
<?xml version="1.0" encoding="utf-16"?><CreateTemplate AuthenticationHeader="{x:Null}" BaseTdeUri="{x:Null}" CreatedTemplateId="{x:Null}" Password="{x:Null}" TemplateContent="{x:Null}" UserName="{x:Null}" xmlns="clr-namespace:XYZ.Workflow.TdeRestApi;assembly=XYZ.Workflow.Activities" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" />