简体   繁体   English

SharePoint API:2003年与2007年对比

[英]SharePoint API: 2003 vs 2007

I have coded a solution that uses the 2007 API to traverse the SharePoint object model. 我已经编写了使用2007 API遍历SharePoint对象模型的解决方案。 Now I need to support SP 2003 as well. 现在,我还需要支持SP 2003。 What is the best way to do this? 做这个的最好方式是什么?

Is it possible / recommended to use the 2007 api to get access to a 2003 SharePoint Farm? 是否可以/建议使用2007 API来访问2003 SharePoint Server?

If I use the 2007 api, do I have to use the deprecated classes to (for instance) reference a configuration database, or do I use the 2007 classes, such as SPFarm? 如果使用2007 API,是否必须使用不推荐使用的类来(例如)引用配置数据库,还是使用2007年的类(例如SPFarm)?

Or do I use the 2007 API for SP 2007 and the 2003 API for SP 2003...? 还是使用SP 2007的2007 API和SP 2003的2003 API ...? Problem with this is that both use the same namespaces and class names. 问题在于两者都使用相同的名称空间和类名称。 So it can get messy. 这样会变得凌乱。 (Except maybe if I use aliases to reference the different namespaces?) (除非我是否使用别名来引用不同的名称空间?)

As far I know the 2007 API and the 2003 API are incompatible. 据我所知,2007 API和2003 API不兼容。 So yes? 是吗 you will need to implement both. 您将需要同时实现。

I can suggest to have interface ISharePointAPI and two implementations SharePoint2007API and SharePoint2003API. 我可以建议使用接口ISharePointAPI和两个实现SharePoint2007API和SharePoint2003API。 This implementations can even be packaged to different assemblies, so you will not have reference hell :). 该实现甚至可以打包到不同的程序集中,因此您将没有参考地狱:)。 This is will also protect you from 2010 API changes as what you will need is to implement SharePoint2010API... 这也将保护您免受2010 API更改的影响,因为您需要实现SharePoint2010API。

The interfaces are (mostly) compatible in a namespace/class/member USAGE but you have to use the right version of the API for the correct version of SharePoint. 这些接口(大多数)在名称空间/类/成员USAGE中兼容,但是对于正确的SharePoint版本,必须使用正确版本的API。 You also have to consider that by WSS2/SPS2003 uses .NET1.1 by default. 您还必须考虑到WSS2 / SPS2003默认情况下使用.NET1.1。

My solution to this is to use MSBEE and some MSBUILD ninja moves to spit out two versions from your source code. 我的解决方案是使用MSBEE和一些MSBUILD ninja动作从源代码中吐出两个版本。

The first targets .NET2 and references Microsoft.SharePoint.dll v12 (WSS3/MOSS2007) and the second targets .NET1.1 and references Microsft.Sharepoint.dll v11 (WSS2/SPS2003). 第一个目标是.NET2,引用Microsoft.SharePoint.dll v12(WSS3 / MOSS2007),第二个目标是.NET1.1,引用Microsft.Sharepoint.dll v11(WSS2 / SPS2003)。

Its quite a faf to setup but works very well after that. 它相当受欢迎,但之后效果很好。 Where you do have code differences you can use conditional compilation :- 如果确实存在代码差异,则可以使用条件编译:

#if FX1_1
   // WSS2/SPS2003 specific code
#else
   // WSS3/MOSS2007 specific code
#endif

This article gives a little more detail. 本文提供了更多细节。 Its a big topic and I've been meaning to write a blog post with some tip. 这是一个大话题,我一直想写一些提示的博客文章。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM