Try WikiClientLibrary on Xamarin Workbooks!

I’ve noticed that MS announced their first pre-release for Workbooks, which allows you to experiment with .NET Framework / .NET Core / Xamarin / WPF in a Jupyter-like fashion. It’s like an enhanced version of C# interactive window.

What is really an improvement, is that you can add reference to NuGet packages in a similar way as you are working with a full C# project, so it exhibit a chance for me to play with WikiClientLibrary. Hopefully, it might give Wiki contributors some convenience on automated edits, such as word-replacement in batch.

Experiment with Workbooks and WCL

If resx localization doesn’t work on your .NET Core application…

Let’s say, you are writing .NET Core application in VS 2017. You have added the following resx resource files to your project

  • Resources.resx (Let’s take it as en)
  • Resources.fr.resx
  • Resources.zh-Hans.resx

However, when running on a French OS, sometimes you may still get English text  for Resource via  GetString.

You might as well try Rebuilding the project.

Written a MediaWiki Client Library

This is a MediaWiki client library based on .NET PCL, targeting at .NET Framework 4.5, ASP.NET Core 1.0, Xamarin.iOS, and Xamarin.Android. The verified supported MediaWiki API version can be as low as MediaWiki 1.19 (Wikia). FYI, now Wikipedia is using MediaWiki 1.28.

Repository: https://github.com/CXuesong/WikiClientLibrary

Other MediaWiki client libraries: https://www.mediawiki.org/wiki/API:Client_code

Advertise for it: Frankly I haven’t take time to summarize, but it supports

  • common API for page query/creation/edit/deletion
  • generators.
  • file upload
  • query result pagination (encapsulated as IAsyncEnumerable )

Continue reading Written a MediaWiki Client Library

Create albums in PowerPoint !

Recently I’ve programmed a tool that can automatically generate albums in PowerPoint. What you’re supposed to do is to prepare your photos, and write a script. When these materials are ready, just run this little application and you’ll get the presentation document.

Here’s a quite simple demo

Continue reading Create albums in PowerPoint !

Querying Network Status in .NET programming

Work with My namespace

We can use My.Computer.Network.IsAvailable in Visual Basic.NET to determine whether the network is connected. The definition of this property is:

It leads to the approach in C#. Continue reading Querying Network Status in .NET programming

So I decided to implement XmlSerializer “again”

Reinventing the wheel T_T

ref = CXuesong/XSerializer/

Pull is welcomed T_T if you’d like to

Recently I’ve been considering the following problems:

When serializing using XmlSerializer to get more control on what the XML should look like,

  1. How to serialize members with type Nullable<T>, persisting it as XML attribute (rather than element)?
  2. How to serialize references, avoiding it persisted as multiple identical copies of one object?
  3. How to achieve the these two things above, without introducting public auxiliary properties?
    (e.g. for case 1, an auxiliary property can be introduced to do the conversions between Nullable<T> and string, the latter of which can be persisted as XML attribute.)

It seems that case 2 can be solved using DataContractSeriallizer. However, DataContractSeriallizer generates Id by itself, and represent Id and its references with z:Id andz:Ref. As I’ve mentioned in previously (在 XmlSerializer 与 DataContractSerializer 之间抉择), DataContractSeriallizer is rather rigid when you want to control the appearance of XML tree it generates.

Then, how to solve these problems?

Maybe, I’ll reinvent the wheel.

See Also

c# – Is there any way for my class to support serialisation as an XML attribute? – Stack Overflow