참조 : beginning_microsoft_visual_studio_lightswitch_development
참조 : beginning_microsoft_visual_studio_lightswitch_development
new-project 해서 새로운 프로젝트를 만들고
Online Templates로 간다.. 아마 비쥬얼 스튜디오 2010을 깔았다면 그냥 wcf service가 있을것이다.
하지만 우리는 WCF REST Service를 만들것이기때문에 online Template으로 가서 프로젝트를 만든다.
만든뒤에
Service1.cs가 보일것이다.
물론 이걸써도 돼지만 새롭게 만드는것도 나쁘지 않다.
나는 윈폰에서 쓸 Notification Server를 만들꺼기때문에 Notifications.cs란 class를 새로 만들었다.
[ServiceContract]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]
public class Notifications
{
private static List<Uri> subscribers = new List<Uri>();
private static object obj = new object();
[WebInvoke(UriTemplate = "register?uri={uri}", ResponseFormat = WebMessageFormat.Json, Method = "GET")]
public void Register(string uri)
{
// TODO: Return the instance of SampleItem with the given id
Uri channelUri = new Uri(uri, UriKind.Absolute);
Subscribe(channelUri);
}
그리고 클래스위에 ServiceContract를 정의 하였으며
저렇게 메소드를 만들어서 인자를 받게 만들었다..
그리고 중요한 Global.aspx.cs에서
private void RegisterRoutes()
{
// Edit the base address of Service1 by replacing the "Service1" string below
RouteTable.Routes.Add(new ServiceRoute("Service1", new WebServiceHostFactory(), typeof(Service1)));
RouteTable.Routes.Add(new ServiceRoute("Notifications", new WebServiceHostFactory(), typeof(Notifications)));
}
이렇게 추가하고 컴파일한후
http://localhost:19976/notifications
컴파일 뒤에 notifications를 붙여서 접속하면 접속이 잘된다.
이제 머 메소드를 붙여 넣든 마음대로 요리하면 된다.
아참 이 Registor 메소드를 부르는쪽에서는 이렇게 호출한다.
/// <summary>
/// MS에서 받아온 url을 서버(WCF Service)에 보낸다.
/// </summary>
private void SubscribeToService()
{
string baseUri = "http://localhost:19976/Notifications/Register?uri={0}";
string theUri = String.Format(baseUri, httpChannel.ChannelUri.ToString());
WebClient client = new WebClient();
client.DownloadStringCompleted += (s, e) =>
{
if (e.Error == null)
{
Dispatcher.BeginInvoke(() => UpdateStatus("Registration Success"));
}
else
{
Dispatcher.BeginInvoke(() => UpdateStatus(e.Error.Message));
}
};
client.DownloadStringAsync(new Uri(theUri));
}
CoworkerSearchService Mybatis.zip
The Common Language Runtime (CLR) is a core component of Microsoft's .NET initiative. It is Microsoft's implementation of the Common Language Infrastructure (CLI) standard, which defines an execution environment for program code. The CLR runs a form of bytecode called the Common Intermediate Language (CIL, previously known as MSIL -- Microsoft Intermediate Language).
Developers using the CLR write code in a language such as C# or VB.NET. At compile time, a .NET compiler converts such code into CIL code. At runtime, the CLR's just-in-time compiler converts the CIL code into code native to the operating system. Alternatively, the CIL code can be compiled to native code in a separate step prior to runtime. This speeds up all later runs of the software as the CIL-to-native compilation is no longer necessary.
Although some other implementations of the Common Language Infrastructure run on non-Windows operating systems, Microsoft's implementation runs only on Microsoft Windows operating systems.
The CLR allows programmers to ignore many details of the specific CPU that will execute the program. It also provides other important services, including the following:
The Microsoft .NET Framework is a software framework available with several Microsoft Windows operating systems. It includes a large library of coded solutions to prevent common programming problems and a virtual machine that manages the execution of programs written specifically for the framework. The .NET Framework is a key Microsoft offering and is intended to be used by most new applications created for the Windows platform.
The framework's Base Class Library provides a large range of features including user interface, data and data access, database connectivity, cryptography, web application development, numeric algorithms, and network communications. The class library is used by programmers, who combine it with their own code to produce applications.
Programs written for the .NET Framework execute in a software environment that manages the program's runtime requirements. Also part of the .NET Framework, this runtime environment is known as the Common Language Runtime (CLR). The CLR provides the appearance of an application virtual machine so that programmers need not consider the capabilities of the specific CPU that will execute the program. The CLR also provides other important services such as security, memory management, and exception handling. The class library and the CLR together compose the .NET Framework.
Version 3.0 of the .NET Framework is included with Windows Server 2008 and Windows Vista. The current version of the framework can also be installed on Windows XP and the Windows Server 2003 family of operating systems.[2] A reduced "Compact" version of the .NET Framework is also available on Windows Mobile platforms, including smartphones.