在C#中,如何获取F#/ Elmish.WPF对象的类/模块类型?

问题描述

我正在尝试将F#与C#混合使用。

在我的C#依赖项属性中,我需要e.NewValue类型-这是F#/ Elmish.WPF提供的对象

e.NewValue.GetType()返回:

{名称=“ viewmodel 2" FullName = "Elmish.WPF.viewmodel 2 [[System.Object,System.Private.CoreLib,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = 7cec85d7bea7798e],[System.Object,System.Private。 CoreLib,版本= 4.0.0.0,区域性=中性,PublicKeyToken = 7cec85d7bea7798e]]}} System.Type {System.RuntimeType}

什么也没告诉我。

如何从F#/ Elmish.WPF获取对象的类/模块类型

谢谢。

TIA

作为全面披露,这来自:

public static readonly DependencyProperty VisitProperty =
            DependencyProperty.Register("Visit",typeof(IInnerRow),typeof(DataGridAnnotationControl),new PropertyMetadata(null,(s,e) =>
            {
                var sender = s as DataGridAnnotationControl;
                var visit = (IInnerRow)e.NewValue;

                if (visit != null)
                    sender.LastName = visit.LastName;
            }));

但是,我看不到如何从Elmish强制转换NewValue,因此希望GetType()可以对此有所启发。

解决方法

类型为Elmish.WPF.ViewModel<,>Its access scope is internal,因此您无法访问比Object更强的类型。