protected internal override void OnEvent(IEvent @event, IMetaInfo metaInfo) { if (count.IncrementAndGet() > repeatLevel) { if (iText.Kernel.Version.IsAGPLVersion() || iText.Kernel.Version.IsExpired()) { String message = iText.IO.Util.JavaUtil.GetStringForBytes(message_1); if (iText.Kernel.Version.IsExpired()) { message = iText.IO.Util.JavaUtil.GetStringForBytes(message_2); } level++; if (level == 1) { repeatLevel = REPEAT[1]; } else { repeatLevel = REPEAT[2]; } if (logger == null) { logger = LogManager.GetLogger(this.GetType()); } logger.Info(message); } count.Set(0); } }
/// <summary> /// Performs OCR with set parameters using provided /// <see cref="IOcrEngine"/> /// and /// creates PDF using provided /// <see cref="iText.Kernel.Pdf.PdfWriter"/> /// and /// <see cref="iText.Kernel.Pdf.PdfOutputIntent"/>. /// </summary> /// <remarks> /// Performs OCR with set parameters using provided /// <see cref="IOcrEngine"/> /// and /// creates PDF using provided /// <see cref="iText.Kernel.Pdf.PdfWriter"/> /// and /// <see cref="iText.Kernel.Pdf.PdfOutputIntent"/>. /// PDF/A-3u document will be created if /// provided /// <see cref="iText.Kernel.Pdf.PdfOutputIntent"/> /// is not null. /// </remarks> /// <param name="inputImages"> /// /// <see cref="System.Collections.IList{E}"/> /// of images to be OCRed /// </param> /// <param name="pdfWriter"> /// the /// <see cref="iText.Kernel.Pdf.PdfWriter"/> /// object /// to write final PDF document to /// </param> /// <param name="pdfOutputIntent"> /// /// <see cref="iText.Kernel.Pdf.PdfOutputIntent"/> /// for PDF/A-3u document /// </param> /// <returns> /// result PDF/A-3u /// <see cref="iText.Kernel.Pdf.PdfDocument"/> /// object /// </returns> public PdfDocument CreatePdfA(IList <FileInfo> inputImages, PdfWriter pdfWriter, PdfOutputIntent pdfOutputIntent ) { LOGGER.Info(MessageFormatUtil.Format(PdfOcrLogMessageConstant.START_OCR_FOR_IMAGES, inputImages.Count)); IMetaInfo storedMetaInfo = null; if (ocrEngine is IThreadLocalMetaInfoAware) { storedMetaInfo = ((IThreadLocalMetaInfoAware)ocrEngine).GetThreadLocalMetaInfo(); ((IThreadLocalMetaInfoAware)ocrEngine).SetThreadLocalMetaInfo(new OcrPdfCreatorMetaInfo(((IThreadLocalMetaInfoAware )ocrEngine).GetThreadLocalMetaInfo(), Guid.NewGuid(), null != pdfOutputIntent ? OcrPdfCreatorMetaInfo.PdfDocumentType .PDFA : OcrPdfCreatorMetaInfo.PdfDocumentType.PDF)); } // map contains: // keys: image files // values: // map pageNumber -> retrieved text data(text and its coordinates) IDictionary <FileInfo, IDictionary <int, IList <TextInfo> > > imagesTextData = new LinkedDictionary <FileInfo, IDictionary <int, IList <TextInfo> > >(); try { foreach (FileInfo inputImage in inputImages) { imagesTextData.Put(inputImage, ocrEngine.DoImageOcr(inputImage)); } } finally { if (ocrEngine is IThreadLocalMetaInfoAware) { ((IThreadLocalMetaInfoAware)ocrEngine).SetThreadLocalMetaInfo(storedMetaInfo); } } // create PdfDocument return(CreatePdfDocument(pdfWriter, pdfOutputIntent, imagesTextData)); }
/// <summary> /// 生成一个继承自实体的类 /// </summary> /// <returns></returns> public virtual Type BuildEntityType(Type baseType, IMetaInfo metaInfo) { if (baseType == null) { throw new ArgumentNullException("baseType"); } if (metaInfo == null) { throw new ArgumentNullException("metaInfo"); } _baseType = baseType; _metaInfo = metaInfo; // var index = Interlocked.Increment(ref _next).ToString();//加上一个全局的标识,防止类名重名。 _codeTypeDeclaration = new CodeTypeDeclaration(string.Concat(_baseType.Name, "_Entity_", index)); _codeTypeDeclaration.Attributes = MemberAttributes.Public; // _codeNamespace = new CodeNamespace(_baseType.Namespace); _codeNamespace.Imports.Add(new CodeNamespaceImport("System")); _codeNamespace.Imports.Add(new CodeNamespaceImport("System.Linq")); _codeNamespace.Imports.Add(new CodeNamespaceImport(_baseType.Namespace)); _codeNamespace.Types.Add(_codeTypeDeclaration); // BuildEntity(); // 编译 return(Compile()); }
public ZugferdProperties(iText.Zugferd.ZugferdProperties other) { this.metaInfo = other.metaInfo; this.zugferdConformanceLevel = other.zugferdConformanceLevel; this.pdfaConformanceLevel = other.pdfaConformanceLevel; this.pdfOutputIntent = other.pdfOutputIntent; }
public virtual void GetDefaultMetaInfoTest() { ConverterProperties properties = new ConverterProperties(); IMetaInfo metaInfo = properties.GetEventMetaInfo(); NUnit.Framework.Assert.IsTrue(metaInfo.GetType().FullName.StartsWith(NamespaceConstant.PDF_HTML + ".")); }
/// <summary> /// Triggers all registered /// <see cref="IEventCounterFactory"/> /// to produce /// <see cref="EventCounter"/> /// instance /// and count the event. /// </summary> /// <param name="event"> /// /// <see cref="iText.Kernel.Counter.Event.IEvent"/> /// to be counted /// </param> /// <param name="metaInfo"> /// /// <see cref="iText.Kernel.Counter.Event.IMetaInfo"/> /// object that can holds information about instance that throws the event /// </param> /// <param name="caller">the class that throws the event</param> public virtual void OnEvent(IEvent @event, IMetaInfo metaInfo, Type caller) { IContext context = null; bool contextInitialized = false; foreach (IEventCounterFactory factory in factories.Keys) { EventCounter counter = factory.GetCounter(caller); if (counter != null) { if (!contextInitialized) { if (metaInfo != null) { context = ContextManager.GetInstance().GetContext(metaInfo.GetType()); } if (context == null) { context = ContextManager.GetInstance().GetContext(caller); } if (context == null) { context = ContextManager.GetInstance().GetContext(@event.GetType()); } contextInitialized = true; } if ((context != null && context.Allow(@event)) || (context == null && counter.fallback.Allow(@event))) { counter.OnEvent(@event, metaInfo); } } } }
protected void ForMeta <TMeta>(IMetaInfo info, Action <TMeta> func) where TMeta : class, IMetaInfo { if (info is TMeta meta) { func(meta); } }
/// <summary>Creates an inner meta info wrapper</summary> /// <param name="wrappedMetaInfo">the meta info to be wrapped</param> /// <param name="uuid">a unique String which corresponds to the ocr event for which this meta info is passed</param> /// <param name="pdfDocumentType">a type of the document which is created during the corresponding ocr event</param> public OcrPdfCreatorMetaInfo(IMetaInfo wrappedMetaInfo, Guid uuid, OcrPdfCreatorMetaInfo.PdfDocumentType pdfDocumentType ) { this.wrappedMetaInfo = wrappedMetaInfo; this.uuid = uuid; this.pdfDocumentType = pdfDocumentType; }
/// <summary> /// 生成一个实体的继承类,重写实体中属性成员,并继承IEntity接口。 /// </summary> /// <param name="baseType"></param> /// <param name="metaInfo"></param> /// <returns></returns> public static Type BuildEntityClass(Type baseType, IMetaInfo metaInfo) { if (_creater != null) { return(_creater().BuildEntityType(baseType, metaInfo)); } return(new EntityBuilder().BuildEntityType(baseType, metaInfo)); }
internal DoImageOcrRunnable(AbstractTesseract4OcrEngine tesseractReader, IMetaInfo metaInfo, FileInfo imgFile , FileInfo outputFile, bool createPdf) { this.tesseractReader = tesseractReader; this.metaInfo = metaInfo; this.imgFile = imgFile; this.outputFile = outputFile; this.createPdf = createPdf; }
public virtual void SetEventMetaInfoAndGetTest() { ConverterProperties properties = new ConverterProperties(); ConverterPropertiesTest.TestMetaInfo testMetaInfo = new ConverterPropertiesTest.TestMetaInfo(); properties.SetEventMetaInfo(testMetaInfo); IMetaInfo metaInfo = properties.GetEventMetaInfo(); NUnit.Framework.Assert.AreSame(testMetaInfo, metaInfo); }
// PUBLIC METHODS /////////////////////////////////////////////////// #region Assert Methods public static void Equal(IMetaInfo expected, IMetaInfo actual) { if (expected == null) { Assert.Null(actual); return; } Assert.NotNull(actual); PropertyInfoAssert.Equal(expected, actual); }
/// <summary> /// Instantiates a new /// <see cref="ConverterProperties"/> /// instance based on another /// <see cref="ConverterProperties"/> /// instance /// (copy constructor). /// </summary> /// <param name="other"> /// the other /// <see cref="ConverterProperties"/> /// instance /// </param> public ConverterProperties(iText.Html2pdf.ConverterProperties other) { this.mediaDeviceDescription = other.mediaDeviceDescription; this.fontProvider = other.fontProvider; this.tagWorkerFactory = other.tagWorkerFactory; this.cssApplierFactory = other.cssApplierFactory; this.baseUri = other.baseUri; this.createAcroForm = other.createAcroForm; this.outlineHandler = other.outlineHandler; this.charset = other.charset; this.metaInfo = other.metaInfo; }
public PublishController(AppSettings appSettings, IPublishPreflight publishPreflight, IWebHtmlPublishService publishService, IMetaInfo metaInfo, ISelectorStorage selectorStorage, IUpdateBackgroundTaskQueue queue, IWebLogger webLogger) { _appSettings = appSettings; _publishPreflight = publishPreflight; _publishService = publishService; _metaInfo = metaInfo; _hostStorage = selectorStorage.Get(SelectorStorage.StorageServices.HostFilesystem); _bgTaskQueue = queue; _webLogger = webLogger; }
// Triggering registered factories to produce events and count them protected override void OnEvent(IEvent eventType, IMetaInfo metaInfo) { try { using (StreamWriter writer = new StreamWriter(DEST, true)) { writer.Write(eventType.GetEventType() + "\n"); } } catch (IOException) { Console.Error.WriteLine("IOException occured."); } }
/// <summary> /// Instantiates a new /// <see cref="ProcessorContext"/> /// instance. /// </summary> /// <param name="converterProperties"> /// a /// <see cref="iText.Html2pdf.ConverterProperties"/> /// instance /// </param> public ProcessorContext(ConverterProperties converterProperties) { if (converterProperties == null) { converterProperties = new ConverterProperties(); } state = new State(); deviceDescription = converterProperties.GetMediaDeviceDescription(); if (deviceDescription == null) { deviceDescription = MediaDeviceDescription.GetDefault(); } fontProvider = converterProperties.GetFontProvider(); if (fontProvider == null) { fontProvider = new DefaultFontProvider(); } tagWorkerFactory = converterProperties.GetTagWorkerFactory(); if (tagWorkerFactory == null) { tagWorkerFactory = DefaultTagWorkerFactory.GetInstance(); } cssApplierFactory = converterProperties.GetCssApplierFactory(); if (cssApplierFactory == null) { cssApplierFactory = DefaultCssApplierFactory.GetInstance(); } baseUri = converterProperties.GetBaseUri(); if (baseUri == null) { baseUri = ""; } outlineHandler = converterProperties.GetOutlineHandler(); if (outlineHandler == null) { outlineHandler = new OutlineHandler(); } resourceResolver = new HtmlResourceResolver(baseUri, this, converterProperties.GetResourceRetriever()); limitOfLayouts = converterProperties.GetLimitOfLayouts(); cssContext = new CssContext(); linkContext = new LinkContext(); createAcroForm = converterProperties.IsCreateAcroForm(); formFieldNameResolver = new FormFieldNameResolver(); radioCheckResolver = new RadioCheckResolver(); immediateFlush = converterProperties.IsImmediateFlush(); metaInfo = converterProperties.GetEventCountingMetaInfo(); processingInlineSvg = false; }
public virtual void Register(IEvent @event, IMetaInfo metaInfo) { V data; //Synchronization is left here mostly in consistency with cache and process, but factories are usually not thread safe anyway. lock (factory) { data = factory.Create(@event, metaInfo); } if (data != null) { lock (cache) { cache.Put(data); } TryProcessNextAsync(); } }
/// <summary> /// Constructor Initializes Iisu and loads the input movie /// </summary> /// <param name="skvMoviePath">skv movie path</param> /// <exception cref="System.Exception"> /// Can occur when Iisu cannot be properly initialized /// or when the input path is not valid. /// </exception> public IisuWrapper() { // We need to specify where is located the iisu dll and its configuration file. // in this sample we'll use the SDK's environment variable as resource to locate them // but you can use any mean you need. string libraryLocation = System.Environment.GetEnvironmentVariable("IISU_SDK_DIR"); IHandleConfiguration config = Iisu.Iisu.Context.CreateHandleConfiguration(); <<<<<<< HEAD ======= >>>>>>> b8e918927be2a4af4732581fe5ad6d829df34356 config.IisuBinDir = (libraryLocation + "/bin"); config.ConfigFileName = "iisu_config.xml"; // get iisu handle _iisuHandle = Iisu.Iisu.Context.CreateHandle(config); // create iisu device _device = _iisuHandle.InitializeDevice(); // check if Mode DS325 is Enable string isCiEnabledString = ""; _iisuHandle.GetConfigString("//CONFIG//PROCESSING//CI", out isCiEnabledString); bool isCiEnabled = isCiEnabledString.Equals("1"); if (isCiEnabled != true) { Console.WriteLine("Hand Control will not be Ok"); } //Envoi du fichier coincoin.iid dans le le moteur IIsi _device.CommandManager.SendCommand("IID.loadGraph", Directory.GetCurrentDirectory() + "\\coincoin.iid"); // register even listener _device.EventManager.RegisterEventListener("SYSTEM.Error", new OnErrorDelegate(onError)); _Hand1Status = _device.RegisterDataHandle<int>("CI.HAND1.Status"); _Hand1PosingGestureId = _device.RegisterDataHandle<int>("CI.HAND1.PosingGestureId"); _Hand1PalmPosition = _device.RegisterDataHandle<Iisu.Data.Vector3>("CI.HAND1.PalmPosition3D"); // enregistrement du la reconnaissance CoinCoin _coincoin = _device.RegisterDataHandle<bool>("IID.Script.CoinCoin"); _imetaInfo = _device.EventManager.GetMetaInfo("CI.HandPosingGesture"); _device.Start(); }
public MetaPropertyInfo(IMetaInfo metaInfo, string propertyName, System.Reflection.PropertyInfo propertyInfo) { if (metaInfo == null) { throw new ArgumentNullException("metaInfo"); } if (string.IsNullOrEmpty(propertyName)) { throw new ArgumentNullException("propertyName"); } if (propertyInfo == null) { throw new ArgumentNullException("propertyInfo"); } _metaInfo = metaInfo; _propertyName = propertyName; _propertyInfo = propertyInfo; }
/// <summary> /// Repository初始化 /// </summary> /// <param name="database">数据库读写访问对象</param> public RepositoryDatabase(Database.DatabaseHelper database) { if (database == null) { throw new ArgumentNullException("database"); } if (typeof(T) == typeof(DynamicEntity)) { throw new ArgumentException(string.Format("泛型T不能是{0}", typeof(DynamicEntity).FullName)); } _dbReader = database; _dbWriter = database; var accessor = Map.GetCheckedAccessor <T>(); dbMetaInfo = accessor.MetaInfo as IDbMetaInfo; metaInfo = accessor.MetaInfo; }
public override string TransformName(IMetaInfo info, string name, NameContext context) { var prefix = string.Empty; var suffix = string.Empty; var forBlueprint = true; if (info is TypeInfo typeInfo) { var asBaseClass = false; typeInfo.ForAttribute <UnrealTypeAttributeBase>(attr => { forBlueprint = attr.ForBlueprint; prefix = forBlueprint ? "U" : "F"; asBaseClass = attr.AsBaseClass; }); typeInfo.ForAttribute <UnrealActorAttribute>(attr => { prefix = "A"; suffix = "Actor"; }); typeInfo.ForAttribute <UnrealComponentAttribute>(attr => { suffix = "Component"; }); typeInfo.ForAttribute <UnrealStructAttribute>(attr => { prefix = "F"; }); if (asBaseClass) { suffix += "Base"; } } return($"{prefix}{name.ToPascalCase()}{suffix}"); }
// PUBLIC CONSTRUCTORS ////////////////////////////////////////////// #region Constructors public ResourceType(Type clrResourceType, IHypermediaInfo hypermediaInfo, IResourceIdentityInfo resourceIdentityInfo, IAttributesInfo attributesInfo, IRelationshipsInfo relationshipsInfo, ILinksInfo linksInfo, IMetaInfo metaInfo) : base(clrResourceType, attributesInfo) { Contract.Requires(hypermediaInfo != null); Contract.Requires(resourceIdentityInfo != null); Contract.Requires(relationshipsInfo != null); Contract.Requires(linksInfo != null); // JSON Properties this.HypermediaInfo = hypermediaInfo; this.ResourceIdentityInfo = resourceIdentityInfo; this.RelationshipsInfo = relationshipsInfo; this.LinksInfo = linksInfo; this.MetaInfo = metaInfo; }
internal virtual void OnEvent() { IMetaInfo metaInfo = this.GetThreadLocalMetaInfo(); if (!(metaInfo is OcrPdfCreatorMetaInfo)) { EventCounterHandler.GetInstance().OnEvent(PdfOcrTesseract4Event.TESSERACT4_IMAGE_OCR, this.GetThreadLocalMetaInfo (), GetType()); } else { Guid uuid = ((OcrPdfCreatorMetaInfo)metaInfo).GetDocumentId(); if (!processedUUID.Contains(uuid)) { processedUUID.Add(uuid); EventCounterHandler.GetInstance().OnEvent(OcrPdfCreatorMetaInfo.PdfDocumentType.PDFA.Equals(((OcrPdfCreatorMetaInfo )metaInfo).GetPdfDocumentType()) ? PdfOcrTesseract4Event.TESSERACT4_IMAGE_TO_PDFA : PdfOcrTesseract4Event .TESSERACT4_IMAGE_TO_PDF, ((OcrPdfCreatorMetaInfo)metaInfo).GetWrappedMetaInfo(), GetType()); } } }
public static bool TryDeconstruct(ILogger <IValidatable> logger, IMetaInfo info, ref List <IMemberInfo> values) { if (!(info is IMemberInfo memberInfo)) { return(false); } if (!info.HasAttribute <DeconstructAttribute>() && !memberInfo.Type.ImplementsInterface <IDeconstructible>()) { return(false); } var deconstruct = info.GetAttribute <DeconstructAttribute>(); var deconstructProperties = deconstruct == null ? memberInfo.Type.Create <IDeconstructible>().Deconstruct() : deconstruct.Properties; Deconstruct(logger, memberInfo.Type, info.Name, deconstructProperties.ToList(), ref values); return(true); }
public MetaInfoControllerTest() { _iStorage = new FakeIStorage(); _metaInfo = new MetaInfo(new FakeIQuery( new List <FileIndexItem> { new FileIndexItem("/test.jpg"), new FileIndexItem("/readonly/image.jpg"), new FileIndexItem("/source_missing.jpg") }), new AppSettings { ReadOnlyFolders = new List <string> { "readonly" } }, new FakeSelectorStorage(new FakeIStorage(new List <string>(), new List <string> { "/test.jpg", "/readonly/image.jpg" }, new List <byte[]> { CreateAnImage.Bytes, CreateAnImage.Bytes })), null); }
/// <summary> /// 初始化 /// </summary> /// <param name="metaInfo">元数据</param> public ObjectAccessor(IMetaInfo metaInfo) { Type type = typeof(T); if (type.IsClass == false) { throw new MapperException(string.Format("类型[{0}]不是[{1}]有效识别的实体类型。", type.FullName, this.GetType().FullName)); } if (metaInfo == null) { throw new ArgumentNullException("metaInfo"); } if (metaInfo.EntityType != typeof(T)) { throw new MapperException("metaInfo元数据中的EntityType与泛型T不一致。"); } _metaInfo = metaInfo; }
/// <summary>The method that should be overridden for actual event processing</summary> /// <param name="event"> /// /// <see cref="iText.Kernel.Counter.Event.IEvent"/> /// to count /// </param> /// <param name="metaInfo"> /// the /// <see cref="iText.Kernel.Counter.Event.IMetaInfo"/> /// that can hold information about event origin /// </param> protected internal abstract void OnEvent(IEvent @event, IMetaInfo metaInfo);
public virtual DataHandlerTest.SimpleData Create(IEvent @event, IMetaInfo metaInfo) { return(new DataHandlerTest.SimpleData(@event.GetEventType())); }
/// <summary>Sets document meta info.</summary> /// <remarks> /// Sets document meta info. This meta info will be passed to the /// <see cref="iText.Kernel.Counter.EventCounter"/> /// with /// <see cref="iText.Kernel.Counter.Event.CoreEvent"/> /// and can be used to determine event origin. /// </remarks> /// <param name="metaInfo">meta info to set</param> /// <returns> /// this /// <see cref="DocumentProperties"/> /// instance /// </returns> public virtual iText.Kernel.Pdf.DocumentProperties SetEventCountingMetaInfo(IMetaInfo metaInfo) { this.metaInfo = metaInfo; return(this); }
public static global::SEOChecker.MVC.MetaData GetSeoSettings(IMetaInfo that) => that.Value <global::SEOChecker.MVC.MetaData>("SeoSettings");
public DocumentProperties(iText.Kernel.Pdf.DocumentProperties other) { this.metaInfo = other.metaInfo; }