Category: c#

Using Autofac in a ASP.NET MVC 4 application

Posted by – October 18, 2012

ASP.NET MVC is a great framework, very flexible, but sometimes we need to organize a little better our business logic, there’s nothing better than have a business logic completely decoupled from controller, which can be easily reused on several controllers over the project.

To help ASP.NET MVC make use of reusable business logic and other logic components aswell, we can add a DI/IoC container to our project, after few days researching about IoC container alternatives, I choose Autofac to create my first web application that takes advantage of Dependency Injection.
More

Share

Fixing SelectedValue issue on DropbDownListFor with SelectList

Posted by – July 30, 2012

After spent several hours trying to figure out how the SelectedValue works on DropDownListFor, I finally figure out how to do it, you can also check my answer on stackoverflow here.

It’s very simple to get SelectList and SelectedValue working together, even if your property isn’t a simple object like a Int, String or a Double value.

Example:

Assuming our Region object is something like this:

1
2
3
4
public class Region {
     public Guid ID { get; set; }
     public string Name { get; set; }
}

More

Share

Using a FSIS CTS flow to generate text files and compile as FAST ESP dictionaries

Posted by – December 23, 2011

After have some trouble trying while create my FSIS CTS flow, I could finally read the data need from SQL Server instance and push to FAST ESP for indexing, once I got everything working as expected I started to think in what else I could easily to in a CTS flow.

My next challenge was create a FAST ESP dictionary for use on query completion server of FAST ESP, the majority of built in operators doesn’t provide a easy way to do it, hopefully I found the RunCode operator that I can use to perform anything that I need with a custom C# or VB code.
More

Share

.NET XMLBuilder, a .NET port of Java XMLBuilder

Posted by – November 30, 2009

Yesteday I finished the port of Java XMLBuilder to .NET, now you can use any .NET language to easily create xml documents, .NET XMLBuilder is written in Delphi Prism and released under Apache 2.0 license. The current release of XMLBuilder can be download here.

XMLBuilder is very easy to use, it contains a kind of DSL, a basic example can be checked below:
More

Share

ByteBuffer implementation for dotNET

Posted by – August 2, 2009

Today I created a dotNET version of ByteBuffer class, with this class you can easily read and write data into byte array. You can get the source file here.

Here’s an example about how to use ByteBuffer class:

Program.cs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TestCode
{
    class Program
    {
        static void Main(string[] args)
        {
            ByteBuffer buffer = new ByteBuffer(20);

            buffer.AddInt(10);
            buffer.AddString("Test");
            buffer.AddLong(10000);
            buffer.AddInt(350);
            buffer.AddChar('c');
            buffer.AddDouble(10000.325);

            Console.WriteLine(buffer.ReadInt());
            Console.WriteLine(buffer.ReadString());
            Console.WriteLine(buffer.ReadLong());
            Console.WriteLine(buffer.ReadInt());
            Console.WriteLine(buffer.ReadChar());
            Console.WriteLine(buffer.ReadDouble());

            Console.ReadLine();
        }
    }
}

My implementation doesn’t contains all features found on Java version of the same class, but can help on most cases.

Share