本文整理汇总了C#中IWorkerContext类的典型用法代码示例。如果您正苦于以下问题:C# IWorkerContext类的具体用法?C# IWorkerContext怎么用?C# IWorkerContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IWorkerContext类属于命名空间,在下文中一共展示了IWorkerContext类的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;
}
开发者ID:smartleos,项目名称:itextsharp,代码行数:33,代码来源:ParaGraph.cs
示例2: End
/// <summary>
/// This method is called when a closing tag has been encountered of the
/// ITagProcessor implementation that is mapped to the tag.
/// </summary>
/// <param name="ctx"></param>
/// <param name="tag">the tag encountered</param>
/// <param name="currentContent">
/// a list of content possibly created by TagProcessing of inner tags, and by startElement and
/// content methods of this ITagProcessor
/// </param>
/// <returns>the resulting element to add to the document or a content stack.</returns>
public override IList<IElement> End(IWorkerContext ctx, Tag tag, IList<IElement> currentContent)
{
IList<IElement> list = new List<IElement>();
var htmlPipelineContext = GetHtmlPipelineContext(ctx);
list.Add(GetCssAppliers().Apply(new Chunk((iTextSharp.text.Image)GetCssAppliers().Apply(_image, tag, htmlPipelineContext), 0, 0, true), tag, htmlPipelineContext));
return list;
}
开发者ID:VahidN,项目名称:PdfReport,代码行数:18,代码来源:TotalPagesNumberXmlWorkerProcessor.cs
示例3: 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>();
}
开发者ID:sensusaps,项目名称:RoboBraille.Web.API,代码行数:27,代码来源:TableTagProcessor.cs
示例4: Start
/*
* (non-Javadoc)
*
* @see com.itextpdf.tool.xml.ITagProcessor#startElement(com.itextpdf.tool.xml.Tag)
*/
public override IList<IElement> Start(IWorkerContext ctx, Tag tag) {
String enc;
tag.Attributes.TryGetValue("encoding", out enc);
if (null != enc) {
try {
Encoding encd = null;
try {
encd = Encoding.GetEncoding(enc);
}
catch (ArgumentException) {
}
if (encd != null) {
GetHtmlPipelineContext(ctx).CharSet(encd);
if (LOGGER.IsLogging(Level.DEBUG)) {
LOGGER.Debug(
String.Format(LocaleMessages.GetInstance().GetMessage(LocaleMessages.META_CC), enc));
}
}
else {
if (LOGGER.IsLogging(Level.DEBUG)) {
LOGGER.Debug(
String.Format(LocaleMessages.GetInstance().GetMessage(LocaleMessages.META_404), GetHtmlPipelineContext(ctx)
.CharSet() == null ? "" : GetHtmlPipelineContext(ctx).CharSet().WebName));
}
}
}
catch (NoCustomContextException) {
throw new RuntimeWorkerException(LocaleMessages.GetInstance().GetMessage(LocaleMessages.NO_CUSTOM_CONTEXT));
}
}
return new List<IElement>(0);
}
开发者ID:Niladri24dutta,项目名称:itextsharp,代码行数:38,代码来源:XML.cs
示例5: 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) {
List<IElement> l = new List<IElement>(1);
if (currentContent.Count > 0) {
IList<IElement> currentContentToParagraph = CurrentContentToParagraph(currentContent, true, true, tag, ctx);
foreach (IElement p in currentContentToParagraph) {
((Paragraph) p).Role = (getHeaderRole(GetLevel(tag)));
}
ParentTreeUtil pt = new ParentTreeUtil();
try {
HtmlPipelineContext context = GetHtmlPipelineContext(ctx);
bool oldBookmark = context.AutoBookmark();
if (pt.GetParentTree(tag).Contains(HTML.Tag.TD))
context.AutoBookmark(false);
if (context.AutoBookmark()) {
Paragraph title = new Paragraph();
foreach (IElement w in currentContentToParagraph) {
title.Add(w);
}
l.Add(new WriteH(context, tag, this, title));
}
context.AutoBookmark(oldBookmark);
} catch (NoCustomContextException e) {
if (LOGGER.IsLogging(Level.ERROR)) {
LOGGER.Error(LocaleMessages.GetInstance().GetMessage(LocaleMessages.HEADER_BM_DISABLED), e);
}
}
l.AddRange(currentContentToParagraph);
}
return l;
}
开发者ID:yu0410aries,项目名称:itextsharp,代码行数:37,代码来源:Header.cs
示例6: Start
public override IList<IElement> Start(IWorkerContext ctx, Tag tag)
{
List<IElement> l = new List<IElement>(1);
try
{
IDictionary<String, String> css = tag.CSS;
if (css.ContainsKey(CSS.Property.BACKGROUND_COLOR))
{
Type type = typeof(PdfWriterPipeline);
MapContext pipeline = (MapContext)ctx.Get(type.FullName);
if (pipeline != null)
{
Document document = (Document)pipeline[PdfWriterPipeline.DOCUMENT];
if (document != null)
{
Rectangle rectangle = new Rectangle(document.Left, document.Bottom, document.Right, document.Top, document.PageSize.Rotation);
rectangle.BackgroundColor = HtmlUtilities.DecodeColor(css[CSS.Property.BACKGROUND_COLOR]);
PdfBody body = new PdfBody(rectangle);
l.Add(body);
}
}
}
}
catch (NoCustomContextException e)
{}
return l;
}
开发者ID:Niladri24dutta,项目名称:itextsharp,代码行数:28,代码来源:Body.cs
示例7: 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;
}
开发者ID:Niladri24dutta,项目名称:itextsharp,代码行数:29,代码来源:TableRow.cs
示例8: End
public override IList<IElement> End(IWorkerContext ctx, Tag tag, IList<IElement> currentContent)
{
if (tag.Name == "th") {
IDictionary<string, string> attributes = tag.Attributes;
var retval = base.End(ctx, tag, currentContent);
PdfPCell cell = (PdfPCell)retval[0];
cell.Role = PdfName.TH;
if (attributes.ContainsKey("scope")) {
switch (attributes["scope"]) {
case "col":
cell.SetAccessibleAttribute(PdfName.SCOPE, PdfName.COLUMN);
break;
case "row":
cell.SetAccessibleAttribute(PdfName.SCOPE, PdfName.ROW);
break;
case "both":
cell.SetAccessibleAttribute(PdfName.SCOPE, PdfName.BOTH);
break;
default:
throw new Exception("Scope is missing or unsupported.");
}
}
return retval;
}
return new List<IElement>();
}
开发者ID:sensusaps,项目名称:RoboBraille.Web.API,代码行数:30,代码来源:THTagProcessor.cs
示例9: MessageReceived
public void MessageReceived(IWorkerContext workerContext)
{
var workerQueue = workerContext.InboundSocket.Recv<Queue<Type>>();
var accumulator = workerContext.InboundSocket.Recv<int>();
var operandQueue = workerContext.InboundSocket.Recv<Queue<int>>();
var resultAddress = workerContext.InboundSocket.Recv<string>();
var nextOperand = operandQueue.Dequeue();
accumulator *= nextOperand;
using(var outboundSocket = workerContext.ZmqContext.Socket(ZMQ.SocketType.PUSH))
{
outboundSocket.HWM = 1000;
if(workerQueue.Any())
{
outboundSocket.Connect(workerContext.Configuration["outboundAddress"]);
outboundSocket.SendMore(workerQueue.Dequeue());
outboundSocket.SendMore(workerQueue);
outboundSocket.SendMore(accumulator);
outboundSocket.SendMore(operandQueue);
outboundSocket.Send(resultAddress);
}
else
{
outboundSocket.Connect(resultAddress);
outboundSocket.Send(accumulator);
}
}
}
开发者ID:Jaecen,项目名称:Retask,代码行数:32,代码来源:Multiplier.cs
示例10: Consume
/**
* Called in <code>open</code>, <code>content</code> and <code>close</code> to pass the {@link Writable}s to the handler
* @param po
*/
private void Consume(IWorkerContext context, ProcessObject po) {
if (po.ContainsWritable()) {
IWritable w = null;
while ( null != (w =po.Poll())) {
handler.Add(w);
}
}
}
开发者ID:newlysoft,项目名称:itextsharp,代码行数:12,代码来源:ElementHandlerPipeline.cs
示例11: Content
/* (non-Javadoc)
* @see com.itextpdf.tool.xml.ITagProcessor#content(com.itextpdf.tool.xml.Tag, java.lang.String)
*/
public override IList<IElement> Content(IWorkerContext ctx, Tag tag, String content)
{
IList<IElement> l = new List<IElement>(1);
if (null != content && content.Length > 0) {
l.Add(new ChunkCssApplier().Apply(new Chunk(content), tag));
}
return l;
}
开发者ID:boecko,项目名称:iTextSharp,代码行数:11,代码来源:NonSanitizedTag.cs
示例12: GameQueueAutoStartCommand
public GameQueueAutoStartCommand(IGameRepository gameRepository, IWorkerContext workerContext, TimeSpan gameQueueTimeoutWaiting, int maxNumberOfPlayersPerGame)
{
this.gameRepository = gameRepository;
this.workerContext = workerContext;
this.gameQueueTimeoutWaiting = gameQueueTimeoutWaiting;
this.maxNumberOfPlayersPerGame = maxNumberOfPlayersPerGame;
}
开发者ID:BigMorty,项目名称:wa-toolkit-games,代码行数:8,代码来源:GameQueueAutoStartCommand.cs
示例13: Init
public override IPipeline Init(IWorkerContext context) {
try {
ObjectContext<ICSSResolver> mc = new ObjectContext<ICSSResolver>(resolver.Clear());
context.Put(GetContextKey(), mc);
return base.Init(context);
} catch (CssResolverException e) {
throw new PipelineException(e);
}
}
开发者ID:newlysoft,项目名称:itextsharp,代码行数:9,代码来源:CssResolverPipeline.cs
示例14: Content
/* (non-Javadoc)
* @see com.itextpdf.tool.xml.ITagProcessor#content(com.itextpdf.tool.xml.Tag, java.lang.String)
*/
public override IList<IElement> Content(IWorkerContext ctx, Tag tag, String content)
{
String sanitized = HTMLUtils.SanitizeInline(content);
IList<IElement> l = new List<IElement>(1);
if (sanitized.Length > 0) {
l.Add(new ChunkCssApplier().Apply(new Chunk(sanitized), tag));
}
return l;
}
开发者ID:boecko,项目名称:iTextSharp,代码行数:12,代码来源:OrderedUnorderedListItem.cs
示例15: 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) {
try {
IList<IElement> list = new List<IElement>();
HtmlPipelineContext htmlPipelineContext = GetHtmlPipelineContext(ctx);
LineSeparator lineSeparator = (LineSeparator) GetCssAppliers().Apply(new LineSeparator(), tag, htmlPipelineContext);
list.Add(lineSeparator);
return list;
} catch (NoCustomContextException e) {
throw new RuntimeWorkerException(LocaleMessages.GetInstance().GetMessage(LocaleMessages.NO_CUSTOM_CONTEXT), e);
}
}
开发者ID:jagruti23,项目名称:itextsharp,代码行数:14,代码来源:HorizontalRule.cs
注:本文中的IWorkerContext类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论