first, the definition of T4 template and the generation of code files
Let's take a look at what the final code generation needs to define, and how the T4 template should be defined. For this framework, the generation of code structures is implemented by inheriting custom types from our custom base class
Microsoft Visual Studio contains a code generation engine called the T4 (abbreviation for the text Template Conversion Toolkit). You may have used the T4 template in Visual Studio, and you don't even know that the templates are already working in the background. In this article, I'll briefly introduce the
Background
I need to write some extension methods for these numeric types, int, long, float, and so on. But I found that they were not an inheritance system, and my first thought was to repeat the extension method for each type, which made me feel very uncomfortable, but I reluctantly wrote that when int and long were finished, I suddenly felt that I could get T4 to write for me, and that C # supported some classes, and it was even better.
Implement
In Entity Framework 4.0, Poco (simple traditional CLR object/plain old CLR object) is supported, so that we can focus on business logic and perform unit tests more effectively. poco does not need to inherit from the default EF entity, so it can be switched more flexibly.
This article describes how to automatically generate poco and replace the entity generated by EF to separate the two.
Download and install the POCO entity generator
This document uses the T4
that the file path here is the true path to your hard drive, unless you place the TXT file in the same directory as the T4 generator.
Well understood, too?! {
stringNAMESTR =Reader.
ReadToEnd (); intindex = Namestr.lastindexof (','); NameStr= Namestr.substring (0, index); ItemCollection= Namestr.split (','); }
#>usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSyste
in the development process, many times we will write a lot of similar code, writing the code is regular, for example, we will generate the entity class according to the data table, likeEFThat way, the entity class is automatically generated from the table, if we write an application, read the database, and then generate a. CSclass file, this is relatively simple, if theVScan solve this problem, do not run a single execution program isHappy, thatT4is to do this thing. T4is atexttemplate Transform
Use EnvDTE add/remove multiple files to ProjectbyAdmin | décembre Un CommentaireProject SourceSource:envdtemanipulateLicence:mitEnvDTE is a assembly-wrapped COM library containing the objects and members for Visual Studio core automation.It ' s widely used in Visual Studio Plugins to provide ability manipulate Visual studio functionalities.By using the EnvDTE inside texttemplate, we can create a easy solution for massive file creation.UsageFirst you need include EnvDTE to TexttemplateAlso, need
ModelModelModelvar manager = Manager.create (Host, generationenvironment);foreach (DBTable dbtable in Dbhelper.getdbtables (config. ConnectionString, CONFIG. Dbdatabase)){String Item=dbtable.tablename;Manager. Startnewfile (item+ ". cs");#>//------------------------------------------------------------------------------This code is automatically generated by the T4 templateBuild Time Changes to this file may result in incorrect behavior, and ifRegenera
Friends who try to use T4 in the UWP may notice that the run-time T4 generated by the VS designer is not compiled by default because he uses some APIs that do not support UWP, the solution is simple, know to copy it, fix incompatible parts, specify the inherits parameter as the new base class, Here is a simple version that should also be optimized public class Formatterbase{private bool _endswithnewline;Pri
T4: Reverse Order
A [I] is the prefix and
Derivation (A [J]-A [I])/(J-I)> = m
A [J]-A [I]> = m (J-I)
A [J]-M * j> = A [I]-M * I
Set B [] = A []-M *();
B [J]> = B [I]
That is, reverse order;
There are two methods for reverse order query:
Merge and sort;
Tree array;
The following two methods are available:
1. Previously, only single-point modification and interval summation were used for tree arrays.
I always think lowbit is a magic thing (so far I hav
]/[emailprotected]/[emailprotected]/[email Protected]/[emailprotected]/[emailprotected],0:a File and args:-vmodule/platform/sun4v/kernel/sparcv9 /unix:text at [0x1000000, 0x10c1c1d] data at 0x1800000module/platform/sun4v/kernel/sparcv9/genunix:text at [0x10c1c20, 0X12A6B77] Data at 0x1935f40module/platform/sun4v/kernel/misc/sparcv9/platmod:text @ [0x12a6b78, 0x12a6b8f] data at 0x 198d598module/platform/sun4v/kernel/cpu/sparcv9/sparc-t4:text at [0x12a
[I] + G;
G = A. Num [I]/10;
A. Num [I] % = 10;
}
While (G> 0)
{
++ A. L;
A. Num [A. L] = g;
G/= 10;
}
Return;
}
Int main ()
{
Int K, W, I, j, N, Ma, NN, Lun, P, start;
Memset (ANS. Num, 0, sizeof (ANS. Num ));
Ans. L = 0;
For (P = 0; P
{
Memset (F [0] [p]. Num, 0, sizeof (F [0] [p]. Num ));
F [0] [p]. L = 0;
}
Cin> K> W;
N = 2;
For (I = 2; I
N * = 2;
-- N;
Lun = (W-1)/k + 1;
If (Lun
Cout
Else
{
MA = (W-1) % K + 1;
Nn = 2;
For
]);
For (j = 2; j
{
Scanf ("% d", UC. Num [J]);
For (k = UC. Num [J-1] + 1; k
{
++ UCC. L; UCC. Num [UCC. L] = K;
}
}
For (j = 1; j
For (k = 1; k
{
If (! Map [UCC. Num [k] [uc. Num [J])
{
Map [UCC. Num [k] [uc. Num [J] = true;
++ Bian [UCC. Num [k] [0];
Bian [UCC. Num [k] [Bian [UCC. Num [k] [0] = UC. Num [J];
++ R [uc. Num [J];
}
}
}
UC. L = 0;
For (I = 1; I
If (R [I] = 0)
{
++ UC. L;
UC. Num [uc. L] = I;
}
TOT = UC. L;
Ans = 1;
While (TOT
{
UCC. L = 0;
For (I = 1; I
For (j = 1; j
{
--
There are many ideas for this question. Here we only introduce one idea: the general idea of the Kruskal algorithm: First sorting, then using and querying the connected edge of the set,Final output maximum Edge Weight.Sort (E + 1, E + 1 + M, CMP); For (INT I = 1; I Q1: Why is Kruskal used in this question )? A1: you only need to determine whether each vertex is connected to $1 $ when the maximum spanning tree is generated. If yes, then his answer is the current edge (because the edge is arranged
Two sequential Series A B, the length of which is m,n, to find their median, requiring time complexity is O (log (m+n)).Interpretation: That is, the two series in order to merge the median number.Ideas1.mine: Two pointers i,j respectively to the head of two columns, when A[i]2.others: The number of k small, the core is when a[k/2-1]"My Code"Try to use the idea of writing code, when the end of the cycle, to consider the situation is simply too much, the division is not clear!Because when M+n is a
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.