我按照如何:创建多项目模板文章来创建一个模板,该模板将生成包含4个项目的解决方案.我的Root.vstemplate文件包含以下内容
<VSTemplate Version="2.0.0" Type="ProjectGroup"
xmlns="http://schemas.microsoft.com/developer/vstemplate/2005">
<TemplateData>
<Name>Yugasat BeyondAdmin</Name>
<Description>The Yugasat BeyondAdmin Project Template</Description>
<Icon>Icon.ico</Icon>
<ProjectType>CSharp</ProjectType>
</TemplateData>
<TemplateContent>
<ProjectCollection>
<ProjectTemplateLink ProjectName="PresentationLayer">
PresentationLayer\MyTemplate.vstemplate
</ProjectTemplateLink>
<ProjectTemplateLink ProjectName="BusinessLogicLayer">
BusinessLogicLayer\MyTemplate.vstemplate
</ProjectTemplateLink>
<ProjectTemplateLink ProjectName="BusinessLogicLayerAPI">
BusinessLogicLayerAPI\MyTemplate.vstemplate
</ProjectTemplateLink>
<ProjectTemplateLink ProjectName="DataAccessLayer">
DataAccessLayer\MyTemplate.vstemplate
</ProjectTemplateLink>
</ProjectCollection>
</TemplateContent>
Run Code Online (Sandbox Code Playgroud)
我将模板复制到[drive]:\Users\[user]\Documents\Visual Studio 2013\Templates\ProjectTemplates\文件夹中.问题是模板未列为多项目模板

所以我可以创建单个项目,但不是包含所有4个项目的解决方案.我的模板文件夹的内容如下

我不知道如何解决我的问题.我不时会收到错误:"进程无法访问文件'xxxx',因为它正被另一个进程使用".
这是我发生错误的方法:
private static void write_history(int index, int time_in_sec, int[] sent_resources)
{
string filepath = "Config\\xxx.txt";
int writing_index = 0;
if (File.Exists(filepath))
{
System.Threading.Thread.Sleep(5000);
StreamReader reader = new StreamReader(new FileStream(filepath, FileMode.Open, FileAccess.Read, FileShare.Read));
string temp = reader.ReadToEnd();
reader.Close();
for (int i = 0; i < 20; i++)
{
if (temp.IndexOf("<hst_" + i.ToString() + ">") == -1)
{
writing_index = i;
break;
}
}
}
System.Threading.Thread.Sleep(5000);
// write to the file
StreamWriter writer = new StreamWriter(filepath, true);
writer.WriteLine("<hst_" + writing_index.ToString() + …Run Code Online (Sandbox Code Playgroud) 如何使AutoMapper将缺少的未映射属性映射到目标对象内的字典?(类似于序列化期间的ExtensionData)
例:
class Source
{
public int A {get;set;}
public int B {get;set;}
public int C {get;set;}
}
class Destination
{
public int A {get;set;}
public Dictionary<string, object> D {get;set;}
}
Source s = new Source { A = 1, B = 2, C = 3 };
Destination d = ... // Mapping code
Run Code Online (Sandbox Code Playgroud)
现在我想要以下结果:
d.A ==> 1
d.D ==> {{ "B", 2 }, { "C", 3 }}
Run Code Online (Sandbox Code Playgroud)
*编辑*
最后,我正在寻找一种无反射的解决方案。含义:在设置/配置/初始化期间允许反射,但是在映射本身期间,我不希望反射引起任何延迟。
*编辑*
我正在寻找一种通用的解决方案,就像序列化程序一样。
如果我要翻译这个匿名方法:
Func<int, int> f = delegate(int i)
{
return i + 1;
};
Run Code Online (Sandbox Code Playgroud)
进入lambda表达式,它会这样:
Func<int, int> f = i => i + 1;
Run Code Online (Sandbox Code Playgroud)
(我知道:这个lambda表达式将秘密生成另一个匿名方法(由编译器),但这不是重点).
现在我想将以下方法转换为lambda表达式:
Func<int, int> f = delegate(int i)
{
Debug.WriteLine("Inside the function!");
return i + 1;
};
Run Code Online (Sandbox Code Playgroud)
有办法吗?我该怎么做?
public void AddEmployee<T> (T employee) where T : Employee
{
//some code here
}
Run Code Online (Sandbox Code Playgroud)
但如果我这样写
public void AddEmployee (Employee Employee)
{
// Code here
}
Run Code Online (Sandbox Code Playgroud)
同样的,
public class GenericList<T> where T : Employee
Run Code Online (Sandbox Code Playgroud)
和
public class GenericList<Employee>
Run Code Online (Sandbox Code Playgroud)
我认为两者之间没有任何区别.我明白当有接口作为派生约束时
public class GenericList<T> where T : IComparable, IConvertible
Run Code Online (Sandbox Code Playgroud)
但是如果使用了子类(如上面的员工那样),那对我来说没有意义.我在这里错过了什么吗?请解释
我有以下数据表:
A B
=== ===
M 2
M 3
M 5
N 5
N 2
O 6
P 13
P 7
P 9
P 11
P 3
Run Code Online (Sandbox Code Playgroud)
现在我需要一个PIVOT(?)查询:
结果将是:
A B1 B2 B3
=== ==== ==== ====
M 2 3 5
N 2 5 null
O 6 null null
P 3 7 9
Run Code Online (Sandbox Code Playgroud)
到目前为止,我一直在尝试用TOP,GROUP BY,PIVOT创建查询.我认为最好的方法是使用PIVOT,但由于我没有值,我可以用作列名,我被卡住了.此外,对这些值进行前3选择似乎也非常具有挑战性.
*编辑*
它们是A列和B列的唯一约束,因此B的值对于相同的A始终是唯一的.
我正在摸不着头脑的例子是C#In Depth,3rd Edition,pg.85,清单3.9,开头就像
public class Outer<T>
{
public class Inner<U,V>
{
static Inner()
{
Console.WriteLine("Outer<{0}>.Inner<{1},{2}>",
typeof(T).Name,
typeof(U).Name,
typeof(V).Name);
}
public static void DummyMethod() { }
}
}
Run Code Online (Sandbox Code Playgroud)
什么是回报值Inner?是否未指定并解释为void?