本文整理汇总了C#中ContentItem类的典型用法代码示例。如果您正苦于以下问题:C# ContentItem类的具体用法?C# ContentItem怎么用?C# ContentItem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ContentItem类属于命名空间,在下文中一共展示了ContentItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteChild
protected virtual void WriteChild(XmlTextWriter writer, ContentItem child)
{
using (ElementWriter childElement = new ElementWriter("child", writer))
{
childElement.WriteAttribute("id", child.ID);
}
}
示例2: Read
public void Read(XPathNavigator navigator, ContentItem item, ReadingJournal journal)
{
foreach (XPathNavigator detailCollectionElement in EnumerateChildren(navigator))
{
ReadDetailCollection(detailCollectionElement, item, journal);
}
}
示例3: AppendCreatorNode
/// <summary>Appends the creator node to the given collection.</summary>
/// <param name="items"></param>
/// <param name="engine"></param>
/// <param name="parent"></param>
/// <returns></returns>
public static IEnumerable<ContentItem> AppendCreatorNode(this IEnumerable<ContentItem> items, IEngine engine, ContentItem parent)
{
if (parent.ID == 0)
return items;
return items.Union(new[] { new CreatorItem(engine, parent) });
}
示例4: Attachment
public Attachment(IAttachmentHandler handler, string url, ContentItem enclosingItem, byte[] fileContents)
{
_handler = handler;
_url = url;
_enclosingItem = enclosingItem;
_fileContents = fileContents;
}
示例5: Navigate
public virtual ContentItem Navigate(ContentItem startingPoint, string path)
{
return startingPoint.GetChild(path)
?? sources.ResolvePath(startingPoint, path).CurrentItem
?? virtualNodes.Get(startingPoint.Path + path.TrimStart('/'))
?? virtualNodes.Get(path);
}
示例6: Read
public void Read(System.Xml.XPath.XPathNavigator navigator, ContentItem item, ReadingJournal journal)
{
foreach (XPathNavigator detailElement in EnumerateChildren(navigator))
{
ReadProperty(detailElement, item, journal);
}
}
示例7: Write
internal static void Write(HierarchyNode<ContentItem> hierarchy, ContentItem selectedItem, IContentAdapterProvider adapters, ItemFilter filter, string selectableTypes, string selectableExtensions, bool excludeRoot, string target, TextWriter writer)
{
N2.Web.Tree.Using(hierarchy)
.OpenTo(selectedItem)
.Filters(filter)
.IdProvider(n => "u" + n.Current.ID, n => "l" + n.Current.ID)
.LinkWriter((n, w) =>
{
BuildLink(adapters.ResolveAdapter<NodeAdapter>(n.Current), n.Current, n.Current.Path == selectedItem.Path, target, IsSelectable(n.Current, selectableTypes, selectableExtensions)).WriteTo(w);
if (n.Children.Count == 0 && adapters.ResolveAdapter<NodeAdapter>(n.Current).HasChildren(n.Current, filter))
{
var ul = new TagBuilder("ul");
ul.AddCssClass("ajax");
w.Write(ul.ToString(TagRenderMode.StartTag));
var li = new TagBuilder("li");
li.InnerHtml = "{url:" + Url.ParseTokenized("{ManagementUrl}/Content/Navigation/LoadTree.ashx")
.AppendQuery("target", target)
.AppendQuery(SelectionUtility.SelectedQueryKey, HttpUtility.UrlEncode(n.Current.Path))
.AppendQuery("selectableTypes", selectableTypes)
.AppendQuery("selectableExtensions", selectableExtensions)
+ "}";
w.Write(li.ToString());
w.Write(ul.ToString(TagRenderMode.EndTag));
}
})
.ExcludeRoot(excludeRoot)
.WriteTo(writer);
}
示例8: IsVersionable
/// <summary>Checks whether an item may have versions.</summary>
/// <param name="item">The item to check.</param>
/// <returns>True if the item is allowed to have versions.</returns>
public bool IsVersionable(ContentItem item)
{
var versionables = (VersionableAttribute[])item.GetContentType().GetCustomAttributes(typeof(VersionableAttribute), true);
bool isVersionable = versionables.Length == 0 || versionables[0].Versionable == N2.Definitions.AllowVersions.Yes;
return isVersionable;
}
示例9: ViewPageResult
public ViewPageResult(ContentItem thePage, IControllerMapper controllerMapper, IWebContext webContext, IActionInvoker actionInvoker)
{
_thePage = thePage;
_controllerMapper = controllerMapper;
_webContext = webContext;
_actionInvoker = actionInvoker;
}
示例10: Match
public override bool Match(ContentItem item)
{
foreach (ItemFilter filter in filters)
if (!filter.Match(item))
return false;
return true;
}
示例11: ReorderChildren
/// <summary>Reorders children according to OrderBy.</summary>
/// <param name="item">The item whose children to re-order.</param>
/// <returns>Items that were changed in the process of ordering. These items needs to be saved for the order to be persisted.</returns>
public virtual IEnumerable<ContentItem> ReorderChildren(ContentItem item)
{
switch (OrderBy)
{
case SortBy.Updated:
return ReorderBy(item, "Updated");
case SortBy.UpdatedDescending:
return ReorderBy(item, "Updated DESC");
case SortBy.CurrentOrder:
return Utility.UpdateSortOrder(item.Children);
case SortBy.Expression:
return ReorderBy(item, SortExpression);
case SortBy.Published:
return ReorderBy(item, "Published");
case SortBy.PublishedDescending:
return ReorderBy(item, "Published DESC");
case SortBy.Title:
return ReorderBy(item, "Title");
case SortBy.Unordered:
case SortBy.Append:
return Enumerable.Empty<ContentItem>();
default:
throw new ArgumentException("Unknown sort order: " + OrderBy);
}
}
示例12: Tree
/// <summary>Creates a navigation using unordered list elements.</summary>
public static N2.Web.Tree Tree(this HtmlHelper html,
ContentItem startsFrom = null,
ContentItem current = null,
int takeLevels = 2,
bool parallelRoot = true,
bool appendCreatorNode = false,
ItemFilter filter = null,
object htmlAttributes = null)
{
if (startsFrom == null) startsFrom = html.StartPage();
if (current == null) current = html.CurrentPage();
if (filter == null) filter = new NavigationFilter(html.ViewContext.HttpContext.User, html.ContentEngine().SecurityManager);
var builder = parallelRoot
? (HierarchyBuilder)new ParallelRootHierarchyBuilder(startsFrom, takeLevels)
: (HierarchyBuilder)new TreeHierarchyBuilder(startsFrom, takeLevels);
if (builder == null)
throw new ArgumentException("builder == null");
if (appendCreatorNode && ControlPanelExtensions.GetControlPanelState(html).IsFlagSet(ControlPanelState.DragDrop))
builder.GetChildren = (i) => i == null ? null : i.Children.FindNavigatablePages().Where(filter).AppendCreatorNode(html.ContentEngine(), i);
else
builder.GetChildren = (i) => i == null ? null : i.Children.FindNavigatablePages().Where(filter);
var tree = N2.Web.Tree.Using(builder);
if (htmlAttributes != null)
tree.Tag(ApplyToRootUl(htmlAttributes));
ClassifyAnchors(startsFrom, current, parallelRoot, tree);
return tree;
}
示例13: CopyAutoImplementedProperties
private static void CopyAutoImplementedProperties(ContentItem source, ContentItem destination)
{
foreach (var property in source.GetContentType().GetProperties().Where(pi => pi.IsInterceptable()))
{
destination[property.Name] = TryClone(source[property.Name]);
}
}
示例14: UpdateContentItemAction
public UpdateContentItemAction(IView view, IController con, ContentItem item, PropertyDescriptor property, object previousValue)
{
_view = view;
_con = con;
_state = ContentItemState.Get(item);
var name = property.Name;
var value = previousValue;
if (name == "Importer")
{
name = "ImporterName";
value = ((ImporterTypeDescription)value).TypeName;
}
if (name == "Processor")
{
name = "ProcessorName";
value = ((ProcessorTypeDescription)value).TypeName;
}
var field = _state.GetType().GetMember(name).SingleOrDefault() as FieldInfo;
if (field == null)
{
if (!_state.ProcessorParams.ContainsKey(name))
throw new Exception();
_state.ProcessorParams[name] = value;
}
else
{
field.SetValue(_state, value);
}
}
示例15: GetPath
public PathData GetPath(ContentItem item, string remainingUrl)
{
int slashIndex = remainingUrl.IndexOf('/');
string action = remainingUrl;
string arguments = null;
if(slashIndex > 0)
{
action = remainingUrl.Substring(0, slashIndex);
arguments = remainingUrl.Substring(slashIndex + 1);
}
var controllerName = controllerMapper.GetControllerName(item.GetContentType());
if (string.IsNullOrEmpty(action) || string.Equals(action, "Default.aspx", StringComparison.InvariantCultureIgnoreCase))
action = "Index";
foreach (string method in methods)
{
if (string.Equals(method, action, StringComparison.InvariantCultureIgnoreCase))
{
return new PathData(item, null, action, arguments)
{
IsRewritable = false,
TemplateUrl = string.Format("~/{0}/{1}", controllerName, method, item.ID) // workaround for start pages
};
}
}
return null;
}