Untitled

From Harmless Terrapin, 3 Weeks ago, written in Plain Text, viewed 9 times. This paste will join the choir invisible in 2 Days.
URL https://paste.afonso.co/view/fe11bdb2 Embed
Download Paste or View Raw
  1. class GraphicsEngineAssignment {
  2.     constructor(graphicsEngine = null, graphicsEngineOutput = null) {
  3.         this._graphicsEngineName = null;
  4.         this._graphicsEngineFullTypeName = null;
  5.         this._graphicsEnginePlatformName = null;
  6.         this._graphicsEngine = null;
  7.         this._engineId = null;
  8.  
  9.         this._output = null;
  10.         this._outputId = null;
  11.         this._outputName = null;
  12.  
  13.         this._language = null;
  14.  
  15.         this._graphicsEngineUpdatedHandlers = new Set();
  16.         this._outputUpdatedHandlers = new Set();
  17.  
  18.         this._propertyChangedHandlers = new Set();
  19.  
  20.         this.UpdateGraphicsEngineAndOutput(graphicsEngine, graphicsEngineOutput);
  21.     }
  22.  
  23.     SubscribeGraphicsEngineUpdated(handler) {
  24.         this._graphicsEngineUpdatedHandlers.add(handler);
  25.     }
  26.  
  27.     UnsubscribeGraphicsEngineUpdated(handler) {
  28.         this._graphicsEngineUpdatedHandlers.delete(handler);
  29.     }
  30.  
  31.     SubscribeOutputUpdated(handler) {
  32.         this._outputUpdatedHandlers.add(handler);
  33.     }
  34.  
  35.     UnsubscribeOutputUpdated(handler) {
  36.         this._outputUpdatedHandlers.delete(handler);
  37.     }
  38.  
  39.     _invokeHandlers(handlers) {
  40.         for (const handler of [...handlers]) {
  41.             handler(this, {});
  42.         }
  43.     }
  44.  
  45.     get OutputName() {
  46.         return this._outputName;
  47.     }
  48.  
  49.     set OutputName(value) {
  50.         this._outputName = value;
  51.     }
  52.  
  53.     get GraphicsEngineName() {
  54.         return this._graphicsEngineName;
  55.     }
  56.  
  57.     set GraphicsEngineName(value) {
  58.         this._graphicsEngineName = value;
  59.     }
  60.  
  61.     get EngineId() {
  62.         return this._engineId;
  63.     }
  64.  
  65.     set EngineId(value) {
  66.         this._engineId = value;
  67.     }
  68.  
  69.     get OutputId() {
  70.         return this._outputId;
  71.     }
  72.  
  73.     set OutputId(value) {
  74.         this._outputId = value;
  75.     }
  76.  
  77.     get GraphicsEngineFullTypeName() {
  78.         return this._graphicsEngineFullTypeName;
  79.     }
  80.  
  81.     set GraphicsEngineFullTypeName(value) {
  82.         this._graphicsEngineFullTypeName = value;
  83.     }
  84.  
  85.     get GraphicsEnginePlatformName() {
  86.         return this._graphicsEnginePlatformName;
  87.     }
  88.  
  89.     set GraphicsEnginePlatformName(value) {
  90.         this._graphicsEnginePlatformName = value;
  91.     }
  92.  
  93.     get Language() {
  94.         return this._language;
  95.     }
  96.  
  97.     set Language(value) {
  98.         this._language = value;
  99.     }
  100.  
  101.     get GraphicsEngine() {
  102.         return this._graphicsEngine;
  103.     }
  104.  
  105.     get Output() {
  106.         return this._output;
  107.     }
  108.  
  109.     get IsGraphicsEngineMissing() {
  110.         return this.GraphicsEngine == null;
  111.     }
  112.  
  113.     get IsOutputMissing() {
  114.         return this.Output == null;
  115.     }
  116.  
  117.     get IsValid() {
  118.         return !this.IsOutputMissing && !this.IsGraphicsEngineMissing;
  119.     }
  120.  
  121.     UpdateGraphicsEngineAndOutput(graphicsEngine, output) {
  122.         this._updateGraphicsEngine(graphicsEngine);
  123.         this._updateOutput(output);
  124.     }
  125.  
  126.     _updateOutput(output) {
  127.         if (this.Output === output) {
  128.             return;
  129.         }
  130.  
  131.         this._output = output;
  132.  
  133.         if (this.Output != null) {
  134.             this.OutputName = this.Output.Name;
  135.             this.OutputId = this.Output.Id;
  136.         }
  137.  
  138.         this._invokeHandlers(this._outputUpdatedHandlers);
  139.     }
  140.  
  141.     _updateGraphicsEngine(graphicsEngine) {
  142.         if (this.GraphicsEngine === graphicsEngine) {
  143.             return;
  144.         }
  145.  
  146.         this._graphicsEngine = graphicsEngine;
  147.  
  148.         if (this.GraphicsEngine != null) {
  149.             this.GraphicsEngineName = this.GraphicsEngine.Name;
  150.             this.GraphicsEngineFullTypeName = this.GraphicsEngine.constructor?.fullTypeName ?? this.GraphicsEngine.constructor?.name ?? null;
  151.             this.GraphicsEnginePlatformName = this.GraphicsEngine.PlatformName;
  152.             this.EngineId = this.GraphicsEngine.Id;
  153.         }
  154.  
  155.         this._invokeHandlers(this._graphicsEngineUpdatedHandlers);
  156.     }
  157. }

Reply to "Untitled"

Here you can reply to the paste above