本文整理汇总了C#中System.IO.TextWriter.WriteAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# TextWriter.WriteAttribute方法的具体用法?C# TextWriter.WriteAttribute怎么用?C# TextWriter.WriteAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.TextWriter
的用法示例。
在下文中一共展示了TextWriter.WriteAttribute方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Render
public override void Render(TextWriter writer)
{
if (state.IsFlagSet(ControlPanelState.DragDrop))
{
if (ZoneName.IndexOfAny(new[] { '.', ',', ' ', '\'', '"', '\t', '\r', '\n' }) >= 0) throw new N2Exception("Zone '" + ZoneName + "' contains illegal characters.");
writer.Write("<div class='" + ZoneName + " dropZone'");
if (CurrentItem.ID != 0 && !CurrentItem.VersionOf.HasValue)
writer.WriteAttribute(PartUtilities.PathAttribute, CurrentItem.Path);
else
{
writer.WriteAttribute(PartUtilities.PathAttribute, Find.ClosestPage(CurrentItem).Path)
.WriteAttribute("data-versionKey", CurrentItem.GetVersionKey())
.WriteAttribute("data-versionIndex", CurrentItem.VersionIndex.ToString());
}
writer.WriteAttribute(PartUtilities.ZoneAttribute, ZoneName)
.WriteAttribute(PartUtilities.AllowedAttribute, PartUtilities.GetAllowedNames(ZoneName, PartsAdapter.GetAllowedDefinitions(CurrentItem, ZoneName, Html.ViewContext.HttpContext.User)))
.WriteAttribute("title", ZoneTitle ?? DroppableZone.GetToolTip(Html.ResolveService<IDefinitionManager>().GetDefinition(CurrentItem), ZoneName));
writer.Write(">");
RenderPreview(writer);
writer.Write("</div>");
}
else if (state.IsFlagSet(ControlPanelState.Previewing))
{
RenderPreview(writer);
}
else
base.Render(writer);
}
示例2: Render
public override void Render(TextWriter writer)
{
if (state == ControlPanelState.DragDrop)
{
if (ZoneName.IndexOfAny(new[] { '.', ',', ' ', '\'', '"', '\t', '\r', '\n' }) >= 0) throw new N2Exception("Zone '" + ZoneName + "' contains illegal characters.");
writer.Write("<div class='" + ZoneName + " dropZone'");
writer.WriteAttribute(PartUtilities.PathAttribute, CurrentItem.Path)
.WriteAttribute(PartUtilities.ZoneAttribute, ZoneName)
.WriteAttribute(PartUtilities.AllowedAttribute, PartUtilities.GetAllowedNames(ZoneName, PartsAdapter.GetAllowedDefinitions(CurrentItem, ZoneName, Html.ViewContext.HttpContext.User)))
.WriteAttribute("title", ZoneTitle ?? DroppableZone.GetToolTip(Html.ResolveService<IDefinitionManager>().GetDefinition(CurrentItem), ZoneName))
.Write(">");
if (string.IsNullOrEmpty(Html.ViewContext.HttpContext.Request["preview"]))
{
base.Render(writer);
}
else
{
string preview = Html.ViewContext.HttpContext.Request["preview"];
RenderReplacingPreviewed(writer, preview);
}
writer.Write("</div>");
}
else
base.Render(writer);
}
示例3: Render
public override void Render(TextWriter writer)
{
if (writer == null)
throw new NullReferenceException("writer cannot be null");
if (state.IsFlagSet(ControlPanelState.DragDrop))
{
if (String.IsNullOrWhiteSpace(ZoneName))
throw new N2Exception("Zone name cannot be null, empty, or consist only of whitespace.");
if (ZoneName.IndexOfAny(new[] { '.', ',', ' ', '\'', '"', '\t', '\r', '\n' }) >= 0)
throw new N2Exception("Zone '" + ZoneName + "' contains illegal characters.");
if (CurrentItem == null)
throw new N2Exception("CurrentItem cannot be null");
var dm = Html.ResolveService<IDefinitionManager>();
if (dm == null)
throw new N2Exception("Failed to resolve the definition manager.");
writer.Write("<div class=\"" + ZoneName + " dropZone\"");
if (CurrentItem.ID != 0 && !CurrentItem.VersionOf.HasValue)
writer.WriteAttribute(PartUtilities.PathAttribute, CurrentItem.Path);
else
{
writer.WriteAttribute(PartUtilities.PathAttribute, (Find.ClosestPage(CurrentItem) ?? CurrentItem).Path);
writer.WriteAttribute("data-versionKey", CurrentItem.GetVersionKey());
writer.WriteAttribute("data-versionIndex", CurrentItem.VersionIndex.ToString());
}
writer.WriteAttribute(PartUtilities.ZoneAttribute, ZoneName)
.WriteAttribute(PartUtilities.AllowedAttribute, PartUtilities.GetAllowedNames(ZoneName, PartsAdapter.GetAllowedDefinitions(CurrentItem, ZoneName, Html.ViewContext.HttpContext.User)))
.WriteAttribute("title", ZoneTitle ?? DroppableZone.GetToolTip(dm.GetDefinition(CurrentItem), ZoneName));
writer.Write(">");
RenderPreview(writer);
writer.Write("</div>");
}
else if (state.IsFlagSet(ControlPanelState.Previewing))
{
RenderPreview(writer);
}
else
base.Render(writer);
}
示例4: RenderTemplate
protected override void RenderTemplate(TextWriter writer, ContentItem model)
{
if (state.IsFlagSet(ControlPanelState.DragDrop) && model.Parent == CurrentItem)
{
ItemDefinition definition = Html.ResolveService<IDefinitionManager>().GetDefinition(model);
writer.Write("<div class='" + definition.Discriminator + " zoneItem'");
if (model.ID != 0 && !model.VersionOf.HasValue)
writer.WriteAttribute(PartUtilities.PathAttribute, model.Path);
else
{
writer.WriteAttribute(PartUtilities.PathAttribute, Find.ClosestPage(model).Path);
writer.WriteAttribute("data-versionKey", model.GetVersionKey())
.WriteAttribute("data-versionIndex", model.VersionIndex.ToString());
}
writer.WriteAttribute("data-sortOrder", model.SortOrder.ToString())
.WriteAttribute(PartUtilities.TypeAttribute, definition.Discriminator);
writer.Write(">");
Html.ResolveService<PartUtilities>().WriteTitleBar(writer, model, Html.ViewContext.HttpContext.Request.RawUrl);
base.RenderTemplate(writer, model);
writer.Write("</div>");
}
else
base.RenderTemplate(writer, model);
}
示例5: RenderTemplate
protected override void RenderTemplate(TextWriter writer, ContentItem model)
{
if (state == ControlPanelState.DragDrop)
{
ItemDefinition definition = Html.ResolveService<IDefinitionManager>().GetDefinition(model);
writer.Write("<div class='" + definition.Discriminator + " zoneItem'");
writer.WriteAttribute(PartUtilities.PathAttribute, model.Path)
.WriteAttribute(PartUtilities.TypeAttribute, definition.Discriminator)
.Write(">");
Html.ResolveService<PartUtilities>().WriteTitleBar(writer, model, Html.ViewContext.HttpContext.Request.RawUrl);
base.RenderTemplate(writer, model);
writer.Write("</div>");
}
else
base.RenderTemplate(writer, model);
}