Immediacy : Useful C# Code Snippets

Create a URL For A Page


Getting the Editor Url

InstallInfo ii = new InstallInfo(InstallInfo.GetLatestVersion());
string s = ii.EditVirtDir;
Called from immediacy.Configuration;

Get IMC Inforamtion

iSession session = new iSession();
ImcFile imc = session.ImcFile;

Get Current Page Id

Immediacy.Web.ImmHttpContext.Current.ContentPage.ID = Current Page ID

Get A Site Option

ISiteOptions options = Immediacy.Configuration.SiteOptions.Instance;
SiteOptionGroup Option1 = options["SiteOptionsName"];

Declaring a Plug-in

using Immediacy.Web;
[PluginDesigner(PluginDesignerType.None, "")]
[PluginInfo("Profile Search Advanced", "Profile", Description = "Advanced Profile Search")]

Adding A Page Via The API

public int ImmediacyAddPage(string PageContent, int submit, int parentPageID)
Hashtable queryStr = new Hashtable();
queryStr.Add("command", "AddPage");
queryStr.Add("site", _siteTitle);
queryStr.Add("devTag", "devTag");
queryStr.Add("parent", parentPageID);
queryStr.Add("content", HttpUtility.UrlEncode(PageContent));
queryStr.Add("submitforapproval", submit);
string Response = Helpers.PostWebResponse(_apiLocation, queryStr);
XPathDocument ResponseDoc = new XPathDocument(new StringReader(Response));
XPathNavigator ResponseNav = ResponseDoc.CreateNavigator();
if (ResponseNav.SelectSingleNode("/fault") != null)
LogMessage("ContentProvider:ImmediacyAddPage() : Error " + ResponseNav.SelectSingleNode("/fault/faultstring").Value + " " + ResponseNav.SelectSingleNode("/fault/detail").Value + " " + PageContent);
return -1;
XPathNavigator PageIDNav = ResponseNav.SelectSingleNode("/AddPageResponse/AddPageResult/PageID");
LogMessage("ContentProvider:ImmediacyAddPage() : Success ");
return PageIDNav.ValueAsInt;
public void Validate(string pageContent)
XmlReaderSettings settings = new XmlReaderSettings();
settings.ValidationType= ValidationType.Schema;
settings.Schemas.Add(XmlSchema.Read(new StringReader(Resources.PageSchema), new ValidationEventHandler(OnValidate)));
XmlReader reader = XmlReader.Create(new StringReader(pageContent),settings);
while (reader.Read());

Jon D Jones

Software Architect, Programmer and Technologist Jon Jones is founder and CEO of London-based tech firm Digital Prompt. He has been working in the field for nearly a decade, specializing in new technologies and technical solution research in the web business. A passionate blogger by heart , speaker & consultant from England.. always on the hunt for the next challenge

More Posts

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *