Current Location:Home - News - . NET News
|
|||
Published:2010.08.04 News Sources:admin Views: | |||
What is C #
C # is my idea in the past few months out of a new programming language. The aim is to generate type-safe code that can run at compile time or when injected (Inject) to a code base (Code Base) in the. C # 2.0 of its syntax is a superset. And other code generation techniques and tools (such as CodeSmith, a great tool / language) different, G # do not intend to build as a starting point (Starting Point) or for consumption (Consumption) code. Instead, C # using aspect-oriented programming (AOP) technology to the client code into the code. We will quickly introduce AOP, because it is still a lot of new developers.
AOP
AOP, or aspect-oriented software development (AOSD) in 1997, created in the Xerox Parc, is a relatively sophisticated software model (Paradigm). The idea is simple, by allowing developers to focus on one issue of a time domain to reduce the complexity of software development. In other words, people try to solve a business problem (such as selling products on the Internet) without having to consider safety, threads, logging, data access and other areas. This is called separation of concerns (Separation of Concerns). By separating these areas or aspects of a particular expert in the area can be developed to solve the problem the best solution, so developers do not go to master all of the industry. This is expected to generate robust and functional software, because developers only need to do a "software problem domain" experts.
AOP by definition (ie a behavior) to start, and then injected into the code in the appropriate way to go. Each code injection points is called a point of integration (Join Point). Let us take the safety as an example. "All input is evil" is a mantra the security sector (Mantra, spell). Confront this problem of a practice that requires all developers to write code before the data should be used to check for malicious input. Developers are likely to develop an auxiliary method to solve this problem, then all the developers in their code will simply call the helper method. AOP can solve this problem, it is these same assisted extraction method and create a connection, and then injected into the need for user input to check the place. This process is called scheduling (Weaving). We do not simply define a will receive the "evil input" of the location of the list, but will be used defined a set of standard (Criteria). As such, we hope that the outside area will be filled except with the parameters of all the public properties, methods, and constructors. Compared to create a list, this has the advantage that developers are no longer with their memory to enter will need to check the method to add to the list.
For you are familiar with AOP languages such as AspectJ, G # and not a separate document layout: layout which is integrated into the grammar. For most programmers, other people can inject code into their code base, this is undoubtedly an easy panic recommendations. To solve this problem, G # contains a security to deal with this problem model, and allows the programmer to control who can inject code, and what kind of code can be injected, which will be discussed later on. In-depth before we look at some basic elements:
Basis
public class Client ( public Client () ( Messenger ("Hello World"); )
private void Messenger (string message) ( Console.WriteLine (message); ) )
public generator Rename ( static generation ChangeIt: target Client.Messenger (string message) ( pre ( string oldMessage = message; message = "Hello G #"; )
post ( message = oldMessage; ) ) )
Although this example has no purpose, but it demonstrates the G # of a lot of features. First, Client class uses the standard C # syntax - which is valid in G #, it is simply a message to the console output "Hello World". This class defines the following is the G # in the new language construct, called a generator (Generator). Now just think of all generators used to define the "how to generate code" of the code of the container can be, This class (Class) similar. Rename is the generator's name, as if Client is the name of the same class. Next, define a named ChangeIt generation (Generation). Generation and methods similar to each call it will perform some action, unlike when the call will usually produce generated code. Note ChangeIt have a goal (Target), here is the Messenger from the Client class method. Target can be any (language) structure, and also can include wildcards and regular expressions to specify a group of projects as the target. This means that issued by the generation (Emit) of all of the code will be injected into the Messenger method. Keyword pre braces behind it provides all of the code defined |
|||
This Paper Is Divided Into 1 Page | |||
|
|||