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