示例#1
0
        private static void CallAction(string action, object sender, EventArgs e)
        {
            var mainFrame = Application.Current.RootVisual as PhoneApplicationFrame;

            if (mainFrame == null)
            {
                Debug.WriteLine("ApplicationBarIconButtonEx -> Could not find PhoneApplicationFrame");
                return;
            }
            var content = mainFrame.Content as Control;

            if (content == null)
            {
                Debug.WriteLine("ApplicationBarIconButtonEx -> PhoneApplicationFrame.Content is not a control!");
                return;
            }
            if (content.DataContext == null)
            {
                Debug.WriteLine("ApplicationBarIconButtonEx -> PhoneApplicationFrame.Content.DataContext is null!");
                return;
            }
            object dataContext = content.DataContext;

            if (action == null)
            {
                Debug.WriteLine("ApplicationBarIconButtonEx -> No action to perform");
                return;
            }
            try {
                Reflector.CallMethod(dataContext, action);
            }
            catch {
                Debug.WriteLine("ApplicationBarIconButtonEx -> Could not find method {0} in object {1}", action, dataContext);
            }
        }
示例#2
0
        public static void Main()
        {
            Reflector reflector = new Reflector();

            reflector.inFile(typeof(CollectionType <int>));
            reflector.GetMethods(reflector.GetType());
            reflector.GetData(typeof(CollectionType <int>));
            reflector.GetInterfaces(typeof(CollectionType <int>));
            reflector.SearchMethods(reflector.GetType());
            reflector.CallMethod(typeof(Test), "input.txt");
            ReadKey();
        }
示例#3
0
    static void Main(string[] agrs)
    {
        Person    person    = new Person("kek", 16);
        Reflector reflector = new Reflector();

        reflector.ClassContains(person);
        reflector.ClassContainsMethods(person);
        Console.WriteLine(new string('_', 50));
        reflector.ClassContainsProperties(person);
        Console.WriteLine(new string('_', 50));
        reflector.ClassContainsInterfaces(person);
        Console.WriteLine(new string('_', 50));
        reflector.MethodContainsArg(person, typeof(int));
        Console.WriteLine(new string('_', 50));
        reflector.CallMethod(person, "kek");
    }
示例#4
0
        private static void CallMethod(Map map, object dataContext, string methodName, object eventArgs)
        {
            var parameters = new List <object>();

            if (map.SendingEventArgs)
            {
                parameters.Add(eventArgs);
            }
            if (map.HasParam)
            {
                parameters.Add(map.WithParam);
            }
            try {
                Reflector.CallMethod(dataContext, methodName, parameters.ToArray());
            }
            catch (ReflectorException ex) {
                Debug.WriteLine("WARN: " + ex.Message);
            }
        }