// add middlewares to pipeline public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IStringFormatter stringFormatter, ShopContext shopContext) { loggerFactory.AddConsole(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseBrowserLink(); } else { app.UseExceptionHandler("/Home/Error"); } //app.UseMiddleware<LoggerComponent>("Admin", DateTime.UtcNow); // default middleware adding. app.UseLoggerComponent("Admin", DateTime.UtcNow); // adding with using extesion class app.UseStaticFiles(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); DbInitializer.Initialize(shopContext); // terminus //app.Run(async (context) => //{ // await context.Response.WriteAsync(stringFormatter.FormatIt(new { Message = "Hello World" })); //}); }
public WordSelector( IWordProvider wordProvider, IStringFormatter stringFormatter) { WordProvider = wordProvider; _stringFormatter = stringFormatter; }
public StringFormatHelper(string text, IStringFormatter formatter = null) { if (text == null) throw new ArgumentNullException("text"); _formatter = formatter ?? new NamedFieldFormatter(); _textToFormat = text; }
public FunnyMessageViewComponent(IStringFormatter stringFormatter) { if (stringFormatter == null) { throw new ArgumentNullException("String formatter!"); } _stringFormatter = stringFormatter; }
/// <param name="formatter"><see cref="IStringFormatter"/> instance.</param> /// <inheritdoc cref="IStringFormatter.Format(string, IDataRecord, IFormatProvider)"/> public static string Format(this IStringFormatter formatter, string format, IDataRecord record) { _ = formatter ?? throw new ArgumentNullException(nameof(formatter)); _ = format ?? throw new ArgumentNullException(nameof(format)); _ = record ?? throw new ArgumentNullException(nameof(record)); return(formatter.Format(format, record, CultureInfo.InvariantCulture)); }
public Atm(IPrinter printer, IAtmClock clock, ICardReader cardReader, IHistory history, IStringFormatter stringFormatter) { this.stringFormatter = stringFormatter; this.printer = printer; this.history = history; this.clock = clock; this.cardReader = cardReader; }
public void SetUp() { //nothing to be mocked with as there is no external service such as data source or web api calling //Arrange formatter = new StringFormatter(); checker = new PalindromeChecker(); finder = new PalindromeFinder(formatter, checker); }
public StringFormatHelper(string text, IStringFormatter formatter = null) { if (text == null) { throw new ArgumentNullException("text"); } _formatter = formatter ?? new NamedFieldFormatter(); _textToFormat = text; }
public bool WriteAsCsvFile <TType>(List <TType> list, IStringFormatter <TType> formatter, string filePath) where TType : class, new() { var result = FileWriter.Write(filePath, formatter.GetFormattedStringFor(list)); if (result) { Console.WriteLine("- [Written Successfully] : \"" + filePath + "\"."); } return(result); }
internal Generator( ISentenceTemplateProvider sentenceProvider, IWordSelectorFactory wordSelectorFactory, IStringFormatter stringFormatter) { _sentenceTemplateProvider = sentenceProvider; _wordSelectorFactory = wordSelectorFactory; _stringFormatter = stringFormatter; _tagExtractor = new TagExtractor( tagFactory: new TagFactory()); }
/// <summary> /// 格式化参数 /// </summary> /// <param name="parameter">参数</param> /// <param name="formater">格式化工具</param> /// <param name="encoding">编码</param> /// <returns></returns> protected string FormatParameter(ApiParameterDescriptor parameter, IStringFormatter formater, Encoding encoding) { if (parameter.Value == null) { return(null); } if (parameter.ParameterType == typeof(string)) { return(parameter.Value.ToString()); } return(formater.Serialize(parameter.Value, encoding)); }
public MessageModelFactory( IBasicMessageModelFactory basicMessageModelFactory, INoteMessageModelFactory noteMessageModelFactory, ISpecialMessageModelFactory specialMessageModelFactory, IVisualMessageModelFactory visualMessageModelFactory, IStringFormatter stringFormatter) { _basicMessageModelFactory = basicMessageModelFactory; _noteMessageModelFactory = noteMessageModelFactory; _specialMessageModelFactory = specialMessageModelFactory; _visualMessageModelFactory = visualMessageModelFactory; _stringFormatter = stringFormatter; }
/// <summary> /// Registers type formatters. /// </summary> /// <param name="formatter">The formatter to register.</param> /// <exception cref="InvalidOperationException"> /// This method was called after having called <see cref="Interpret" /> /// successfully for the first time. /// </exception> public void RegisterTypeFormatter(IStringFormatter formatter) { _ = Requires.NotNull( formatter, nameof(formatter)); if (interpretationDone != 0) { throw new InvalidOperationException( Resources .TheExpressionParsingServiceHasAlreadyDoneInterpretationAndCannotHaveAnyMoreFormattersRegistered); } stringFormatters.Add(formatter); }
public void Integration_Display_ConditionChecker_AirSpaceFilter() { stringFormatter = Substitute.For <IStringFormatter>(); filter = new AirspaceFilter(stringFormatter); conditionChecker = new ConditionChecker(5000, 300, filter); display = new DisplaySeparator(filter, conditionChecker); stringFormatter.DataFormattedEvent += Raise.EventWith(new DataFormattedEventArgs() { DataFormatted = tracks }); //Assert.That(display.ListOfConditionsToDisplay, Is.EqualTo()); Assert.That(display.ListOfTracksToDisplay, Is.EqualTo(tracks)); }
static ImmutableBase() { ordinalIgnoreCase = StringComparer.OrdinalIgnoreCase; var propertiesByName = PropertyHelpers.GetPropertyMap <TImmutable>(); var constructor = ConstructorHelpers .GetImmutableSetterConstructor <TImmutable>(propertiesByName); createImmutable = constructor.CreateArrayFunc <TImmutable>(); var properties = constructor .GetParameters() .Select(parameter => propertiesByName[parameter.Name]) .ToImmutableArray(); var provider = AggregatePropertyHandlerProvider.Create( new StringPropertyHandlerProvider(), new SinglePropertyHandlerProvider(), new DoublePropertyHandlerProvider(), new NullablePropertyHandlerProvider <Single>(new SinglePropertyHandlerProvider()), new NullablePropertyHandlerProvider <Double>(new DoublePropertyHandlerProvider()), new EnumerablePropertyHandlerProvider(), new DefaultPropertyHandlerProvider() ); var handlersBuilder = ImmutableArray.CreateBuilder <IPropertyHandler>(); var handlersByNameBuilder = ImmutableDictionary.CreateBuilder <String, IPropertyHandler>(ordinalIgnoreCase); foreach (var property in properties) { var handler = provider.Create(property); handlersBuilder.Add(handler); handlersByNameBuilder.Add(handler.PropertyName, handler); } handlers = handlersBuilder.ToImmutable(); handlersByName = handlersByNameBuilder.ToImmutable(); stringFormatter = new DefaultStringFormatter(); }
public void SetUp() { _receivedEventArgs = null; _track1 = new Track(); _track2 = new Track(); _track3 = new Track(); _track4 = new Track(); _tracklist = new List <Track>(); //Making fakes (Stubs and mocks) _fakeFormatter = Substitute.For <IStringFormatter>(); _uut = new AirspaceFilter(_fakeFormatter); //Fake Event Handler _uut.DataFilteredEvent += (o, args) => { _receivedEventArgs = args; }; }
public void Integration_Display_ConditionChecker_AirSpaceFilter_StringFormatter() { transponderR = Substitute.For <ITransponderReceiver>(); compassCourseCalculator = Substitute.For <ICompassCourseCalculator>(); velocityCalculator = Substitute.For <IVelocityCalculator>(); stringFormatter = new StringFormatter(transponderR, compassCourseCalculator, velocityCalculator); filter = new AirspaceFilter(stringFormatter); conditionChecker = new ConditionChecker(5000, 300, filter); display = new DisplaySeparator(filter, conditionChecker); List <string> transponderData = new List <string>(); transponderData.Add("T1;39045;29000;14000;20191029154852789"); transponderData.Add("T2;39030;29030;14020;20191029154852789"); transponderData.Add("T3;20045;29000;14000;20191029154852789"); transponderData.Add("T4;39045;29000;12000;20191029154852789"); transponderR.TransponderDataReady += Raise.EventWith(this, new RawTransponderDataEventArgs(transponderData)); Assert.That(display.ListOfTracksToDisplay.ElementAt(0).Tag, Is.EqualTo("T1")); Assert.That(display.ListOfTracksToDisplay.ElementAt(3).PositionX, Is.EqualTo(39045)); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IStringFormatter stringFormatter) { loggerFactory.AddConsole(); //app.UseEndOfTheWorldComponent(); app.UseLoggerComponent("Elvis Presley", DateTime.UtcNow); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else if (env.IsProduction()) { //app.UseExceptionHandler("/Error.html"); app.UseExceptionHandler(new ExceptionHandlerOptions() { //ExceptionHandlingPath = new PathString("/Error.html"), ExceptionHandler = context => context.Response.WriteAsync("An exception has occurred. Please contact [email protected] for assistance.") }); } else if (env.IsEnvironment("DonaldDuck")) { Debug.WriteLine("QuackQuack"); } app.UseFileServer(); /* * app.UseFileServer(new FileServerOptions() * { * FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), @"Images")), * RequestPath = new PathString("/Img") * });*/ /* * DefaultFilesOptions options = new DefaultFilesOptions(); * options.DefaultFileNames.Clear(); * options.DefaultFileNames.Add("myhome.html"); * app.UseDefaultFiles(options); * app.UseStaticFiles(); * app.UseStaticFiles(new StaticFileOptions() * { * FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), @"Images")), * RequestPath = new PathString("/Img") * });*/ app.UseWelcomePage("/hello"); app.UseIdentity(); app.UseMvc(routeBuilder => { //routeBuilder.MapRoute("Default", "{controller=Home}/{action=Index}/{id?}"); //routeBuilder.MapRoute("Default", "{controller}/{action}/{id?}", new { controller = "Home", action = "Index"}); routeBuilder.MapRoute("Default", "{controller}/{action}/{id?}", defaults: new { controller = "Home", action = "Index", token = "blah" } , constraints: new { id = new IntRouteConstraint() }); routeBuilder.MapRoute("Route", "Route/{*whatever}", defaults: new { controller = "Route", action = "activity" }); //routeBuilder.MapRoute("NewRoute", "Route/{*whatever}", defaults: new { controller = "Route", action = "activity" }); //routeBuilder.MapRoute("Route", "routing/{controller}/{action}"); }); /* * app.Run(async (context) => * { * //throw new ArgumentException("NONO!"); * await context.Response.WriteAsync(stringFormatter.FormatMe(new { Message = "Hello World!" })); * });*/ }
protected virtual string OnRender(ICsvDefinition defintion, TResult value, CultureInfo formattingCulture, IStringFormatter formatter) { if (value == null) { return(string.Empty); } return(value.ToString()); }
/// <summary> /// Renders the specified element contents. /// </summary> /// <param name="element">The element.</param> /// <returns></returns> public virtual string[] Render(ICsvDefinition definition, TSource element, CultureInfo formattingCulture, IStringFormatter formatter) { var value = this.Selector(element); return(new[] { this.OnRender(definition, value, formattingCulture.Parent, formatter) }); }
public TemporaryFileRepository(IStringFormatter stringFormatter) { _stringFormatter = stringFormatter; Paths = new List <string>(); }
public AssetBank(IStringFormatter stringFormatter) { _stringFormatter = stringFormatter; }
/// <summary> /// Executed each time the cell/value is written to a file. /// </summary> /// <param name="defintion"> The CSV definition. </param> /// <param name="value"> The value to render. </param> /// <param name="culture"> the culture to render in. </param> /// <param name="formatter"> The formatter to use for rendering the value into the cell. </param> /// <returns>A string that can be directly written into the CSV file. </returns> public override string[] Render(ICsvDefinition defintion, TSource value, CultureInfo culture, IStringFormatter formatter) { var collection = this.Selector(value); return((from item in collection let column = converter(item) select column.Render(defintion, item, culture, formatter)) .SelectMany(elements => elements) .ToArray()); }
/// <summary> /// Formats a string based on a format string passed in. /// The default formatter uses the following format: /// # = digits /// @ = alpha characters /// \ = escape char /// </summary> /// <param name="Input">Input string</param> /// <param name="Format">Format of the output string</param> /// <param name="Provider">String formatter provider (defaults to GenericStringFormatter)</param> /// <returns>The formatted string</returns> public static string FormatString(this string Input, string Format, IStringFormatter Provider = null) { return(Provider.NullCheck(new GenericStringFormatter()).Format(Input, Format)); }
/// <summary> /// Formats a string based on a format string passed in. /// The default formatter uses the following format: /// # = digits /// @ = alpha characters /// \ = escape char /// </summary> /// <param name="input">Input string</param> /// <param name="format">Format of the output string</param> /// <param name="provider">String formatter provider (defaults to GenericStringFormatter)</param> /// <returns>The formatted string</returns> public static string FormatString(this string input, string format, IStringFormatter provider = null) { return(provider.NullCheck(new GenericStringFormatter()).Format(input, format)); }
/// <summary>Executed each time the cell/value is written to a file.</summary> /// <param name="defintion">The CSV definition.</param> /// <param name="value">The value to render.</param> /// <param name="culture">the culture to render in.</param> /// <param name="formatter">The formatter to use for rendering the value into the cell.</param> /// <returns>A string that can be directly written into the CSV file.</returns> protected override string OnRender(ICsvDefinition defintion, int?value, CultureInfo culture, IStringFormatter formatter) { return(this.Format(value, culture)); }
/// <summary> /// Formats a string based on a format string passed in. /// The default formatter uses the following format: /// # = digits /// @ = alpha characters /// \ = escape char /// </summary> /// <param name="input">Input string</param> /// <param name="format">Format of the output string</param> /// <param name="provider">String formatter provider (defaults to GenericStringFormatter)</param> /// <returns>The formatted string</returns> public static string FormatString(this string input, string format, IStringFormatter provider = null) { return provider.NullCheck(new GenericStringFormatter()).Format(input, format); }
public Formatter(IStringFormatter formatter) { _formatter = formatter; }
public AirspaceFilter(IStringFormatter stringFormatter) //Could add all boundaries as parameters, if you wish to be able to change the airspace area { CurrentListOfTracks = new List <Track>(); stringFormatter.DataFormattedEvent += HandleDataFormattedEvent; }
/// <summary> /// Formats a string based on a format string passed in. /// The default formatter uses the following format: /// # = digits /// @ = alpha characters /// \ = escape char /// </summary> /// <param name="Input">Input string</param> /// <param name="Format">Format of the output string</param> /// <param name="Provider">String formatter provider (defaults to GenericStringFormatter)</param> /// <returns>The formatted string</returns> public static string FormatString(this string Input, string Format, IStringFormatter Provider = null) { return Provider.NullCheck(new GenericStringFormatter()).Format(Input, Format); }
public SqlQueryPreparator() { SF = new StringFormatter.StringFormatter(); }
public StringManipulator(IStringFormatter stringFormatter) { this.stringFormatter = stringFormatter; }
public SqlQueryPreparator(IStringFormatter sf) { SF = sf; }