Sunday, 25 March 2012

Injecting MVC with MEF (Managed Extensibility Framework )


2 Min Video - http://channel9.msdn.com/posts/Injecting-MVC-with-MEF-2-in-2-Minutes



In this video, you'll see how you can get MEF running in an ASP.NET MVC site and how to successfully decouple the controller layer from the service infrastructure and allow for reuse of the service layer across multiple controllers. TheMicrosoft.MEF.CompositionProvider NuGet package put forth by the MEF team makes MEF an irresistible DI/IoC option for MVC developers.



Welcome to the MEF Community Site

Important: this site hosts source code for unsupported, pre-release versions of MEF. If you want to use MEF in production, you should strongly consider using the supported versions included in the .NET Frameworkand Silverlight.

What is it?

The Managed Extensibility Framework (MEF) is a composition layer for .NET that improves the flexibility, maintainability and testability of large applications. MEF can be used for third-party plugin extensibility, or it can bring the benefits of a loosely-coupled plugin-like architecture to regular applications.

Status

MEF is a part of the Microsoft .NET Framework, with types primarily under theSystem.ComponentModel.Composition.* namespaces.
  • MEF has shipped with .NET 4.0 and Silverlight 4
  • MEF 2 is under development
Extracted from - http://mef.codeplex.com/

Tuesday, 13 March 2012

Entity Framework 4.3 Data Migration by Scott Guthrie



What is EF Migrations? If you are using Entity Framework Code-First, Migrations allows you to update your database schema to reflect your POCO classes without having to drop and recreate them. This involves DDL statements to create new tables/columns, alter existing ones, etc. which get generated. The feature has been available to developers for a while as a Nuget package (which can be still used if you are using a lower version of Entity Framework for legacy reasons), but not formally supported by Microsoft.


http://www.youtube.com/watch?v=WzJQtG8dhso&feature=related

Thank you very much Scott Guthrie

Thursday, 8 March 2012

Globalization with Windows Phone Apps



Introduction

In this article, we are going to take a look at how easy it is to get your first app built and deployed. We will then revisit the app to implement globalization and localization. The terms globalization and localization often confuse developers, and it is important to know that these are two different tasks that must be used together to ensure that your app is ready for a target language and culture. Localization refers to making sure that all text in the app is translated appropriately. Globalization deals with dates, times, number formats, and currencies will translate to various cultures. When developing an application it is never too early to think about how these tasks will be accomplished.



http://www.devx.com/MS/mobilephone/Article/47925?trk=DXRSS_LATEST

Monday, 5 March 2012

Know Javascript..use node.js server-side




node.js Introduction 

node.js firstly is a (unexpectedly) spawned server side execution of Google's V8 Javascript engine. The V8 engine is said to be also used by chrome Browser.
node.js may be compared to something like vbruntime enabling vbscript.
So this enables Javascript to be used on server-side.  
All browsers have a javascript engine which nobody seems to have thought of making into a server-side engine which will allow javascript enthusiasts code on the server-side. Now node.js is popular, and Microsoft even supports node.js scripting on their Azure cloud systems (could help tap Javascript coders to use Azure). 

Android: How to communicate with .NET application via TCP






Good one - http://www.codeproject.com/Articles/340714/Android-How-to-communicate-with-NET-application-vi

Thursday, 1 March 2012

Autocomplete in ASP.NET MVC3 in fields




<link href="../../Content/themes/base/jquery-ui.css" rel="stylesheet" type="text/css" />

write a script as:
$(function () {
              function split(val) {
                  return val.split(/,\s*/);
              }
              function extractLast(term) {
                  return split(term).pop();
              }
 
              $("#NewAddress").bind("keydown", function (event) {
                  if (event.keyCode === $.ui.keyCode.TAB &&
                      $(this).data("autocomplete").menu.active) {
                      event.preventDefault();
                  }
              })
              $("#NewAddress").autocomplete({
                  source: function (request, response) {
                      //define a function to call your Action (assuming UserController)
                      $.ajax({
                          url: '/Controller/action', type: "GET", dataType: "json",
                          //query will be the param used by your action method
                          data: { query: request.term },
                          term: extractLast(request.term),
                          success: function (data) {
                              response($.map(data, function (item) {
                                  return { label: item, value: item };
                              }))
                          }
                      })
                  },
                  search: function () {
                      // custom minLength
                      var term = extractLast(this.value);
                      if (term.length < 1) {
                          return false;
                      }
                  },
                  focus: function () {
                      // prevent value inserted on focus
                      return false;
                  },
                  select: function (event, ui) {
                      var terms = split(this.value);
                      // remove the current input
                      terms.pop();
                      // add the selected item
                      terms.push(ui.item.value);
                      // add placeholder to get the comma-and-space at the end
                      terms.push("");
                      this.value = terms.join(", ");
                      return false;
                  }
              });
 
          });


In the view body write:
<%=Html.TextBoxFor(m => m.NewAddress)%>

in the controller :
public ActionResult GetEmailIds(string query)
       {
           query = query.Replace(" ", "");
           if (query.Length > 1)
           {
               int op = query.LastIndexOf(",");
               query = query.Substring(op + 1);
           }
           var users = (from u in _userService.GetAllUsers()
                        where u.EmailAddress.Contains(query)
                        orderby u.EmailAddress // optional
                        select u.EmailAddress).Distinct().ToArray();
 
           return Json(users, JsonRequestBehavior.AllowGet);
       }





Extracted From - http://www.codeproject.com/Tips/338537/autocomplete-in-asp-net-mvc3