本文整理汇总了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;
}
示例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;
}
示例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>();
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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>();
}
示例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);
}
}
}
示例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);
}
}
}
示例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;
}
示例12: GameQueueAutoStartCommand
public GameQueueAutoStartCommand(IGameRepository gameRepository, IWorkerContext workerContext, TimeSpan gameQueueTimeoutWaiting, int maxNumberOfPlayersPerGame)
{
this.gameRepository = gameRepository;
this.workerContext = workerContext;
this.gameQueueTimeoutWaiting = gameQueueTimeoutWaiting;
this.maxNumberOfPlayersPerGame = maxNumberOfPlayersPerGame;
}
示例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);
}
}
示例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;
}
示例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);
}
}