This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Text.Json; | |
// Client Code | |
public static class Program { | |
public static void Main() { | |
// Sample Data | |
var people = new List<Person> { | |
new("John", "Doe"), | |
new("Jane", "Smith"), | |
new("Alice", "Johnson") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Text.Json; | |
// Client Code | |
public static class Program { | |
public static void Main(string[] args) { | |
// Sample Data | |
var people = new List<Person> { | |
new("John", "Doe"), | |
new("Jane", "Smith"), | |
new("Alice", "Johnson") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#https://quera.org/problemset/294 | |
#This solution is failed in test case 8. | |
import math | |
# Read coefficients a, b, and c | |
a = float(input()) | |
b = float(input()) | |
c = float(input()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
services: | |
api: | |
image: asp-api | |
build: | |
context: . | |
dockerfile: Dockerfile | |
environment: | |
- ASPNETCORE_ENVIRONMENT=Production | |
- ConnectionStrings__Default=Server=db,1433;Database=AspApi;User Id=sa;Password=thisIsMssql@Password;TrustServerCertificate=True; | |
ports: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base | |
USER $APP_UID | |
WORKDIR /app | |
EXPOSE 8080 | |
EXPOSE 8081 | |
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build | |
ARG BUILD_CONFIGURATION=Release | |
WORKDIR /src | |
COPY ["./src/Api/ApiApp.csproj", "./"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
`IProgress<T>` in C# is an interface provided by the .NET Framework to report progress in an asynchronous operation. It allows a producer (usually a background task) to communicate progress updates to a consumer (often the UI thread or another monitoring task). | |
This setup ensures that the progress reporting mechanism is thread-safe and that the consumer of the progress updates can safely update the UI or other state based on the progress. | |
*/ | |
// var progress = new Progress<(long count, List<string> files)>(ReportProgress); | |
var progress = new Progress<(long count, List<string> files)>(); | |
progress.ProgressChanged += (_, data) => { | |
Console.WriteLine($"{data.count} files read. Last file: {data.files.Last()}"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.MapGet("/sse/connect", async (HttpContext context, CancellationToken ct) => { | |
context.Response.Headers.Append("Content-Type", "text/event-stream"); | |
context.Response.Headers.Append("Cache-Control", "no-cache"); | |
context.Response.Headers.Append("Connection", "keep-alive"); | |
var result = new SSEResult(); | |
for (var i = 0; i < 10; i++) { | |
if (ct.IsCancellationRequested) return; | |
result.DateTime = DateTime.Now; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Linq.Expressions; | |
using ConsoleApp.Models; | |
using Microsoft.EntityFrameworkCore; | |
using Microsoft.EntityFrameworkCore.Query; | |
namespace ConsoleApp.Data; | |
public class AppDbContext : DbContext { | |
protected override void OnModelCreating(ModelBuilder modelBuilder) { | |
base.OnModelCreating(modelBuilder); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.ComponentModel; | |
using System.Runtime.CompilerServices; | |
var person = new Person { | |
FirstName = "Hamid" | |
}; | |
person.PropertyChanged += HandlePersonPropertyChanged; | |
person.FirstName = "Mohammad"; | |
return; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public sealed class MySingleton | |
{ | |
private static readonly Lazy<MySingleton> instance = new Lazy<MySingleton>(() => new MySingleton()); | |
private MySingleton() | |
{ | |
// Private constructor to prevent instantiation. | |
} | |
public static MySingleton Instance => instance.Value; |
NewerOlder