나는이 시도하지 않은, 어쩌면 그것은 작동 할 수 있습니다
public enum VisualStudioVersion
{
Unknown,
VS2010,
VS2012,
VS2013,
VS14
}
public class VsSpecificExportAttribute : ExportAttribute
{
// the place for this is not right,
// but you can figure this out on your own.
private static VisualStudioVersion _currentVisualStudioVersion =
VisualStudioVersion.VS2013;
class DummySentil{}
public VsSpecificExportAttribute(Type typeToExport,
VisualStudioVersion visualStudioVersion)
: base(visualStudioVersion == _currentVisualStudioVersion ?
typeToExport : typeof(DummySentil))
{
}
}
는 다음 사용할 수 그것으로;
[VsSpecificExport(typeof(IWpfTextViewCreationListener), VisualStudioVersion.VS14)]
public class MyTextViewCreationListener: IWpfTextViewCreationListener
{
}
기본이되는 아이디어는 우리가 "비주얼 스튜디오 버전"올바른에있는 wheenever은 "VsSpecificExport은"속성이 결정하는 것입니다, 우리가하지 않은 경우, 우리는 절대적으로 아무것도하지 않는다 "DummySentil"클래스를 내보낼 예정 아무도 사용하지 않습니다.
참고로, 이것은 @ JaredPar가 VsVim에서 Proxy 대신 Factory를 사용하는 것과 비슷합니다. - ISharedService 인터페이스와 [SharedServiceFactory.cs] (https://github.com/jaredpar/VsVim/blob)가 있습니다. /848f333b942eaa2ddde2cbfb08362d03d0491f7a/Src/VsVimShared/Implementation/SharedService/SharedServiceFactory.cs) 모든 다른 구현을 '가져오고'VS 버전별로 올바른 것을 선택합니다. –