TreF01L
TreF01L
CC#
Created by TreF01L on 5/12/2024 in #help
Delegate with Task problem
I pasted all code
9 replies
CC#
Created by TreF01L on 5/12/2024 in #help
Delegate with Task problem
9 replies
CC#
Created by TreF01L on 5/12/2024 in #help
Delegate with Task problem
private async void RunAndCompareSortMethodMenu(string? errorMessage = null)
{
try
{
foreach (var sortDelegate in _sortsListToShow)
{
var result = await sortDelegate.SortMethod;
Console.WriteLine($"Name: {result.Name} Time: {result.Time}");
}
}
catch (Exception e)
{
Console.WriteLine(e);
throw;
}
private async void RunAndCompareSortMethodMenu(string? errorMessage = null)
{
try
{
foreach (var sortDelegate in _sortsListToShow)
{
var result = await sortDelegate.SortMethod;
Console.WriteLine($"Name: {result.Name} Time: {result.Time}");
}
}
catch (Exception e)
{
Console.WriteLine(e);
throw;
}
9 replies
CC#
Created by TreF01L on 5/12/2024 in #help
Delegate with Task problem
public class SortStopwatch
{
public delegate Task<MethodResponse> SortMethod();

private List<SortDelegate> _sortsList = new List<SortDelegate>();
private List<SortDelegate> _sortsListToShow = new List<SortDelegate>();
private int[] _array;

public SortStopwatch()
{
InitializeArray();
InitializeSortsList();
ShowMainMenu();
}

private void InitializeArray()
{
Console.WriteLine("Enter length of random array: ");
if (!int.TryParse(Console.ReadLine(), out int length) || length <= 0)
{
Console.WriteLine("Your length is incorrect! Try again");
InitializeArray();
}

_array = ArrayGenerator.GenerateRandomArray(length);
}

private void InitializeSortsList()
{
_sortsList.Add(new SortDelegate(nameof(BubbleSort),
Task.Run(async () => await SortMethodFunction(BubbleSort.Sort, (int[])_array.Clone(), nameof(BubbleSort)))));

_sortsList.Add(new SortDelegate(nameof(ChickenSort) + " (Be careful! If you add it when the array length > 50, it will take some more time to sort it)",
Task.Run(async () => await SortMethodFunction(ChickenSort.Sort, (int[])_array.Clone(), nameof(ChickenSort)))));
}

private async Task<MethodResponse> SortMethodFunction(Func<int[], Task<int[]>> function, int[] array, string methodName)
{
Stopwatch stopwatch = Stopwatch.StartNew();
var result = await function(array);

stopwatch.Stop();
return new MethodResponse()
{
Name = methodName,
Time = stopwatch.Elapsed,
Array = result
};
}





}
public class SortStopwatch
{
public delegate Task<MethodResponse> SortMethod();

private List<SortDelegate> _sortsList = new List<SortDelegate>();
private List<SortDelegate> _sortsListToShow = new List<SortDelegate>();
private int[] _array;

public SortStopwatch()
{
InitializeArray();
InitializeSortsList();
ShowMainMenu();
}

private void InitializeArray()
{
Console.WriteLine("Enter length of random array: ");
if (!int.TryParse(Console.ReadLine(), out int length) || length <= 0)
{
Console.WriteLine("Your length is incorrect! Try again");
InitializeArray();
}

_array = ArrayGenerator.GenerateRandomArray(length);
}

private void InitializeSortsList()
{
_sortsList.Add(new SortDelegate(nameof(BubbleSort),
Task.Run(async () => await SortMethodFunction(BubbleSort.Sort, (int[])_array.Clone(), nameof(BubbleSort)))));

_sortsList.Add(new SortDelegate(nameof(ChickenSort) + " (Be careful! If you add it when the array length > 50, it will take some more time to sort it)",
Task.Run(async () => await SortMethodFunction(ChickenSort.Sort, (int[])_array.Clone(), nameof(ChickenSort)))));
}

private async Task<MethodResponse> SortMethodFunction(Func<int[], Task<int[]>> function, int[] array, string methodName)
{
Stopwatch stopwatch = Stopwatch.StartNew();
var result = await function(array);

stopwatch.Stop();
return new MethodResponse()
{
Name = methodName,
Time = stopwatch.Elapsed,
Array = result
};
}





}
9 replies
CC#
Created by TreF01L on 5/3/2024 in #help
JwtBearerAuthentication
No description
74 replies
CC#
Created by TreF01L on 5/3/2024 in #help
JwtBearerAuthentication
I thought that it does't work because I don't confirm email foreach user but I'd turned off this functions in configuration and it didn't work
74 replies
CC#
Created by TreF01L on 5/3/2024 in #help
JwtBearerAuthentication
JWTBearer and JWT NuGenPackets work in my previous project, but still don't work in my project I'm working on now
74 replies
CC#
Created by TreF01L on 5/3/2024 in #help
JwtBearerAuthentication
can you show it too, please?
74 replies
CC#
Created by TreF01L on 5/3/2024 in #help
JwtBearerAuthentication
can you show how did you use it?
74 replies
CC#
Created by TreF01L on 5/3/2024 in #help
JwtBearerAuthentication
okay
74 replies
CC#
Created by TreF01L on 5/3/2024 in #help
JwtBearerAuthentication
nothing changed))
74 replies
CC#
Created by TreF01L on 5/3/2024 in #help
JwtBearerAuthentication
No description
74 replies
CC#
Created by TreF01L on 5/3/2024 in #help
JwtBearerAuthentication
No description
74 replies
CC#
Created by TreF01L on 5/3/2024 in #help
JwtBearerAuthentication
but JWT.Extentions.AspNetCore I've installed
74 replies
CC#
Created by TreF01L on 5/3/2024 in #help
JwtBearerAuthentication
No description
74 replies
CC#
Created by TreF01L on 5/3/2024 in #help
JwtBearerAuthentication
Do you mean that I should paste this code to my project? But there is no such commands even for AddJwt. I only have AddJwtBearer
services.AddAuthentication(options =>
{
options.DefaultAuthenticateScheme = JwtAuthenticationDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = JwtAuthenticationDefaults.AuthenticationScheme;
})
.AddJwt(options =>
{
// secrets, required only for symmetric algorithms, such as HMACSHA256Algorithm
// options.Keys = new[] { "mySecret" };

// optionally; disable throwing an exception if JWT signature is invalid
// options.VerifySignature = false;
});
services.AddAuthentication(options =>
{
options.DefaultAuthenticateScheme = JwtAuthenticationDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = JwtAuthenticationDefaults.AuthenticationScheme;
})
.AddJwt(options =>
{
// secrets, required only for symmetric algorithms, such as HMACSHA256Algorithm
// options.Keys = new[] { "mySecret" };

// optionally; disable throwing an exception if JWT signature is invalid
// options.VerifySignature = false;
});
74 replies
CC#
Created by TreF01L on 5/3/2024 in #help
JwtBearerAuthentication
And I don't know how to debbug it
74 replies
CC#
Created by TreF01L on 5/3/2024 in #help
JwtBearerAuthentication
It is very stange, because there no errors
74 replies
CC#
Created by TreF01L on 5/3/2024 in #help
JwtBearerAuthentication
And it doesn't work
74 replies
CC#
Created by TreF01L on 5/3/2024 in #help
JwtBearerAuthentication
you can see it on this screenshot
74 replies