当使用TFS作为源代码控制时,是否可以在Visual Studio中获取特定代码行的历史记录?
在我使用其他源代码控制(Vault)之前,我能够获取代码行的历史记录并检查是谁添加/修改了它.看起来TFS缺乏这样的功能.是否有任何报告工具可以做到这一点.
我正在使用Visual Studio 2010和TFS 2010.
我需要在反序列化后初始化私有只读字段.我有以下DataContract:
[DataContract]
public class Item
{
public Item()
{
// Constructor not called at Deserialization
// because of FormatterServices.GetUninitializedObject is used
// so field will not be initialized by constructor at Deserialization
_privateReadonlyField = new object();
}
// Initialization will not be called at Deserialization (same reason as for constructor)
private readonly object _privateReadonlyField = new object();
[DataMember]
public string SomeSerializableProperty { get; set; }
[OnDeserializing]
public void OnDeserializing(StreamingContext context)
{
// With this line code even not compiles, since …Run Code Online (Sandbox Code Playgroud) 我使用Automapper.我有两个类:具有单个属性的TypeA; TypeB有两个属性,其中一个有私有的setter,这个属性的值是通过构造函数传递的.TypeB没有默认构造函数.
问题:是否可以配置Automapper将TypeA转换为TypeB.
public class TypeA
{
public string Property1 { get; set; }
}
public class TypeB
{
public TypeB(int contextId)
{ ContextId = contextId; }
public string Property1 { get; set; }
public int ContextId { get; private set; }
}
public class Context
{
private int _id;
public void SomeMethod()
{
TypeA instanceOfA = new TypeA() { Property1 = "Some string" };
// How to configure Automapper so, that it uses constructor of TypeB
// and passes …Run Code Online (Sandbox Code Playgroud) 在我的项目中,我需要同时使用Castle.Windsor和Moq dll.Windsor要求Castle.Core也在项目中引用.
当我尝试使用Castle.Core中的方法时问题开始:
Castle.DynamicProxy.Generators.AttributesToAvoidReplicating.Add(...);
问题1: 如果我使用NET40文件夹中的Moq.dll,我得到了错误"类型'Castle.DynamicProxy.Generators.AttributesToAvoidReplicating'存在于'...\Windsor\dotNet40\Castle.Core.dll'和'..\MOQ\NET40\Moq.dll'"
问题2: 如果我使用"NET40-RequiresCastle"文件夹中的Moq.dll,这在逻辑上是我的情况,我得到版本冲突 - Moq.dll使用Castle.Core,Version = 2.5.0.0,但Windsor使用Castle.Core,Version = 2.5.1.0
我有两个Data类:BaseDataClass和DerivedDataClass,它们派生自第一个.我还有两个Consuming类:ConsumingBaseClass和ConsumingDerivedClass,它们派生自第一个.在ConsumingBaseClass中,我有虚拟方法DoWork,它接受DerivedDataClass并做一些工作.
在ConsumingDerivedClass中,我对方法DoWork进行了覆盖,并且我对DoWork也有重载,它接受BaseDataClass.当我尝试调用DoWork的,路过的实例DerivedDataClass,DoWork的(BaseDataClass)被称为替代的DoWork(DerivedDataClass) .
有什么想法,为什么叫错方法?
以下代码阐述了问题:
class Program
{
private static void Main(string[] args)
{
ConsumingDerivedClass x = new ConsumingDerivedClass();
// Wrong DoWork is called - expected calling of DoWork(DerivedDataClass) but actually called DoWork(BaseDataClass)
x.DoWork(new DerivedDataClass());
Console.ReadKey();
}
}
public class ConsumingBaseClass
{
public virtual void DoWork(DerivedDataClass instance)
{
Console.WriteLine("ConsumingBaseClass.DoWork(DerivedDataClass); Type of …Run Code Online (Sandbox Code Playgroud)