I've got a MenuManager class to which each module can add a key and and element to be loaded into the main content:
private Dictionary<string,object> _mainContentItems = new Dictionary<string,object>();
public Dictionary<string,object> MainContentItems
{
get { return _mainContentItems; }
set { _mainContentItems = value; }
}
So the customer module registers its views like this:
layoutManager.MainContentViews.Add("customer-help", this.container.Resolve<HelpView>());
layoutManager.MainContentViews.Add("customer-main", this.container.Resolve<MainView>());
So then later to bring a specific view to the front I say:
layoutManager.ShowMainContentView("customer-help");
And to get the default view (first view registered), I say:
layoutManager.ShowDefaultView("customer");
And this works fine.
However, I want to eliminate the "code smell" with the hyphen which separates module name and view name, so I would like to register with this command:
layoutManager.MainContentViews.Add("customer","help", this.container.Resolve<HelpView>());
But what is the best way to replace my current Dictionary, e.g. what comes to mind are these:
Dictionary<string, string, object> (doesn't exist)
Dictionary<KeyValuePair<string,string>, object>
Dictionary<CUSTOM_STRUCT, object>
The new collection needs to be able to do this:
Compared to C, C++ has significantly more libraries and functions to use. If you're working with complex software, C++ is a better fit because you have more libraries to rely on. Thinking practically, having knowledge of C++ is often a requirement for a variety of programming roles.
The C programming language is the recommended language for creating embedded system drivers and applications. The availability of machine-level hardware APIs, as well as the presence of C compilers, dynamic memory allocation, and deterministic resource consumption, make this language the most popular.
Published in June 2018 as ISO/IEC 9899:2018, C17 is the current standard for the C programming language.
Strictly meeting your criteria, use a Dictionary<string, Dictionary<string, object>>
;
var dict = new Dictionary<string, Dictionary<string, object>>();
...
object view = dict["customer"]["help"];
Dictionary<string, object>.ValueCollection views = dict["customer"].Values;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With