本文整理汇总了C#中Tag类的典型用法代码示例。如果您正苦于以下问题:C# Tag类的具体用法?C# Tag怎么用?C# Tag使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Tag类属于命名空间,在下文中一共展示了Tag类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Content
/*
* (non-Javadoc)
*
* @see
* com.itextpdf.tool.xml.ITagProcessor#content(com.itextpdf.tool.xml.Tag,
* java.util.List, com.itextpdf.text.Document, java.lang.String)
*/
public override IList<IElement> Content(IWorkerContext ctx, Tag tag, String content) {
List<Chunk> sanitizedChunks = HTMLUtils.Sanitize(content, false);
List<IElement> l = new List<IElement>(1);
foreach (Chunk sanitized in sanitizedChunks) {
HtmlPipelineContext myctx;
try {
myctx = GetHtmlPipelineContext(ctx);
} catch (NoCustomContextException e) {
throw new RuntimeWorkerException(e);
}
if (tag.CSS.ContainsKey(CSS.Property.TAB_INTERVAL)) {
TabbedChunk tabbedChunk = new TabbedChunk(sanitized.Content);
if (null != GetLastChild(tag) && GetLastChild(tag).CSS.ContainsKey(CSS.Property.XFA_TAB_COUNT)) {
tabbedChunk.TabCount = int.Parse(GetLastChild(tag).CSS[CSS.Property.XFA_TAB_COUNT]);
}
l.Add(GetCssAppliers().Apply(tabbedChunk, tag,myctx));
} else if (null != GetLastChild(tag) && GetLastChild(tag).CSS.ContainsKey(CSS.Property.XFA_TAB_COUNT)) {
TabbedChunk tabbedChunk = new TabbedChunk(sanitized.Content);
tabbedChunk.TabCount = int.Parse(GetLastChild(tag).CSS[CSS.Property.XFA_TAB_COUNT]);
l.Add(GetCssAppliers().Apply(tabbedChunk, tag, myctx));
} else {
l.Add(GetCssAppliers().Apply(sanitized, tag, myctx));
}
}
return l;
}
示例2: TestTag
public void TestTag()
{
Tag tag = new Tag();
tag.Initialize("tag", null, null);
Assert.AreEqual("tag", tag.Name);
Assert.AreEqual(string.Empty, tag.Render(new Context()));
}
示例3: MakeLayout
/// <summary>
/// Makes a layout from a layout guess.
/// </summary>
/// <param name="layout">The layout guess.</param>
/// <param name="name">The name of the final layout.</param>
/// <param name="groupTag">The group tag of the final layout. Can be <c>null</c>.</param>
/// <returns></returns>
public static TagLayout MakeLayout(TagLayoutGuess layout, string name, Tag groupTag)
{
var result = new TagLayout(name, layout.Size, groupTag);
var finalizer = new LayoutGuessFinalizer(result, 0);
finalizer.ProcessLayout(layout);
return result;
}
示例4: OnTagDeleted
public void OnTagDeleted(Tag tag)
{
if (TagDeleted != null)
{
TagDeleted(new SingleItemEventArgs<Tag>(tag));
}
}
示例5: Process
public override string Process(Tag tag)
{
if (tag == null) return "";
float size = 0.0f;
bool do_not_process = false;
if (tag.Attributes.ContainsKey("")) {
try {
size = float.Parse(tag.Attributes[""]);
}
catch (System.FormatException) {
do_not_process = true;
}
}
else {
do_not_process = true;
}
if (size == 0.0) {
do_not_process = true;
}
if (do_not_process == true) {
return tag.Content;
}
else {
return "<span style=\"font-size:" + size + "pt;\">" + tag.Content + "</span>";
}
}
示例6: SetUp
virtual public void SetUp() {
parent = new Tag("body");
parent.CSS[CSS.Property.FONT_FAMILY] = "Helvetica";
parent.CSS[CSS.Property.FONT_SIZE] = "12pt";
first = new Tag(null);
first.CSS[CSS.Property.FONT_FAMILY] = "Helvetica";
first.CSS[CSS.Property.FONT_SIZE] = "12pt";
second = new Tag(null);
second.CSS[CSS.Property.FONT_FAMILY] = "Helvetica";
second.CSS[CSS.Property.FONT_SIZE] = "12pt";
child = new Tag(null);
child.CSS[CSS.Property.FONT_FAMILY] = "Helvetica";
child.CSS[CSS.Property.FONT_SIZE] = "12pt";
parent.AddChild(first);
first.Parent = parent;
second.Parent = parent;
first.AddChild(child);
second.AddChild(child);
parent.CSS[CSS.Property.FONT_SIZE] = fst.TranslateFontSize(parent) + "pt";
first.CSS[CSS.Property.FONT_SIZE] = fst.TranslateFontSize(first) + "pt";
first.CSS[CSS.Property.TEXT_ALIGN] = CSS.Value.LEFT;
second.CSS[CSS.Property.FONT_SIZE] = fst.TranslateFontSize(second) + "pt";
child.CSS[CSS.Property.FONT_SIZE] = fst.TranslateFontSize(child) + "pt";
firstPara = new Paragraph(new Chunk("default text for chunk creation"));
secondPara = new Paragraph(new Chunk("default text for chunk creation"));
configuration = new HtmlPipelineContext(null);
applier.Apply(firstPara, first, configuration);
}
示例7: End
public override IList<IElement> End(IWorkerContext ctx, Tag tag, IList<IElement> currentContent)
{
if (currentContent.Count > 0)
{
IDictionary<string, string> attributes = tag.Attributes;
var retval = base.End(ctx, tag, currentContent);
foreach (PdfPTable table in retval.OfType<PdfPTable>())
{
if (attributes.ContainsKey("summary") && attributes.ContainsKey("caption"))
{
table.SetAccessibleAttribute(PdfName.SUMMARY, new PdfString(attributes["summary"].ToString()));
table.SetAccessibleAttribute(PdfName.CAPTION, new PdfString(attributes["caption"].ToString()));
table.KeepRowsTogether(0);
}
else
{
throw new Exception("Table is missing attributes. Summary and Caption must be available.");
}
}
return retval;
}
return new List<IElement>();
}
示例8: TagLayout
/// <summary>
/// Creates a tag layout with a name, a size in bytes, and a group tag.
/// </summary>
/// <param name="name">The name of the layout.</param>
/// <param name="size">The size of the layout.</param>
/// <param name="groupTag">The group tag.</param>
public TagLayout(string name, uint size, Tag groupTag)
{
Name = name;
Size = size;
GroupTag = groupTag;
Fields = _fields.AsReadOnly();
}
示例9: FindGameObjectsWithTags
public static GameObject[] FindGameObjectsWithTags(Tag[] searchTags)
{
List<GameObject> searchResult = new List<GameObject> ();
foreach (MultiTags taggedObject in taggedObjects) {
bool tagsFound = true;
foreach(Tag searchTag in searchTags) {
bool tagFound = false;
foreach(Tag objectTag in taggedObject.tags) {
if(objectTag == searchTag) {
tagFound = true;
break;
}
}
if (!tagFound) {
tagsFound = false;
break;
}
}
if (tagsFound) {
searchResult.Add(taggedObject.gameObject);
}
}
return searchResult.ToArray();
}
示例10: SomeTests
public void SomeTests()
{
Tag t1 = new Tag (null, 1, "tag1");
Tag t2 = new Tag (null, 2, "tag2");
Tag t3 = new Tag (null, 3, "tag3");
Tag t4 = new Tag (null, 4, "tag4");
Tag t5 = new Tag (null, 5, "tag5");
TagTerm tt1 = new TagTerm (t1);
TagTerm tt2 = new TagTerm (t2);
TagTerm tt3 = new TagTerm (t3);
TagTerm tt4 = new TagTerm (t4);
TagTerm tt5 = new TagTerm (t5);
object [] tests = {
" (photos.id IN (SELECT photo_id FROM photo_tags WHERE tag_id = 1)) ", tt1,
" (photos.id IN (SELECT photo_id FROM photo_tags WHERE tag_id IN (2, 3))) ", new OrTerm (tt2, tt3),
" (photos.id IN (SELECT photo_id FROM photo_tags WHERE tag_id IN (3, 4, 5))) ", new OrTerm (tt3, tt4, tt5),
};
for (int i=0; i < tests.Length; i+=2) {
//System.Console.WriteLine ((tests[i+1] as LogicalTerm).SqlClause ());
//System.Console.WriteLine (tests[i]);
Assert.AreEqual (tests[i] as string, (tests[i+1] as LogicalTerm).SqlClause ());
}
}
示例11: Tag
public static IEnumerable<News> Tag(this IEnumerable<News> news, Tag tag)
{
Assertion.NotNull(news);
Assertion.NotNull(tag);
return news.Where(it => it != null && it.Tags.Contains(tag));
}
示例12: End
/* (non-Javadoc)
* @see com.itextpdf.tool.xml.ITagProcessor#endElement(com.itextpdf.tool.xml.Tag, java.util.List, com.itextpdf.text.Document)
*/
public override IList<IElement> End(IWorkerContext ctx, Tag tag, IList<IElement> currentContent) {
TableRowElement row = null;
IList<IElement> l = new List<IElement>(1);
if (Util.EqualsIgnoreCase(tag.Parent.Name, HTML.Tag.THEAD)) {
row = new TableRowElement(currentContent, TableRowElement.Place.HEADER);
} else if (Util.EqualsIgnoreCase(tag.Parent.Name, HTML.Tag.TBODY)) {
row = new TableRowElement(currentContent, TableRowElement.Place.BODY);
} else if (Util.EqualsIgnoreCase(tag.Parent.Name, HTML.Tag.TFOOT)) {
row = new TableRowElement(currentContent, TableRowElement.Place.FOOTER);
} else {
row = new TableRowElement(currentContent, TableRowElement.Place.BODY);
}
int direction = GetRunDirection(tag);
if (direction != PdfWriter.RUN_DIRECTION_DEFAULT) {
foreach (HtmlCell cell in row.Content) {
if (cell.RunDirection == PdfWriter.RUN_DIRECTION_DEFAULT) {
cell.RunDirection = direction;
}
}
}
l.Add(row);
return l;
}
示例13: Apply
/* (non-Javadoc)
* @see com.itextpdf.tool.xml.css.CssApplier#apply(com.itextpdf.text.Element, com.itextpdf.tool.xml.Tag)
*/
virtual public LineSeparator Apply(LineSeparator ls, Tag t, IPageSizeContainable psc) {
float lineWidth = 1;
IDictionary<String, String> css = t.CSS;
if (css.ContainsKey(CSS.Property.HEIGHT)) {
lineWidth = CssUtils.GetInstance().ParsePxInCmMmPcToPt(css[CSS.Property.HEIGHT]);
}
ls.LineWidth = lineWidth;
BaseColor lineColor = BaseColor.BLACK;
if (css.ContainsKey(CSS.Property.COLOR)) {
lineColor = HtmlUtilities.DecodeColor(css[CSS.Property.COLOR]);
} else if (css.ContainsKey(CSS.Property.BACKGROUND_COLOR)) {
lineColor = HtmlUtilities.DecodeColor(css[CSS.Property.BACKGROUND_COLOR]);
}
ls.LineColor = lineColor;
float percentage = 100;
String widthStr;
css.TryGetValue(CSS.Property.WIDTH, out widthStr);
if (widthStr != null) {
if (widthStr.Contains("%")) {
percentage = float.Parse(widthStr.Replace("%", ""), CultureInfo.InvariantCulture);
} else {
percentage = (CssUtils.GetInstance().ParsePxInCmMmPcToPt(widthStr)/psc.PageSize.Width)*100;
}
}
ls.Percentage = percentage;
ls.Offset = 9;
return ls;
}
示例14: AddsNamespaceToOutput
public void AddsNamespaceToOutput(Namespaces namespaces, Tag tag)
{
sut.UseNamespaces(namespaces);
sut.WriteStartTagFor(tag);
Assert.Equal($"<{tag} {namespaces}>", sut.ToString());
}
示例15: LoadFromStream
public static Tag LoadFromStream(Stream stream)
{
BinaryReader binaryReader = new BinaryReader(stream);
Tag tag = new Tag();
tag.ID = binaryReader.ReadByte();
byte b;
uint size;
b = binaryReader.ReadByte();
if (b < 0x80)
{
size = b;
}
else if (b == 0xFF)
{
size = binaryReader.ReadUInt32();
}
else
{
size = ((uint)b & 0x7F) << 8;
b = binaryReader.ReadByte();
size |= b;
}
tag.Data = binaryReader.ReadBytes((int)size);
return tag;
}