Skip to content
This repository has been archived by the owner on May 23, 2023. It is now read-only.

NCaptcha.CaptchaFactories.Base

yueyinqiu edited this page Jan 24, 2021 · 3 revisions

NCaptcha.CaptchaFactories.Base is a library in this repository. Its full name and package id on nuget.org is Nololiyt.Captcha.CaptchaFactories.Base.

This library provides an abstract class called StaticAnswerCaptchaFactory<TAnswer> which can help simplify the process of implementing a ICaptchaFactory<TCaptchaDisplay, TAnswer>.


There is an interface called ICaptchaAnswerSaver<TAnswer> which can save and get static captcha answer.

The interface will mostly be used in a StaticAnswerCaptchaFactory<TAnswer>, but the TAnswers of the two types don't necessarily the same. For example, a StaticAnswerCaptchaFactory<Point> may just use an existed third-party ICaptchaAnswerSaver<KeyValuePair<int,int>>.

TAnswer is recommended to be a reference type or a nullable value type, so that TryGetAsync(string, CancellationToken) can return null to represent that there isn't such an answer or the answer has expired.

We recommend TryGetAsync(string, CancellationToken) to make the answer invalid in the meantime.