Generated by All in One SEO v4.9.10, this is an llms.txt file, used by LLMs to index the site. # Tom's Tech Blog ...about C#, .Net and Realm ## Sitemaps - [XML Sitemap](https://techblog.kison.info/sitemap.xml): Contains all public & indexable URLs for this website. ## Posts - [How to use ISODate in MongoAPI](https://techblog.kison.info/2023/04/28/how-to-use-isodate-in-mongoapi/) - Usually we would use the following syntax to filter a collection by a date in Mongo { "CreationDate": { $gt: ISODate('2022-01-01T00:00:00Z')} } That doesnt work in the API (especially when using the Dataverse Connector in PowerPlatform). There we can use the following syntax { "CreationDate": { "$gt": {"$date" : "2022-01-01T00:00:00Z" } } } See that - [Margin,Padding,Border?](https://techblog.kison.info/2020/02/19/marginpaddingborder/) - A colleague of me is always pretty unsure what to set. So he always looks it up, so maybe one day he will find this post.. This is for you Fabian. - [Adventures with DelayedAction (C#)](https://techblog.kison.info/2021/11/17/adventures-with-delayedaction-c/) - Today I worked on a project and found a piece of code, that left me wondering what the one who wrote it was actually thinking this should do. I know what the code is intended to do, but it was so weird, I wanted to share and try to find a better solution. First of - [What's wrong with those ObservableCollections and Threading?](https://techblog.kison.info/2021/04/27/whats-wrong-with-those-observablecollections-and-threading/) - When you are developing Apps with Xamarin.Forms you probably used ObservableCollections more than once. That's pretty neat, because an ObservableCollection notifies the View on any changes that occur, so you don't have to care about updating the Views. A common use case is as follows. You have a list of items (models) that are being - [How to find the root Page of a specific Control in Xamarin.Forms](https://techblog.kison.info/2020/11/04/how-to-find-the-root-page-of-a-specific-control-in-xamarin-forms/) - Actually it's very easy to achieve this. Just traverse the visual tree upwards to find the root. public static class VisualTreeHelper { public static ContentPage FindParentPage(Element view) { if (view is ContentPage page) { return page; } return FindParentPage(view.Parent); } } This does what we intended to do, but... we can do better than that!Maybe - [Creating a Flyout in Xamarin.Forms](https://techblog.kison.info/2020/11/08/creating-a-flyout-in-xamarin-forms/) - Flyouts are a pretty neat control, first introduced in Windows UWP, but there is nothing close in Xamarin.Forms which can be used on all platforms. So I decided to create one. What is a Flyout? from the Windows UWP documentation (https://docs.microsoft.com/en-us/uwp/api/windows.ui.xaml.controls.flyout?view=winrt-19041) "Use a Flyout control for collecting information, for displaying more info, or for warnings - [Using async/await in an IValueConverter in Xamarin.Forms](https://techblog.kison.info/2020/11/28/using-async-await-in-an-ivalueconverter-in-xamarin-forms/) - Let's start out with a very simple Setting - we have the following Models:Product+ Id : string+ Name: string+ Image: Image Image+ Id: string+ Filename: string In our service layer, we have a function that gets all products, and we want to show them on a Xamarin.Forms page, including each image. The Image-Model has no - [Supported Linq query expressions in Realm](https://techblog.kison.info/2020/07/06/supported-linq-query-expressions-in-realm/) - Sooner or later, you'll come to the point, that you don't only want to get objects by Id or the whole set of objects of a specific type in Realm. The easiest, but probably most unsophisticated way to do it, would be just use a function on a Linq-Where statement. That's easy and has reasonable - [User Access Management in Realm](https://techblog.kison.info/2020/06/04/user-access-management-in-realm/) - As I already stated before, I love Realm.io. It's a pretty cool object oriented database, with a very mighty synchronization mechanism, that helps you build mobile apps just right out of the box. But that's not the end of the line.. It also ships with a very mighty user management feature. When you develop mobile - [Using Realm Notifications in .Net](https://techblog.kison.info/2020/05/13/using-realm-notifications-in-net/) - There is a documentation on Realm.io, that describes how to hook up on a ROS (Realm Object Server) to observe changes on specific Realms, RealmObjects or whole instances. So there is no need to actually download the whole Realm, since it "sees" the changes directly on the server. It is also pretty cool, that you - [Performance of loading Xaml dynamically in Xamarin.Forms](https://techblog.kison.info/2020/04/22/performance-of-loading-xaml-dynamically-in-xamarin-forms/) - As I mentioned in a previous post, you can quite easily load Xaml dynamically in your Xamarin.Forms App. But how about performance? How long does it take in comparison to "regular" loading of pre-compiled Xaml. It's anything but easy to really measure this. We could eventually use LoadFromXaml and measure the differences. I decided to - [Never ever use Task.Result in Xamarin.Forms! Why?](https://techblog.kison.info/2020/04/21/never-ever-use-task-result-in-xamarin-forms-why/) - I recently stumbled over a deadlock in our code. Someone called a method, that returned a Task, and instead of awaiting it, he called: I reason for this code was just plain laziness, because using await requires an async-context, which probably isn't that easy to achieve. But what's the reason for that deadlock, and why - [Remove whitespaces of a string in C#](https://techblog.kison.info/2020/04/16/remove-whitespaces-from-string-in-c/) - This seems to be really simple, so why am I writing this blog post? Everyone I asked, had a different idea to achieve this, the first idea was to use Regular Expressions, which is really straight forward and simple, but there are several other methods with quite different performance. Let's have a look at all - [Dynamically create controls in Xamarin Forms](https://techblog.kison.info/2020/04/15/dynamically-create-controls-in-xamarin-forms/) - This is a very broad topic. You can actually always dynamically create controls in code behind, by just adding them to the UI during runtime. This is very easy, but it's not generic at all, you need to code everything you would actually do in Xaml. Another solution (which I actually prefer) is to use - [Copy an entire synced Realm](https://techblog.kison.info/2020/04/14/copy-an-entire-synced-realm/) - In our company, we use realm.io as mobile Database with the ROS Cloud to sync data between mobile devices and the server. Main advantage is, that we can build Apps in a fraction of time, without juggling with synchronization. One of our main challenges was the disability to copy data from one realm to another. - [Move Controls in Xamarin.Forms App with your finger](https://techblog.kison.info/2020/02/22/move-controls-in-xamarin-forms-app-with-your-finger/) - ...or Mouse.. or Pen.. or nose, whatever you like. In WPF this is very easy accomplished, because Drag&Drop is a main UI feature in Windows. Each OS implements this feature slightly different, that's why there is no such generic solution for all platforms. Microsoft proposes a solution called TouchEffect, which implements a specific Effect for - [Xamarin.Forms FlowLayout](https://techblog.kison.info/2020/02/21/xamarin-forms-flowlayout/) - Motivation I recently faced the challenge to add Items of different sizes to a Page on a Xamarin.Forms App. The result should be some kind of a Dashboard with Diagrams and info boxes on it. Some diagrams are smaller, some bigger. The first thing, that came in mind, was a FlexLayout, but this looks a - [Adding Themes to Xamarin.Forms App](https://techblog.kison.info/2020/02/18/adding-themes-to-xamarin-forms-app/) - I just want to make some short notes about themes in Xamarin.Forms Apps, since there are already a lot of tutorials available online, that go way deeper. Themes Themes are actually ResourceDictionaries. Each atomic type you use in your XAMLs and Styles, will be defined here. Types are f.e. Color, Double (for font sizes), etc. - [CSC : error CS1703: Multiple assemblies with equivalent identity have been imported (iOS)](https://techblog.kison.info/2019/11/18/csc-error-cs1703-multiple-assemblies-with-equivalent-identity-have-been-imported-ios/) - I recently encountered a problem compiling my Xamarin.Forms iOS project. Everything worked well when testing the UWP App during development, but when I tried to test the iOS project, the compiler threw the following error: CSC : error CS1703: Multiple assemblies with equivalent identity have been imported (iOS)'[..]\packages\system.reflection.emit.3.0\ref\netstandard1.1\System.Reflection.Emit.dll' and 'C:\Program Files (x86)\Microsoft Visual Studio19\Professional\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\Xamarin.iOS\v1.0\Facades\System.Reflection.Emit.dll'. Remove - [read and write properties on dynamic objects in .NET/C#](https://techblog.kison.info/2019/10/16/read-and-write-properties-on-dynamic-objects-in-net-c/) - Ok, the headline sounds a little bit funny, because first of all, dynamic objects have no properties. Also you can not use reflection on a dynamic type, because it's dynamic. What I actually want to do, is to access values of a dynamic object by its name - but I don't know the name of - [C# Creating Types during runtime (.Net Core)](https://techblog.kison.info/2019/10/10/c-creating-types-during-runtime-net-core/) - This is really fancy stuff, no one would probably never ever get along doing this. And I actually have no real straight forward "all day" use-case, I would ever recommend this for. But guess what, there is always an exception. So why am I doing this? My situation is the following: On one hand I - [Problem with ResourceDictionary in Xamarin Forms .Net Native](https://techblog.kison.info/2019/08/29/problem-with-resourcedictionary-in-xamarin-forms-net-native/) - Last week a colleague had the idea, to split the Resources, that we have defined in App.xaml in several ResourceDictionaries. Since our App.xaml has grown to over 400 lines, we thought this would be a very good idea, and did it as always: Looks good, and when we were testing the App, it worked well. - [Error 0xC000041D using GetCallingAssembly()](https://techblog.kison.info/2019/08/15/error-0xc000041d-using-system-reflection-assembly-getcallingassembly/) - Reflection is very cool, the meta data system of .Net is pretty cool. You can create objects of a given class, without knowing it at compile time, by just looking it up and instantiating it using reflection. But how can I look up a type? Some times you only know the name of a type - [How to assign properties (fast) in C#?](https://techblog.kison.info/2019/08/14/how-to-assign-properties-fast-in-c/) - Ok, the short answer to that question is easy, just assign it directly. That's it, and this is the shortest blog post ever. But actually that's not the point, I wanted to make. There are a bunch of methods to assign a class-property with a specific value, but how do they differ, when it comes - [Arduino Object-oriented](https://techblog.kison.info/2019/08/06/arduino-object-oriented/) - It has been more than a decade, that I switched over to programming in C# and even longer I am developing object-oriented code. But when it comes to Arduino, I can not count on C#. (Actually, there is an Arduino-like microcontroller, which can be programmed with C#. It is called Netduino) But we can still - [Do I really need to unsubscribe every event?](https://techblog.kison.info/2019/07/10/do-i-really-need-to-unsubscribe-every-event/) - I've seen a lot of source code in my life. Some really good code, that I loved to read and understand. My wife loves to read good books, I love to read good source code. :-) But sometimes, you read lines of code and think: Why??? Why, is someone doing this??? I remember one code - [using enums with Realm](https://techblog.kison.info/2019/07/10/using-enums-with-realm/) - Realm is a very sweet object-oriented database engine for various languages. Since I am a .Net developer, I'll stick to the features and problems we have using it within Xamarin Apps. Recently we encountered a problem, using enums within a RealmObject. The most challenging thing in using Realm is, the constraint that comes with the - [About me](https://techblog.kison.info/2019/07/08/about-me/) - This is my awesome first blog post… Now that I got everything set up, I don't really know, what to write. Let's talk about me - I am Tom, born in the early '80s and a Software Developer and father of three beautiful kids. I am writing Software as long as I can think of ## Pages - [Tools](https://techblog.kison.info/tools/) - This is a collection of some tools I wrote using Blazor. This was my first App with Blazor WASM and .NET6. I use it frequently and hope you enjoy it. https://devtools.kison.info/ - [Privacy Policy](https://techblog.kison.info/privacy-policy/) - Who we are Our website address is: https://techblog.kison.info. What personal data we collect and why we collect it Comments When visitors leave comments on the site we collect the data shown in the comments form, and also the visitor’s IP address and browser user agent string to help spam detection. An anonymised string created from - [About](https://techblog.kison.info/about/) - LinkedIn Twitter - [Overview](https://techblog.kison.info/overview/) - Categories .Net native About me Arduino Async C# dynamic Events iOS IOT Realm Reflection Resources TPL Uncategorized ViewModels Xamarin.Forms Xaml Latest posts How to use ISODate in MongoAPI by thomas@kison.info April 28, 2023 Usually we would use the following syntax to filter a collection by a date in Mongo That doesnt work in the API - [Some VisualStudio snippets](https://techblog.kison.info/some-visualstudio-snippets/) - When I install or upgrade a new version of Visual Studio, or when I am on a computer of a colleague, I am always missing some snippets. So here I will collect each one. propvm (Windows, propvm.snippet) cmd (Windows, cmd.snippet) - [funny code](https://techblog.kison.info/funny-code/) - As I stated in one of my blog posts, I've already seen a lot of strange code, some code parts are really funny. Since most of the code is closed source, I can not copy-paste the original code, but I will try to write it down as close to the original, as I can. I ## Categories - [Uncategorized](https://techblog.kison.info/category/uncategorised/) - [About me](https://techblog.kison.info/category/about-me/) - [C#](https://techblog.kison.info/category/c/) - [dynamic](https://techblog.kison.info/category/c/dynamic/) - [Events](https://techblog.kison.info/category/c/events/) - [iOS](https://techblog.kison.info/category/c/ios/) - [IOT](https://techblog.kison.info/category/iot/) - [Realm](https://techblog.kison.info/category/realm/) - [Reflection](https://techblog.kison.info/category/c/reflection/) - [Resources](https://techblog.kison.info/category/c/resources/) - [TPL](https://techblog.kison.info/category/c/tpl/) - [ViewModels](https://techblog.kison.info/category/c/viewmodels/) - [Xamarin.Forms](https://techblog.kison.info/category/c/xamarin-forms/) - [Xaml](https://techblog.kison.info/category/c/xaml/) - [.Net native](https://techblog.kison.info/category/c/net-native/) - [Arduino](https://techblog.kison.info/category/iot/arduino/) - [Async](https://techblog.kison.info/category/c/async/) ## Tags - [enum](https://techblog.kison.info/tag/enum/) - [IDisposable](https://techblog.kison.info/tag/idisposable/) - [me](https://techblog.kison.info/tag/me/) - [Realm.io](https://techblog.kison.info/tag/realm-io/) - [RealmObject](https://techblog.kison.info/tag/realmobject/) - [Themes](https://techblog.kison.info/tag/themes/) - [Thomas Kison](https://techblog.kison.info/tag/thomas-kison/) - [Xamarin](https://techblog.kison.info/tag/xamarin/)