public SPDeploymentObjectType GetTypeFromUrl(string url)
{
using (SPSite site = new SPSite(url))
{
if (url.Equals(site.Url, StringComparison.OrdinalIgnoreCase))
return SPDeploymentObjectType.Site;
using (SPWeb web = site.OpenWeb())
{
if (url.Equals(web.Url, StringComparison.OrdinalIgnoreCase))
return SPDeploymentObjectType.Web;
SPList list = web.GetList(url);
if (list != null)
{
string objRelativeUrl = url.Substring(web.Url.Length + 1);
if (objRelativeUrl.Equals(list.RootFolder.Url, StringComparison.OrdinalIgnoreCase))
return SPDeploymentObjectType.List;
}
object obj = web.GetObject(url);
if (obj is SPFile)
return SPDeploymentObjectType.File;
else if (obj is SPFolder)
return SPDeploymentObjectType.Folder;
else if (obj is SPListItem)
return SPDeploymentObjectType.ListItem;
}
}
return SPDeploymentObjectType.Invalid;
}
|