11 August 2019
Category: Learning Projects
a new post after long time, huh? Well I was busy with other stuff, mainly Virtual Reality… There is so much to learn in so many areas…
One of the things that I desperately wanted to learn was a bit of WPF and JSON, and how to approach moding. So in this small project I made a simple crypting program with some interesting mechanics hidden under the hood.
- There are two UI versions. The first one is a classic Windows Forms version, the other one is a WPF version. I like WPF, I must say.
- There are abstract classes as bases for any future crypting methods. All you need to do is to write one, compile it and put into the same directory as the already present Morse and Caesar methods.
- Crypting methods are loaded from CipherDescriptions.JSON file, so after editing this file, the methods appear directly in the UI, where they neatly line up into columns and rows.
- And that’s it! You don’t need to do anything else to add a new method. Now I understand a bit more how moding works. In other words - adding content without recompiling or updating the main program.
- To achieve this, I had to learn a bit of reflections - a very interesting and powerful concept. And not such a black magic as I had thought!
- Furthermore, I have finally learnt how to work with JSON from scratch. I was working with JSON before, but only in the way of expanding old code. It was very exciting to create my own mechanics to integrate initialization from JSON and connecting this to reflections mechanics.
- I also like the architecture of this demo, it doesn’t matter if its WPF or WF, or if you connect it to HTML. You just need to connect UI to OptionsServices API and the rest is dealt with on C# side separately.
It’s a simple project in effect, but I have really learnt a lot while making this work. It was fun and surprisingly much easier than I thought. Once I got the hang of JSON, reflections and WPF principles, the rest was quite fast.
I hope this example could help some of you as well to learn these principles. I believe this program is a working example of these principles, in spite of being very simple.