MCPcopy Create free account
hub / github.com/glideapps/quicktype / emitTypeSwitch

Method emitTypeSwitch

src/Language/CSharp.ts:488–509  ·  view source on GitHub ↗
(
        types: OrderedSet<T>,
        condition: (t: T) => Sourcelike,
        withBlock: boolean,
        withReturn: boolean,
        f: (t: T) => void
    )

Source from the content-addressed store, hash-verified

486 };
487
488 emitTypeSwitch<T extends Sourcelike>(
489 types: OrderedSet<T>,
490 condition: (t: T) => Sourcelike,
491 withBlock: boolean,
492 withReturn: boolean,
493 f: (t: T) => void
494 ): void {
495 assert(!withReturn || withBlock, "Can only have return with block");
496 types.forEach(t => {
497 this.emitLine("if (", condition(t), ")");
498 if (withBlock) {
499 this.emitBlock(() => {
500 f(t);
501 if (withReturn) {
502 this.emitLine("return;");
503 }
504 });
505 } else {
506 this.indent(() => f(t));
507 }
508 });
509 }
510
511 emitConverterMembers = (): void => {
512 const enumNames = this.enums.map(this.nameForNamedType);

Callers 1

CSharpRendererClass · 0.95

Calls 1

assertFunction · 0.90

Tested by

no test coverage detected