Exemple #1
0
        public override string ToString()
        {
            var builder = new StringBuilder();
            builder.AppendFormatLine("namespace {0}", this.NameSpace ?? "undefined");
            builder.AppendLine("{");
            foreach (string @using in this.usings)
            {
                builder.AppendFormatLine("{0}using {1};", SourceLib.Constants.SharpIndentation, @using);
            }

            if (this.usings.Count > 0)
            {
                // Add a space after the using section if we had any
                builder.AppendLine();
            }

            foreach (SharpClass @class in this.classes)
            {
                @class.ToString(builder, 1);
            }

            builder.AppendLine("}");

            return builder.ToString();
        }
Exemple #2
0
    /// <summary>
    /// Returns PDF string representation
    /// </summary>
    public string ToPdfString()
    {
      var styleBuilder = new StringBuilder();

      if (StrokeColor != null)
        styleBuilder.AppendFormatLine("{0} RG", StrokeColor.ToPdfString());

      if (FillColor != null)
        styleBuilder.AppendFormatLine("{0} rg", FillColor.ToPdfString());

      if (StrokeThickness != null)
        styleBuilder.AppendFormatLine("{0} w", TextAdapter.FormatFloat(StrokeThickness.Value));

      if (StrokeType != null)
      {
        switch (StrokeType)
        {
          case PdfLineType.OutlinedThin:
            styleBuilder.AppendLine("[2 2] 0 d");
            break;
          case PdfLineType.Outlined:
            styleBuilder.AppendLine("[4 4] 0 d");
            break;
          case PdfLineType.OutlinedBold:
            styleBuilder.AppendLine("[6 6] 0 d");
            break;
        }
      }

      return styleBuilder.ToString();
    }
 public string ToHumanReadableText()
 {
     var sb = new StringBuilder();
     sb.AppendFormatLine("Number of words: {0}", wordsCount.ToString("N0", CultureInfo.InvariantCulture));
     sb.AppendLine("Top 10 most used words in the text: ");
     foreach(WordsFrequency wf in top)
         sb.AppendFormatLine("\t{0} \t [used {1} times]", wf.Word, wf.Frequency.ToString("N0", CultureInfo.InvariantCulture));
     return sb.ToString();
 }
        public string CreateMessageBody(string customerName, AccountType accountType,
			string accountNumber, bool showAccountNumber, decimal newRate)
        {
            var sb = new StringBuilder();

            sb.AppendFormatLine("Dear {0}", customerName);
            sb.AppendLine();

            sb.Append("We are sending you this message with respect to your ");
            switch (accountType)
            {
                case AccountType.Cheque:
                    sb.Append("chequing account");
                    break;
                case AccountType.Savings:
                    sb.Append("on line savings account");
                    break;
                case AccountType.Credit:
                    sb.Append("credit card");
                    break;
            }

            if (showAccountNumber)
            {
                sb.AppendFormatLine(" with the account number {0}.", accountNumber);
            }
            else
            {
                sb.AppendLine(".");
            }

            sb.AppendLine();
            sb.AppendLine();

            switch (accountType)
            {
                case AccountType.Cheque:
                    sb.AppendFormatLine("The interest rate at which you earn interest has changed to {0}%.",
                        newRate);
                    break;
                case AccountType.Savings:
                    sb.AppendFormatLine("Your savings interest rate has changed to {0}%", newRate);
                    break;
                case AccountType.Credit:
                    sb.AppendFormatLine(
                        "The interest rate for which you will be charged for new purchases is now {0}%", newRate);
                    break;
            }

            sb.AppendLine();
            sb.AppendLine();

            sb.AppendLine("Kind regards - your bank.");

            return sb.ToString();
        }
Exemple #5
0
        public override void ToString(StringBuilder builder)
        {
            builder.AppendFormatLine("{0} ({0:D}) loot contains {1} and {2} items",
                this.Type, this.Gold, this.Items.Count);
            builder.AppendLine("Object: " + this.Guid);

            builder.AppendLine();
            builder.AppendLine("Items: " + this.Items.Count);

            foreach (Item item in this.Items)
            {
                builder.AppendFormat(CultureInfo.InvariantCulture, " [{0}] (Permission: {1}) {2} x {3} (DisplayId: {4})",
                    item.Index, item.Perm, item.Count, item.Entry, item.DisplayId);

                if (item.RandomPropertyId != 0 || item.RandomSuffix != 0)
                    builder.AppendFormatLine(" (Random: Suffix {0}, PropertyId {1})",
                        item.RandomSuffix, item.RandomPropertyId);
                else
                    builder.AppendLine();
            }

            builder.AppendLine();
            builder.AppendLine("Currencies: " + this.Currencies.Count);

            foreach (Currency currency in this.Currencies)
                builder.AppendFormat(CultureInfo.InvariantCulture, " [{0}] {1} x {2}",
                    currency.Index, currency.Count, currency.Entry);
        }
