Category: .NET
-
Obtain data from ANAF(local IRS)
In ROmania ANAF is providing a WebAPI that allows access to some of the information that any enterprise should provide. The API is described at https://webservicesp.anaf.ro/PlatitorTvaRest/api/v3/, I have made a C# console and a node,js script. The differences: 1.it is easiear in node to make an http request. 2. For C# – I think in…
-
Tiny Types–documentation–part 4
This is a series http://msprogrammer.serviciipeweb.ro/2018/03/12/tiny-types-in-cpart-1/ http://msprogrammer.serviciipeweb.ro/2018/03/19/tiny-types-part-2adding-iequatable/ http://msprogrammer.serviciipeweb.ro/2018/03/26/tinytypesadding-equality-operatorpart-3/ http://msprogrammer.serviciipeweb.ro/2018/04/02/tiny-typesdocumentationpart-4/ tiny types in C# Tiny types is a NuGET dll,https://www.nuget.org/packages/TinyTypesObjects/ Also,you can find the construction here: http://msprogrammer.serviciipeweb.ro/category/tinytypes/ The documentation is copied shameless from https://github.com/jan-molak/tiny-types Installation To install the module from nuget : … Install-Package TinyTypesObjects … Defining Tiny Types An int on its own is just a…
-
TinyTypes–adding equality operator–part 3
This is a series http://msprogrammer.serviciipeweb.ro/2018/03/12/tiny-types-in-cpart-1/ http://msprogrammer.serviciipeweb.ro/2018/03/19/tiny-types-part-2adding-iequatable/ http://msprogrammer.serviciipeweb.ro/2018/03/26/tinytypesadding-equality-operatorpart-3/ http://msprogrammer.serviciipeweb.ro/2018/04/02/tiny-typesdocumentationpart-4/ Now we have come to the interesting part – the equality operator. We have already operator equals,but not == Because we primary want this TinyTypes for structs( int,double,bool,and so on) we can define a new class For this we could implement operator == by using the Equals…
-
Tiny Types part 2–adding IEquatable
This is a series http://msprogrammer.serviciipeweb.ro/2018/03/12/tiny-types-in-cpart-1/ http://msprogrammer.serviciipeweb.ro/2018/03/19/tiny-types-part-2adding-iequatable/ http://msprogrammer.serviciipeweb.ro/2018/03/26/tinytypesadding-equality-operatorpart-3/ http://msprogrammer.serviciipeweb.ro/2018/04/02/tiny-typesdocumentationpart-4/ As always,the bigger problem is adding equality. The Tiny Type should be equal with the inner value – and with the other type with the same value. And,in C#,when you implement equality,there is a whole theory – see https://msdn.microsoft.com/en-us/library/336aedhh(v=vs.100).aspx . So the code to define equality is…
-
Tiny types in C#–part 1
This is a series http://msprogrammer.serviciipeweb.ro/2018/03/12/tiny-types-in-cpart-1/ http://msprogrammer.serviciipeweb.ro/2018/03/19/tiny-types-part-2adding-iequatable/ http://msprogrammer.serviciipeweb.ro/2018/03/26/tinytypesadding-equality-operatorpart-3/ http://msprogrammer.serviciipeweb.ro/2018/04/02/tiny-typesdocumentationpart-4/ I have read about tiny types in Javascript – at https://darrenhobbs.com/2007/04/11/tiny-types/ and at https://janmolak.com/tiny-types-in-typescript-4680177f026e . It was an interesting idea – especially in this world of REST API . I decided to make the same on C# – so here it is: https://github.com/ignatandrei/tinyTypes and at https://www.nuget.org/packages/TinyTypesObjects .…
-
Making any call to a function of an object thread safe
I was wondering how to modify old code to support threads /task . So I was making a small project about making any function of an object thread safe. NuGet Package at : https://www.nuget.org/packages/ThreadSafeObject/ The solution contain tests and 2 console project for .NET Core and .NET Framework 4.5.1 The usage is pretty…
-
Task and generic list
Could you spot the problem in transforming one code that is sequential into a Task ( threaded ) one? First,this is the sequential one: This is the modified with task: Ok. If you do not know,here is a helper: Sometimes,at line it gives the error: System.Reflection.TargetInvocationException: Exception has been thrown by the…
-
Maintaining history of data
What is this about? I tend to quote Fowler: “Usually when we see properties on a class,they represent questions we can ask of an object now. However there are times when we don’t want to just ask questions about a property of an object now,we also want to ask these questions about some point…
-
Five common mistakes for ASP.NET MVC accesing resources : css,js,images,ajax
This is a Razor /MVC5 variant of older post http://msprogrammer.serviciipeweb.ro/2010/10/09/five-common-mistakes-for-asp-net-mvc-accesing-resources-css-js-images-ajax/ To have once for all the link to show to people,because too much makes the same error again and again. (From here – you can use ResolveUrl or Url.Content – it’s the same for me. I use ResolveUrl because I used first …) Case 1…
-
Async + sync completion + lock
Let’s suppose that you have 2 functions = one true sync and one true async . Let’s suppose more that the sync one can must finish before calling next time ( think about some weird COM component or,in our days,SqlConnection ) If we look just at the async function,we could wait for all. However,the sync…