Search code examples
f#elmish-wpf

In C#, how to get the class/module type of an F#/Elmish.WPF object?


I am attempting to mix F# with C#.

In my C# Dependency property, I need the type of e.NewValue -- which is a supplied object from F#/Elmish.WPF

e.NewValue.GetType() returns:

{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, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]"} System.Type {System.RuntimeType}

which tells me nothing.

How do you get the class/module type of an object from F#/Elmish.WPF

Thank you.

TIA

As full disclosure, this comes from:

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;
            }));

However, I don't see how to cast the NewValue from Elmish, so was hoping the GetType() would shed some light on this.


Solution

  • The type is Elmish.WPF.ViewModel<,>. Its access scope is internal, so you don't have access to any stronger type than Object.