Exemple #6
0
        public override void ToString(StringBuilder builder)
        {
            builder.AppendLine("Aggressor: " + this.Unit);

            for (int i = 0; i < ThreatList.Length;++i)
                builder.AppendFormatLine("Threat: {0}   Unit: {1}", ThreatList[i].Threat, ThreatList[i].Unit);
        }
        /// <summary>
        /// Generates a detailed error message
        /// </summary>
        /// <param name="activeScriptException">Active script exception</param>
        /// <returns>Detailed error message</returns>
        public static string Format(ActiveScriptException activeScriptException)
        {
            var errorMessage = new StringBuilder();
            errorMessage.AppendFormatLine("{0}: {1}", Strings.ErrorDetails_Message,
                activeScriptException.Message);
            errorMessage.AppendFormatLine("{0}: {1}", Strings.ErrorDetails_ErrorCode,
                activeScriptException.ErrorCode);
            if (activeScriptException.ErrorWCode != 0)
            {
                errorMessage.AppendFormatLine("{0}: {1}", Strings.ErrorDetails_ErrorWCode,
                    activeScriptException.ErrorWCode);
            }
            errorMessage.AppendFormatLine("{0}: {1}", Strings.ErrorDetails_Subcategory,
                activeScriptException.Subcategory);
            if (!string.IsNullOrWhiteSpace(activeScriptException.HelpLink))
            {
                errorMessage.AppendFormatLine("{0}: {1}", Strings.ErrorDetails_HelpKeyword,
                    activeScriptException.HelpLink);
            }
            errorMessage.AppendFormatLine("{0}: {1}", Strings.ErrorDetails_LineNumber,
                activeScriptException.LineNumber.ToString());
            if (!string.IsNullOrWhiteSpace(activeScriptException.SourceError))
            {
                errorMessage.AppendFormatLine("{0}: {1}", Strings.ErrorDetails_LineSource,
                    activeScriptException.SourceError);
            }

            return errorMessage.ToString();
        }
        public override void ToString(StringBuilder builder)
        {
            builder.AppendFormatLine("Items: {0} (displayed: {1})", TotalItemCount, Items.Length);
            builder.AppendLine();

            foreach (var item in Items)
            {
                builder.AppendFormatLine("Auction Id: {0}  Item Entry: {1}", item.AuctionId, item.ItemEntry);

                for (uint i = 0; i < item.Enchantments.Length; ++i)
                {
                    var ench = item.Enchantments[i];
                    if (ench.Id != 0)
                        builder.AppendFormatLine("  Enchantment {0}: {1}", i, ench);
                }

                builder.AppendFormatLine("Property: {0}  RandomSuffix: {1}  Unknown: {2}",
                    item.PropertyId, item.SuffixFactor, item.Unknown);
                builder.AppendFormatLine("Stack Count: {0}  Charges: {1}", item.Count, item.SpellCharges);
                builder.AppendLine("Owner: " + item.Owner);
                builder.AppendFormatLine("Start Bid: {0}  Minimum Bid: {1}  BuyOut: {2}",
                    item.StartBid, item.MinimumBid, item.BuyOut);
                builder.AppendLine("Time Left: " + item.TimeLeftMs);
                builder.AppendFormatLine("Current Bid: {0}  Bidder: {1}", item.CurrentBid, item.CurrentBidder);

                builder.AppendLine();
            }

            builder.AppendLine("Delay: " + NextSearchDelayMs);
        }
