public XWikiObject ToRcpObject() { XWikiObject obj = new XWikiObject(); obj.id = this.id; obj.pageId = this.PageId; obj.objectDictionary = new CookComputing.XmlRpc.XmlRpcStruct(); obj.objectDictionary.Add("annotation", this.AnnotationText); obj.objectDictionary.Add("date", this.Date); obj.objectDictionary.Add("author", this.Author); obj.objectDictionary.Add("originalSelection", this.OriginalSelection); obj.objectDictionary.Add("selection", this.Selection); obj.objectDictionary.Add("selectionRightContext", this.SelectionRightContext); obj.objectDictionary.Add("selectionLeftContext", this.SelectionLeftContext); obj.objectDictionary.Add("state", this.State); obj.objectDictionary.Add("target", this.Target); return obj; }
public static Annotation FromRpcObject(XWikiObject obj) { Annotation annotation = new Annotation(); annotation.AnnotationText = (string) obj.objectDictionary["annotation"]; annotation.Author = (string) obj.objectDictionary["author"]; annotation.Date = (DateTime)obj.objectDictionary["date"]; annotation.OriginalSelection = (string) obj.objectDictionary["originalSelection"]; annotation.Selection = (string) obj.objectDictionary["selection"]; annotation.SelectionRightContext = (string) obj.objectDictionary["selectionRightContext"]; annotation.SelectionLeftContext = (string) obj.objectDictionary["selectionLeftContext"]; annotation.State = (string) obj.objectDictionary["state"]; annotation.Target = (string) obj.objectDictionary["target"]; annotation.Id = obj.id; annotation.PageId = obj.pageId; return annotation; }
/// <summary> /// Creates a <code>SSXManager</code> from the cleaned HTML of a local editing page. /// </summary> /// <param name="pageConverter">An instance of the <code>ConversionManager</code> for this page.</param> /// <param name="cleanHTML">Cleaned HTML of the local page.</param> /// <returns>An instance of a <code>SSXManager</code>.</returns> public static SSXManager BuildFromLocalHTML(ConversionManager pageConverter, string cleanHTML) { SSXManager ssxManager = new SSXManager(); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(cleanHTML); XmlNodeList styleNodes = xmlDoc.GetElementsByTagName("style"); string pageCSSContent = ""; foreach (XmlNode styleNode in styleNodes) { pageCSSContent += styleNode.InnerText; } XmlRpcStruct dictionary = new XmlRpcStruct(); dictionary.Add("code", pageCSSContent); dictionary.Add("name", "XOfficeStyle"); dictionary.Add("use", "currentPage"); dictionary.Add("parse", "0"); dictionary.Add("cache", "forbid"); XWikiObject ssxObject = new XWikiObject(); ssxObject.className = SSX_CLASS_NAME; ssxObject.pageId = pageConverter.States.PageFullName; ssxObject.objectDictionary = dictionary; ssxManager.pageFullName = pageConverter.States.PageFullName; ssxManager.pageCSSContent = pageCSSContent; ssxManager.pageStyleSheetExtensions = new List<XWikiObject>(); ssxManager.pageStyleSheetExtensions.Add(ssxObject); ssxManager.pageConverter = pageConverter; return ssxManager; }
/// <summary> /// Updates a xwiki object. /// </summary> /// <param name="pageFullName">The full name of the page containing the object.</param> /// <param name="className">The class name of the object.</param> /// <param name="fieldsValues">Name-value pairs containig corespongin to the field names and values ov the object.</param> public void UpdateObject(string pageFullName, string className, System.Collections.Specialized.NameValueCollection fieldsValues) { XmlRpcStruct objectDictionary = new XmlRpcStruct(); foreach (string key in fieldsValues.Keys) { objectDictionary.Add(key, fieldsValues[key]); } XWikiObject obj = new XWikiObject(); obj.className = className; obj.objectDictionary = objectDictionary; obj.pageId = pageFullName; obj.guid = string.Empty; obj.prettyName = fieldsValues["name"]; obj = proxy.StoreObject(token, obj); }
/// <summary> /// Sets the "ExpectAndReturn" for "GetObject" method. /// The returned SSX object has: name='XOfficeStyle', use='onDemand', parse='0' and the 'code' is /// some CSS for '.xoffice0' class and '#id1" id. /// </summary> /// <param name="xWikiClientMock">A reference to a <code>DynamicMock</code>.</param> private static void SetObjForGetObject(ref DynamicMock xWikiClientMock) { XmlRpcStruct dictionary = new XmlRpcStruct(); dictionary.Add("code", CSS_CONTENT_XOFFICE0 + CSS_CONTENT_ID1); dictionary.Add("name", "XOfficeStyle"); dictionary.Add("use", "onDemand"); dictionary.Add("parse", "0"); XWikiObject xWikiObject = new XWikiObject(); xWikiObject.className = SSX_CLASS_NAME; xWikiObject.id = 1; xWikiObject.pageId = PAGE_FULL_NAME; xWikiObject.prettyName = "XOfficeStyle"; xWikiObject.objectDictionary = dictionary; xWikiClientMock.ExpectAndReturn("GetObject", xWikiObject, new object[3] { PAGE_FULL_NAME, SSX_CLASS_NAME, 1 }); }