ModelItem 和 ModelTreeManager not found.System.Activities.Presentation 缺少 .net core 3.1

ModelItem and ModelTreeManager not found.System.Activities.Presentation is missing .net core 3.1

我需要使用 ModelItem 和 ModelTreeManager,但是 visual studio 没有找到在 .net core 3.1

中使用 System.Activities.Presentation.Model 的参考资料

.net core 3.1 CoreWf 在 System.Activity(.Net Framework 4.x) 命名空间中提供 classes,但不提供 System.Activity.Presentation,因此 ModelItem 和 ModelTreeManager 是无法访问。

我正在尝试将 class from.net 框架迁移到 dot net core 3.1


    using System;
    using System.Diagnostics;
    using System.Globalization;
    using System.Activities.Presentation;
    using CoreWf;

    namespace Utils.Converters
    { 
            public class ClassTest
        {
            public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
            {
                object convertedValue = null;
                if (value != null)
                {
                    ModelItem argumentModelItem = value as ModelItem;
                    if (argumentModelItem != null &&
                        argumentModelItem.Properties["Expression"] != null &&
                        argumentModelItem.Properties["Expression"].Value != null)
                    {
                        convertedValue = argumentModelItem.Properties["Expression"].Value;
                    }
                }
                return convertedValue;
            }

            public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
            {
                Argument target = null;
                ArgumentDirection direction = ArgumentDirection.In;
                string directionString = parameter?.ToString();
                if (!string.IsNullOrEmpty(directionString))
                {
                    direction = (ArgumentDirection)Enum.Parse(typeof(ArgumentDirection), directionString);
                }

                ActivityWithResult expression = value as ActivityWithResult;
                ModelItem valueExpressionModelItem = value as ModelItem;
                if (valueExpressionModelItem != null && typeof(ActivityWithResult).IsAssignableFrom(valueExpressionModelItem.ItemType))
                {
                    expression = (ActivityWithResult)valueExpressionModelItem.GetCurrentValue();
                }

                if (expression != null)
                {
                    Type argumentType;
                    argumentType = direction == ArgumentDirection.In ? expression.ResultType : expression.ResultType.IsGenericType ? expression.ResultType.GetGenericArguments()[0] : expression.ResultType;
                    try
                    {
                        target = Argument.Create(argumentType, direction);
                        target.Expression = expression;
                    }
                    catch (Exception err)
                    {
                        Trace.WriteLine(err.ToString());
                        throw;
                    }
                }
                var mtm = new ModelTreeManager(valueExpressionModelItem.GetEditingContext());
                return mtm.CreateModelItem(null, target);
            }
        }
    }

感谢@orosandrei 解释 me.The 实际情况是 CoreWF 帮助运行时 + etw。不幸的是,演示文稿/重新托管的设计器不可用。为此,我必须继续使用 .net framework 4x

Explain with detail in this link