Exemple #9
0
 public override void ToString(StringBuilder builder)
 {
     builder.AppendFormatLine("Container Slot: {0}, Slot: {1}", ContainerSlot, Slot);
     builder.AppendLine("Cast Id: " + CastId);
     builder.AppendLine("Spell Id: " + SpellId);
     builder.AppendLine("Item: "  + ItemGuid);
     builder.AppendLine("Glyph Index: " + GlyphSlot);
     builder.AppendLine("Unk Flags: " + UnkFlags);
     builder.AppendLine();
     TargetData.ToString(builder);
 }
            public void ToString(StringBuilder builder)
            {
                builder.AppendFormatLine("Count: {0}    Type: {1} ({1:D})", this.Count, this.Type);
                if (this.HasWeekCap)
                    builder.AppendLine("Week Cap: " + this.WeekCap);
                if (this.HasTotalCap)
                    builder.AppendLine("Total Cap: " + this.TotalCap);
                if (this.HasThisWeek)
                    builder.AppendLine("This Week: " + this.ThisWeek);

                builder.AppendLine("Unk Byte: " + this.UnkByte);
            }
        public override void Write(System.Text.StringBuilder sb)
        {
            ++IndentCount;
            Indent(sb); sb.AppendFormat("export interface {0}", TypeDefinition.ToTypeScriptItemName());

            if (TypeDefinition.HasGenericParameters)
            {
                sb.Append("<");
                TypeDefinition.GenericParameters.For((genericParam, i, isLastItem) =>
                {
                    sb.AppendFormat("{0}{1}", genericParam.ToTypeScriptType(), (isLastItem ? "" : ", "));
                });
                sb.Append(">");
            }

            sb.AppendLine(" {");
            IndentCount++;

            // 'ctor' is at index 0
            // 'invoke' is at index 1
            var invokeMethod = TypeDefinition.Methods[1];

            if (invokeMethod.Parameters.Any())
            {
                var target = invokeMethod.Parameters[0];
                Indent(sb); sb.AppendFormatLine("target: {0};", target.ParameterType.ToTypeScriptType());
            }
            else
            {
                Indent(sb); sb.AppendFormatLine("target: any;");
            }
            Indent(sb); sb.AppendFormatLine("detail: any[];");

            Indent(sb); sb.AppendLine("type: string;");
            IndentCount--;
            Indent(sb); sb.AppendLine("}");
        }
		/// <summary>
		/// Displays trace information
		/// </summary>
		/// <param name="context">Object BundleContext</param>
		/// <param name="response">Object BundleResponse</param>
		public void Process(BundleContext context, BundleResponse response)
		{
			var content = new StringBuilder();

			content.AppendLine("*************************************************************************************");
			content.AppendLine("* BUNDLE RESPONSE                                                                   *");
			content.AppendLine("*************************************************************************************");

			IEnumerable<BundleFile> responseFiles = response.Files;
			foreach (var responseFile in responseFiles)
			{
				content.AppendLine("  " + responseFile.IncludedVirtualPath);
			}

			content.AppendLine();

			content.AppendLine("*************************************************************************************");
			content.AppendLine("* BUNDLE COLLECTION                                                                 *");
			content.AppendLine("*************************************************************************************");
			BundleCollection bundles = context.BundleCollection;
			foreach (var bundle in bundles)
			{
				content.AppendFormatLine("-= {0} =-", bundle.Path);

				IEnumerable<BundleFile> bundleFiles = bundle.EnumerateFiles(context);
				foreach (var bundleFile in bundleFiles)
				{
					content.AppendLine("  " + bundleFile.IncludedVirtualPath);
				}

				content.AppendLine();
			}

			response.ContentType = "text/plain";
			response.Content = content.ToString();
		}
        protected override void FormatData(ExcelDataSheet sheet, StringBuilder target)
        {
            target.AppendFormatLine("    {0}: {{", sheet.Name);

            bool hasIdColumn = sheet.Columns.Any(x => x.Equals(IdFieldKey));

            for (var i = 0; i < sheet.Data.Count; i++)
            {
                string id = sheet.Data[i][0];

                if (sheet.Columns.Count == 1)
                {
                    target.AppendFormat(
                        "{0}\"{1}\": {{{2}: {1}}}",
                        DataDelimiter,
                        sheet.Data[i][0],
                        sheet.Columns[0]);
                }
                else
                {
                    // Write the key for the data
                    target.AppendFormatLine("{0}\"{1}\": {{", DataDelimiter, id.Trim('"'));

                    // Auto-add the ID field if we don't have it and assign it the default value
                    //  Note: This is mostly for easier access in Javascript projects
                    if (!hasIdColumn)
                    {
                        target.AppendFormatLine("{0}    {1}: {2},", DataDelimiter, IdFieldKey, id);
                    }

                    for (var n = 0; n < sheet.Columns.Count; n++)
                    {
                        // Ignore null values
                        if (string.IsNullOrEmpty(sheet.Data[i][n]))
                        {
                            continue;
                        }

                        target.AppendFormat("{0}    {1}: {2}", DataDelimiter, sheet.Columns[n], sheet.Data[i][n]);
                        if (n < sheet.Columns.Count - 1)
                        {
                            target.AppendLine(",");
                        }
                        else
                        {
                            target.AppendLine();
                        }
                    }

                    target.AppendFormat("{0}}}", DataDelimiter);
                }

                if (i < sheet.Data.Count - 1)
                {
                    target.AppendLine(",");
                }
                else
                {
                    target.AppendLine();
                }
            }

            target.Append(@"    }");
        }
        protected override void FormatData(ExcelDataSheet sheet, StringBuilder target)
        {
            bool isSingleEntry = sheet.Data.Count == 1;

            target.AppendFormatLine("    {0}: {1}", sheet.Name, isSingleEntry ? "{" : "[");

            for (var i = 0; i < sheet.Data.Count; i++)
            {
                if (sheet.Columns.Count == 1)
                {
                    target.AppendFormat(
                        "{0}\"{1}\": {{{2}: {1}}}",
                        DataDelimiter,
                        sheet.Data[i][0],
                        sheet.Columns[0]);
                }
                else
                {
                    // Write the key for the data
                    if (!isSingleEntry)
                    {
                        target.AppendFormatLine("{0}{{", DataDelimiter);
                    }

                    for (var n = 0; n < sheet.Columns.Count; n++)
                    {
                        // Ignore null values
                        if (string.IsNullOrEmpty(sheet.Data[i][n]))
                        {
                            continue;
                        }

                        target.AppendFormat("{0}    {1}: {2}", DataDelimiter, sheet.Columns[n], sheet.Data[i][n]);
                        if (n < sheet.Columns.Count - 1)
                        {
                            target.AppendLine(",");
                        }
                        else
                        {
                            target.AppendLine();
                        }
                    }

                    if (!isSingleEntry)
                    {
                        target.AppendFormat("{0}}}", DataDelimiter);

                        if (i < sheet.Data.Count - 1)
                        {
                            target.AppendLine(",");
                        }
                        else
                        {
                            target.AppendLine();
                        }
                    }
                }
            }

            target.AppendFormat("    {0}", isSingleEntry ? "}" : "]");
        }
		/// <summary>
		/// Generates a detailed error message based on object ContextError
		/// </summary>
		/// <param name="error">Object ContextError</param>
		/// <returns>Detailed error message</returns>
		internal static string FormatContextError(ContextError error)
		{
			var errorMessage = new StringBuilder();
			errorMessage.AppendFormatLine("{0}: {1}", CoreStrings.ErrorDetails_Message, error.Message);
			errorMessage.AppendFormatLine("{0}: {1}", CoreStrings.ErrorDetails_ErrorCode, error.ErrorCode);
			errorMessage.AppendFormatLine("{0}: {1}", CoreStrings.ErrorDetails_Severity, error.Severity);
			errorMessage.AppendFormatLine("{0}: {1}", CoreStrings.ErrorDetails_Subcategory, error.Subcategory);
			if (!string.IsNullOrWhiteSpace(error.HelpKeyword))
			{
				errorMessage.AppendFormatLine("{0}: {1}", CoreStrings.ErrorDetails_HelpKeyword, error.HelpKeyword);
			}
			if (!string.IsNullOrWhiteSpace(error.File))
			{
				errorMessage.AppendFormatLine("{0}: {1}", CoreStrings.ErrorDetails_File, error.File);
			}
			errorMessage.AppendFormatLine("{0}: {1}", CoreStrings.ErrorDetails_StartLine, error.StartLine);
			errorMessage.AppendFormatLine("{0}: {1}", CoreStrings.ErrorDetails_StartColumn, error.StartColumn);
			errorMessage.AppendFormatLine("{0}: {1}", CoreStrings.ErrorDetails_EndLine, error.EndLine);
			errorMessage.AppendFormat("{0}: {1}", CoreStrings.ErrorDetails_EndColumn, error.EndColumn);

			return errorMessage.ToString();
		}