本文整理汇总了C#中IContent.GetPropertyValues方法的典型用法代码示例。如果您正苦于以下问题:C# IContent.GetPropertyValues方法的具体用法?C# IContent.GetPropertyValues怎么用?C# IContent.GetPropertyValues使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IContent
的用法示例。
在下文中一共展示了IContent.GetPropertyValues方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateXml
/// <summary>
/// The generate xml.
/// </summary>
/// <param name="page">
/// The page.
/// </param>
/// <returns>
/// The <see cref="string"/>.
/// </returns>
public static string GenerateXml(IContent page)
{
if (page == null)
{
return string.Empty;
}
XDocument xDocument = new XDocument(new XDeclaration("1.0", "utf-8", "yes"), new object[0]);
XElement xElement = new XElement("content");
xElement.SetAttributeValue("name", XmlConvert.EncodeName(page.Name));
List<KeyValuePair<string, string>> propertyValues = page.GetPropertyValues();
foreach (KeyValuePair<string, string> content in propertyValues)
{
XElement xElement3 = new XElement(XmlConvert.EncodeName(content.Key));
xElement3.SetValue(TextIndexer.StripHtml(content.Value, content.Value.Length));
xElement.Add(xElement3);
}
xDocument.Add(xElement);
return xDocument.ToString();
}
示例2: GenerateJson
/// <summary>
/// Generate the json output for the page.
/// </summary>
/// <param name="page">
/// The page.
/// </param>
/// <returns>
/// The <see cref="string"/>.
/// </returns>
public static string GenerateJson(IContent page)
{
string json;
List<KeyValuePair<string, string>> propertyValues = page.GetPropertyValues();
StringBuilder stringBuilder = new StringBuilder();
using (StringWriter sw = new StringWriter(stringBuilder, CultureInfo.InvariantCulture))
{
JsonWriter jsonWriter = new JsonTextWriter(sw) { Formatting = Formatting.Indented };
jsonWriter.WriteStartObject();
jsonWriter.WritePropertyName(page.Name);
jsonWriter.WriteStartObject();
foreach (KeyValuePair<string, string> content in propertyValues)
{
jsonWriter.WritePropertyName(content.Key);
jsonWriter.WriteValue(TextIndexer.StripHtml(content.Value, content.Value.Length));
}
jsonWriter.WriteEndObject();
jsonWriter.WriteEndObject();
json = sw.ToString();
}
return json;
}
示例3: GenerateTxt
/// <summary>
/// Generates the TXT.
/// </summary>
/// <param name="page">The page.</param>
/// <returns>
/// The <see cref="string" />.
/// </returns>
public static string GenerateTxt(IContent page)
{
if (page == null)
{
return string.Empty;
}
StringBuilder contentString = new StringBuilder();
contentString.AppendLine(page.Name);
contentString.AppendLine();
List<KeyValuePair<string, string>> propertyValues = page.GetPropertyValues();
foreach (KeyValuePair<string, string> content in propertyValues)
{
contentString.AppendLine(TextIndexer.StripHtml(content.Value, content.Value.Length));
contentString.AppendLine();
}
return contentString.ToString();
}