func init // initialize instance this.setfield('instance', 'instance' + this.id) // create a blocks of the element sys.create_blocks() // create an arrays of the element this.setfield('class_events', new array()) this.setfield('uses', new array()) // defines using interfaces if(not isdef("Interfaces")) arr = this.props("Interfaces").value this.interfaces = code(arr.join(', ')) end // defines level this.level = isdef("AccessModifier") ? '' : lower(this.props("AccessModifier").value) + ' ' // defines class type modifier t = this.props("TypeModifier").value this.tMode = ((t _and_ 1) ? 'abstract ' : '') + ((t _and_ 2) ? 'partial ' : '') + ((t _and_ 4) ? 'sealed ' : '') + ((t _and_ 8) ? 'static ' : '') + ((t _and_ 16) ? 'virtual ' : '') // defines class name if(isdef("ClassName")) this.setfield('cName', this.codename) else this.setfield('cName', code(this.props("ClassName").value)) end // adds the class to project file sys.compile_add(this.cName + '.cs') // defines base class this.base = '' if(not isdef("Base")) sdk = this.props("Base").value.child for(i = 1; i < sdk.numelements; i++) el = cgt.get_element(cgt.get_element_id(sdk.id, i)) if(el.name == 'UserClass') this.base = ': ' + el.cName el.instance = this.instance end end end // cleanup arr.clear() end func doFinally() // defines instance if(not (this.props("TypeModifier").value _and_ 8)) // not static? if(this.instance == ('instance' + this.id)) // not base? blk_vars.println('private ', this.cName, ' ', this.instance, ';') end end // save original blocks sys.all_blocks_store() // defines constructor body event("onConstructor") // init all unlinked elements this.parent.initall() sys.copy_blocks() sys.copy_members_blocks() // restore original blocks sys.all_blocks_restore() // creates user class b = block.reggen() // defines using namespaces b.copyhere(this._blk_using) arr = this.props("Using").value if(arr.size()) arr = this.props("Using").value for(i = 0; i < arr.size(); i++) b.println('using ', code(arr.get(i)), ';') end end b.println() if(isdef("Namespace")) namespace = 'my' + code(replace(project_name(), "-" , "_")) else namespace = code(this.props("Namespace").value) end b.println('namespace ', namespace) .println('{').inc() // defines comments if(not isdef("Comment")) arr = this.props("Comment").value for(i = 0; i < arr.size(); i++) b.println('/// ', code(arr.get(i))) end end // defines attributes if(not isdef("Attributes")) arr = this.props("Attributes").value attr = code(arr.join(', ')) b.println('[', attr, ']') end // declares class b.println(this.level, this.tMode, 'class ', this.cName, this.base, isdef("Interfaces") ? '' : (isdef("Base") ? ': ' : ', ') + this.interfaces) .println('{').inc() // constants this._copyhere(b, 'UserConst') // variables b.copyhere(this._blk_vars) // fields this._copyhere(b, 'UserField') // constructors if(this.props("TypeModifier").value _and_ 8) // static? b.println('static ', this.cName, '()') else b.println('public ', this.cName, '()') end b.println('{').inc() .copyhere(this._blk_init) .copyhere(this._blk_lvars) .copyhere(this._blk) .dec().println('}') this._copyhere(b, 'UserConstructor') // destructor this._copyhere(b, 'UserDestructor') // properties this._copyhere(b, 'UserProperty') // indexers this._copyhere(b, 'UserIndexer') // methods this._copyhere(b, 'UserMethod') // other methods b.copyhere(this._blk_proc_imp) for(i = 0; i < this.class_events.size(); i++) b.copyhere(this.class_events.get(i)) end b.dec().println('}') // classes .copyhere(this._blk_class) .dec().println('}') // save user class to code folder fName = this.cName + '.cs' b.save(fName) b.delete() // cleanup arr.clear() end func .this return('this') end func UserClass return(this.instance) end func ClassName return(this.cName) end func Constructor(data) return('new ' + this.cName + '()') end func doConstructor(data) blk.println(this.instance, ' = new ', this.cName, '();') end func _copyhere(blkout, name) sdk = this.parent for(i = 1; i < sdk.numelements; i++) el = cgt.get_element(cgt.get_element_id(sdk.id, i)) if(el.name == name) blkout.copyhere(el._blk) end end end