CommonUtility

Tags: sharepoint moss Description The Microsoft.Office.Server.Utilities.CommonUtility sealed class provides one static method, ExpandUrlTokens. ExpandUrlTokens is primarily used for SharePoint tokenized URL string cleaning internally by SharePoint. The ExpandUrlTokens method consumes 4 parameters: the source URL, the site collection relative URL, the web relative URL, and the web locale name.

This Post Details Content That I Have Written Regarding The SharePoint API On MSDN. The Full Article Will Have These Contents As Annotations Of The Full Article.

I Encourage You To Read The Full MSDN Class Documentation, Since Things Like Type Hierarchy Are Illustrated.

Adam Buenz – WSS MVP – Community Content From Annotations edited by Adam Buenz – MVP:

Tags: sharepoint moss Description The Microsoft.Office.Server.Utilities.CommonUtility sealed class provides one static method, ExpandUrlTokens. ExpandUrlTokens is primarily used for SharePoint tokenized URL string cleaning internally by SharePoint. The ExpandUrlTokens method consumes 4 parameters: the source URL, the site collection relative URL, the web relative URL, and the web locale name.

Read All Of This MSDN Community Content: CommonUtility

Share

Getting Some SharePoint Object URL’s In C#

There have been some questions posted in the SharePoint development newsgroups about how to appropriately get some object URL’s in SharePoint.

Here are some examples:

[csharp]

public string GetListUrl(SPList oList)
{
if (oList.DefaultView == null)
{
return oList.ParentWeb.Url;
}
return (oList.ParentWeb.Url + “/” + oList.DefaultView.Url);
}

public string GetWebUrl(SPWeb oWeb)
{
return oWeb.Url;
}

private string GetCurRequestUrl()
{
string l_strCurRequest = this.Page.Request.Url.AbsoluteUri;
if (l_strCurRequest.IndexOf(“/”, 8) >= 0)
{
l_strCurRequest = l_strCurRequest.Substring(0, l_strCurRequest.IndexOf(“/”, 8));
}
return l_strCurRequest;
}

[/csharp]

Pretty simple, but there were some questions about it.

Share

Get Locale From SPWeb URL

So I was working today on a some code where I was passing in the URL as a parameter and needed to harvest the locale so that I could get the culture information, the WebPart was going to be involved with a geo-deployment. Here is the code to accomplish that:

[csharp]

public static CultureInfo GetLocale(string url)
{
SPWeb web = GetWeb(url);
CultureInfo locale = web.Locale;
web.Close();
web.Dispose();
return locale;
}

[/csharp]

Notice that you should take into account of disposing of the relevant objects that you are using!

The helper method that you see in the above is just a static wrapper that is called when I want to return a SharePoint Web, as opposed to having to re-code it each time. I keep it in a generic class library.

[csharp]

public static SPWeb GetWeb(string url)
{
SPSite site = new SPSite(url);
return site.OpenWeb();
}

[/csharp]

Happy geo-developing (that should be a word).

Share