Exemplo n.º 1
0
        private string Callsutmethods(string input)
        {
            string         output  = "";
            Object         ob      = null;;
            Abstractmethod _method = Abstractiontable.Getmethod(input);

            if (_method != null)
            {
                if (_method.concretemethod.method.IsPublic)
                {
                    object[] _inputs = new object[_method.parameters.Count];
                    int      cnt     = 0;
                    foreach (var item in _method.parameters)
                    {
                        _inputs[cnt] = Convert.ChangeType(item.value, item.param.ParameterType);
                        cnt++;
                    }
                    ///
                    ob = _method.concretemethod.method.Invoke(null, _inputs);
                    ///
                }
                else if (_method.concretemethod.method.IsPrivate)
                {
                    object[] _inputs = new object[_method.parameters.Count];
                    int      cnt     = 0;
                    foreach (var item in _method.parameters)
                    {
                        _inputs[cnt] = Convert.ChangeType(item.value, item.param.ParameterType);
                        cnt++;
                    }
                    MethodInfo dynMethod = _method.concretemethod.method.DeclaringType.GetMethod(_method.concretemethod.method.Name,
                                                                                                 BindingFlags.NonPublic | BindingFlags.Instance);
                    ob = dynMethod.Invoke(null, _inputs);
                }
            }
            if (ob != null)
            {
                if (Convert.ToBoolean(ob) == true)
                {
                    output = _method.abstractvalue + "-OK";
                }
                else
                {
                    output = _method.abstractvalue + "-NOK";
                }
            }
            return(output);
        }
Exemplo n.º 2
0
        private static void Additem(object[] y, string methodname, string symbol)
        {
            Method _m1 = Callgraph.listmethods.Where(p => p.method.Name.Equals(methodname)).Single();

            ParameterInfo[]  param1 = _m1.method.GetParameters();
            List <Parameter> p11    = new List <Parameter>();

            for (int i = 0; i < param1.Length; i++)
            {
                Parameter p2 = new Parameter(param1[i], y[i]);
                p11.Add(p2);
            }

            Abstractmethod abs1 = new Abstractmethod(symbol, _m1, p11, "TRUE");

            Abstractiontable.Additem(abs1);
        }
Exemplo n.º 3
0
        private List <Abstractmethod> Discovernewalphabet(List <Method> _listunused, List <Loggedmethods> _listlog)
        {
            Callgraph.listmethods.ForEach(delegate(Method m){
                m.score         = 0;
                m.calledmethods = new List <Method>();
            });
            foreach (var item in _listunused)
            {
                int functionnumber = Callgraph.listmethods.Where(p => p.ID == item.ID).Select(p => p.ID).Single();
                Callgraph.listmethods.Where(p => p.ID == functionnumber).Single().score++;
                Method _m = Callgraph.listmethods.Where(p => p.ID == functionnumber).Single();
                Callgraph.listmethods.Where(p => p.ID == functionnumber).Single().calledmethods.Add(_m);
                List <Method> _called = new List <Method>();
                _called.Add(_m);
                Updatecallinformations(_m, _m);
            }
            List <Method>         newfunctions = Findbestfunctions(_listunused);
            List <Abstractmethod> newrows      = Abstractiontable.Updateabstracttable(newfunctions);

            return(newrows);
        }
Exemplo n.º 4
0
        private static void Initialabstractiontable()
        {
            // object[] x;
            //should change
            Abstractiontable.Resettable();
            object[] x = { "1", "", "", "", "1", "", "", "" };
            Additem(x, "Registerstudent", "REGISTERSTUDENT");

            //Registercity
            object[] x1 = { "" };
            Additem(x1, "Registercity", "REGISTERCITY");

            //Registermajor
            object[] x2 = { "" };
            Additem(x2, "Registermajor", "REGISTERMAJOR");

            //login
            object[] x3 = { "", 0 };
            Additem(x3, "Loginuser", "LOGINUSER");

            //login
            object[] x4 = { };
            Additem(x4, "Logout", "LOGOUT");
        }