コード例 #1
0
        public static void Filter(this StringBuilder builder, string field, string value, bool and = true)
        {
            if (builder.Length > 0)
                builder.AppendFormat(" {0} ", and ? "and" : "or");

            builder.AppendFormat("{0} eq '{1}'", field, value);
        }
コード例 #2
0
ファイル: TraceUtils.cs プロジェクト: hanswolff/FryProxy
        public static void WriteHttpTrace(this StringBuilder stringBuilder, HttpMessageHeader messageHeader)
        {
            if (messageHeader == null)
            {
                return;
            }

            stringBuilder
                .AppendFormat("StartLine: {0}", messageHeader.StartLine)
                .AppendLine();

            var headers = messageHeader.Headers.Lines.ToList();

            if (headers.Count == 0)
            {
                return;
            }

            stringBuilder.AppendLine("Headers:");

            foreach (var header in headers)
            {
                stringBuilder
                    .AppendFormat("    {0}", header)
                    .AppendLine();
            }
        }
コード例 #3
0
        public static void Filter(this StringBuilder builder, string field, DateTime value, string op, bool and = true)
        {
            if (builder.Length > 0) builder.AppendFormat(" {0} ", and ? "and" : "or");

            builder.AppendFormat("(");
            builder.AppendFormat("{0} {1} {2}", field, op, AzureSearchHelper.ConvertToOffset(value).ToString("u").Replace(" ", "T"));
            builder.AppendFormat(")");
        }
コード例 #4
0
        private static void AppendTriggerable(this StringBuilder builder, Triggerable triggerable)
        {
            builder.AppendLine("   [TRIGGERABLE]");

            builder.AppendFormat("      <STRING>Name:{0}\r\n", triggerable.Name);
            builder.AppendFormat("      <STRING>File:{0}\r\n", triggerable.File);

            builder.AppendLine("   [/TRIGGERABLE]");
        }
コード例 #5
0
        private static void AppendSkill(this StringBuilder builder, Skill skill)
        {
            builder.AppendLine("   [SKILL]");

            builder.AppendFormat("      <INTEGER64>GUID:{0}\r\n", skill.GUID);
            builder.AppendFormat("      <STRING>Name:{0}\r\n", skill.Name);
            builder.AppendFormat("      <STRING>File:{0}\r\n", skill.File);

            builder.AppendLine("   [/SKILL]");
        }
コード例 #6
0
        private static void AppendAffix(this StringBuilder builder, Affix affix)
        {
            builder.AppendLine("   [AFFIX]");

            builder.AppendFormat("      <STRING>Name:{0}\r\n", affix.Name);
            builder.AppendFormat("      <STRING>File:{0}\r\n", affix.File);
            builder.AppendFormat("      <INTEGER>MinSpawnRange:{0}\r\n", affix.MinSpawnRange);
            builder.AppendFormat("      <INTEGER>MaxSpawnRange:{0}\r\n", affix.MaxSpawnRange);
            builder.AppendFormat("      <INTEGER>Weight:{0}\r\n", affix.Weight);
            builder.AppendFormat("      <INTEGER>DifficultiesAllowed:{0}\r\n", affix.DifficultiesAllowed);

            if (affix.UnitTypes.Count > 0)
            {
                builder.AppendLine("      [UNITTYPES]");
                foreach (var unitType in affix.UnitTypes)
                {
                    builder.AppendFormat("         <STRING>{0}\r\n", unitType);
                }
                builder.AppendLine("      [/UNITTYPES]");
            }

            if (affix.NotUnitTypes.Count > 0)
            {
                builder.AppendLine("      [NOTUNITTYPES]");
                foreach (var unitType in affix.NotUnitTypes)
                {
                    builder.AppendFormat("         <STRING>{0}\r\n", unitType);
                }
                builder.AppendLine("      [/NOTUNITTYPES]");
            }
            builder.AppendLine("   [/AFFIX]");
        }
コード例 #7
0
        public static void AppendLine(this StringBuilder self, String format, params Object[] args)
        {
            Check.Argument(self, "self");

            self.AppendFormat(format, args);
            self.AppendLine();
        }
コード例 #8
0
		public static void AppendFormatIfNotNull(this StringBuilder sb, object parameter, string value, params object[] args)
		{
			if (parameter != null)
			{
				sb.AppendFormat(value, args);
			}
		}
コード例 #9
0
		public static void AppendFormatIfNotNullOrEmpty(this StringBuilder sb, string parameter, string value)
		{
			if (!string.IsNullOrEmpty(parameter))
			{
				sb.AppendFormat(value, parameter);
			}
		}
