Ejemplo n.º 1
0
    public static MethodInfo GetMethodInfoOf(VMBase viewModel, string targetMethodName)
    {
        MethodInfo[] methodInfoColl = viewModel.GetType()
                                      .GetRuntimeMethods()
                                      .Where(m => m.GetCustomAttributes(typeof(ViewToViewModelAttribute), false).Length > 0)
                                      .Where(m => ((ViewToViewModelAttribute)m.GetCustomAttribute(typeof(ViewToViewModelAttribute))).UniqueName.Equals(targetMethodName))
                                      .ToArray();

        if (methodInfoColl.Length == 0)
        {
            throw new BindableMethodNotFoundException(viewModel, targetMethodName);
        }

        return(methodInfoColl[0]);
    }
Ejemplo n.º 2
0
    public static PropertyInfo GetListPropertyInfoOf <TPLD>(VMBase viewModel)
        where TPLD : IPLDBase
    {
        PropertyInfo[] propInfoColl = viewModel.GetType()
                                      .GetRuntimeProperties()
                                      .Where(m => m.GetCustomAttributes(typeof(ViewModelToViewAttribute), false).Length > 0)
                                      .Where(m => m.PropertyType.Equals(typeof(List <TPLD>)))
                                      .ToArray();

        if (propInfoColl.Length == 0)
        {
            throw new BindablePropertyNotFoundException(viewModel, typeof(List <TPLD>));
        }

        return(propInfoColl[0]);
    }