本文整理汇总了C#中IWorkerContext.Get方法的典型用法代码示例。如果您正苦于以下问题:C# IWorkerContext.Get方法的具体用法?C# IWorkerContext.Get怎么用?C# IWorkerContext.Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IWorkerContext
的用法示例。
在下文中一共展示了IWorkerContext.Get方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
示例2: Open
/*
* (non-Javadoc)
*
* @see
* com.itextpdf.tool.xml.pipeline.AbstractPipeline#open(com.itextpdf.tool
* .xml.Tag, com.itextpdf.tool.xml.pipeline.ProcessObject)
*/
public override IPipeline Open(IWorkerContext context, Tag t, ProcessObject po)
{
try {
String tagName = t.Name;
if (tag.Equals(tagName)) {
MapContext cc;
cc = (MapContext) context.Get(typeof(PdfWriterPipeline).FullName);
Document d = new Document(pagesize);
try {
Stream os = fm.GetStream();
cc[PdfWriterPipeline.DOCUMENT] = d;
cc[PdfWriterPipeline.WRITER] = PdfWriter.GetInstance(d, os);
} catch (IOException e) {
throw new PipelineException(e);
} catch (DocumentException e) {
throw new PipelineException(e);
}
}
if (Util.EqualsIgnoreCase(t.Name, opentag)) {
MapContext cc;
cc = (MapContext) context.Get(typeof(PdfWriterPipeline).FullName);
Document d = (Document) cc[PdfWriterPipeline.DOCUMENT];
CssUtils cssUtils = CssUtils.GetInstance();
float pageWidth = d.PageSize.Width;
float marginLeft = 0;
float marginRight = 0;
float marginTop = 0;
float marginBottom = 0;
IDictionary<String, String> css = t.CSS;
foreach (KeyValuePair<String, String> entry in css) {
String key = entry.Key;
String value = entry.Value;
if (Util.EqualsIgnoreCase(key, CSS.Property.MARGIN_LEFT)) {
marginLeft = cssUtils.ParseValueToPt(value, pageWidth);
} else if (Util.EqualsIgnoreCase(key, CSS.Property.MARGIN_RIGHT)) {
marginRight = cssUtils.ParseValueToPt(value, pageWidth);
} else if (Util.EqualsIgnoreCase(key, CSS.Property.MARGIN_TOP)) {
marginTop = cssUtils.ParseValueToPt(value, pageWidth);
} else if (Util.EqualsIgnoreCase(key, CSS.Property.MARGIN_BOTTOM)) {
marginBottom = cssUtils.ParseValueToPt(value, pageWidth);
}
}
d.SetMargins(marginLeft, marginRight, marginTop, marginBottom);
d.Open();
}
} catch (NoCustomContextException e) {
throw new PipelineException(LocaleMessages.GetInstance().GetMessage(LocaleMessages.PIPELINE_AUTODOC), e);
}
return GetNext();
}
示例3: Close
/*
* (non-Javadoc)
*
* @see
* com.itextpdf.tool.xml.pipeline.AbstractPipeline#close(com.itextpdf.tool
* .xml.Tag, com.itextpdf.tool.xml.pipeline.ProcessObject)
*/
public override IPipeline Close(IWorkerContext context, Tag t, ProcessObject po)
{
String tagName = t.Name;
if (tag.Equals(tagName)) {
MapContext cc;
try {
cc = (MapContext) context.Get(typeof(PdfWriterPipeline).FullName);
Document d = (Document) cc[PdfWriterPipeline.DOCUMENT];
d.Close();
} catch (NoCustomContextException e) {
throw new PipelineException("AutoDocPipeline depends on PdfWriterPipeline.", e);
}
try {
HtmlPipelineContext hpc = (HtmlPipelineContext) context.Get(typeof(HtmlPipeline).FullName);
HtmlPipelineContext clone = (HtmlPipelineContext)hpc.Clone();
clone.SetPageSize(pagesize);
((WorkerContextImpl)context).Put(typeof(HtmlPipeline).FullName, clone);
} catch (NoCustomContextException) {
}
}
return GetNext();
}
示例4: GetHtmlPipelineContext
/**
* Utility method that fetches the HtmlPipelineContext used if any and if it
* uses the default key.
* @return a HtmlPipelineContext
* @throws NoCustomContextException if the context of the
* {@link HtmlPipelineContext} could not be found.
*/
public virtual HtmlPipelineContext GetHtmlPipelineContext(IWorkerContext ctx) {
return (HtmlPipelineContext) ctx.Get(typeof(HtmlPipeline).FullName);
}
示例5: GetCSSResolver
/**
* Utility method that fetches the CSSResolver from the if any and if it uses the default key.
*
* @return CSSResolver
* @throws NoCustomContextException if the context of the
* {@link CssResolverPipeline} could not be found.
*/
public virtual ICSSResolver GetCSSResolver(IWorkerContext context) {
return ((ObjectContext<ICSSResolver>)context.Get(typeof(CssResolverPipeline).FullName)).Get();
//return (ICSSResolver) ((MapContext)ctx.Get(typeof(CssResolverPipeline).FullName))[CssResolverPipeline.CSS_RESOLVER];
}
示例6: GetLocalContext
public virtual ICustomContext GetLocalContext(IWorkerContext context) {
try {
ICustomContext cc = context.Get(GetContextKey());
if (null != cc) {
return cc;
}
throw new PipelineException(String.Format(LocaleMessages.GetInstance().GetMessage(LocaleMessages.OWN_CONTEXT_404), this.GetType().FullName));
} catch (NoCustomContextException e) {
throw new PipelineException(String.Format(LocaleMessages.GetInstance().GetMessage(LocaleMessages.OWN_CONTEXT_404), this.GetType().FullName), e);
}
}