예제 #1
0
        /// <summary>
        /// Return a display string
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            int length = _value.Length;

            if (length > 64)
            {
                length = 64;
            }

            return(GeneralUtils.EscapeString(BinaryEncoding.Instance.GetString(_value, 0, length)));
        }
예제 #2
0
        public virtual string ToString(LogPacket p, int index)
        {
            object value = GetValue(p);

            byte[] ba = value as byte[];

            if (ba != null)
            {
                int length = ba.Length;
                if (length > 64)
                {
                    length = 64;
                }

                if (!String.IsNullOrWhiteSpace(CustomFormat))
                {
                    try
                    {
                        StringBuilder builder = new StringBuilder();

                        for (int i = 0; i < length; ++i)
                        {
                            builder.AppendFormat(CustomFormat, ba[i]);
                        }

                        return(builder.ToString());
                    }
                    catch (FormatException)
                    {
                        // Error in format
                    }
                }

                return(GeneralUtils.EscapeString(BinaryEncoding.Instance.GetString(ba, 0, length)));
            }
            else
            {
                if (!String.IsNullOrWhiteSpace(CustomFormat))
                {
                    try
                    {
                        return(String.Format(CustomFormat, value));
                    }
                    catch (FormatException)
                    {
                        // Error in format
                    }
                }

                return(value.ToString());
            }
        }
예제 #3
0
 protected override void HandleString(string str, Context ctx)
 {
     ctx.Writer.Write("\"" + GeneralUtils.EscapeString(str, '"', '"') + "\"");
 }
예제 #4
0
 /// <summary>
 /// Method to return displayable string
 /// </summary>
 /// <returns></returns>
 protected override string ToDisplayString()
 {
     return(String.Format("{0} '{1}'", base.ToDisplayString(), GeneralUtils.EscapeString(new BinaryEncoding().GetString(Match))));
 }