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
interface MyStructure { | |
a: boolean; | |
b: number; | |
c: string; | |
d: { | |
e: boolean; | |
f: number; | |
g: string[]; | |
} | |
} |
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
static class PackUtil | |
{ | |
public static string Pack(string[] original) | |
{ | |
return Pack(original, '|', '0', '~'); | |
} | |
public static string[] Unpack(string original) | |
{ | |
return Unpack(original, '|', '0', '~'); |
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
SELECT * FROM [dbo].[UnpackStrings]('|~0123|0|ABC||~0000|DEF|0', '|', '0', '~') | |
SELECT * FROM [dbo].[UnpackStrings]('0|', '|', '0', '~') | |
DECLARE @Test dbo.StringArray | |
PRINT '::' + [dbo].[PackStrings](@Test, '|', '0', '~') + '::' | |
INSERT INTO @Test (Element) |
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
/* | |
CREATE TYPE [dbo].[StringArray] AS TABLE ( | |
ElementNumber INT IDENTITY(1,1) | |
,[Element] NVARCHAR(MAX) | |
) | |
*/ | |
CREATE FUNCTION [dbo].[PackStrings] | |
( |
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
CREATE FUNCTION [dbo].[UnpackStrings] | |
( | |
@original NVARCHAR(MAX) | |
,@delimiter NCHAR(1) | |
,@zed NCHAR(1) | |
,@escape NCHAR(1) | |
) | |
RETURNS | |
@Unpacked TABLE | |
( |
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
interface ILiteEvent<T> { | |
on(handler: { (data?: T): void }) : void; | |
off(handler: { (data?: T): void }) : void; | |
} | |
class LiteEvent<T> implements ILiteEvent<T> { | |
private handlers: { (data?: T): void; }[] = []; | |
public on(handler: { (data?: T): void }) : void { | |
this.handlers.push(handler); |
NewerOlder