Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/22/10 00:44:01 (14 years ago)
Author:
swagner
Message:

Sorted usings and removed unused usings in entire solution (#1094)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.Netron/3.0.2672.12446/Netron.Diagramming.Core-3.0.2672.12446/Utils/Formatting.cs

    r2768 r4068  
    11
    22using System;
    3 using System.Reflection;
    4 using System.Reflection.Emit;
    5 using System.Diagnostics;
     3using System.Collections.Generic;
    64using System.Text;
    7 using System.Collections;
    8 using System.Collections.Generic;
    9 namespace Netron.Diagramming.Core
    10 {
     5namespace Netron.Diagramming.Core {
    116  /// <summary>
    127  /// <i>(Describe usage of "L:300" format string.)</i>
    138  /// </summary>
    14   public interface IShowable : IFormattable
    15   {
     9  public interface IShowable : IFormattable {
    1610    //TODO: wonder if we should use TextWriters instead of StringBuilders?
    1711    /// <summary>
     
    3327  ///
    3428  /// </summary>
    35   public static class Showing
    36   {
     29  public static class Showing {
    3730    /// <summary>
    3831    /// Show  <code>Object obj</code> by appending it to <code>stringbuilder</code>
     
    4336    /// <param name="formatProvider"></param>
    4437    /// <returns>True if <code>obj</code> was shown completely.</returns>
    45     public static bool Show(Object obj, StringBuilder stringbuilder, ref int rest, IFormatProvider formatProvider)
    46     {
     38    public static bool Show(Object obj, StringBuilder stringbuilder, ref int rest, IFormatProvider formatProvider) {
    4739      if (rest <= 0)
    4840        return false;
     
    6254    /// <param name="formatProvider"></param>
    6355    /// <returns></returns>
    64     public static String ShowString(IShowable showable, String format, IFormatProvider formatProvider)
    65     {
     56    public static String ShowString(IShowable showable, String format, IFormatProvider formatProvider) {
    6657      int rest = maxLength(format);
    6758      StringBuilder sb = new StringBuilder();
     
    7566    /// <param name="format"></param>
    7667    /// <returns></returns>
    77     static int maxLength(String format)
    78     {
     68    static int maxLength(String format) {
    7969      //TODO: validate format string
    8070      if (format == null)
    8171        return 80;
    82       if (format.Length > 1 && format.StartsWith("L"))
    83       {
     72      if (format.Length > 1 && format.StartsWith("L")) {
    8473        return int.Parse(format.Substring(1));
    85       }
    86       else
     74      } else
    8775        return int.MaxValue;
    8876    }
     
    9785    /// <param name="formatProvider"></param>
    9886    /// <returns>True if collection was shown completely</returns>
    99     public static bool ShowCollectionValue<T>(ICollectionBase<T> items, StringBuilder stringbuilder, ref int rest, IFormatProvider formatProvider)
    100     {
     87    public static bool ShowCollectionValue<T>(ICollectionBase<T> items, StringBuilder stringbuilder, ref int rest, IFormatProvider formatProvider) {
    10188      string startdelim = "{ ", enddelim = " }";
    10289      bool showIndexes = false;
    103      
     90
    10491      //TODO: do not test here at run time, but select code at compile time
    10592      //      perhaps by delivering the print type to this metod
    106       if (items is IList<T>)
    107       {
     93      if (items is IList<T>) {
    10894        startdelim = "[ ";
    10995        enddelim = " ]";
    110        
    111       }
    112       else if (items is ICollection<T>)
    113       {
    114        
    115           startdelim = "{{ ";
    116           enddelim = " }}";
    117        
     96
     97      } else if (items is ICollection<T>) {
     98
     99        startdelim = "{{ ";
     100        enddelim = " }}";
     101
    118102      }
    119103
     
    124108      int index = 0;
    125109
    126      
     110
    127111      {
    128         foreach (T x in items)
    129         {
     112        foreach (T x in items) {
    130113          complete = false;
    131114          if (rest <= 0)
     
    133116          if (first)
    134117            first = false;
    135           else
    136           {
     118          else {
    137119            stringbuilder.Append(", ");
    138120            rest -= 2;
    139121          }
    140           if (showIndexes)
    141           {
     122          if (showIndexes) {
    142123            string indexString = string.Format("{0}:", index++);
    143124            stringbuilder.Append(indexString);
     
    147128        }
    148129      }
    149       if (!complete)
    150       {
     130      if (!complete) {
    151131        stringbuilder.Append("...");
    152132        rest -= 3;
     
    167147    /// <param name="rest"></param>
    168148    /// <returns></returns>
    169     public static bool ShowDictionary<K, V>(IDictionary<K, V> dictionary, StringBuilder stringbuilder, ref int rest, IFormatProvider formatProvider)
    170     {
     149    public static bool ShowDictionary<K, V>(IDictionary<K, V> dictionary, StringBuilder stringbuilder, ref int rest, IFormatProvider formatProvider) {
    171150      stringbuilder.Append("{ ");
    172151      rest -= 4;           // Account for "( " and " )"
     
    174153      bool complete = true;
    175154
    176       foreach (KeyValuePair<K, V> p in dictionary)
    177       {
     155      foreach (KeyValuePair<K, V> p in dictionary) {
    178156        complete = false;
    179157        if (rest <= 0)
     
    181159        if (first)
    182160          first = false;
    183         else
    184         {
     161        else {
    185162          stringbuilder.Append(", ");
    186163          rest -= 2;
     
    188165        complete = Showing.Show(p, stringbuilder, ref rest, formatProvider);
    189166      }
    190       if (!complete)
    191       {
     167      if (!complete) {
    192168        stringbuilder.Append("...");
    193169        rest -= 3;
    194170      }
    195       stringbuilder.Append( " }");
     171      stringbuilder.Append(" }");
    196172      return complete;
    197173    }
Note: See TracChangeset for help on using the changeset viewer.