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
function deco( | |
target: any, | |
propertyKey: string, | |
descriptor: PropertyDescriptor | |
) { | |
console.log(`method "${propertyKey}" decorator: begin`); | |
if (descriptor === undefined) { | |
descriptor = Object.getOwnPropertyDescriptor(target, propertyKey); | |
} | |
const originalMethod = descriptor.value; |
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 class WebBlogsDbContext : Microsoft.EntityFrameworkCore.DbContext | |
{ | |
public virtual DbSet<Author> Authors { get; protected set; } | |
public WebBlogsDbContext(DbContextOptions options) : base(options) | |
{ | |
} | |
protected override void OnModelCreating(ModelBuilder 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
// Author.cs | |
public class Author | |
{ | |
public int Id { get; protected set; } | |
public string FirstName { get; protected set; } | |
public string LastName { get; protected set; } | |
private readonly List<Blog> _blogs = new List<Blog>(); | |
public IReadOnlyCollection<Blog> Blogs => _blogs; | |
} |
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
// AuthorEntityTypeConfiguration.cs | |
internal class AuthorEntityTypeConfiguration : IEntityTypeConfiguration<Author> | |
{ | |
public void Configure(EntityTypeBuilder<Author> builder) | |
{ | |
builder.ToTable("Authors"); | |
builder.HasKey(x => x.Id); | |
builder.Property(x => x.Id).HasColumnName("Id").ValueGeneratedOnAdd(); | |
builder.Property(x => x.FirstName).HasColumnName("FirstName").HasMaxLength(50).IsRequired(); |
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
export class CanvasAnimation { | |
private readonly context: CanvasRenderingContext2D; | |
constructor(private readonly canvas: HTMLCanvasElement) { | |
this.context = this.canvas.getContext('2d'); | |
window.requestAnimationFrame(() => this.draw()); | |
} | |
draw() { | |
// do stuff |
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
private calculateMouseRelativePositionInCanvas(e: MouseEvent) { | |
// Note: I have handled scroll effect | |
this.mousePosition.x = | |
e.clientX + | |
(document.documentElement.scrollLeft || document.body.scrollLeft) - | |
this.canvas.offsetLeft; | |
this.mousePosition.y = | |
e.clientY + | |
(document.documentElement.scrollTop || document.body.scrollTop) - | |
this.canvas.offsetTop; |
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
export class CsvDataService { | |
static exportToCsv(filename: string, rows: object[]) { | |
if (!rows || !rows.length) { | |
return; | |
} | |
const separator = ','; | |
const keys = Object.keys(rows[0]); | |
const csvContent = | |
keys.join(separator) + | |
'\n' + |
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
import { Injectable, Inject } from '@angular/core'; | |
import { ReplaySubject, Observable, forkJoin } from 'rxjs'; | |
import { DOCUMENT } from '@angular/common'; | |
@Injectable({ | |
providedIn: 'root' | |
}) | |
export class QuillEditorService { | |
private _loadedLibraries: { [url: string]: ReplaySubject<any> } = {}; |
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
declare var Quill: any; | |
@Component({ | |
//... | |
}) | |
export class QuillEditorComponent implements OnInit { | |
constructor( | |
// ... | |
private readonly svc: QuillEditorService, |
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 class LotNamesCache : ILotNamesCache | |
{ | |
public const string CacheKey = nameof(LotNamesCache); | |
private readonly ImmutableCacheDbContext _dbContext; | |
private readonly IMemoryCache _cache; | |
public LotNamesCache(ImmutableCacheDbContext dbContext, IMemoryCache cache) | |
{ | |
_dbContext = dbContext; | |
_cache = cache; |
OlderNewer