static void testGetHandle() { EnablePlugin obj = new EnablePlugin(); IntPtr handle; /*The actual algorithm is here.*/ #if (!TEST) { handle = obj.getHandle(); /*This is to log if we get handle zero even after all the checks are done*/ //Console.WriteLine("The handle is : " + handle); if (handle == IntPtr.Zero) { #if (EXCEPTION) { Exception ex = new Exception("The Handle is zero in main program"); throw ex; } #else { Console.WriteLine("The Handle is zero in main program"); } #endif } else { Console.WriteLine("Found Handle for Firefox"); Console.WriteLine("Done"); } AccessibleCode acobj = new AccessibleCode(handle); //acobj.checkHandle(); acobj.doAccessibleHandle(); # if (TEST) //For testing whether we got the right handle //SetWindowText(handle, "Found it "); //obj.closeWindow(handle); #endif } #endif #if (TEST) //TEST CASES: //1. One instance of Firefox Open - so gets 1 handle //2. 2 instance open - so we need to get the right thing //3. No instance of FF open, so we need to open FF #endif //Console.ReadLine(); obj.closeWindow(handle); }
//Function to test the function which finds the FF installation folder private static void testFFinstallation() { EnablePlugin obj = new EnablePlugin(); //To Test this, set function getFFExepath() in EnablePlugin.cs to public and uncomment the below line //obj.getFFExepath(); Console.ReadLine(); }
static void actualalgo() { EnablePlugin obj = new EnablePlugin(); IntPtr handle; ///Get the handle for FF : getHandle() function /// 1. If there is no instance of FF running on the system, it runs FF and returns the handle of that instance. /// 2. If there are more than 1 instance of FF running on the system, then it returns the handle of the last FF which is iterated by Enumwindows /// 3. If there is firefox Browser and Thunderbird both running, then it returns the handle of FF /// 4. if there are more than 1 instance of FF browser and Thunderbird running, then it returns the FF of the last FF which is iterated by Enumwindows /// 5. if FF is not running and we are not able to run it(i.e. it is not installed), it throws an exception saying that FF not installed handle = obj.getHandle(); }
/// <summary> /// Initialize /// </summary> public void Init() { // System plugins ( basic features - loops, if etc ) _sysMap["Break"] = new BreakPlugin(); _sysMap["Continue"] = new ContinuePlugin(); _sysMap["For"] = new ForLoopPlugin(); _sysMap["FuncDeclare"] = new FuncDeclarePlugin(); _sysMap["If"] = new IfPlugin(); _sysMap["New"] = new NewPlugin(); _sysMap["Return"] = new ReturnPlugin(); _sysMap["Throw"] = new ThrowPlugin(); _sysMap["TryCatch"] = new TryCatchPlugin(); _sysMap["TypeOf"] = new TypeOfPlugin(); _sysMap["While"] = new WhilePlugin(); _sysMap["Var"] = new VarPlugin(); // Custom plugins - extended functionality. _extMap["Aggregate"] = new AggregatePlugin(); _extMap["Alias"] = new AliasPlugin(); _extMap["AndOr"] = new AndOrPlugin(); _extMap["Bool"] = new BoolPlugin(); _extMap["Compare"] = new ComparePlugin(); _extMap["ConstCaps"] = new ConstCapsPlugin(); _extMap["Date"] = new DatePlugin(); _extMap["DateNumber"] = new DateNumberPlugin(); _extMap["DateTimeCombiner"] = new DateTimeCombinerPlugin(); _extMap["Day"] = new DayPlugin(); _extMap["Def"] = new DefPlugin(); _extMap["Enable"] = new EnablePlugin(); _extMap["Email"] = new EmailPlugin(); _extMap["Fail"] = new FailPlugin(); _extMap["FileExt"] = new FileExtPlugin(); _extMap["FluentFunc"] = new FluentFuncPlugin(); _extMap["FluentMember"] = new FluentMemberPlugin(); _extMap["FuncWildCard"] = new FuncWildCardPlugin(); _extMap["HashComment"] = new HashCommentPlugin(); _extMap["Holiday"] = new HolidayPlugin(); _extMap["Linq"] = new LinqPlugin(); _extMap["Log"] = new LogPlugin(); _extMap["MachineInfo"] = new MachineInfoPlugin(); _extMap["Marker"] = new MarkerPlugin(); _extMap["MarkerLex"] = new MarkerLexPlugin(); _extMap["Money"] = new MoneyPlugin(); _extMap["Percent"] = new PercentPlugin(); _extMap["Print"] = new PrintPlugin(); _extMap["PrintExpression"] = new PrintExpressionPlugin(); _extMap["Records"] = new RecordsPlugin(); _extMap["Repeat"] = new RepeatPlugin(); _extMap["Round"] = new RoundPlugin(); _extMap["Run"] = new RunPlugin(); _extMap["Set"] = new SetPlugin(); _extMap["Sort"] = new SortPlugin(); _extMap["Step"] = new StepPlugin(); _extMap["StringLiteral"] = new StringLiteralPlugin(); _extMap["Suffix"] = new SuffixPlugin(); _extMap["Swap"] = new SwapPlugin(); _extMap["Time"] = new TimePlugin(); _extMap["TypeOperations"] = new TypeOperationsPlugin(); _extMap["Units"] = new UnitsPlugin(); _extMap["Uri"] = new UriPlugin(); _extMap["VariablePath"] = new VariablePathPlugin(); _extMap["Version"] = new VersionPlugin(); _extMap["Words"] = new WordsPlugin(); _extMap["WordsInterpret"] = new WordsInterpretPlugin(); /* * var info = ""; * foreach(var pair in _extMap) * if(pair.Value is IExprPlugin) * { * var tokens = ((IExprPlugin)pair.Value).StartTokens; * info += pair.Value.GetType().Name + " - "; * foreach (var token in tokens) * { * //if (token.Contains("$")) * info += token + ", "; * } * info += Environment.NewLine; * } * else if (pair.Value is ILexPlugin) * { * var tokens = ((ILexPlugin)pair.Value).Tokens; * info += pair.Value.GetType().Name + " - "; * foreach (var token in tokens) * { * //if (token.Contains("$")) * info += token + ", "; * } * info += Environment.NewLine; * } * Console.WriteLine(info); */ }
/// <summary> /// Initialize /// </summary> public void Init() { // System plugins ( basic features - loops, if etc ) _sysMap["Break"] = new BreakPlugin(); _sysMap["Continue"] = new ContinuePlugin(); _sysMap["For"] = new ForPlugin(); _sysMap["Lambda"] = new LambdaPlugin(); _sysMap["FuncDeclare"] = new FunctionDeclarePlugin(); _sysMap["If"] = new IfPlugin(); _sysMap["New"] = new NewPlugin(); _sysMap["Return"] = new ReturnPlugin(); _sysMap["Throw"] = new ThrowPlugin(); _sysMap["TryCatch"] = new TryCatchPlugin(); _sysMap["TypeOf"] = new TypeOfPlugin(); _sysMap["While"] = new WhilePlugin(); _sysMap["Var"] = new VarPlugin(); _sysMap["Plugin"] = new PluginPlugin(); // Custom plugins - extended functionality. _extMap["AnyOf"] = new AnyOfPlugin(); _extMap["Aggregate"] = new AggregatePlugin(); _extMap["Alias"] = new AliasPlugin(); //_extMap["AndOr"] = new AndOrPlugin(); //_extMap["Bool"] = new BoolPlugin(); //_extMap["Compare"] = new ComparePlugin(); _extMap["ConstCaps"] = new ConstCapsPlugin(); //_extMap["Date"] = new DatePlugin(); _extMap["DateNumber"] = new DateNumberPlugin(); //_extMap["DateTimeCombiner"] = new DateTimeCombinerPlugin(); //_extMap["Day"] = new DayPlugin(); //_extMap["Def"] = new DefPlugin(); _extMap["Enable"] = new EnablePlugin(); _extMap["Email"] = new EmailPlugin(); _extMap["Fail"] = new FailPlugin(); _extMap["FileExt"] = new FileExtPlugin(); _extMap["FluentFunc"] = new FluentFuncPlugin(); _extMap["FluentMember"] = new FluentMemberPlugin(); _extMap["FuncWildCard"] = new FuncWildCardPlugin(); _extMap["HashComment"] = new HashCommentPlugin(); _extMap["Holiday"] = new HolidayPlugin(); _extMap["Linq"] = new LinqPlugin(); _extMap["Log"] = new LogPlugin(); _extMap["MachineInfo"] = new MachineInfoPlugin(); _extMap["Marker"] = new MarkerPlugin(); _extMap["MarkerLex"] = new MarkerLexPlugin(); //_extMap["Money"] = new MoneyPlugin(); _extMap["Module"] = new ModulePlugin(); _extMap["NamedIndex"] = new NamedIndexPlugin(); _extMap["Percent"] = new PercentPlugin(); _extMap["PhoneNumber"] = new PhoneNumberPlugin(); _extMap["Preprocessor"] = new PreprocessorPlugin(); _extMap["Plugin"] = new PluginPlugin(); _extMap["Print"] = new PrintPlugin(); _extMap["PrintExpression"] = new PrintExpressionPlugin(); _extMap["Records"] = new RecordsPlugin(); _extMap["Repeat"] = new RepeatPlugin(); _extMap["Round"] = new RoundPlugin(); _extMap["Run"] = new RunPlugin(); //_extMap["Set"] = new SetPlugin(); _extMap["Sort"] = new SortPlugin(); //_extMap["Step"] = new StepPlugin(); //_extMap["StringLiteral"] = new StringLiteralPlugin(); _extMap["Suffix"] = new SuffixPlugin(); _extMap["Swap"] = new SwapPlugin(); _extMap["Time"] = new TimePlugin(); _extMap["TypeOperations"] = new TypeOperationsPlugin(); _extMap["Units"] = new UnitsPlugin(); _extMap["Uri"] = new UriPlugin(); _extMap["VariablePath"] = new VariablePathPlugin(); _extMap["Version"] = new VersionPlugin(); _extMap["Words"] = new WordsPlugin(); _extMap["WordsInterpret"] = new WordsInterpretPlugin(); //SerializePluginMetadata(); }