本文整理汇总了C#中IContent类的典型用法代码示例。如果您正苦于以下问题:C# IContent类的具体用法?C# IContent怎么用?C# IContent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IContent类属于命名空间,在下文中一共展示了IContent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PagesController
/// <summary>
/// Initializes a new instance of the <b>PagesController</b> class.
/// </summary>
/// <param name="structureInfo">The structure info.</param>
/// <param name="currentPage">The current page.</param>
/// <param name="session">The session.</param>
/// <param name="content">The content.</param>
public PagesController(IStructureInfo structureInfo, IPageModel currentPage, IDocumentSession session, IContent content)
{
_structureInfo = structureInfo;
_currentPage = currentPage;
_session = session;
_content = content;
}
示例2: UmbracoDataMappingContext
/// <summary>
/// Initializes a new instance of the <see cref="UmbracoDataMappingContext"/> class.
/// </summary>
/// <param name="obj">The obj.</param>
/// <param name="content">The content.</param>
/// <param name="service">The service.</param>
public UmbracoDataMappingContext(object obj, IContent content, IUmbracoService service, bool publishedOnly)
: base(obj)
{
Content = content;
Service = service;
PublishedOnly = publishedOnly;
}
示例3: ListImpulses
public IEnumerable<IImpulse> ListImpulses(IContent content, string displayType, object data = null)
{
var impulses = new List<ImpulseDisplayContext>();
foreach (var impulse in GetDescriptors().Values) {
if (!CheckDescriptor(impulse, content, data)) {
continue;
}
int? versionId = null;
if (content.ContentItem.VersionRecord != null) versionId = content.ContentItem.VersionRecord.Id;
var display = new ImpulseDisplayContext(impulse) {
Content = content,
DisplayType = displayType,
Data = data,
HrefRoute = new RouteValueDictionary(new {
action = "Actuate",
controller = "Impulse",
area = "Downplay.Mechanics",
name = impulse.Name,
returnUrl = Services.WorkContext.HttpContext.Request.RawUrl,
contentId = content.Id,
contentVersionId = versionId
})
};
foreach (var e in impulse.DisplayingHandlers) {
e(display);
}
impulses.Add(display);
}
return impulses;
}
示例4: Serialise
public RuntimeContentModel Serialise(IContent content)
{
var publishedContent = _umbracoHelper.TypedContent(content.Id);
if (publishedContent == null)
return null;
var runtimeContent = Mapper.Map<RuntimeContentModel>(publishedContent);
runtimeContent.Url = RemovePortFromUrl(publishedContent.UrlWithDomain());
runtimeContent.RelativeUrl = publishedContent.Url;
runtimeContent.CacheTime = null;
runtimeContent.Type = publishedContent.DocumentTypeAlias;
runtimeContent.Template = publishedContent.GetTemplateAlias();
runtimeContent.Content = new Dictionary<string, object>();
foreach (var property in content.Properties)
{
if (!runtimeContent.Content.ContainsKey(property.Alias))
runtimeContent.Content.Add(property.Alias, property.Value);
}
foreach (var contentParser in _contentParsers)
{
runtimeContent = contentParser.ParseContent(runtimeContent);
}
RuntimeContext.Instance.ContentService.AddContent(runtimeContent);
return runtimeContent;
}
示例5: Write
public Task Write(IContent content, Stream outputStream)
{
if (content.Model != null)
{
var enumerable = content.Model as IEnumerable<object>;
if (enumerable != null)
{
WriteList(outputStream, enumerable);
}
else
{
var links = content.Links.ToList();
if (links.Count == 0)
{
new DataContractSerializer(content.Model.GetType()).WriteObject(outputStream, content.Model);
}
else
{
WriteWithLinks(content, outputStream, links);
}
}
}
return TaskHelper.Completed();
}
示例6: ItemInspector
public ItemInspector(IContent item, ContentItemMetadata metadata) {
_item = item;
_metadata = metadata;
_common = item.Get<ICommonAspect>();
_routable = item.Get<RoutableAspect>();
_body = item.Get<BodyAspect>();
}
示例7: Slugify
public string Slugify(IContent content)
{
var metadata = content.ContentItem.ContentManager.GetItemMetadata(content);
if (metadata == null) return null;
var title = metadata.DisplayText.Trim();
return Slugify(new FillSlugContext(content,title));
}
示例8:
void ILocalizationService.SetContentCulture(IContent content, string culture) {
var localized = content.As<LocalizationPart>();
if (localized == null || localized.MasterContentItem == null)
return;
localized.Culture = _cultureManager.GetCultureByName(culture);
}
示例9: 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();
}
示例10: ContentValueChangedActionItem
/// <summary>
/// Initializes a new instance of the <see cref="ContentValueChangedActionItem"/> class.
/// </summary>
/// <param name="name">The name of this action item.</param>
/// <param name="content">The <see cref="IContent"/> instance that has changed.</param>
/// <param name="index">The index of the change if the change occurred on an item of a collection. <c>null</c> otherwise.</param>
/// <param name="previousValue">The previous value of the content (or the item if the change occurred on an item of a collection).</param>
/// <param name="dirtiables">The dirtiable objects associated to this action item.</param>
public ContentValueChangedActionItem(string name, IContent content, object index, object previousValue, IEnumerable<IDirtiable> dirtiables)
: base(name, dirtiables)
{
this.Content = content;
PreviousValue = previousValue;
Index = index;
}
示例11: SetupViewModel
public void SetupViewModel(FrontendContext frontendContext, IContent node, NodeViewModel viewModel)
{
if (node.ContentItem.ContentType != "WikipediaPage") return;
viewModel.name = node.As<ITitleAspect>().Title;
viewModel.data["url"] = node.As<WikipediaPagePart>().Url;
}
示例12: 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;
}
示例13: UpdateEditorContext
public UpdateEditorContext(IShape model, IContent content, IUpdateModel updater, string groupInfoId, IShapeFactory shapeFactory, ShapeTable shapeTable, string path)
: base(model, content, groupInfoId, shapeFactory) {
ShapeTable = shapeTable;
Updater = updater;
Path = path;
}
示例14: GetMarkup
/// <summary>
/// Gets the markup for the tag based upon the passed in parameters.
/// </summary>
/// <param name="currentPage">The current page.</param>
/// <param name="parameters">The parameters.</param>
/// <returns></returns>
public override string GetMarkup(IContent currentPage, IDictionary<string, string> parameters)
{
var email = parameters["email"];
var text = email;
if (parameters.ContainsKey("subject"))
email += ((email.IndexOf("?", StringComparison.InvariantCulture) == -1) ? "?" : "&") + "subject=" + parameters["subject"];
if (parameters.ContainsKey("body"))
email += ((email.IndexOf("?", StringComparison.InvariantCulture) == -1) ? "?" : "&") + "body=" + parameters["body"];
var sb = new StringBuilder();
sb.AppendFormat("<a href=\"mailto:{0}\"", email); // TODO: HTML encode
if (parameters.ContainsKey("title"))
sb.AppendFormat(" title=\"{0}\"", parameters["title"]);
if (parameters.ContainsKey("class"))
sb.AppendFormat(" class=\"{0}\"", parameters["class"]);
sb.Append(">");
sb.Append(parameters.ContainsKey("text")
? parameters["text"]
: text);
sb.Append("</a>");
return sb.ToString();
}
示例15: ExecuteSync
protected override void ExecuteSync(IContent content, Index index, object parameter)
{
var value = content.Retrieve(index);
var collectionDescriptor = (CollectionDescriptor)TypeDescriptorFactory.Default.Find(value.GetType());
object itemToAdd = null;
// TODO: Find a better solution for ContentSerializerAttribute that doesn't require to reference Core.Serialization (and unreference this assembly)
if (collectionDescriptor.ElementType.IsAbstract || collectionDescriptor.ElementType.IsNullable() || collectionDescriptor.ElementType.GetCustomAttributes(typeof(ContentSerializerAttribute), true).Any())
{
// If the parameter is a type instead of an instance, try to construct an instance of this type
var type = parameter as Type;
if (type?.GetConstructor(Type.EmptyTypes) != null)
itemToAdd = Activator.CreateInstance(type);
}
else if (collectionDescriptor.ElementType == typeof(string))
{
itemToAdd = parameter ?? "";
}
else
{
itemToAdd = parameter ?? ObjectFactory.NewInstance(collectionDescriptor.ElementType);
}
if (index.IsEmpty)
{
content.Add(itemToAdd);
}
else
{
// Handle collections in collections
// TODO: this is not working on the observable node side
var collectionNode = content.Reference.AsEnumerable[index].TargetNode;
collectionNode.Content.Add(itemToAdd);
}
}