Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ob"></param>
        public void DebugObjectsPropertiesUsingReflection(object ob)
        {
            FiddleFiddleLogger.FiddleLog(
                String.Format(
                    "Try to access {0}",
                    ob.GetType().Name
                    )
                );
            List <KeyValuePair <string, object> > Prefs = new List <KeyValuePair <string, object> >();

            foreach (var prop in ob.GetType().GetProperties())
            {
                try
                {
                    // Check for Type and Conversion to present data properly
                    // It is responsible for decoding ResponseBody, RequestBody
                    if (prop.PropertyType == typeof(Byte[]))
                    {
                        FiddleFiddleLogger.FiddleLog(
                            String.Format(
                                "Try to Convert Byte[] `{0}` Property into UTF8.String",
                                prop.Name
                                )
                            );

                        Prefs.Add(
                            new KeyValuePair <string, object>(
                                prop.Name,
                                FiddleFiddleHex.ConvertByteArrayToHexlifiedStringEx(
                                    (byte[])prop.GetValue(ob, null),
                                    15
                                    )
                                )
                            );
                    }
                    else
                    {
                        FiddleFiddleLogger.FiddleLog(String.Format("Try to Resolve `{0}` Property", prop.Name));
                        Prefs.Add(new KeyValuePair <string, object>(prop.Name, prop.GetValue(ob, null)));
                    }
                }
                catch (TargetParameterCountException e)
                {
                    FiddleFiddleLogger.FiddleLog(
                        String.Format("While Resolving `{0}` Property, \n Error Occurred : {1}",
                                      prop.Name,
                                      e.Message));
                }
                catch (Exception e)
                {
                    FiddleFiddleLogger.FiddleLog(
                        String.Format("[CAUTION][DANGER] Not Filtered Explicitly!! `{0}` Property, \n Error Occurred : {1}",
                                      prop.Name,
                                      e.Message));
                }
            }
            FiddleFiddleLogger.FiddleDebugLogWithPairs(Prefs.ToArray());
        }
Exemplo n.º 2
0
        /// <summary>
        /// Suddenly, The question comes up. it is about "What differences between Property and Field".
        /// It has some points.
        /// when is it inialized,
        /// or It must be initialized?
        /// </summary>
        /// <param name="ob"></param>
        public void DebugObjectsFieldsUsingReflection(object ob)
        {
            FiddleFiddleLogger.FiddleLog(
                String.Format(
                    "Try to access {0}",
                    ob.GetType().Name
                    )
                );
            List <KeyValuePair <string, object> > Prefs = new List <KeyValuePair <string, object> >();

            foreach (var field in ob.GetType().GetFields())
            {
                try
                {
                    if (field.FieldType == typeof(byte[]))
                    {
                        FiddleFiddleLogger.FiddleLog(
                            String.Format(
                                "Try to Convert Byte[] `{0}` Property into UTF8.String",
                                field.Name
                                )
                            );

                        Prefs.Add(
                            new KeyValuePair <string, object>(
                                field.Name,
                                FiddleFiddleHex.ConvertByteArrayToHexlifiedStringEx(
                                    (byte[])field.GetValue(ob),
                                    15
                                    )
                                )
                            );
                    }
                    else
                    {
                        FiddleFiddleLogger.FiddleLog(String.Format("Try to Resolve `{0}` Property", field.Name));
                        Prefs.Add(new KeyValuePair <string, object>(
                                      field.Name,
                                      field.GetValue(ob)
                                      )
                                  );
                    }
                }catch (Exception e)
                {
                    FiddleFiddleLogger.FiddleLog(
                        String.Format("While Resolving `{0}` Fields, \n `{2}` Error Occurred : {1}",
                                      field.Name,
                                      e.Message,
                                      e.GetType().FullName
                                      )
                        );
                }
            }
            FiddleFiddleLogger.FiddleDebugLogWithPairs(Prefs.ToArray());
        }