コード例 #10
0
		public static void AppendFormatIfFalse(this StringBuilder sb, bool parameter, string value, params object[] args)
		{
			if (!parameter)
			{
				sb.AppendFormat(value, args);
			}
		}
コード例 #11
0
        public static void AppendFormatIfNotZero(this TextBoxBase textbox, string format, float arg)
        {
            Contract.Requires(format != null);

            if (arg != 0.0f)
                textbox.AppendFormat(format, arg);
        }
コード例 #12
0
 private static void AppendProperty(this StringBuilder sb, string addition)
 {
     if (sb.Length > 0)
         sb.AppendFormat(",{0}", addition);
     else
         sb.Append(addition);
 }
コード例 #13
0
 public static StringBuilder AppendNonNullOrEmpty(this StringBuilder sb, string format, object arg0, int padLeftWidth = 0)
 {
     if (arg0 == null) return sb;
     if (arg0.GetType().FullName == "System.String" && string.IsNullOrWhiteSpace(arg0.ToString()))
         return sb;
     return sb.AppendFormat(format, arg0).PadLeft(padLeftWidth);
 }
コード例 #14
0
 public static void AppendFormatLineIfNotNull(this RichTextBox builder, string format, uint arg, object s)
 {
     if (arg != 0)
     {
          builder.AppendFormat(format+Environment.NewLine, arg,s);
     }
 }
コード例 #15
0
    public static StringBuilder AppendLineFormat(this StringBuilder builder, string format, params object[] args)
    {
        builder.AppendFormat(format, args);
        builder.AppendLine();

        return builder;
    }
コード例 #16
0
 public static void AppendFormatIfNotNull(this RichTextBox builder, string format, object arg)
 {
     if (arg.ToInt32() != 0)
     {
         builder.AppendFormat(format, arg);
     }
 }
コード例 #17
0
 public static void AppendFormatIfNotNull(this RichTextBox builder, string format, string arg)
 {
     if (arg != String.Empty)
     {
         builder.AppendFormat(format, arg);
     }
 }
コード例 #18
0
ファイル: Messages.cs プロジェクト: CatSkald/Roguelike
 public static void AppendMessage(
     this StringBuilder sb, MessageType type, params string[] args)
 {
     switch (type)
     {
         case MessageType.None:
             break;
         case MessageType.StartGame:
             sb.AppendLine(Messages.StartGame);
             break;
         case MessageType.EndGame:
             sb.AppendLine(Messages.EndGame);
             sb.AppendLine();
             foreach (var message in GetGameInfo())
             {
                 sb.AppendLine(message);
             }
             sb.AppendLine();
             break;
         case MessageType.CannotMoveThere:
             sb.AppendLine(Messages.CannotMove);
             if (args != null)
             {
                 sb.AppendFormat(ObstacleDescriptionPattern, args[0]);
                 sb.AppendLine();
             }
             break;
         default:
             throw new ArgumentOutOfRangeException(
                 $"Don't know how to write message: {type}.");
     }
 }
コード例 #19
0
 public static void AppendFormatIfNotNull(this RichTextBox builder, string format, float arg)
 {
     if (arg != 0.0f)
     {
         builder.AppendFormat(format, arg);
     }
 }
コード例 #20
0
ファイル: RichTextBoxExtensions.cs プロジェクト: lan143/Yuki
 public static void AppendFormatIfNotNull(this RichTextBox builder, string format, uint arg)
 {
     if (arg != 0)
     {
         builder.AppendFormat(format, new object[] { arg });
     }
 }
コード例 #21
0
        private static void AppendUnit(this StringBuilder builder, Unit unit)
        {
            builder.AppendLine("      [UNIT]");

            builder.AppendFormat("         <INTEGER64>GUID:{0}\r\n", unit.GUID);
            builder.AppendFormat("         <STRING>Name:{0}\r\n", unit.Name);
            builder.AppendFormat("         <STRING>File:{0}\r\n", unit.File);
            builder.AppendFormat("         <STRING>UnitType:{0}\r\n", unit.Type);
            builder.AppendFormat("         <BINARY>Unknown:{0:X2}\r\n", unit.Unknown);
            builder.AppendFormat("         <INTEGER>Level:{0}\r\n", unit.Level);
            builder.AppendFormat("         <INTEGER>MinLevel:{0}\r\n", unit.MinLevel);
            builder.AppendFormat("         <INTEGER>MaxLevel:{0}\r\n", unit.MaxLevel);
            builder.AppendFormat("         <INTEGER>Rarity:{0}\r\n", unit.Rarity);
            builder.AppendFormat("         <INTEGER>RarityHC:{0}\r\n", unit.RarityHC);

            builder.AppendLine("      [/UNIT]");
        }
