Tutorial Inject Id

0 views
Skip to first unread message

Christina Smith

unread,
Aug 5, 2024, 11:25:56 AM8/5/24
to myoflycriecus
Thistutorial shows how to use dependency injection (DI) in .NET. With Microsoft Extensions, DI is managed by adding services and configuring them in an IServiceCollection. The IHost interface exposes the IServiceProvider instance, which acts as a container of all the registered services.

Using either the dotnet new command or an IDE new project wizard, create a new .NET console application named ConsoleDI.Example. Add the Microsoft.Extensions.Hosting NuGet package to the project.


In this example, the Microsoft.Extensions.Hosting NuGet package is required to build and run the app. Some metapackages might contain the Microsoft.Extensions.Hosting package, in which case an explicit package reference isn't required.


In this sample app, you'll learn how dependency injection handles service lifetime. You'll create several interfaces that represent different service lifetimes. Add the following interfaces to the project root directory:


All of the subinterfaces of IReportServiceLifetime explicitly implement the IReportServiceLifetime.Lifetime with a default. For example, IExampleTransientService explicitly implements IReportServiceLifetime.Lifetime with the ServiceLifetime.Transient value.


The example implementations all initialize their Id property with the result of Guid.NewGuid(). Add the following default implementation classes for the various services to the project root directory:


Each implementation is defined as internal sealed and implements its corresponding interface. They're not required to be internal or sealed, however, it's common to treat implementations as internal to avoid leaking implementation types to external consumers. Furthermore, since each type will not be extended, it's marked as sealed. For example, ExampleSingletonService implements IExampleSingletonService.


The ServiceLifetimeReporter defines a constructor that requires each of the aforementioned service interfaces, that is, IExampleTransientService, IExampleScopedService, and IExampleSingletonService. The object exposes a single method that allows the consumer to report on the service with a given lifetimeDetails parameter. When invoked, the ReportServiceLifetimeDetails method logs each service's unique identifier with the service lifetime message. The log messages help to visualize the service lifetime.


Each services.AddLIFETIME extension method adds (and potentially configures) services. We recommend that apps follow this convention. Don't place extension methods in the Microsoft.Extensions.DependencyInjection namespace unless you're authoring an official Microsoft package. Extension methods that are defined within the Microsoft.Extensions.DependencyInjection namespace:


In this sample app, you created several interfaces and corresponding implementations. Each of these services is uniquely identified and paired with a ServiceLifetime. The sample app demonstrates registering service implementations against an interface, and how to register pure classes without backing interfaces. The sample app then demonstrates how dependencies defined as constructor parameters are resolved at run time.


Its even easier than this now. Just open a 2k14 bg##.pac that you want to replace with Xpacker, then inject the new arena pach that you want. Xpacker will tell you the new size and all you have to do it edit the size in your arc using a Hex editor.


Rooster my pal, yes i do have Xpacker and I am going to try it later tonight ... and your arenas are incredible man, i wonder how awesome you must have transformed your copy of game with everything you do .. some of you guys should be working for 2k with all this immense talent. Excellent


