本文整理汇总了C#中IOptions类的典型用法代码示例。如果您正苦于以下问题:C# IOptions类的具体用法?C# IOptions怎么用?C# IOptions使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IOptions类属于命名空间,在下文中一共展示了IOptions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RequestCultureMiddleware
public RequestCultureMiddleware(RequestDelegate next, IOptions<RequestCultureOptions> options)
{
if (next == null) throw new ArgumentNullException(nameof(next));
if (options == null) throw new ArgumentNullException(nameof(options));
_next = next;
_options = options.Value;
}
示例2: CommonExceptionHandlerMiddleware
public CommonExceptionHandlerMiddleware(
RequestDelegate next,
ILoggerFactory loggerFactory,
DiagnosticSource diagnosticSource,
IOptions<ExceptionHandlerOptions> options = null
)
{
_next = next;
if(options == null)
{
_options = new ExceptionHandlerOptions();
}
else
{
_options = options.Value;
}
_logger = loggerFactory.CreateLogger<CommonExceptionHandlerMiddleware>();
if (_options.ExceptionHandler == null)
{
_options.ExceptionHandler = _next;
}
_clearCacheHeadersDelegate = ClearCacheHeaders;
_diagnosticSource = diagnosticSource;
}
示例3: DevelopmentDefaultData
public DevelopmentDefaultData(IOptions<DevelopmentSettings> options, IDataContext dataContext, UserManager<User> userManager, RoleManager<Role> roleManager)
{
this.settings = options.Value;
this.dataContext = dataContext;
this.userManager = userManager;
this.roleManager = roleManager;
}
示例4: TwilioSMSService
public TwilioSMSService(IOptions<SmsSettings> smsSettings)
{
_smsSettings = smsSettings.Value;
//TwilioClient.Init(_smsSettings.Sid, _smsSettings.Token);
_restClient = new TwilioRestClient(_smsSettings.Sid, _smsSettings.Token);
}
示例5: RaygunAspNetMiddleware
public RaygunAspNetMiddleware(RequestDelegate next, IOptions<RaygunSettings> settings, RaygunMiddlewareSettings middlewareSettings)
{
_next = next;
_middlewareSettings = middlewareSettings;
_settings = _middlewareSettings.ClientProvider.GetRaygunSettings(settings.Value ?? new RaygunSettings());
}
示例6: RedisMessageBus
internal RedisMessageBus(IStringMinifier stringMinifier,
ILoggerFactory loggerFactory,
IPerformanceCounterManager performanceCounterManager,
IOptions<MessageBusOptions> optionsAccessor,
IOptions<RedisScaleoutOptions> scaleoutConfigurationAccessor,
IRedisConnection connection,
bool connectAutomatically)
: base(stringMinifier, loggerFactory, performanceCounterManager, optionsAccessor, scaleoutConfigurationAccessor)
{
_connectionString = scaleoutConfigurationAccessor.Options.ConnectionString;
_db = scaleoutConfigurationAccessor.Options.Database;
_key = scaleoutConfigurationAccessor.Options.EventKey;
_connection = connection;
_logger = loggerFactory.CreateLogger<RedisMessageBus>();
ReconnectDelay = TimeSpan.FromSeconds(2);
if (connectAutomatically)
{
ThreadPool.QueueUserWorkItem(_ =>
{
var ignore = ConnectWithRetry();
});
}
}
示例7: Unbind
public override UnbindResult Unbind(HttpRequestData request, IOptions options)
{
if (request == null)
{
throw new ArgumentNullException(nameof(request));
}
var payload = Convert.FromBase64String(request.QueryString["SAMLRequest"].First());
using (var compressed = new MemoryStream(payload))
{
using (var decompressedStream = new DeflateStream(compressed, CompressionMode.Decompress, true))
{
using (var deCompressed = new MemoryStream())
{
decompressedStream.CopyTo(deCompressed);
var xml = new XmlDocument()
{
PreserveWhitespace = true
};
xml.LoadXml(Encoding.UTF8.GetString(deCompressed.GetBuffer()));
return new UnbindResult(
xml.DocumentElement,
request.QueryString["RelayState"].SingleOrDefault());
}
}
}
}
示例8: SessionMiddleware
/// <summary>
/// Creates a new <see cref="SessionMiddleware"/>.
/// </summary>
/// <param name="next">The <see cref="RequestDelegate"/> representing the next middleware in the pipeline.</param>
/// <param name="loggerFactory">The <see cref="ILoggerFactory"/> representing the factory that used to create logger instances.</param>
/// <param name="sessionStore">The <see cref="ISessionStore"/> representing the session store.</param>
/// <param name="options">The session configuration options.</param>
public SessionMiddleware(
RequestDelegate next,
ILoggerFactory loggerFactory,
ISessionStore sessionStore,
IOptions<SessionOptions> options)
{
if (next == null)
{
throw new ArgumentNullException(nameof(next));
}
if (loggerFactory == null)
{
throw new ArgumentNullException(nameof(loggerFactory));
}
if (sessionStore == null)
{
throw new ArgumentNullException(nameof(sessionStore));
}
if (options == null)
{
throw new ArgumentNullException(nameof(options));
}
_next = next;
_logger = loggerFactory.CreateLogger<SessionMiddleware>();
_options = options.Value;
_sessionStore = sessionStore;
_sessionStore.Connect();
}
示例9: SiteAdminController
public SiteAdminController(
SiteManager siteManager,
GeoDataManager geoDataManager,
IOptions<MultiTenantOptions> multiTenantOptions,
IOptions<UIOptions> uiOptionsAccessor,
IOptions<LayoutSelectorOptions> layoutSeletorOptionsAccessor,
ILayoutFileListBuilder layoutListBuilder
//ConfigHelper configuration
//, ITriggerStartup startupTrigger
)
{
//if (siteResolver == null) { throw new ArgumentNullException(nameof(siteResolver)); }
if (geoDataManager == null) { throw new ArgumentNullException(nameof(geoDataManager)); }
//if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); }
//config = configuration;
this.multiTenantOptions = multiTenantOptions.Value;
//Site = siteResolver.Resolve();
this.siteManager = siteManager;
this.geoDataManager = geoDataManager;
uiOptions = uiOptionsAccessor.Value;
this.layoutListBuilder = layoutListBuilder;
layoutOptions = layoutSeletorOptionsAccessor.Value;
//startup = startupTrigger;
}
示例10: GravatarProvider
public GravatarProvider(
IOptions<AppSettings> appSettings
, ApplicationUserManager userManager)
{
_appSettings = appSettings.Value;
_userManager = userManager;
}
示例11: Run
public static CommandResult Run(
HttpRequestData request,
string returnPath,
IOptions options)
{
if (request == null)
{
throw new ArgumentNullException(nameof(request));
}
if (options == null)
{
throw new ArgumentNullException(nameof(options));
}
var binding = Saml2Binding.Get(request);
if (binding != null)
{
var unbindResult = binding.Unbind(request, options);
VerifyMessageIsSigned(unbindResult, options);
switch (unbindResult.Data.LocalName)
{
case "LogoutRequest":
return HandleRequest(unbindResult, options);
case "LogoutResponse":
return HandleResponse(unbindResult, request);
default:
throw new NotImplementedException();
}
}
return InitiateLogout(request, returnPath, options);
}
示例12: Configure
public static void Configure(IHostingEnvironment env, IOptions<AppConfig> config)
{
ActionsFile = env.WebRootPath + config.Value.ActionsFile;
ConfigsFile= env.WebRootPath + config.Value.ConfigsFile;
LoadActions();
LoadConfigs();
}
示例13: FolderTenantNodeUrlPrefixProvider
public FolderTenantNodeUrlPrefixProvider(
SiteSettings currentSite,
IOptions<MultiTenantOptions> multiTenantOptions)
{
site = currentSite;
options = multiTenantOptions.Value;
}
示例14: OpenSearchService
public OpenSearchService(
IOptions<AppSettings> appSettings,
IUrlHelper urlHelper)
{
this.appSettings = appSettings;
this.urlHelper = urlHelper;
}
示例15: ProcessResponse
private static CommandResult ProcessResponse(IOptions options, Saml2Response samlResponse)
{
var principal = new ClaimsPrincipal(samlResponse.GetClaims(options));
principal = options.SPOptions.SystemIdentityModelIdentityConfiguration
.ClaimsAuthenticationManager.Authenticate(null, principal);
var requestState = samlResponse.GetRequestState(options);
if(requestState == null && options.SPOptions.ReturnUrl == null)
{
throw new ConfigurationErrorsException(MissingReturnUrlMessage);
}
return new CommandResult()
{
HttpStatusCode = HttpStatusCode.SeeOther,
Location = requestState?.ReturnUrl ?? options.SPOptions.ReturnUrl,
Principal = principal,
RelayData =
requestState == null
? null
: requestState.RelayData
};
}