コード例 #22
0
		/// <summary>
		/// Append format a string builder by named parameters.
		/// </summary>
		/// <param name="formatString">Format string.</param>
		/// <param name="parameters">Format string and parameters object or the parameters object as unique member of the array.</param>
		/// <returns>The updated string builder.</returns>
		public static StringBuilder AppendFormatNamed(this StringBuilder stringBuilder, string formatString, params object[] parameters)
		{
			List<KeyValuePair<string, object>> newList;
			StringBuilder newFormat;
			InternalFormat(formatString, parameters, out newList, out newFormat);

			return stringBuilder.AppendFormat(newFormat.ToString(), newList.Select(kv => kv.Value).ToArray());
		}
コード例 #23
0
 public static StringBuilder AppendFormatWhen(this StringBuilder builder, bool condition, string format, params object[] args)
 {
     if (condition)
     {
         builder.AppendFormat(format, args);
     }
     return builder;
 }
コード例 #24
0
 /// <summary>
 /// Appends the string returned by processing a composite format string, which contains zero or more format items, to this instance. 
 /// Each format item is replaced by the string representation of a corresponding object argument.        
 /// </summary>
 /// <param name="stringBuilder">The target <see cref="StringBuilder"/> instance.</param>
 /// <param name="indentLevel">The indent level to use</param>
 /// <param name="format">A composite format string.</param>
 /// <param name="arguments">An array of objects to format.</param>
 public static void AppendFormat(this StringBuilder stringBuilder, int indentLevel, string format, params object[] arguments)
 {
     for (int i = 0; i < indentLevel; i++)
     {
         stringBuilder.Append("\t");
     }
     stringBuilder.AppendFormat(format, arguments);
 }
コード例 #25
0
		/// <summary>
		/// Appends the string returned by processing a composite format string, which
		/// contains zero or more format items, with default line terminator to this instance.
		/// Each format item is replaced by the string representation of a corresponding
		/// argument in a parameter array.
		/// </summary>
		/// <param name="sb">Object StringBuilder</param>
		/// <param name="format">A composite format string</param>
		/// <param name="args">An array of objects to format</param>
		/// <returns>Object StringBuilder</returns>
		public static StringBuilder AppendFormatLine(this StringBuilder sb, string format, params object[] args)
		{
			if (_formatPlaceholderRegExp.IsMatch(format))
			{
				return sb.AppendFormat(format, args).AppendLine();
			}

			return sb.AppendLine(format.Replace("{{", "{").Replace("}}", "}"));
		}
コード例 #26
0
        public static void InsertFormat(this StringBuilder sb, int index, string format, params object[] args) {
            var length = sb.Length;

            if (length > index) {
                var keep = new Stack<char>();
                for (var i = length - 1; i >= index; i--) {
                    keep.Push(sb[i]);
                }
                sb.Remove(index, length - index);
                sb.AppendFormat(format, args);
                if (!keep.Any()) return;
                while (keep.Count > 0) {
                    sb.Append(keep.Pop());
                }
            } else {
                sb.AppendFormat(format, args);
            }
        }
コード例 #27
0
        public static StringBuilder AppendFormatIf(this StringBuilder sb, bool condition, string format, params object[] args)
        {
            if (condition)
            {
                return sb.AppendFormat(format, args);
            }

            return sb;
        }
        /// <summary>
        /// Appends the key-value in the form of key="value" with a trailing trailer
        /// and a space, if value is not null or String.Empty
        /// </summary>
        internal static StringBuilder AppendIfNotEmpty(this StringBuilder builder, string key, string value, char trailer)
        {
            if (!String.IsNullOrEmpty(value))
            {
                builder.AppendFormat("{0}=\"{1}\"", key, value).Append(trailer).Append(" ");
            }

            return builder;
        }
コード例 #29
0
ファイル: StringBuilderExm.cs プロジェクト: kidaa/Pulse
        public static StringBuilder AppendFormatLine(this StringBuilder self, string format, params object[] args)
        {
            Exceptions.CheckArgumentNull(self, "self");

            self.AppendFormat(format, args);
            self.AppendLine();

            return self;
        }
コード例 #30
0
 public static StringBuilder AppendCommaSeparated(this StringBuilder sb, string format, params object[] arguments)
 {
     if (sb.Length > 0)
     {
         sb.Append(",");
     }
     sb.AppendFormat(format, arguments);
     return sb;
 }