#include <xtd/xtd>
class example {
public:
static auto main() -> void {
auto open_with = dictionary<string, string> {};
open_with.add("txt", "notepad.exe");
open_with.add("bmp", "paint.exe");
open_with.add("dib", "paint.exe");
open_with.add("rtf", "wordpad.exe");
try {
open_with.add("txt", "winword.exe");
} catch (const argument_exception&) {
console::write_line("An element with key = \"txt\" already exists.");
}
console::write_line("For key = \"rtf\", value = {0}.", open_with["rtf"]);
open_with["rtf"] = "winword.exe";
console::write_line("For key = \"rtf\", value = {0}.", open_with["rtf"]);
open_with["doc"] = "winword.exe";
try {
console::write_line("For key = \"tif\", value = {0}.", open_with["tif"]);
} catch (const key_not_found_exception&) {
console::write_line("key = \"tif\" is not found.");
}
auto value = ""_s;
if (open_with.try_get_value("tif", value))
console::write_line("For key = \"tif\", value = {0}.", value);
else
console::write_line("key = \"tif\" is not found.");
if (!open_with.contains_key("ht")) {
open_with.add("ht", "hypertrm.exe");
console::write_line("value added for key = \"ht\": {0}", open_with["ht"]);
}
console::write_line();
for (const key_value_pair<string, string>& kvp : open_with)
console::write_line("key = {0}, value = {1}", kvp.key(), kvp.value());
dictionary<string, string>::value_collection values = open_with.values();
console::write_line();
for(const auto& s : values)
console::write_line("value = {0}", s);
dictionary<string, string>::key_collection keys = open_with.keys();
console::write_line();
for(const string& s : keys)
console::write_line("key = {0}", s);
console::write_line("\nRemove(\"doc\")");
open_with.remove("doc");
if (!open_with.contains_key("doc"))
console::write_line("key \"doc\" is not found.");
}
};
#define startup_(main_method)
Defines the entry point to be called when the application loads. Generally this is set either to the ...
Definition startup.hpp:168