src/Shared/EntityFramework/Core/Objects/ObjectViewFactory.cs
// <summary>
// Create an ObjectView using reflection.
// </summary>
// <param name="clrElementType"> Type to be used for the ObjectView's generic type parameter. </param>
// <param name="objectViewDataType"> The type of class that implements the IObjectViewData to be used by the ObjectView. </param>
// <param name="viewData"> The IObjectViewData to be used by the ObjectView to access the binding list. </param>
// <param name="eventDataSource"> Event source used by ObjectView for entity and membership changes. </param>
Create an ObjectView using reflection.
Create an ObjectView using reflection .
private static IBindingList CreateObjectView(Type clrElementType, Type objectViewDataType, object viewData, object eventDataSource)
        {
            var objectViewType = _genericObjectViewType.MakeGenericType(clrElementType);
            var viewDataInterfaces =
                objectViewDataType.FindInterfaces(
                    (Type type, object unusedFilter) => type.Name == _genericObjectViewDataInterfaceType.Name, null);
            Debug.Assert(
                viewDataInterfaces.Length == 1, "Could not find IObjectViewData<T> interface definition for ObjectViewQueryResultData<T>.");
            var viewConstructor = objectViewType.GetDeclaredConstructor(viewDataInterfaces[0], typeof(object));
            Debug.Assert(viewConstructor != null, "ObjectView constructor not found. Please ensure constructor signature is correct.");
            return (IBindingList)viewConstructor.Invoke(new[] { viewData, eventDataSource });
        }
private static IBindingList CreateObjectView ( Type clrElementType , Type objectViewDataType , object viewData , object eventDataSource ) { var objectViewType = _genericObjectViewType . MakeGenericType ( clrElementType ) ; var viewDataInterfaces = objectViewDataType . FindInterfaces ( ( Type type , object unusedFilter ) => type . Name == _genericObjectViewDataInterfaceType . Name , null ) ; Debug . Assert ( viewDataInterfaces . Length == 1 , " " ) ; var viewConstructor = objectViewType . GetDeclaredConstructor ( viewDataInterfaces [ 0 ] , typeof ( object ) ) ; Debug . Assert ( viewConstructor != null , " " ) ; return ( IBindingList ) viewConstructor . Invoke ( new [ ] { viewData , eventDataSource } ) ; }
Create an ObjectView using reflection.
Create an ObjectView using reflection .
// Create ObjectView instance
clrElementType
Type
Type to be used for the ObjectView's generic type parameter.
Type to be used for the ObjectView ' s generic type parameter .
objectViewDataType
Type
The type of class that implements the IObjectViewData to be used by the ObjectView.
The type of class that implements the IObjectViewData to be used by the ObjectView .
viewData
object
The IObjectViewData to be used by the ObjectView to access the binding list.
The IObjectViewData to be used by the ObjectView to access the binding list .
eventDataSource
object
Event source used by ObjectView for entity and membership changes.
Event source used by ObjectView for entity and membership changes .