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
// Implemented as an extension method (on IMonitorTestHelper that provides logging) but this | |
// dependency can easily ve removed. | |
public static class MonitorTestHelperExtension | |
{ | |
sealed class Resumer | |
{ | |
internal readonly TaskCompletionSource _tcs; | |
readonly Timer _timer; | |
readonly Func<bool, bool> _resume; | |
bool _reentrant; |
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
/* | |
// We need an index to generate the "brand" field. | |
// This correctly handles the inheritance. | |
class Duck { | |
private _0: undefined; | |
constructor(public name: string) { | |
} | |
} | |
class Dog extends Duck { |
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
/// <summary> | |
/// Provides a reading buffer on a Utf8 stream of bytes. | |
/// The Utf8 Byte Order Mask (BOM: 0xEF, 0xBB, 0xBF) that may exist at the start is | |
/// kindly handled. | |
/// <para> | |
/// The buffer comes from the <see cref="ArrayPool{T}.Shared"/> of bytes: this | |
/// reader MUST be disposed to return the current buffer to the pool. | |
/// </para> | |
/// <para> | |
/// The pattern to use it is to replace all <c>Read()</c> calls with: |
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
class EchoTcpServer | |
{ | |
readonly int _port; | |
public EchoTcpServer( int port ) | |
{ | |
_port = port; | |
} | |
public async Task<Exception?> Run( CancellationToken cancel ) |
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; | |
// notnull constraint cannot handle both in and Nullable<T>. | |
public interface IWriter<T> where T : notnull | |
{ | |
void Write( in T o ); | |
void WriteNullable( in T? o ); | |
} | |
public class ValueTypeWriter<T> : IWriter<T> where T : struct | |
{ |
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; | |
using System.Runtime.CompilerServices; | |
public ref struct ROSpanMatcher | |
{ | |
public ReadOnlySpan<char> Head; | |
public int _le; | |
public ROSpanMatcher( ReadOnlySpan<char> text ) | |
{ | |
Head = text; |
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 memorize( f ) { return f; } | |
function MyObject( name ) { | |
this.name = name; | |
} | |
MyObject.prototype.show = function( x, y ) { | |
console.log( this.name, x, y ); | |
} | |
var o1 = new MyObject( 'o1' ); | |
var o2 = new MyObject( 'o2' ); |
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 Animal( objectName ) { | |
this._name = objectName; | |
} | |
Animal.prototype._name = "Animal’s prototype."; | |
Animal.prototype.makeNoise = function () { console.log( this._name + ' is silent.' ); }; | |
Animal.prototype.run = function () { console.log( this._name + ' runs.' ); }; | |
var a = new Animal( "Basic Animal." ); | |
a.makeNoise(); |
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
[TestFixture] | |
public class CommandDemoTests | |
{ | |
[Test] | |
public async Task command_pattern_just_work_with_poco_result() | |
{ | |
var cmd = new CmdDemo() | |
{ | |
ActorId = 878, | |
CompanyName = "Invenietis", |
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
if OBJECT_ID( 'EG.TestWithTable' ) is not null drop procedure EG.TestWithTable; | |
if TYPE_ID( 'EG.TestWithTableData' ) is not null drop type EG.TestWithTableData; | |
GO | |
create type EG.TestWithTableData as table | |
( | |
Value int, | |
Name nvarchar(3), | |
Doc xml, | |
Point Geometry, | |
CName as Name + ' (' + cast(Value as nvarchar) + ')', |
NewerOlder