Alright so I copied plist360.arc and bg39pac on my desktop .. than i first opened the Hex Workshop, than plist360.arc, found 0039 and changed the value to 00 00 A8 A8 as instructed by rooster, than I opened Xpacker / wwe2k14 / stringspac.0000 file and opened bg39.pac and injected bg33.pac (rooster's royal rumble arena) but i got a pop up that the size should be same? So I chose the option to compress and inject but it did not inject it and i got another file bg33.pac.zlib?


Edit: Just Now - So I opened plist360.arc in Hex, found 0039 and changed the value to 00 9F A0 00, moved the files to the game, started a match and selected WM12 arena .. the match started in TLC arena .. I did another match and it started in WM1 arena .. another match and it started it No Way Out arena ... LOL .. i am not sure where i screwed up but now everytime i select wm12 arena, it gives a random arena .. i guess i will do it to in-game Royal Rumble arena pac file so i can see RR in various arenas .. though really wanted to play in your RR arena but tough luck i guess


This looks great. Unfortunately, on my current machine, sketchup doesn't like to play nice with the model unless I reduce the polygon count in transmutr to the point where I lose the shape of everything. Especially as the edges of the tiles get distorted rather than smoothed in to a single plane.


Herbo, this workflow looks promising, but I guess I'm doing something wrong. When I press "Inject" in RenderDoc, and "OK" on Chrome PID box, then "Inject Into Process" tab disappear, and Chrome creates new PID box and number. It happens perpetually. Chrome never gets in debugger mode. Tried with RenderDoc v1.16 and v1.10 with same result..


I, also, cannot get it to work at the same point as Hirvio. The injection breaks as soon as the chrome PID box is OK'd. I tried in the current version of renderdoc and old version 1.10 which arqcova recommended in this thread. The new version of renderdoc does allow injecting but you need to checkbox it in settings otherwise its hidden. Chrome is updated as well. I suspect that the new/current version of chrome is the culprit but cannot validate. I also dont see any stats above chrome although it does offer the pid number in the opening dialogue box.


I guess it could have something with windows built, perhaps. On another PC, it just works as described, with newest RenderDoc, Chrome and Blender (Python version has to match between RenderDoc and Blender).


My problem (I believe) was I had normal chrome windows open separately so even though this opened a new instance and pid- it wouldnt work with those prior open chrome windows. I closed them and then ran the chrome shortcut alone and all was good.


I skipped the transmtr portion and simply exported the blender file via collada (.dae) which sketchup imports natively for this test. It worked as expected although the model was heavy and should lilkly be cleaned up via


External Contentyoutu.beContent embedded from external sources will not be displayed without your consent.Display all external contentThrough the activation of external content, you agree that personal data may be transferred to third party platforms. We have provided more information on this in our privacy policy.


I don't know blender yet so I purposelessly avoided that part for the time being. The export/import produced slight imperfections at overlapping geometry of the textures being wrong but it is minor but worth noting. My full process would involve cleaning it up as meantioned in the thread and the link I provided...


I have tried this technique and wonder if anyone else gets double tiles of geometry? It can be cleaned in SketchUp later, but when using Lily texture packer in Blender, the packed texture contains two sets of every tile and is twice as big as needed. I am not familiar with Blender, but manually deleting the duplicate tiles one by one isn't an effective way to work.



I also wonder whether is is legally OK to use the geometry from Google Earth? We have been trying to understand Googles terms, but am still not sure what we are allowed to use or not. Has anyone else had a lawyer tell them what is OK to use and how?


I'm guessing here but the vast majority of the data probably isn't even Google's, they will have licensed it from aerial surveying businesses from around the world and the surveying business license would prevent Google from providing it for download.


I may be crazy, but I thought you could extract 3D building content from Google Earth Pro years ago when it was a stand alone desktop app. Did they shut that feature down when everything moved to the cloud?


I think Paul is correct above - The reason we can extract Topo so easily is that it is GIS info and in the public domain, but the more detailed side-scan / low altitude photogrammetry building data is third party provided. Too bad Google doesn't see our community as a market opportunity.


You are right a LONG time ago that was possible. But back then the 3d data was hand modelled by people across the world, and the fidelity was very poor. And, it only had building geometry, not vegetation, landscape data, and all the other stuff that makes it look real.


Now, all the 3d data is generated from aereal photos, satellite data and other information, and it is therefore MUCH more accurate and complete. The main issue is, that the geometry is now all tied together, and it is not as streamlined as the previous hand modelled geometry.


Almost certainly isn't... clearly it has occurred to Google that their 3D dataset would be useful outside of their application. If Google wanted to provide this capability they would have. Sketchup would have been a logical connection but they chose to only allow for 2D import. More recently Google Studio has provided great access for this type of use case (via a different methodolody) Google again chose not to allow for export of the 3D data.

3a8082e126
Reply all
Reply to author
Forward
0 new messages