Beispiel #1
0
        internal void SetOutputStrategy(FormatType formatType)
        {
            switch (formatType)
            {
            case FormatType.NameRevenueDecimalPhone:
                TextOutput.bufferFiller = new FormatNameRevenueDecimalPhone();
                break;

            case FormatType.Phone:
                TextOutput.bufferFiller = new FormatPhone();
                break;

            case FormatType.NameRevenueDecimal:
                TextOutput.bufferFiller = new FormatNameRevenueDecimal();
                break;

            case FormatType.Name:
                TextOutput.bufferFiller = new FormatName();
                break;

            case FormatType.RevenueRounded:
                TextOutput.bufferFiller = new FormatRevenueRounded();
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(formatType), formatType, null);
                break;
            }
        }
Beispiel #2
0
        public Report(IFormatStrategy formatter)
        {
            _formatter = formatter;

            Title = "Esto es un titulo";
            Body = new List<string>();
            Body.Add("Esto es un texto...");
            Body.Add("Esto es otro texto...");
        }
 public Document(DocumentFormat df)
 {
     sb             = new StringBuilder();
     formatStrategy = df switch
     {
         DocumentFormat.Json => new Json(),
         DocumentFormat.Xml => new Xml(),
         _ => new Md()
     };
     formatStrategy.Init(sb);
 }
        public static string Convert(Dictionary <string, string> dic, IFormatStrategy format)
        {
            StringBuilder t = new();

            format.Init(t);

            foreach (var item in dic)
            {
                format.AddElement(t, item.Key, item.Value);
            }

            format.Close(t);
            return(t.ToString());
        }
Beispiel #5
0
 public Report(IFormatStrategy strategy)
 {
     _strategy = strategy;
 }
 public IEnumerable <string> Format
     (IFormatStrategy formatStrategy)
 {
     return(formatStrategy.Execute(Contacts));
 }