RSS

Tag Archives: .net

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

Read the rest of this entry »

 
1 Comment

Posted by on December 15, 2016 in Dotnet/C#, Programming

 

Tags: , , , , , , , , , ,

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.

Read the rest of this entry »

 
3 Comments

Posted by on September 14, 2015 in Dotnet/C#, Programming, Unity 3d

 

Tags: , , , , , ,

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?

 
Leave a comment

Posted by on August 17, 2015 in Dotnet/C#, Programming

 

Tags: , , , , , , , , , , , , ,

Using RabbitMQ in C# (II) Sending message to RabbitMQ


Create a Winform application, add below UI to the form:

image

Read the rest of this entry »

 
1 Comment

Posted by on August 13, 2015 in Dotnet/C#, Programming

 

Tags: , , , , , , , , ,

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

Read the rest of this entry »

 
2 Comments

Posted by on August 13, 2015 in Dotnet/C#, Programming

 

Tags: , , , , , , , , ,

C# Websocket programming: the simplest example


Create a winform Application:

image

Read the rest of this entry »

 
14 Comments

Posted by on July 23, 2015 in Dotnet/C#, Programming

 

Tags: , , , , , , , ,

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);
            }
        }

Read the rest of this entry »

 
Leave a comment

Posted by on July 14, 2015 in Dotnet/C#, Programming

 

Tags: , , , , , ,

Using MySQL with C# (III): Coding in C#


  • Install the nuget package: in the nuget management console, type below line and run

Install-Package MySql.Data

  • Let’s create a class SqlUtils, and in the static constructor, type below code:
                
                  static
    SqlUtils()
            {
                try
                {
                    con = new MySqlConnection(connectionStr);
                    con.Open(); //open the connection
                    Console.WriteLine(“Successfully opened database.”);
                }
                catch (MySqlException err) //Catch MySql errors
                {
                    Console.WriteLine(“Error: “ + err.ToString());
                }
            }

where the connection string is:

Read the rest of this entry »

 
1 Comment

Posted by on July 13, 2015 in Dotnet/C#, Programming

 

Tags: , , , , , ,

Using MySQL with C# (II): Creating a DB for programming


You might be interested in how to install MySQL in windows, check up this link for details.

  • Run MySQL workbench after clicking Finish

image_thumb[23]  image_thumb[24]

  • In the MySQL workbench, copy below scripts to create a new database called “MyBooks”:

create database MyBooks

  • Select the above script line, then click the thunder icon to execute the sql statement
  • A new DB is created, as shown in the left DB group:

image   image

Read the rest of this entry »

 
1 Comment

Posted by on July 13, 2015 in Dotnet/C#, Programming

 

Tags: , , , , , ,