Page 21 - MSDN Magazine, May 2019
P. 21
easy
multicolor
hit-
highlighting
®
Figure 3 Supporting Talk Creation with TalkRepository
public class Speaker {
public TalkRepository TalkRepository { set; protected get; } public IDomainObjectContainer Container { set; protected get; }
public void EnterNewTalk(string title, string description, Topic topic) {
var talk = TalkRepository.CreateTalk(this, title, description, topic);
_talks.Add(talk); }
}
public class TalkRepository {
public IDomainObjectContainer Container { set; protected get; }
public Talk CreateTalk(Speaker speaker, string title, string description, Topic topic)
{
var talk = Container.NewTransientInstance<Talk>(); talk.Title = title;
talk.Abstract = description;
talk.Speaker = speaker; Container.Persist<Talk>(ref talk);
return talk;
} }
into this field. (To see this in action in the default NOF Gemini interface, fire up the app, select a Speaker, then click the “Swap Pane” button—the double-arrowed button at the bottom of the display. The Speaker selected will shift to the right of the screen, and the Home interface will appear, allowing selection of the “Talks/Create Talk” item. Drag the Speaker’s name to the Speaker field in the Create Talk dialog, and voila—the Speaker is selected.)
It’s absolutely crucial to understand what’s happening here: I now have two different UI paths (creating a Talk from the top-level menu, or creating a Talk from a given Speaker) that allow for two different user-navigation scenarios, with little effort and zero duplication. The TalkRepository worries about all things “CRUD” and “Talk” related, and the Speaker uses that code, all while keep- ing the user interaction entirely within the Speaker if that’s how the user wants to arrange it.
Wrapping Up
This is not your grandfather’s UI toolkit. In only a few lines of code, I have a workable interface (and, considering that data is being stored and retrieved from a standard SQL back end, a data stor- age system) that could, at least for the moment, be used directly by users. More importantly, none of this is in a proprietary for- mat or language—this is straight C#, straight SQL Server, and the UI itself is Angular. There are a few more things to discuss about NOF’s default interface, which I’ll get to in the next piece, includ- ing authentication and authorization facilities. In the meantime, however ... happy coding! n
Ted Neward is a Seattle-based polytechnology consultant, speaker and mentor. He has written a ton of articles, authored and co-authored a dozen books, and speaks all over the world. Reach him at ted@tedneward.com or read his blog at blogs.tedneward.com.
ThaNks to the following technical expert for reviewing this article: Richard Pawson
msdnmagazine.com
Instantly Search Terabytes
dtSearch’s document filters support: • popular file types
• emails with multilevel attachments • a wide variety of databases
• web data
Over 25 search options including:
• efficient multithreaded search
•
• forensics options like credit card search
• SDKs for Windows, UWP, Linux, Mac, iOS in beta, Android in beta
• FAQs on faceted search, granular data classification, Azure and more
Visit dtSearch.com for
• hundreds of reviews and case studies
• fully-functional enterprise and developer evaluations
The Smart Choice for Text Retrieval® since 1991
dtSearch.com 1-800-IT-FINDS
Developers:
• APIs for C++, Java and .NET, including cross-platform .NET Standard with Xamarin and .NET Core