func init // adds using namespace sys.add_use('AsyncStreaming') // use external class sys.UseClass("AsyncStreamIO") // initialize instance params = this.props('Constructor').value if(params == 'None') sys.add_var(this.name, 'AsyncStreamReader') else sys.add_object(this.codename, 'AsyncStreamReader', d("Path")) end // makes implementation of methods as properties sys._mtd_as_prop_init('AsyncStreamReader') // initialize event handlers // event "onError" if(linked("onError")) if(params == 'Constructor') blk_init.println(this.codename, '.OnError += new EventHandler(reader_OnError);') end sys.blocks_store() event("onError", 'args.Error') blk_proc_imp.println('private void reader_OnError(object sender, AsyncStreamErrorEventArgs args) { // ', this.codename, ':onError').inc() .println('if (this.InvokeRequired) {').inc() .println('try {').inc() .println('this.Invoke(new EventHandler(reader_OnError), sender, args);') .dec().println('} catch {} return;') .dec().println('}') if(not blk_lvars.empty()) blk_proc_imp.copyhere(blk_lvars) end blk_proc_imp.copyhere(blk) .dec().println('}') sys.blocks_restore() end // event "onRead" if(linked("onRead")) if(params == 'Constructor') blk_init.println(this.codename, '.OnReadedBytes += new EventHandler(reader_OnRead);') end sys.blocks_store() event("onRead", 'args') blk_proc_imp.println('private void reader_OnRead(object sender, AsyncReadEventArgs args) { // ', this.codename, ':onRead').inc() .println('if (this.InvokeRequired) {').inc() .println('try {').inc() .println('this.Invoke(new EventHandler(reader_OnRead), sender, args);') .dec().println('} catch {} return;') .dec().println('}') if(not blk_lvars.empty()) blk_proc_imp.copyhere(blk_lvars) end blk_proc_imp.copyhere(blk) .dec().println('}') sys.blocks_restore() end // event "onFinish" if(linked("onFinish")) if(params == 'Constructor') blk_init.println(this.codename, '.OnEndRead += new EventHandler(reader_OnFinish);') end sys.blocks_store() event("onFinish", 'args') blk_proc_imp.println('private void reader_OnFinish(object sender, AsyncReadEventArgs args) { // ', this.codename, ':onFinish').inc() .println('if (this.InvokeRequired) {').inc() .println('try {').inc() .println('this.Invoke(new EventHandler(reader_OnFinish), sender, args);') .dec().println('} catch {} return;') .dec().println('}') if(not blk_lvars.empty()) blk_proc_imp.copyhere(blk_lvars) end blk_proc_imp.copyhere(blk) .dec().println('}') sys.blocks_restore() end // event "onStateChanged" if(linked("onStateChanged")) if(params == 'Constructor') blk_init.println(this.codename, '.OnStateChanged += new EventHandler(reader_OnStateChanged);') end sys.blocks_store() event("onStateChanged", 'args.CurrentState') blk_proc_imp.println('private void reader_OnStateChanged(object sender, AsyncStreamStateChangeArgs args) { // ', this.codename, ':onStateChanged').inc() .println('if (this.InvokeRequired) {').inc() .println('try {').inc() .println('this.Invoke(new EventHandler(reader_OnStateChanged), sender, args);') .dec().println('} catch {} return;') .dec().println('}') if(not blk_lvars.empty()) blk_proc_imp.copyhere(blk_lvars) end blk_proc_imp.copyhere(blk) .dec().println('}') sys.blocks_restore() end end func doConstructor(data) blk.println(this.codename, ' = new AsyncStreamReader(', d("Path"), ');') this.set_events() end func set_events() if(linked("onError")) blk.println(this.codename, '.OnError += new EventHandler(reader_OnError);') end if(linked("onRead")) blk.println(this.codename, '.OnReadBytes += new EventHandler(reader_OnRead);') end if(linked("onFinish")) blk.println(this.codename, '.OnEndRead += new EventHandler(reader_OnFinish);') end if(linked("onStateChanged")) blk.println(this.codename, '.OnStateChanged += new EventHandler(reader_OnStateChanged);') end end func doStart() blk.println(this.codename, '.StartRead();') end func doPause() blk.println(this.codename, '.PauseRead();') end func doResume() blk.println(this.codename, '.ResumeRead();') end func doStop() blk.println(this.codename, '.StopRead();') end func doClose() blk.println(this.codename, '.Dispose();') end func State return(this.codename + '.State') end