Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/nuget/Microsoft.NET.Test.Sdk-17.8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
earloc committed May 29, 2024
2 parents 23c69d8 + fa10857 commit e6e8245
Show file tree
Hide file tree
Showing 36 changed files with 1,349 additions and 1,115 deletions.
207 changes: 105 additions & 102 deletions src/Playground.Console/Program.cs
Original file line number Diff line number Diff line change
@@ -1,103 +1,106 @@
#pragma warning disable CA1812 // Type 'Program' can be sealed because it has no subtypes in its containing assembly and is not externally visible
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Localization;
using My.Super.Special.Namespace;
using Playground.Console.NoCodeGen;
using Playground.Console.WithCodeGen;
using Playground.Common;
using Playground.Common.Groups;
using Playground.Common.Groups.TypealizR;
using Playground.Common.NoCodeGen;


var services = new ServiceCollection();
services.AddLogging();
services.AddLocalization();

services.AddScoped(x => x.GetRequiredService<IStringLocalizer<Ressources>>().Typealize());
var provider = services.BuildServiceProvider();
using var scope = provider.CreateScope();
var typealized = scope.ServiceProvider.GetRequiredService<TypealizedRessources>();

Console.WriteLine(typealized.Messages.Info.Info1);
Console.WriteLine(typealized.Messages.Info.Info2);
Console.WriteLine(typealized.Messages.Info.Info3);
Console.WriteLine(typealized.Questions.What_to_do);
Console.WriteLine(typealized.Questions.What_to_do__now(DateTime.Now));


services.AddSingleton<Greeter, Greeter>();

var customNamespace = provider.GetRequiredService<IStringLocalizer<CustomNameSpace>>();
Console.WriteLine(customNamespace.Hello());


var greeter = provider.GetRequiredService<Greeter>();

greeter.SayHello("Arthur");
greeter.SayHelloPublic("Arthur");

var internalLocalizable = provider.GetRequiredService<IStringLocalizer<InternalClass>>();
Console.WriteLine(internalLocalizable.Hello__name("Arthur"));


var publicLocalizable = provider.GetRequiredService<IStringLocalizer<PublicClass>>();
Console.WriteLine(publicLocalizable.Hello__name("Arthur"));


var localize = internalLocalizable;

var userName = "Arthur";
var today = DateOnly.FromDateTime(DateTimeOffset.Now.UtcDateTime);

localize.Hello__user__it_is__today(userName, today);


var groups = provider.GetRequiredService<IStringLocalizer<Ressources>>();
Console.WriteLine(
groups.SomeDeeplyNestedThingCalledAfterAMonster_With_the__name("Chewbacca")
);

var typealizedGroups = groups.Typealize();

Console.WriteLine(
typealizedGroups.Some.Deeply.Nested.Thing.Called.After.A.Monster.With_the__name("Chewbacca")
);

var without_Params_In_MethodNames = provider.GetRequiredService<IStringLocalizer<Without_Params_In_MethodNames>>();

Console.WriteLine(
without_Params_In_MethodNames.Hello("Earth")
);

Console.WriteLine(
without_Params_In_MethodNames.Goodbye("Arthur")
);

#pragma warning restore CA1812 // Type 'Program' can be sealed because it has no subtypes in its containing assembly and is not externally visible









var g = typealizedGroups;

static void SomeMethod(IStringLocalizer<Ressources> L)
{
//use L
}

SomeMethod(g.Localizer);


Console.WriteLine(
g.Some.Deeply.Nested.Thing.Called.After.A.Monster.It
);

Console.WriteLine(
g.Some.Deeply.Nested.Thing.Called.After.A.Monster.With_the__name("Chewbacca")
#pragma warning disable CA1812 // Type 'Program' can be sealed because it has no subtypes in its containing assembly and is not externally visible
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Localization;
using My.Super.Special.Namespace;
using Playground.Console.NoCodeGen;
using Playground.Console.WithCodeGen;
using Playground.Common;
using Playground.Common.Groups;
using Playground.Common.Groups.TypealizR;
using Playground.Common.NoCodeGen;
using System.Runtime.InteropServices;

const string arthur = "Arthur";
const string chewbacca = "Chewbacca";

var services = new ServiceCollection();
services.AddLogging();
services.AddLocalization();

services.AddScoped(x => x.GetRequiredService<IStringLocalizer<Ressources>>().Typealize());
var provider = services.BuildServiceProvider();
using var scope = provider.CreateScope();
var typealized = scope.ServiceProvider.GetRequiredService<TypealizedRessources>();

Console.WriteLine(typealized.Messages.Info.Info1);
Console.WriteLine(typealized.Messages.Info.Info2);
Console.WriteLine(typealized.Messages.Info.Info3);
Console.WriteLine(typealized.Questions.What_to_do);
Console.WriteLine(typealized.Questions.What_to_do__now(DateTime.Now));


services.AddSingleton<Greeter, Greeter>();

var customNamespace = provider.GetRequiredService<IStringLocalizer<CustomNameSpace>>();
Console.WriteLine(customNamespace.Hello());


var greeter = provider.GetRequiredService<Greeter>();

greeter.SayHello(arthur);
greeter.SayHelloPublic(arthur);

var internalLocalizable = provider.GetRequiredService<IStringLocalizer<InternalClass>>();
Console.WriteLine(internalLocalizable.Hello__name(arthur));


var publicLocalizable = provider.GetRequiredService<IStringLocalizer<PublicClass>>();
Console.WriteLine(publicLocalizable.Hello__name(arthur));


var localize = internalLocalizable;

var userName = arthur;
var today = DateOnly.FromDateTime(DateTimeOffset.Now.UtcDateTime);

localize.Hello__user__it_is__today(userName, today);


var groups = provider.GetRequiredService<IStringLocalizer<Ressources>>();
Console.WriteLine(
groups.SomeDeeplyNestedThingCalledAfterAMonster_With_the__name(chewbacca)
);

var typealizedGroups = groups.Typealize();

Console.WriteLine(
typealizedGroups.Some.Deeply.Nested.Thing.Called.After.A.Monster.With_the__name(chewbacca)
);

var without_Params_In_MethodNames = provider.GetRequiredService<IStringLocalizer<Without_Params_In_MethodNames>>();

Console.WriteLine(
without_Params_In_MethodNames.Hello("Earth")
);

Console.WriteLine(
without_Params_In_MethodNames.Goodbye(arthur)
);

#pragma warning restore CA1812 // Type 'Program' can be sealed because it has no subtypes in its containing assembly and is not externally visible









var g = typealizedGroups;

static void SomeMethod(IStringLocalizer<Ressources> L)
{
//use L
}

SomeMethod(g.Localizer);


Console.WriteLine(
g.Some.Deeply.Nested.Thing.Called.After.A.Monster.It
);

Console.WriteLine(
g.Some.Deeply.Nested.Thing.Called.After.A.Monster.With_the__name("Chewbacca")
);
Loading

0 comments on commit e6e8245

Please sign in to comment.