Some time ago I developed a small tool that allowed you to turn regular old console applications as a service. It’s been download many times but there is no forum to discuss the issues. That’s why I’m creating this blog post now on the suggestion of one of the users. (Thanks Richard)
Placing text and controls inside text input in Bootstrap 2.3.2
I wanted to place an “x” inside a text input. Bootstrap offers something like this, except in Bootstrap the additional control is attached to the left or right of the input, it is not inside the input.
For example this is what Bootstrap does:
What I want is this:
Minimum Code First Setup
This is the absolute minimum you need to get started with Code-First.
Before I start I assume you have Visual Studio, are familiar with NuGet and have access to some version of SQL Server.
First use NuGet to install EntityFramework. Now you need 2 classes to get started. One to represent the database and the other to represent your table:
Inline IL in C#
One of the features I liked in C++ was the ability to include inline assembly. Granted I never found much practical use for it but it was a great way to learn assembly without having to write a whole application in it.
Well a very clever Canadian by the name of Roy has now made that possible in C# and VB.NET. Not only is it a great feature but the way he implemented it is very clever and can be applied to do your own IL manipulation of your binaries.
Basically Roy uses the existing Visual Studio tools ildasm and ilasm to decompile your binary into IL, insert your IL code blocks, and recompile the result.
You specify your IL by enclosing it inside an #if
directive, like so:
public static int Add(int n, int n2) { #if IL ldarg n ldarg n2 add ret #endif return 0; // place holder so method compiles }
Adding this feature to your project is as simple as adding a post-build step. You can find the whole article here: http://www.codeproject.com/Articles/438868/Inline-MSIL-in-Csharp-VB-NET-and-Generic-Pointers
Invoke base method using reflection
I came across this problem when I was writing a proxy library. I wanted to invoke the method of the base class but was instead invoking the overriden version. I was able to find the answer on Stack Overflow. Here is the code sample of the problem.
class BaseClass { public virtual void Test() { Console.WriteLine("Test() from BaseClass"); } } class OverridingClass : BaseClass { public override void Test() { Console.WriteLine("Test() from OverridingClass"); } } public static void Main() { var d = new OverridingClass(); typeof(BaseClass).GetMethod("Test").Invoke(d, null); }