public virtual void WriteDetail(PropertyData detail, XmlTextWriter writer) { using (ElementWriter detailElement = new ElementWriter("property", writer)) { detailElement.WriteAttribute("name", detail.Name); detailElement.WriteAttribute("typeName", detail.Value.GetType().GetTypeAndAssemblyName()); if (detail is ObjectProperty) { string base64representation = detail.Value.ToBase64String(); detailElement.Write(base64representation); } else if (detail.ValueType == typeof(ContentItem)) { detailElement.Write(((LinkProperty) detail).LinkedItem.ID.ToString()); } else if (detail.ValueType == typeof(string))//was detail.Value a typo? { string value = ((StringProperty) detail).StringValue; if (!string.IsNullOrEmpty(value)) detailElement.WriteCData(value); } else if (detail.ValueType == typeof(DateTime)) { detailElement.Write(ElementWriter.ToUniversalString(((DateTimeProperty) detail).DateTimeValue)); } else { detailElement.Write(detail.Value.ToString()); } } }
protected virtual void WriteChild(XmlTextWriter writer, ContentItem child) { using (ElementWriter childElement = new ElementWriter("child", writer)) { childElement.WriteAttribute("id", child.ID); } }
protected virtual void WriteRule(XmlTextWriter writer, LanguageSetting ls) { using (ElementWriter role = new ElementWriter("setting", writer)) { role.WriteAttribute("language", ls.Language); role.WriteAttribute("fallbackLanguage", ls.FallbackLanguage); } }
protected virtual void WriteDetailCollection(XmlTextWriter writer, PropertyCollection collection) { using (ElementWriter collectionElement = new ElementWriter("collection", writer)) { collectionElement.WriteAttribute("name", collection.Name); foreach (PropertyData detail in collection.Details) WriteDetail(detail, writer); } }
protected virtual void WriteRule(XmlTextWriter writer, AuthorizationRule ar) { using (ElementWriter role = new ElementWriter("rule", writer)) { role.WriteAttribute("operation", ar.Operation); role.WriteAttribute("role", ar.Role); role.WriteAttribute("user", ar.User); role.WriteAttribute("allowed", ar.Allowed); } }
public virtual void WriteSingleItem(ContentItem item, ExportOptions options, XmlTextWriter writer) { using (ElementWriter itemElement = new ElementWriter("item", writer)) { WriteDefaultAttributes(itemElement, item); foreach (IXmlWriter xmlWriter in GetWriters(options)) xmlWriter.Write(item, writer); } }
public virtual void Export(ContentItem item, ExportOptions options, TextWriter output) { XmlTextWriter xmlOutput = new XmlTextWriter(output); xmlOutput.Formatting = XmlFormatting; xmlOutput.WriteStartDocument(); using (ElementWriter envelope = new ElementWriter("zeus", xmlOutput)) { envelope.WriteAttribute("version", GetType().Assembly.GetName().Version.ToString()); envelope.WriteAttribute("exportVersion", 1); envelope.WriteAttribute("exportDate", DateTime.Now); itemWriter.Write(item, options, xmlOutput); } xmlOutput.WriteEndDocument(); xmlOutput.Flush(); }
protected virtual void WriteDefaultAttributes(ElementWriter itemElement, ContentItem item) { itemElement.WriteAttribute("id", item.ID); itemElement.WriteAttribute("name", item.Name); itemElement.WriteAttribute("parent", item.Parent != null ? item.Parent.ID.ToString() : string.Empty); itemElement.WriteAttribute("title", item.Title); if (item is WidgetContentItem) itemElement.WriteAttribute("zoneName", ((WidgetContentItem) item).ZoneName); itemElement.WriteAttribute("created", item.Created); itemElement.WriteAttribute("updated", item.Updated); itemElement.WriteAttribute("published", item.Published); itemElement.WriteAttribute("expires", item.Expires); itemElement.WriteAttribute("sortOrder", item.SortOrder); //itemElement.WriteAttribute("url", parser.BuildUrl(item)); itemElement.WriteAttribute("visible", item.Visible); itemElement.WriteAttribute("savedBy", item.SavedBy); itemElement.WriteAttribute("language", item.Language); itemElement.WriteAttribute("translationOf", (item.TranslationOf != null) ? item.TranslationOf.ID.ToString() : string.Empty); itemElement.WriteAttribute("typeName", item.GetType().GetTypeAndAssemblyName()); itemElement.WriteAttribute("discriminator", definitions.GetContentType(item.GetType()).Discriminator); }