Here are the examples of the csharp api System.Threading.Tasks.Task.FromResult(int) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
1711 Examples
19
View Source File : HelloService.cs
License : MIT License
Project Creator : 1100100
License : MIT License
Project Creator : 1100100
public async Task<int> Age()
{
//await Task.Delay(2000);
return await Task.FromResult(18);
}
19
View Source File : TaskBuild.cs
License : MIT License
Project Creator : 2881099
License : MIT License
Project Creator : 2881099
[JSFunction]
public async Task CodeGenerates(string jsonStr)
{
var ids = Newtonsoft.Json.JsonConvert.DeserializeObject<string[]>(jsonStr);
foreach(var id in ids)
{
if (Guid.TryParse(id, out Guid gid) && gid != Guid.Empty)
{
var model = Curd.TaskBuild.Select.WhereDynamic(gid)
.LeftJoin(a => a.Templates.Id == a.TemplatesId)
.IncludeMany(a => a.TaskBuildInfos, b => b.Include(p => p.DataBaseConfig))
.ToOne();
InvokeJS($"$('.helper-loading-text').text('正在生成[{model.TaskName}]请稍后....')");
await Task.Delay(500);
var res = await new CodeGenerate().Setup(model);
InvokeJS($"$('.helper-loading-text').text('[{model.TaskName}]{res}')");
if(res.Contains("发生异常")) await Task.Delay(3000);
}
else
{
InvokeJS("Helper.ui.alert.error('生成失败','参数不是有效的.');");
}
}
await Task.FromResult(0);
InvokeJS("Helper.ui.removeDialog();");
}
19
View Source File : TaskBuild.cs
License : MIT License
Project Creator : 2881099
License : MIT License
Project Creator : 2881099
[JSFunction]
public async Task delTaslBuild(string id)
{
if (Guid.TryParse(id, out Guid gid) && gid != Guid.Empty)
{
Curd.TaskBuildInfo.Delete(a => a.TaskBuildId == gid);
Curd.TaskBuild.Delete(gid);
var _temp = Data.FirstOrDefault(a => a.Id == gid);
Data.Remove(_temp);
Data.SaveChanges();
InvokeJS("tableTaskBuild.bootstrapTable('load', page.Data);$('[data-toggle=\"tooltip\"]').tooltip();");
InvokeJS("Helper.ui.message.success('删除任务成功');");
await Task.FromResult(0);
}
}
19
View Source File : Template.cs
License : MIT License
Project Creator : 2881099
License : MIT License
Project Creator : 2881099
[JSFunction]
public async Task delTemplate(string id)
{
if (Guid.TryParse(id, out Guid gid) && gid != Guid.Empty)
{
if(Curd.TaskBuild.Select.Any(a => a.TemplatesId == gid))
{
InvokeJS("Helper.ui.message.error('当前模板有任务构建,删除失败.');");
return;
}
Curd.Templates.Delete(gid);
var _temp = Data.FirstOrDefault(a => a.Id == gid);
Data.Remove(_temp);
Data.SaveChanges();
InvokeJS("departments.bootstrapTable('load', page.Data);$('[data-toggle=\"tooltip\"]').tooltip();");
InvokeJS("Helper.ui.message.success('删除数据库信息成功');");
await Task.FromResult(0);
}
}
19
View Source File : DbList.cs
License : MIT License
Project Creator : 2881099
License : MIT License
Project Creator : 2881099
[JSFunction]
public async Task delDataBase(string id)
{
if (Guid.TryParse(id, out Guid gid) && gid != Guid.Empty)
{
Curd.TaskBuildInfo.Delete(a => a.DataBaseConfigId == gid);
Curd.DataBase.Delete(gid);
var _temp = Data.FirstOrDefault(a => a.Id == gid);
Data.Remove(_temp);
Data.SaveChanges();
InvokeJS("departments.bootstrapTable('load', page.Data);$('[data-toggle=\"tooltip\"]').tooltip();");
InvokeJS("Helper.ui.message.success('删除数据库信息成功');");
await Task.FromResult(0);
}
}
19
View Source File : SliceStream.cs
License : MIT License
Project Creator : abdullin
License : MIT License
Project Creator : abdullin
public override Task<int> ReadAsync(byte[] buffer, int offset, int count, System.Threading.CancellationToken cancellationToken)
{
ValidateBuffer(buffer, offset, count);
if (cancellationToken.IsCancellationRequested)
{
return TaskHelpers.FromCancellation<int>(cancellationToken);
}
try
{
int n = Read(buffer, offset, count);
var task = m_lastTask;
return task != null && task.Result == n ? task : (m_lastTask = Task.FromResult(n));
}
catch (Exception e)
{
return TaskHelpers.FromException<int>(e);
}
}
19
View Source File : BaseCommand.cs
License : Apache License 2.0
Project Creator : acblog
License : Apache License 2.0
Project Creator : acblog
public virtual Task<int> Handle(T argument, IHost host, CancellationToken cancellationToken) => Task.FromResult(0);
19
View Source File : ApiClientTestFixtureBase.cs
License : Apache License 2.0
Project Creator : Actify-Inc
License : Apache License 2.0
Project Creator : Actify-Inc
public virtual Task InitializeAsync()
{
return Task.FromResult(0);
}
19
View Source File : JobDispatcherL0.cs
License : MIT License
Project Creator : actions
License : MIT License
Project Creator : actions
[Fact]
[Trait("Level", "L0")]
[Trait("Category", "Runner")]
public async void DispatchesJobRequest()
{
//Arrange
using (var hc = new TestHostContext(this))
{
var jobDispatcher = new JobDispatcher();
hc.SetSingleton<IConfigurationStore>(_configurationStore.Object);
hc.SetSingleton<IRunnerServer>(_runnerServer.Object);
hc.EnqueueInstance<IProcessChannel>(_processChannel.Object);
hc.EnqueueInstance<IProcessInvoker>(_processInvoker.Object);
_configurationStore.Setup(x => x.GetSettings()).Returns(new RunnerSettings() { PoolId = 1 });
jobDispatcher.Initialize(hc);
var ts = new CancellationTokenSource();
Pipelines.AgentJobRequestMessage message = CreateJobRequestMessage();
string strMessage = JsonUtility.ToString(message);
_processInvoker.Setup(x => x.ExecuteAsync(It.IsAny<String>(), It.IsAny<String>(), "spawnclient 1 2", null, It.IsAny<CancellationToken>()))
.Returns(Task.FromResult<int>(56));
_processChannel.Setup(x => x.StartServer(It.IsAny<StartProcessDelegate>()))
.Callback((StartProcessDelegate startDel) => { startDel("1", "2"); });
_processChannel.Setup(x => x.SendAsync(MessageType.NewJobRequest, It.Is<string>(s => s.Equals(strMessage)), It.IsAny<CancellationToken>()))
.Returns(Task.CompletedTask);
var request = new TaskAgentJobRequest();
PropertyInfo sessionIdProperty = request.GetType().GetProperty("LockedUntil", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
replacedert.NotNull(sessionIdProperty);
sessionIdProperty.SetValue(request, DateTime.UtcNow.AddMinutes(5));
_runnerServer.Setup(x => x.RenewAgentRequestAsync(It.IsAny<int>(), It.IsAny<long>(), It.IsAny<Guid>(), It.IsAny<string>(), It.IsAny<CancellationToken>())).Returns(Task.FromResult<TaskAgentJobRequest>(request));
_runnerServer.Setup(x => x.FinishAgentRequestAsync(It.IsAny<int>(), It.IsAny<long>(), It.IsAny<Guid>(), It.IsAny<DateTime>(), It.IsAny<TaskResult>(), It.IsAny<CancellationToken>())).Returns(Task.FromResult<TaskAgentJobRequest>(new TaskAgentJobRequest()));
//Actt
jobDispatcher.Run(message);
//replacedert
await jobDispatcher.WaitAsync(CancellationToken.None);
replacedert.False(jobDispatcher.RunOnceJobCompleted.Task.IsCompleted, "JobDispatcher should not set task complete token for regular agent.");
}
}
19
View Source File : JobDispatcherL0.cs
License : MIT License
Project Creator : actions
License : MIT License
Project Creator : actions
[Fact]
[Trait("Level", "L0")]
[Trait("Category", "Runner")]
public async void DispatchesOneTimeJobRequest()
{
//Arrange
using (var hc = new TestHostContext(this))
{
var jobDispatcher = new JobDispatcher();
hc.SetSingleton<IConfigurationStore>(_configurationStore.Object);
hc.SetSingleton<IRunnerServer>(_runnerServer.Object);
hc.EnqueueInstance<IProcessChannel>(_processChannel.Object);
hc.EnqueueInstance<IProcessInvoker>(_processInvoker.Object);
_configurationStore.Setup(x => x.GetSettings()).Returns(new RunnerSettings() { PoolId = 1 });
jobDispatcher.Initialize(hc);
var ts = new CancellationTokenSource();
Pipelines.AgentJobRequestMessage message = CreateJobRequestMessage();
string strMessage = JsonUtility.ToString(message);
_processInvoker.Setup(x => x.ExecuteAsync(It.IsAny<String>(), It.IsAny<String>(), "spawnclient 1 2", null, It.IsAny<CancellationToken>()))
.Returns(Task.FromResult<int>(56));
_processChannel.Setup(x => x.StartServer(It.IsAny<StartProcessDelegate>()))
.Callback((StartProcessDelegate startDel) => { startDel("1", "2"); });
_processChannel.Setup(x => x.SendAsync(MessageType.NewJobRequest, It.Is<string>(s => s.Equals(strMessage)), It.IsAny<CancellationToken>()))
.Returns(Task.CompletedTask);
var request = new TaskAgentJobRequest();
PropertyInfo sessionIdProperty = request.GetType().GetProperty("LockedUntil", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
replacedert.NotNull(sessionIdProperty);
sessionIdProperty.SetValue(request, DateTime.UtcNow.AddMinutes(5));
_runnerServer.Setup(x => x.RenewAgentRequestAsync(It.IsAny<int>(), It.IsAny<long>(), It.IsAny<Guid>(), It.IsAny<string>(), It.IsAny<CancellationToken>())).Returns(Task.FromResult<TaskAgentJobRequest>(request));
_runnerServer.Setup(x => x.FinishAgentRequestAsync(It.IsAny<int>(), It.IsAny<long>(), It.IsAny<Guid>(), It.IsAny<DateTime>(), It.IsAny<TaskResult>(), It.IsAny<CancellationToken>())).Returns(Task.FromResult<TaskAgentJobRequest>(new TaskAgentJobRequest()));
//Act
jobDispatcher.Run(message, true);
//replacedert
await jobDispatcher.WaitAsync(CancellationToken.None);
replacedert.True(jobDispatcher.RunOnceJobCompleted.Task.IsCompleted, "JobDispatcher should set task complete token for one time agent.");
replacedert.True(jobDispatcher.RunOnceJobCompleted.Task.Result, "JobDispatcher should set task complete token to 'TRUE' for one time agent.");
}
}
19
View Source File : DotNetFrameworkTests.cs
License : MIT License
Project Creator : adamant
License : MIT License
Project Creator : adamant
[Fact]
public async Task TaskCycleDeadlocks()
{
var t2 = Task.FromResult(2);
var t1 = GetValueAsync(() => t2);
t2 = GetValueAsync(() => t1);
var delayTask = Task.Delay((int)TimeSpan.FromSeconds(2).TotalMilliseconds);
var completedTask = await Task.WhenAny(t1, delayTask).ConfigureAwait(false);
replacedert.Equal(delayTask, completedTask);
}
19
View Source File : DotNetFrameworkTests.cs
License : MIT License
Project Creator : adamant
License : MIT License
Project Creator : adamant
[Fact]
public async Task TaskSelfReferenceDeadlocks()
{
var task = Task.FromResult(1);
task = GetValueAsync(() => task);
var delayTask = Task.Delay((int)TimeSpan.FromSeconds(2).TotalMilliseconds);
var completedTask = await Task.WhenAny(task, delayTask).ConfigureAwait(false);
replacedert.Equal(delayTask, completedTask);
}
19
View Source File : ValueTaskOverheadBenchmarks.cs
License : MIT License
Project Creator : adamsitnik
License : MIT License
Project Creator : adamsitnik
Task<int> SampleUsageAsync() => Task.FromResult(1);
19
View Source File : ValueTaskOverheadBenchmarks.cs
License : MIT License
Project Creator : adamsitnik
License : MIT License
Project Creator : adamsitnik
Task<int> ExecuteAsync() => Task.FromResult(1);
19
View Source File : Startup.cs
License : MIT License
Project Creator : Adoxio
License : MIT License
Project Creator : Adoxio
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IOptions<AzureAdB2COidcOptions> azureAdB2COidcOptions, IOptions<AzureAdB2CJwtOptions> azureAdB2CJwtOptions)
{
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseBrowserLink();
}
else
{
app.UseExceptionHandler("/Home/Error");
}
app.UseStaticFiles();
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
LoginPath = new PathString("/Account/SignIn"),
LogoutPath = new PathString("/Account/LogOff"),
CookieName = Configuration["Authentication:CookieName"]
});
app.UseCors("CorsPolicy");
// Setup Azure AD B2C OpenID Connect Authentication
app.UseOpenIdConnectAuthentication(new OpenIdConnectOptions
{
Authority = azureAdB2COidcOptions.Value.Authority,
MetadataAddress = azureAdB2COidcOptions.Value.Metadata,
SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme,
AuthenticationScheme = azureAdB2COidcOptions.Value.DefaultPolicy.ToLower(),
ClientId = azureAdB2COidcOptions.Value.ClientId,
PostLogoutRedirectUri = azureAdB2COidcOptions.Value.RedirectUri,
Events = new OpenIdConnectEvents
{
OnRemoteFailure = RemoteFailure,
OnRedirectToIdenreplacedyProvider = context =>
{
if (context.Request.Path.StartsWithSegments("/api") && context.Response.StatusCode == (int)HttpStatusCode.Unauthorized)
{
context.SkipToNextMiddleware();
}
return Task.FromResult(0);
}
},
ResponseType = OpenIdConnectResponseType.IdToken,
TokenValidationParameters = new TokenValidationParameters
{
NameClaimType = "name",
}
});
// Setup Azure AD B2C JWT Bearer Authentication
app.UseJwtBearerAuthentication(new JwtBearerOptions
{
MetadataAddress = azureAdB2CJwtOptions.Value.Metadata,
Audience = azureAdB2CJwtOptions.Value.ClientId,
Events = new JwtBearerEvents
{
OnAuthenticationFailed = context =>
{
return Task.FromResult(0);
},
OnChallenge = context =>
{
return Task.FromResult(0);
},
OnMessageReceived = context =>
{
return Task.FromResult(0);
},
OnTokenValidated = context =>
{
return Task.FromResult(0);
},
}
});
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
}
19
View Source File : Startup.cs
License : MIT License
Project Creator : Adoxio
License : MIT License
Project Creator : Adoxio
private Task RemoteFailure(FailureContext context)
{
context.HandleResponse();
if (context.Failure is OpenIdConnectProtocolException && context.Failure.Message.Contains("access_denied"))
{
context.Response.Redirect("/");
}
else
{
context.Response.Redirect("/Home/Error?message=" + context.Failure.Message);
}
return Task.FromResult(0);
}
19
View Source File : CrmInvitationStore.cs
License : MIT License
Project Creator : Adoxio
License : MIT License
Project Creator : Adoxio
public virtual Task RedeemAsync(TInvitation invitation, CrmUser<TKey> user, string userHostAddress)
{
ThrowIfDisposed();
if (invitation == null) throw new ArgumentNullException("invitation");
if (user == null) throw new ArgumentNullException("user");
Execute(ToRedeemRequests(invitation, user, userHostAddress));
return Task.FromResult(0);
}
19
View Source File : CrmUserStore.cs
License : MIT License
Project Creator : Adoxio
License : MIT License
Project Creator : Adoxio
public virtual Task SetPreplacedwordHashAsync(TUser user, string preplacedwordHash)
{
ThrowIfDisposed();
user.PreplacedwordHash = preplacedwordHash;
return Task.FromResult(0);
}
19
View Source File : CrmUserStore.cs
License : MIT License
Project Creator : Adoxio
License : MIT License
Project Creator : Adoxio
public virtual Task SetEmailAsync(TUser user, string email)
{
ThrowIfDisposed();
user.Email = email;
return Task.FromResult(0);
}
19
View Source File : CrmUserStore.cs
License : MIT License
Project Creator : Adoxio
License : MIT License
Project Creator : Adoxio
public virtual Task SetEmailConfirmedAsync(TUser user, bool confirmed)
{
ThrowIfDisposed();
user.EmailConfirmed = confirmed;
return Task.FromResult(0);
}
19
View Source File : CrmUserStore.cs
License : MIT License
Project Creator : Adoxio
License : MIT License
Project Creator : Adoxio
public virtual Task SetPhoneNumberAsync(TUser user, string phoneNumber)
{
ThrowIfDisposed();
user.PhoneNumber = phoneNumber;
return Task.FromResult(0);
}
19
View Source File : CrmUserStore.cs
License : MIT License
Project Creator : Adoxio
License : MIT License
Project Creator : Adoxio
public virtual Task SetPhoneNumberConfirmedAsync(TUser user, bool confirmed)
{
ThrowIfDisposed();
user.PhoneNumberConfirmed = confirmed;
return Task.FromResult(0);
}
19
View Source File : CrmUserStore.cs
License : MIT License
Project Creator : Adoxio
License : MIT License
Project Creator : Adoxio
public virtual Task SetSecurityStampAsync(TUser user, string stamp)
{
ThrowIfDisposed();
user.SecurityStamp = stamp;
return Task.FromResult(0);
}
19
View Source File : CrmUserStore.cs
License : MIT License
Project Creator : Adoxio
License : MIT License
Project Creator : Adoxio
public virtual Task SetTwoFactorEnabledAsync(TUser user, bool enabled)
{
ThrowIfDisposed();
user.TwoFactorEnabled = enabled;
return Task.FromResult(0);
}
19
View Source File : CrmUserStore.cs
License : MIT License
Project Creator : Adoxio
License : MIT License
Project Creator : Adoxio
public virtual Task ResetAccessFailedCountAsync(TUser user)
{
ThrowIfDisposed();
user.AccessFailedCount = 0;
return Task.FromResult(0);
}
19
View Source File : CrmUserStore.cs
License : MIT License
Project Creator : Adoxio
License : MIT License
Project Creator : Adoxio
public virtual Task SetLockoutEnabledAsync(TUser user, bool enabled)
{
ThrowIfDisposed();
user.LockoutEnabled = enabled;
return Task.FromResult(0);
}
19
View Source File : CrmUserStore.cs
License : MIT License
Project Creator : Adoxio
License : MIT License
Project Creator : Adoxio
public virtual Task SetLockoutEndDateAsync(TUser user, DateTimeOffset lockoutEnd)
{
ThrowIfDisposed();
user.LockoutEndDateUtc = lockoutEnd == DateTimeOffset.MinValue
? new DateTime?()
: lockoutEnd.UtcDateTime;
return Task.FromResult(0);
}
19
View Source File : CrmUserStore.cs
License : MIT License
Project Creator : Adoxio
License : MIT License
Project Creator : Adoxio
public virtual Task AddLoginAsync(TUser user, UserLoginInfo login)
{
ThrowIfDisposed();
user.AddLogin(login);
return Task.FromResult(0);
}
19
View Source File : CrmUserStore.cs
License : MIT License
Project Creator : Adoxio
License : MIT License
Project Creator : Adoxio
public virtual Task RemoveLoginAsync(TUser user, UserLoginInfo login)
{
ThrowIfDisposed();
user.RemoveLogin(login);
return Task.FromResult(0);
}
19
View Source File : AppDataPortalBusProvider.cs
License : MIT License
Project Creator : Adoxio
License : MIT License
Project Creator : Adoxio
protected virtual Task OnSubscriptionErrorAsync(Exception error)
{
WebEventSource.Log.GenericErrorException(new Exception("Subscription error: InstanceId: " + this.Options.InstanceId, error));
return Task.FromResult(0);
}
19
View Source File : AppDataPortalBusProvider.cs
License : MIT License
Project Creator : Adoxio
License : MIT License
Project Creator : Adoxio
protected virtual Task WriteMessage(TimeSpan timeout, string subscriptionPath, TMessage message)
{
// clean up expired files
var directory = this.Options.RetryPolicy.GetDirectory(subscriptionPath);
var expired =
this.Options.RetryPolicy.GetFiles(directory, "*.msg")
.Where(file => file.LastAccessTimeUtc + timeout < DateTime.UtcNow)
.ToArray();
foreach (var file in expired)
{
try
{
this.Options.RetryPolicy.FileDelete(file);
}
catch (Exception e)
{
ADXTrace.Instance.TraceError(TraceCategory.Application, e.ToString());
}
}
var name = GetFilename(message);
var tempPath = Path.Combine(subscriptionPath, name + ".lock.msg");
var messagePath = Path.Combine(subscriptionPath, name + ".msg");
// write to a temporary file
using (var fs = this.Options.RetryPolicy.Open(tempPath, FileMode.CreateNew))
using (var sw = new StreamWriter(fs))
using (var jw = new JsonTextWriter(sw))
{
jw.Formatting = Formatting.Indented;
_serializer.Serialize(jw, message);
}
// rename to the destination file
this.Options.RetryPolicy.FileMove(tempPath, messagePath);
ADXTrace.Instance.TraceInfo(TraceCategory.Application, string.Format("messagePath={0}", messagePath));
return Task.FromResult(0);
}
19
View Source File : ApplicationRestartPortalBusMessage.cs
License : MIT License
Project Creator : Adoxio
License : MIT License
Project Creator : Adoxio
public override Task InvokeAsync(IOwinContext context)
{
WebEventSource.Log.WriteApplicationLifecycleEvent(ApplicationLifecycleEventCategory.Restart, "PortalBusMessage Initiating Restart");
TelemetryState.ApplicationEndInfo = ApplicationEndFlags.MetadataDriven;
Web.Extensions.RestartWebApplication();
return Task.FromResult(0);
}
19
View Source File : CacheInvalidationPortalBusMessage.cs
License : MIT License
Project Creator : Adoxio
License : MIT License
Project Creator : Adoxio
public override Task InvokeAsync(IOwinContext context)
{
ADXTrace.Instance.TraceInfo(TraceCategory.Application, string.Format("Id={0}", Id));
Trace(Message);
var cache = OrganizationServiceCachePluginMessageHandler.GetOrganizationServiceCache();
cache.ExtendedRemoveLocal(Message);
return Task.FromResult(0);
}
19
View Source File : LocalOnlyPortalBusProvider.cs
License : MIT License
Project Creator : Adoxio
License : MIT License
Project Creator : Adoxio
protected override Task SendRemoteAsync(IOwinContext context, TMessage message)
{
// do nothing
return Task.FromResult(0);
}
19
View Source File : PortalBusManager.cs
License : MIT License
Project Creator : Adoxio
License : MIT License
Project Creator : Adoxio
public static Task PostAsync(IOwinContext context, TMessage message)
{
_buffer.Post(new Tuple<IOwinContext, TMessage>(context, message));
return Task.FromResult(0);
}
19
View Source File : SiteMapAuthenticationMiddleWare.cs
License : MIT License
Project Creator : Adoxio
License : MIT License
Project Creator : Adoxio
protected override Task TeardownCoreAsync()
{
if (Response == null
|| Response.StatusCode != (int)HttpStatusCode.Forbidden
|| !Options.LoginPath.HasValue
|| Request == null || Request.User == null || Request.User.Idenreplacedy == null
|| Request.User.Idenreplacedy.IsAuthenticated)
{
return Task.FromResult(0);
}
var challenge = Helper.LookupChallenge(Options.AuthenticationType, Options.AuthenticationMode);
if (challenge != null)
{
var contextLanguageInfo = Context.GetContextLanguageInfo();
var region = contextLanguageInfo.IsCrmMultiLanguageEnabled ? "/" + contextLanguageInfo.ContextLanguage.Code : null;
var currentUri = Request.PathBase + Request.Path + Request.QueryString;
var baseUri = new Uri(Request.Scheme + Uri.SchemeDelimiter + Request.Host);
var relativeUri = Request.PathBase + region + (Options.LoginPath.Value.AppendQueryString(Options.ReturnUrlParameter, currentUri));
var loginUri = new Uri(baseUri, relativeUri).AbsoluteUri;
var redirectContext = new CookieApplyRedirectContext(Context, Options, loginUri);
_logger.WriteInformation(loginUri);
Options.Provider.ApplyRedirect(redirectContext);
}
return Task.FromResult(0);
}
19
View Source File : IdentityConfig.cs
License : MIT License
Project Creator : Adoxio
License : MIT License
Project Creator : Adoxio
public Task SendAsync(IdenreplacedyMessage message)
{
// Plug in your email service here to send an email.
return Task.FromResult(0);
}
19
View Source File : IdentityConfig.cs
License : MIT License
Project Creator : Adoxio
License : MIT License
Project Creator : Adoxio
public Task SendAsync(IdenreplacedyMessage message)
{
// Plug in your sms service here to send a text message.
return Task.FromResult(0);
}
19
View Source File : MessageServices.cs
License : Apache License 2.0
Project Creator : Aguafrommars
License : Apache License 2.0
Project Creator : Aguafrommars
public Task SendEmailAsync(string email, string subject, string message)
{
// Plug in your email service here to send an email.
return Task.FromResult(0);
}
19
View Source File : MessageServices.cs
License : Apache License 2.0
Project Creator : Aguafrommars
License : Apache License 2.0
Project Creator : Aguafrommars
public Task SendSmsAsync(string number, string message)
{
// Plug in your SMS service here to send a text message.
return Task.FromResult(0);
}
19
View Source File : MessageServices.cs
License : Apache License 2.0
Project Creator : Aguafrommars
License : Apache License 2.0
Project Creator : Aguafrommars
public static Task SendEmailAsync(string email, string subject, string message)
{
// Plug in your email service
return Task.FromResult(0);
}
19
View Source File : MessageServices.cs
License : Apache License 2.0
Project Creator : Aguafrommars
License : Apache License 2.0
Project Creator : Aguafrommars
public static Task SendSmsAsync(string number, string message)
{
// Plug in your sms service
return Task.FromResult(0);
}
19
View Source File : EmptyDeviceAccessor.cs
License : MIT License
Project Creator : aguang-xyz
License : MIT License
Project Creator : aguang-xyz
public Task<int> GetDurationAsync()
{
return Task.FromResult(1);
}
19
View Source File : EmptyDeviceAccessor.cs
License : MIT License
Project Creator : aguang-xyz
License : MIT License
Project Creator : aguang-xyz
public Task<int> GetCurrentTimeAsync()
{
return Task.FromResult(0);
}
19
View Source File : EmptyDeviceAccessor.cs
License : MIT License
Project Creator : aguang-xyz
License : MIT License
Project Creator : aguang-xyz
public Task<int> GetVolumeAsync()
{
return Task.FromResult(100);
}
19
View Source File : FileDeleter.cs
License : MIT License
Project Creator : AiursoftWeb
License : MIT License
Project Creator : AiursoftWeb
public async Task DeleteOnDisk(File file)
{
try
{
var haveDaemon = await _probeDbContext.Files.Where(f => f.Id != file.Id).AnyAsync(f => f.HardwareId == file.HardwareId);
if (!haveDaemon)
{
await _retryEngine.RunWithTry(taskFactory: _ =>
{
_storageProvider.DeleteToTrash(file.HardwareId);
return Task.FromResult(0);
}, attempts: 10);
}
}
catch (Exception e)
{
var token = await _appsContainer.AccessToken();
await _eventService.LogExceptionAsync(token, e, "Deleter");
}
}
19
View Source File : AnonymousIdMiddlewareTests.cs
License : MIT License
Project Creator : aleripe
License : MIT License
Project Creator : aleripe
[Fact]
public async Task TestAvailableFeature()
{
var cookieOptions = new AnonymousIdCookieOptionsBuilder().Build();
var requestMock = new Mock<HttpRequest>();
requestMock.Setup(x => x.Cookies).Returns(new RequestCookieCollection());
var userMock = new Mock<ClaimsPrincipal>();
userMock.Setup(x => x.Idenreplacedy).Returns(new ClaimsIdenreplacedy());
var contextMock = new Mock<HttpContext>();
contextMock.Setup(x => x.Features).Returns(new FeatureCollection());
contextMock.Setup(x => x.Request).Returns(requestMock.Object);
contextMock.Setup(x => x.Response).Returns(new DefaultHttpResponse(new DefaultHttpContext()));
contextMock.Setup(x => x.User).Returns(userMock.Object);
var anonymousIdMiddleware = new AnonymousIdMiddleware(nextDelegate: (innerHttpContext) => Task.FromResult(0), cookieOptions: cookieOptions);
await anonymousIdMiddleware.Invoke(contextMock.Object);
replacedert.NotNull(contextMock.Object.Features.Get<IAnonymousIdFeature>());
replacedert.True(!string.IsNullOrWhiteSpace(contextMock.Object.Features.Get<IAnonymousIdFeature>().AnonymousId));
}
19
View Source File : AnonymousIdMiddlewareTests.cs
License : MIT License
Project Creator : aleripe
License : MIT License
Project Creator : aleripe
[Fact]
public async Task TestDeleteExistingNonSecureCookie()
{
var cookieOptions = new AnonymousIdCookieOptionsBuilder()
.SetCustomCookieRequireSsl(true)
.Build();
Dictionary<string, string> cookies = new Dictionary<string, string>();
cookies.Add(cookieOptions.Name, "QOOUV4vy0gEkAAAANDQ3ZGU5OTUtNTQ4Ny00OTNlLThhM2QtMDQ5ZDUyNmY2NzIw");
var requestMock = new Mock<HttpRequest>();
requestMock.Setup(x => x.IsHttps).Returns(false);
requestMock.Setup(x => x.Cookies).Returns(new RequestCookieCollection(cookies));
var userMock = new Mock<ClaimsPrincipal>();
userMock.Setup(x => x.Idenreplacedy).Returns(new ClaimsIdenreplacedy());
var contextMock = new Mock<HttpContext>();
contextMock.Setup(x => x.Features).Returns(new FeatureCollection());
contextMock.Setup(x => x.Request).Returns(requestMock.Object);
contextMock.Setup(x => x.Response).Returns(new DefaultHttpResponse(new DefaultHttpContext()));
contextMock.Setup(x => x.User).Returns(userMock.Object);
var anonymousIdMiddleware = new AnonymousIdMiddleware(nextDelegate: (innerHttpContext) => Task.FromResult(0), cookieOptions: cookieOptions);
await anonymousIdMiddleware.Invoke(contextMock.Object);
replacedert.NotNull(contextMock.Object.Features.Get<IAnonymousIdFeature>());
replacedert.Equal(null, contextMock.Object.Features.Get<IAnonymousIdFeature>().AnonymousId);
replacedert.True(string.IsNullOrWhiteSpace(GetCookieValueFromResponse(contextMock.Object.Response, cookieOptions.Name)));
}
19
View Source File : AnonymousIdMiddlewareTests.cs
License : MIT License
Project Creator : aleripe
License : MIT License
Project Creator : aleripe
[Fact]
public async Task TestCreateCookie()
{
var cookieOptions = new AnonymousIdCookieOptionsBuilder().Build();
var requestMock = new Mock<HttpRequest>();
requestMock.Setup(x => x.Cookies).Returns(new RequestCookieCollection());
var userMock = new Mock<ClaimsPrincipal>();
userMock.Setup(x => x.Idenreplacedy).Returns(new ClaimsIdenreplacedy());
var contextMock = new Mock<HttpContext>();
contextMock.Setup(x => x.Features).Returns(new FeatureCollection());
contextMock.Setup(x => x.Request).Returns(requestMock.Object);
contextMock.Setup(x => x.Response).Returns(new DefaultHttpResponse(new DefaultHttpContext()));
contextMock.Setup(x => x.User).Returns(userMock.Object);
var anonymousIdMiddleware = new AnonymousIdMiddleware(nextDelegate: (innerHttpContext) => Task.FromResult(0), cookieOptions: cookieOptions);
await anonymousIdMiddleware.Invoke(contextMock.Object);
replacedert.True(!string.IsNullOrWhiteSpace(GetCookieValueFromResponse(contextMock.Object.Response, cookieOptions.Name)));
}
19
View Source File : AnonymousIdMiddlewareTests.cs
License : MIT License
Project Creator : aleripe
License : MIT License
Project Creator : aleripe
[Fact]
public async Task TestReadExistingCookie()
{
var cookieOptions = new AnonymousIdCookieOptionsBuilder().Build();
Dictionary<string, string> cookies = new Dictionary<string, string>();
cookies.Add(cookieOptions.Name, "QOOUV4vy0gEkAAAANDQ3ZGU5OTUtNTQ4Ny00OTNlLThhM2QtMDQ5ZDUyNmY2NzIw");
var requestMock = new Mock<HttpRequest>();
requestMock.Setup(x => x.Cookies).Returns(new RequestCookieCollection(cookies));
var userMock = new Mock<ClaimsPrincipal>();
userMock.Setup(x => x.Idenreplacedy).Returns(new ClaimsIdenreplacedy());
var contextMock = new Mock<HttpContext>();
contextMock.Setup(x => x.Features).Returns(new FeatureCollection());
contextMock.Setup(x => x.Request).Returns(requestMock.Object);
contextMock.Setup(x => x.Response).Returns(new DefaultHttpResponse(new DefaultHttpContext()));
contextMock.Setup(x => x.User).Returns(userMock.Object);
var anonymousIdMiddleware = new AnonymousIdMiddleware(nextDelegate: (innerHttpContext) => Task.FromResult(0), cookieOptions: cookieOptions);
await anonymousIdMiddleware.Invoke(contextMock.Object);
replacedert.NotNull(contextMock.Object.Features.Get<IAnonymousIdFeature>());
replacedert.Equal("447de995-5487-493e-8a3d-049d526f6720", contextMock.Object.Features.Get<IAnonymousIdFeature>().AnonymousId);
}
See More Examples