private DeviceScriptorInterface LoadDeviceScriptorPlugin()
        {
            // Find all files

            FileInfo[] files = new DirectoryInfo(System.Windows.Forms.Application.StartupPath).GetFiles();
            foreach (FileInfo file in files)
            {
                // analyze only dll and exe files
                if (file.Extension.ToUpper() == ".DLL" || file.Extension.ToUpper() == ".EXE")
                {
                    // If a file points to an plugin that implement the interface
                    Type     ClassImplementedInterface = null;
                    Assembly assembly = null;
                    assembly = GetPluginInfo(file, typeof(DeviceScriptorInterface), ref ClassImplementedInterface);
                    if ((assembly != null) && (ClassImplementedInterface != null))
                    {
                        DeviceScriptorInterface plugin = null;
                        try
                        {
                            plugin = assembly.CreateInstance(ClassImplementedInterface.FullName) as DeviceScriptorInterface;
                        }
                        catch (Exception)
                        {
                            plugin = null;
                        }
                        if (plugin != null)
                        {
                            return(plugin);
                        }
                    }
                }
            }
            return(null);
        }
        public DeviceScriptorTest(string ScriptProjectFileName)
        {
            ScriptorInterface = LoadDeviceScriptorPlugin();
            if (ScriptorInterface == null)
            {
                throw new Exception("Failed to load the Device Scriptor Plug-in. Please make sure the DeviceScriptor.exe file is in the same directory");
            }
            FileInfo Info = new FileInfo(ScriptProjectFileName);

            char []   Separator = { '.' };
            string [] NameExt   = Info.Name.Split(Separator);
//			for(int i=0; i<NameExt.GetLength(0);i++)
//				if (i !=  (NameExt.GetLength(0) -1))	//ignore the last one since it is the extension
//					GroupName += NameExt[i];
            if ((NameExt != null) && (NameExt.GetLength(0) > 0))
            {
                GroupName = NameExt[0];
            }
            try
            {
                ScriptorInterface.LoadScriptProject(ScriptProjectFileName);
            }
            catch (Exception ex)
            {
                throw new Exception("Failed to load the Script Project: " + ex.Message);
            }
            Category    = "Script Projects";
            Description = ScriptorInterface.ScriptProjectDescription;
            ScriptorInterface.OnProgressChanged    += new ProgressEventHandler(OnProgressChangedSink);
            ScriptorInterface.OnStateChanged       += new StateEventHandler(OnStateChangedSink);
            ScriptorInterface.OnPacketTraceChanged += new PacketEventHandler(OnPacketTraceChangedSink);
            ScriptorInterface.OnEventLog           += new ScriptLogEventHandler(OnEventLogSink);
            AddTestFromScriptProject();
            Reset();
        }
 public DeviceScriptorTest(string ScriptProjectFileName)
 {
     ScriptorInterface = LoadDeviceScriptorPlugin();
     if (ScriptorInterface == null)
     {
         throw new Exception("Failed to load the Device Scriptor Plug-in. Please make sure the DeviceScriptor.exe file is in the same directory");
     }
     FileInfo Info = new FileInfo(ScriptProjectFileName);
     char [] Separator = {'.'};
     string [] NameExt = Info.Name.Split(Separator);
     //			for(int i=0; i<NameExt.GetLength(0);i++)
     //				if (i !=  (NameExt.GetLength(0) -1))	//ignore the last one since it is the extension
     //					GroupName += NameExt[i];
     if ((NameExt != null)&&(NameExt.GetLength(0)>0))
         GroupName = NameExt[0];
     try
     {
         ScriptorInterface.LoadScriptProject(ScriptProjectFileName);
     }
     catch (Exception ex)
     {
         throw new Exception("Failed to load the Script Project: " + ex.Message);
     }
     Category = "Script Projects";
     Description = ScriptorInterface.ScriptProjectDescription;
     ScriptorInterface.OnProgressChanged += new ProgressEventHandler(OnProgressChangedSink);
     ScriptorInterface.OnStateChanged += new StateEventHandler(OnStateChangedSink);
     ScriptorInterface.OnPacketTraceChanged += new PacketEventHandler(OnPacketTraceChangedSink);
     ScriptorInterface.OnEventLog += new ScriptLogEventHandler(OnEventLogSink);
     AddTestFromScriptProject();
     Reset();
 }
        private void OnStateChangedSink(DeviceScriptorInterface sender, StateEventStruct StateInfo)
        {
            UPnPTestStates ReportedState = GetEquivalentUPnPTestState(StateInfo.States);

            for (int i = 0; i < TestList.Count; i++)
            {
                if (StateInfo.ScriptName == ((string [])TestList[i])[0])
                {
                    if (ReportedState > states[i])
                    {
                        states[i] = ReportedState;
                        SetState(StateInfo.ScriptName, ReportedState);
                    }
                }
            }
        }
 private void OnProgressChangedSink(DeviceScriptorInterface sender, byte progess)
 {
     SetProgress(progess);
 }
 private void OnEventLogSink(DeviceScriptorInterface sender, LogInfo log)
 {
     AddEvent(GetEquivalentLogImportance(log.importance), log.TestName, log.LogEntry);
 }
 private void OnPacketTraceChangedSink(DeviceScriptorInterface sender, PacketLogStruct PacketLog)
 {
     AddPacket(PacketLog.packet);
 }
 private void OnStateChangedSink(DeviceScriptorInterface sender, StateEventStruct StateInfo)
 {
     UPnPTestStates ReportedState = GetEquivalentUPnPTestState(StateInfo.States);
     for (int i=0; i<TestList.Count; i++)
     {
         if (StateInfo.ScriptName == ((string [])TestList[i])[0])
         {
             if (ReportedState > states[i])
             {
                 states[i] = ReportedState;
                 SetState(StateInfo.ScriptName, ReportedState);
             }
         }
     }
 }
 private void OnProgressChangedSink(DeviceScriptorInterface sender, byte progess)
 {
     SetProgress(progess);
 }
 private void OnPacketTraceChangedSink(DeviceScriptorInterface sender, PacketLogStruct PacketLog)
 {
     AddPacket(PacketLog.packet);
 }
 private void OnEventLogSink(DeviceScriptorInterface sender, LogInfo log)
 {
     AddEvent(GetEquivalentLogImportance(log.importance), log.TestName, log.LogEntry);
 }