0

我希望能够在以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" />

4

1 回答 1

1

有趣的想法 - 我应该向执行此操作的 XamlInjector 添加一个重载。

您收到错误的原因是 XamlInjector ctor 需要一个文件名,而不是序列化的 xaml。

于 2012-06-29T23:12:54.017 回答