Esempio n. 1
0
 private IScoreMethod ScoreMethodInstance(int evt)
 {
     string sClassName = "ScoreMethod";
     string sAssemblyName = "";
     try
     {
         EventsRepository oevtrep = new EventsRepository();
         lsevent oevt = oevtrep.GetByID(evt);
         ScoreMethodRepository ismrep = new ScoreMethodRepository();
         score_method osm = ismrep.GetByID(oevt.score_method_id);
         sAssemblyName = osm.proc;
         Assembly asmCurrent = Assembly.Load(new AssemblyName(sAssemblyName));
         sAssemblyName = osm.proc + "." + sClassName;
         IScoreMethod inst = (IScoreMethod)asmCurrent.CreateInstance(sAssemblyName);
         if (inst == null)
         {
             throw new Exception("Could not create an instance of class " + sClassName);
         }
         return inst;
     }
     catch (Exception ex)
     {
         sAssemblyName = "LaserSportDataAPI.ScoreMethod.Sample";
         sClassName = sAssemblyName + ".ScoreMethod";
         Assembly asmCurrent = Assembly.Load(new AssemblyName(sAssemblyName));
         IScoreMethod inst = (IScoreMethod)asmCurrent.CreateInstance(sClassName);
         return inst;
         //return null;
     }
 }
Esempio n. 2
0
        private IScoreMethod ScoreMethodInstance(int evt)
        {
            string sClassName = "ScoreMethod";
            string sAssemblyName = "";
            string sObjectName = "";
            IScoreMethod inst;
            try
            {
                //get the full location of the assembly with DaoTests in it
                EventsRepository oevtrep = new EventsRepository();
                lsevent oevt = oevtrep.GetByID(evt);
                ScoreMethodRepository ismrep = new ScoreMethodRepository();
                score_method osm = ismrep.GetByID(oevt.score_method_id);
                sAssemblyName = osm.proc;
                if (String.IsNullOrEmpty(sAssemblyName)) {
                    sAssemblyName = "LaserSportDataAPI.SystemObjects.Sample";
                }
                string AssemblyFilePath = AssemblyDirectory + "\\" + sAssemblyName + ".dll";

                Assembly asmCurrent = Assembly.Load(new AssemblyName(sAssemblyName));
                sObjectName = osm.proc + "." + sClassName;
                inst = (IScoreMethod)asmCurrent.CreateInstance(sObjectName);
                if (inst==null) {
                    throw new Exception("Could not create an instance of class " + sObjectName);
                }
                return inst;
            }
            catch (Exception ex)
            {
                sAssemblyName = "LaserSportDataAPI.SystemObjects.Sample";
                sObjectName = sAssemblyName + "." + sClassName;
                Assembly asmCurrent = Assembly.Load(new AssemblyName(sAssemblyName));
                inst = (IScoreMethod)asmCurrent.CreateInstance(sObjectName);
                return inst;
                //return null;
            }
        }