Skip to main content

Posts

DI-Y: Crafting Code with Multiple Services Using IEnumerable in Dependency Injection

Registering Services for IEnumerable Injection Service Registration Fundamentals Service registration is the process of telling the DI container how to create instances of a service, typically done at application startup. Registering Services for IEnumerable When services implement a common interface, you can register them in such a way that the DI container can provide an IEnumerable of these services. In .NET, for example: services.AddTransient<ICommonService, ServiceA>(); services.AddTransient<ICommonService, ServiceB>(); Why would you register mulitple instances of the same interface? One use-case is that it is the same service with a different configuration. Here is an example of how that would look: services.Configure<CustomOption>("Opt1", configuration.GetSection("Options1")); services.Configure<CustomOption>("Opt2", configuration.GetSection("Options2")); builder.Services.AddSingleton<ICommonService,Servic
Recent posts

Dialing-in Your AI with Optimizely Feature Experimentation

If you're in technology, AIs are everywhere nowadays. At work, I use an AI to help me make proofs of concept, sometimes in communicating with other AIs. At home, I use Google's Bard to help with those day-to-day mental chores such as meal planning. Even at play, when indulging in some Gran Turismo there's an AI to race against . I can't do anything about the AIs I use more casually (aside from being aware of them). At work though, I have some control! When interfacing with an AI through an API, you're given the opportunity to tweak parameters or try the same query with different contexts before getting a response from your AI. And what better to help judge your user engagement with an AI than Optimizely's Feature Experimentation! Here I'll be working with OpenAI's API along with their client package from nuget in order to simplify some rather ugly setup. I'll include an HttpClient version of the call at the end of the post so you can see the details

Databases from the Future: What is Database Version 954?

 Have you started up a new Optimizely site, and prepared your database only get to this error message? Reading the error message itself, you'll see that the created DB version is at 957 where the current version of Optimizely, at the time of this writing, is 904.  Where did this come from? How do I put my database in a time machine and bring it back to the present? The good news on both parts of this manageable with a visit from Dr. Emmett Brown. The first question: "Where did this come from?" is a versioning issue. SQL Server 2022 (v16) will create future database if you simply run your database creation against a SQL 2022 instance. This will occur if your default instance is SQL 2022 regardless of how you go about generating your database.  So, that's how it happens, now how do you create a database that is ready now, instead of a database from the far future? This is where Visual Studio and SQL Server Object Explorer come in handy. Visual Studio installs a database

Fixing Missing Token in For This {0}

 I recently encountered an issue where my non-content blocks (site settings, categories, etc.) were producing a "For This" folder with a missing token. This missing token appeared in custom content, as well as add-ons like Geta Categories. For custom content, two things are required to get a value into that empty token: an XML file under the lang folder, and UIDescriptor. In order to fix an add-on like Geta Categories (which already has the UIDescriptor baked-in), all that is needed is an XML file under the lang folder. This is a pretty simple XML which simply denotes the content type in question and the name you'd like to give it. Like so: <?xml version="1.0" encoding="utf-8" standalone="yes"?> <languages>   <language name="English" id="en">     <contenttypes>       <CategoryData>         <name>Working Category! </name>       </CategoryData>     </contenttypes>   </

Privacy Policy

PRIVACY POLICY Last updated October 13, 2023 This privacy notice for HTTP418.dev , describes how and why we might collect, store, use, and/or share ( " process " ) your information when you use our services ( " Services " ), such as when you: Visit our website at http418.dev , or any website of ours that links to this privacy notice Engage with us in other related ways, including any sales, marketing, or events Questions or concerns?  Reading this privacy notice will help you understand your privacy rights and choices. If you do not agree with our policies and practices, please do not use our Services. If you still have any questions or concerns, please contact us at greg.jeffers@perficient.com . SUMMARY OF KEY POINTS This summary provides key points from our privacy notice, but you can find out more details about any of these topics by clicking the link following each key point or by using our  table of contents  below to find the section you are lo