internal void PrintValues(IMethodCallMessage msg) { try { SeleniumLog log = SeleniumLog.Instance(); log.Blue().WriteLine("Expand to view input parameters"); log.SaveIndent("__SELENIUMLOG_PRINT_INPUTS__"); log.Indent(); int argumentIndex = 0; foreach (var arg in msg.Args) { // Display Values for custom attribute CURRENT_ARGUMENT_NAME = msg.GetInArgName(argumentIndex); DispalyInformation(CURRENT_ARGUMENT_NAME, arg); argumentIndex++; } log.RestoreIndent("__SELENIUMLOG_PRINT_INPUTS__"); } catch (Exception e) { SeleniumLog log = SeleniumLog.Instance(); log.Warning().WriteLine("SeleniumLog Exception: 01-18 - " + e.Message); } }
public void PostMethodExecutionProcess(IMethodCallMessage callMsg, ref IMethodReturnMessage retMsg) { SeleniumLog log = SeleniumLog.Instance(); try { if (_enabled) { _stopwatch.Stop(); log.Blue().WriteLine(string.Format("Return value: {0}", retMsg.ReturnValue)); log.Blue().WriteLine(string.Format("Duration: {0} msec", _stopwatch.ElapsedMilliseconds)); //log.RestoreIndent("__SELENIUMLOG_INDENT__"); log.RestoreIndent("__PRE_METHOD_EXECUTION_PROCESS_1_"); } } catch (Exception e) { log.Warning().WriteLine("SeleniumLog Exception: 01-02 - " + e.Message); } }
public void Process(IMethodCallMessage callMsg, ref IMethodReturnMessage retMsg) { if (_enabled) { SeleniumLog log = SeleniumLog.Instance(); try { //_stopwatch.Stop(); log.Blue().WriteLine(string.Format("Return value: {0}", retMsg.ReturnValue)); log.RestoreIndent("__SELENIUMLOG_INDENT__"); } catch (Exception e) { log.Warning().WriteLine("SeleniumLog Exception: 01-05 - " + e.Message); } } }
private void DispalyInformation(string argumentName, object arg) { try { SeleniumLog log = SeleniumLog.Instance(); // Display data structure if (arg == null) { if (log.Config.FunctionTrace_DisplayNullInputs == true) { log.Pink().WriteLine(argumentName + " [NULL]"); } } else { if (ParameterProcessor.CheckIfEnumerable(arg)) { //log.Red().WriteLine("Property: " + argumentName); log.Blue().WriteLine(argumentName + " :"); log.SaveIndent("__DISPLAY_ARRAY__"); log.Indent(); int i = 0; foreach (var iterateValue in (IEnumerable)arg) { ManageCustomDataStructure(argumentName, iterateValue, 1, i); i++; } log.RestoreIndent("__DISPLAY_ARRAY__"); } else { // Display property (simple structure) ManageCustomDataStructure(argumentName, arg, 0); } } } catch (Exception e) { SeleniumLog log = SeleniumLog.Instance(); if (log.Config.Enable_Generic_Function_Trace == true) { log.Warning().WriteLine("SeleniumLog Exception: 01-19 - " + e.Message); } } }
public void Process(ref IMethodCallMessage msg) { SeleniumLog log = SeleniumLog.Instance(); try { log.Blue().WriteLine("FUNCTION CALL: " + msg.MethodBase); log.SaveIndent("__SELENIUMLOG_INDENT__"); log.Indent(); PrintParameters printParameters = new PrintParameters(); printParameters.PrintValues(msg); } catch (Exception e) { log.Warning().WriteLine("SeleniumLog Exception: 01-04 - " + e.Message); } }
public void PreMethodExecutionProcess(ref IMethodCallMessage msg) { SeleniumLog log = SeleniumLog.Instance(); try { if (_enabled) { _stopwatch.Start(); log.Blue().WriteLine("FUNCTION CALL: " + msg.MethodBase); log.SaveIndent("__PRE_METHOD_EXECUTION_PROCESS_1_"); log.Indent(); log.SaveIndent("__PRE_METHOD_EXECUTION_PROCESS_2_"); PrintParameters printParameters = new PrintParameters(); printParameters.PrintValues(msg); log.RestoreIndent("__PRE_METHOD_EXECUTION_PROCESS_2_"); } } catch (Exception e) { log.Warning().WriteLine("SeleniumLog Exception: 01-01 - " + e.Message); } }
/// <summary> /// /// </summary> /// <param name="argumentName"></param> /// <param name="arg"></param> /// <param name="type">0 for Input parameter. 1 for data structure property.</param> /// <param name="elem_counter">The nth element if type is a data structure array.</param> /// <returns></returns> private bool ManageCustomDataStructure(string argumentName, object arg, int type, int elem_counter = -1) { try { SeleniumLog log = SeleniumLog.Instance(); if (arg == null) { if (log.Config.FunctionTrace_DisplayNullInputs == true) { log.Pink().WriteLine(string.Format("{0} {1} : [NULL]", argumentName, elem_counter)); } } else { if (ParameterProcessor.CheckIfCustomType(arg.GetType())) { var properties = ParameterProcessor.GetPublicProperties(arg); //log.Blue().WriteLine(">>> Input data structure:" + argumentName + ":"); if (elem_counter > -1) { log.Blue().WriteLine(string.Format("{0} {1} :", argumentName, elem_counter)); } else { log.Blue().WriteLine(string.Format("{0} :", argumentName)); } log.SaveIndent("__MANAGE_CUSTOM_DATA_STRUCTURE__"); log.Indent(); if (properties.Any()) { foreach (PropertyInfo property in properties) { DispalyInformation(property.Name, property.GetValue(arg, null)); } } var fields = ParameterProcessor.GetPublicFields(arg); if (fields.Any()) { foreach (FieldInfo field in fields) { DispalyInformation(field.Name, field.GetValue(arg)); } } log.RestoreIndent("__MANAGE_CUSTOM_DATA_STRUCTURE__"); return(true); } if (type == 0) { log.Blue().WriteLine(string.Format("{0} [{1}]", argumentName, arg)); } else { log.Blue().WriteLine(string.Format("[{0}]", arg)); } //log.Blue().WriteLine(string.Format("+++ Input {0} [{1}]", argumentName, arg)); //log.RestoreIndent("__SELENIUMLOG_PRINT_INPUTS__"); //log.RestoreIndent("__MANAGE_CUSTOM_DATA_STRUCTURE__"); return(false); } return(false); } catch (Exception e) { SeleniumLog log = SeleniumLog.Instance(); log.Warning().WriteLine("SeleniumLog Exception: 01-20 - " + e.Message); return(false); } }
public void DispalyInformation(string argumentName, object arg, int elem_counter = -1, int type = -1, string comment = "") { SeleniumLog log = SeleniumLog.Instance(); log.SaveIndent("DispalyInformation"); //log.Purple().WriteLine("DisplayInformation()"); //log.Indent(); if (arg == null) { //Console.WriteLine("TP-0.1.S"); if (log.Config.FunctionTrace_DisplayNullInputs == true) { log.Gray().WriteLine(argumentName + " [NULL]"); } //Console.WriteLine("TP-0.1.E"); } else { int j = 0; // Display Dictionary and Sorted List values if (CheckParameterType.CheckIfDictionary(arg) || CheckParameterType.CheckIfSortedList(arg)) { //Console.WriteLine("TP-1.S"); var data = arg as IDictionary; if (data == null) { return; } if (debug) { log.Blue().WriteLine("45 " + argumentName + ": "); } else { log.Purple().WriteLine(argumentName + ": "); } log.SaveIndent("______DisplayDictionaryValues_____"); log.Indent(); int count = data.Count; object[] keysArray = new object[count]; object[] valuesArray = new object[count]; data.Keys.CopyTo(keysArray, 0); data.Values.CopyTo(valuesArray, 0); for (int i = 0; i < count; i++) { ManageCustomDataStructure("" + keysArray[i], valuesArray[i], i, type: 1, comment: comment); } log.RestoreIndent("______DisplayDictionaryValues_____"); } // Display HashTable values else if (CheckParameterType.CheckIfHashTable(arg)) { var hashtable = arg as Hashtable; if (hashtable == null) { return; } int count = hashtable.Count; object[] keysArray = new object[count]; object[] valuesArray = new object[count]; hashtable.Keys.CopyTo(keysArray, 0); hashtable.Values.CopyTo(valuesArray, 0); //Console.WriteLine(argumentName + ":"); if (elem_counter > -1) { if (debug) { log.Purple().WriteLine("60" + argumentName + " " + elem_counter + " : "); } else { log.Purple().WriteLine(argumentName + " " + elem_counter + " : "); } } else if (debug) { log.Purple().WriteLine("60" + argumentName + " " + "COUNT?? : "); } else { log.Purple().WriteLine(argumentName + " " + elem_counter + " : "); } log.SaveIndent("______DisplayHashTableValues_____"); log.Indent(); for (int i = 0; i < count; i++) { ManageCustomDataStructure("" + keysArray[i], valuesArray[i], elem_counter: i, type: 2, comment: comment); } log.RestoreIndent("______DisplayHashTableValues_____"); } // Display Enumerable values else if (CheckParameterType.CheckIfEnumerable(arg)) { if (debug) { log.Red().WriteLine("50 type " + type + " " + argumentName + ": "); } else { log.Purple().WriteLine(argumentName + ": "); } log.SaveIndent("______DisplayEenumerableValues_____"); log.Indent(); foreach (var iterateValue in (IEnumerable)arg) { log.SaveIndent("______DisplayEenumerableValues2_____"); ManageCustomDataStructure(argumentName, iterateValue, j, type: 3, comment: comment); j++; log.RestoreIndent("______DisplayEenumerableValues2_____"); } log.RestoreIndent("______DisplayEenumerableValues_____"); } else { ManageCustomDataStructure(argumentName, arg, type: 4, comment: comment); } } log.RestoreIndent("DispalyInformation"); }