Exemplo n.º 1
0
        private bool ManageCustomDataStructure(string argumentName, object arg)
        {
            if (ParameterProcessor.CheckIfCustomType(arg.GetType()))
            {
                var properties = ParameterProcessor.GetPublicProperties(arg);

                //Console.WriteLine(argumentName + ":");

                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));
                    }
                }

                return(true);
            }

            //Console.WriteLine(string.Format("{0}:{1}", argumentName, arg));
            return(false);
        }
Exemplo n.º 2
0
 private void DispalyInformation(string argumentName, object arg)
 {
     // Display Enumerable values
     if (ParameterProcessor.CheckIfEnumerable(arg))
     {
         foreach (var iterateValue in (IEnumerable)arg)
         {
             ManageCustomDataStructure(argumentName, iterateValue);
         }
     }
     else
     {
         ManageCustomDataStructure(argumentName, arg);
     }
 }
 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);
         }
     }
 }
        /// <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);
            }
        }