【问题标题】:In C#, how to get the class/module type of an F#/Elmish.WPF object?在 C# 中,如何获取 F#/Elmish.WPF 对象的类/模块类型?
【发布时间】:2020-10-24 20:30:48
【问题描述】:

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

在我的 C# Dependency 属性中,我需要 e.NewValue 的类型——它是 F#/Elmish.WPF 提供的对象

e.NewValue.GetType() 返回:

{Name = "ViewModel2" FullName = "Elmish.WPF.ViewModel2[[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() 能对此有所了解。

【问题讨论】:

  • e.NewValue 的类型显然是Elmish.WPF.ViewModel<Object, Object>。 “获取类型”对您意味着什么?
  • @FyodorSoikin 你是对的。完整代码如上,我不知道如何转换来自 Elmish.WPF 视图模型的 e.NewValue。我希望 GetType() 能对此有所了解。谢谢。
  • 如何转换成什么?

标签: f# elmish-wpf


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-07-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-10
    相关资源
    最近更新 更多