Bing Search in C#: A step by step walk-through tutorial


This blog is the 3rd article of the series Search in C# example demonstration. If you are interested in my earlier blogs in this series, please refer to below blogs:

In this blog, I am going to walk through how to do Bing Web Search using the latest v5 API.

BingSearch

Continue reading “Bing Search in C#: A step by step walk-through tutorial”

Using SmartFox with C# (III) : Frequently used functions


If you haven’t read below posts, you might wish to have a quick go through:

Using SmartFox with C# (I) : Installations and 1st handshaking
Using SmartFox with C# (II) : Login and join room

If you are comfortable with above implementations, you might be interested in below frequently called functions. Assuming below variable is instantiated successfully:

private SmartFox client;

To Send a message:

client.Send(new PublicMessageRequest(someMessage));
client.AddEventListener(SFSEvent.PUBLIC_MESSAGE, OnPublicMessage);
private void OnPublicMessage(BaseEvent evt) {
     User sender = (User) evt.Params[“sender”];
     string message = (string) evt.Params[“message”];   
}

To create a room:

var settings = new RoomSettings(“New Room Name”);
settings.maxUsers = 100;
Settings.groupId = “ChatGroup”;
client.Send(new CreateRoomRequest(settings));
client.addEventListener(SFSEvent.ROOM_ADD, OnRoomAdded);

For a zone, to join/remove a room:

client.Send(new Sfs2X.Requests.JoinRoomRequest(roomId));
client.AddEventListener(SFSEvent.ROOM_JOIN, OnRoomJoin);
private void OnRoomJoin(BaseEvent evt) {
     Room room = (Room) evt.Params[“room”];           
     //room.Name,  room.UserList
}

For user to enter/leave a room

client.Send(new Sfs2X.Requests.LeaveRoomRequest());
client.AddEventListener(SFSEvent.USER_EXIT_ROOM, OnUserExitRoom);
private void OnUserExitRoom(BaseEvent evt) { User user = (User) evt.Params[“user”]; }

For more information, have a read on SFSEvent class and Sfs2X.Requests namespace will be vey helpful.

Using SmartFox with C# (I) : Installations and 1st handshaking


Despite that SmartFox has offered a Unity3D package for easy access SmartFox functionalities for game developers, however it is not very straightforward to directly get to know how to consume SmartFox with C# (Mono), particularly in a step-by-step fashion. This post offers a concise introduction on how to get started with SmartFox in C# in 2 minutes. Hope you love it …

Server setup

C# Client

  • Got o SmartFoxServer web site
  • Download the Client API
  • Extract the downloaded zip file, and grab the dll for further use.

Continue reading “Using SmartFox with C# (I) : Installations and 1st handshaking”

Using RabbitMQ in C# (III) Consuming messages from RabbitMQ


It can be found that In earlier posts, setup RabbitMQ and sending messages are a piece of cake using RabbitMQ C# client. Let’s take a further step and see how to consume messages from RabbitMQ.

Create a console application, and add below code:

public static void Main()
{
        var factory = new ConnectionFactory() { HostName = "…" };
        using (var connection = factory.CreateConnection())
        {
            using (var channel = connection.CreateModel())
            {
//Assuming you have a queue named “whatever” created already
var consumer = new EventingBasicConsumer(channel); consumer.Received += (model, ea) => { var body = ea.Body; var message = Encoding.Default.GetString(body); Console.WriteLine(" [x] Received {0}", message); }; channel.BasicConsume("whatever", true, consumer); Console.WriteLine(" Press [enter] to exit."); Console.ReadLine(); } } }

That is it! Simple?

Using RabbitMQ in C# (I) Installation of RabbitMQ


image image

 

  • Select the server software on the desired platform and download the setup package. In this example, I will use windows installer.
  • Run the windows installer, and you will be prompted to install Erlang, follow the links and download install Erlang:

image

image image

Continue reading “Using RabbitMQ in C# (I) Installation of RabbitMQ”

Visual Studio 2015 RTM ISO/offline download links: official links


Visual Studio Enterprise 2015 (x86 and x64) – DVD (English)
SHA1:07C949078F895CE0D9C03A1B8D55571A8C90AC94

Visual Studio Professional 2015 (x86 and x64) – DVD (English)
SHA1:E01F364C3F21CDFCEBB25D3C028398741F08EB24

Visual Studio Community 2015 – (English)
SHA1:BAAD3CEBAB7A5834D8F78F7D02E4880C010F3BA9

Visual Studio Test Professional 2015 (x86 and x64) – DVD (English)
SHA1: A532B03F4B461DE68F4A86D34F478F2C87F6413D

Visual Studio 2015 SDK (x86 and x64) – (English)
SHA1:6CC9DE044EAB28B6CF2E298990320D116DC37036

Modeling SDK for Visual Studio 2015 (x86 and x64) – (English)
SHA1:0E748AB43E7135D8692947DC946FCEA207DDC7FB

Microsoft Build Tools 2015 (x86) – (Multiple Languages):18 MB
SHA1:ABF9EFBCFE2B896C07EB14B97E0FC972F1BBAAD8

All from official Microsoft sites! Enjoy!

Using Redis with C# (II): Coding


Now that you have installed Redis on your system, let’s jump to the actual coding using C#. If you wish to get the detailed procedures to install Redis, click here.

  • Create a winform project in Visual Studio
  • Install the nuget package by running the following command in the Package Manager Console

PM> Install-Package ServiceStack.Redis

Add a button and a button click event handler:

              private void button1_Click(object sender, EventArgs e)
        {
            string elementKey = “TableId”;
            using (var redisClient = new RedisClient(host, port, password))
            {
                if (redisClient.Get<string>(elementKey) == null)
                {
                    redisClient.Set(elementKey, “12345678”);
                }
                else
                    redisClient.Set(elementKey, “87654321”);
                // get value from the cache by key
                var message = “Item value is: “ + redisClient.Get<string>(elementKey);
                MessageBox.Show(message);
            }
        }

Continue reading “Using Redis with C# (II): Coding”