public List <IGingerService> GetServices() { // TODO: cache if (!Isloaded) { ScanPackage(); } List <IGingerService> services = new List <IGingerService>(); // TODO: fix make more efficent and load only what needed foreach (PluginAssemblyInfo PAI in mAssembliesInfo) { var list = from type in PAI.Assembly.GetTypes() where typeof(IGingerService).IsAssignableFrom(type) && type.IsAbstract == false select type; foreach (Type t in list) { IGingerService service = (IGingerService)PAI.Assembly.CreateInstance(t.FullName); // TODO: fix me find the driver without creating instance services.Add(service); } } return(services); }
//TODO: return DriverInfo //List<string> drivers = null; //public List<string> GetDrivers() //{ // if (!Isloaded) // { // ScanPackage(); // } // if (drivers == null) // { // drivers = new List<string>(); // foreach (PluginAssemblyInfo PAI in mAssembliesInfo) // { // var list = from type in PAI.Assembly.GetTypes() // where typeof(PluginDriverBase).IsAssignableFrom(type) && type.IsAbstract == false // select type; // foreach (Type t in list) // { // PluginDriverBase driver = (PluginDriverBase)PAI.Assembly.CreateInstance(t.FullName); // //TODO: get driver info from annotation on the class // drivers.Add(driver.Name); // } // } // } // return drivers; //} // Services are used for standalone action/ ActWithoutDriver public IGingerService GetService(string serviceName) { if (!Isloaded) { ScanPackage(); } // TODO: fix make more efficent and load only what needed foreach (PluginAssemblyInfo PAI in mAssembliesInfo) { var list = from type in PAI.Assembly.GetTypes() where typeof(IGingerService).IsAssignableFrom(type) && type.IsAbstract == false select type; foreach (Type t in list) { IGingerService service = (IGingerService)PAI.Assembly.CreateInstance(t.FullName); // TODO: fix me find the driver without creating instance //TODO: read the attr of service //if (service.Name == serviceName) //{ // return service; //} } } throw new Exception("Service not found in Plugin Package - " + serviceName); }
public GingerNode(IGingerService service) { mService = service; GingerServiceAttribute attr = (GingerServiceAttribute)Attribute.GetCustomAttribute(mService.GetType(), typeof(GingerServiceAttribute), false); mServiceID = attr.Id; }
private void StartServiceOnGingerNode(IGingerService service, string NodeName, string GingerGridHost = "127.0.0.1", int GingerGridPort = 15001) { Console.WriteLine("Service Name: " + service); bool bReady = false; bNodest = true; Task t = new Task(() => { GingerNode GN = new GingerNode(service); GN.StartGingerNode(NodeName, GingerGridHost, GingerGridPort); GN.GingerNodeMessage += GingerNodeMessage; GingerNodes.Add(GN); bReady = true; }); t.Start(); while (!bReady) // TODO: add timeout or use ManualResetEvent with timeout { Console.WriteLine("Waiting for service Node to be ready"); Thread.Sleep(500); } Console.WriteLine("Ginger Service started - " + NodeName); // Add ports and GingerGrid details }
//TODO: check what we can hide from here and move to GingerCore -- all the communcation Payload stuff move from here public GingerNode(DriverCapabilities DriverCapabilities, IGingerService service) { //TODO: remove me!? mService = service; }
// ================================================================ //private GingerNode StartDriverOnGingerNode(PluginDriverBase driver, string NodeName, string GingerGridHost = "127.0.0.1", int GingerGridPort = 15001) //{ // Console.WriteLine("Driver Name: " + driver.Name); // DriverCapabilities DC = new DriverCapabilities(); // //TODO: add info about the driver and machine // DC.Platform = "Web"; // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // DC.OS = "Win 7"; // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // GingerNode GN = new GingerNode(DC, driver); // GN.StartGingerNode(NodeName, GingerGridHost, GingerGridPort); // Console.WriteLine("Ginger Node started - " + NodeName); // Add ports and GingerGrid details // return GN; //} public void StartService(string Name, string ID, string GingerGridHost = "127.0.0.1", int GingerGridPort = 15001) { IGingerService d = P.GetService(Name); StartServiceOnGingerNode(d, ID, GingerGridHost, GingerGridPort); }