摘要:
Method and apparatus for encapsulating a reference to a method in object-based programming systems and ensuring that the reference is safe are disclosed. The method of encapsulation provides for: a) defining an entity that defines the shape of the method to be referenced; b) obtaining a reference to a method; c) storing this reference in arbitrary data structures; d) passing the reference to code written by other parties; e) enabling invocation of the method by anyone holding the method reference; and f) enabling the holder of a method reference to determine the target object and method being referenced. These objectives are achieved in a strongly typed manner, making it possible for: a) developers to learn of type mismatch problems early (at compile-time) rather than late (at run-time); and b) development tools to present information to developers about the shape of components that use delegates. In addition, a model of event based programming is disclosed, wherein event-related code can be encapsulated in delegates.
摘要:
A delegate-based event-driven programming model facilitates application development by allowing event handlers to be manipulated on an individual basis. In the delegate-based event-driven programming model, the recipient of an event need not be aware that is receiving the event because the event is treated as a call from a method. In addition, event handlers can be dynamically manipulated, such that recipients of events can be added or removed during runtime. Flexibility of event handling is improved as a result.
摘要:
A blueprint is described that provides a framework for writing a code generator. A blueprint translator translates the blueprint into one or more classes with source code. The newly generated code can then be compiled. If the user wishes to add additional functionality to a generated class, this is done in a separate source file. At compilation time, the compiler combines the generated class with the user's additions, as if they were written in a single class. Later, if the blueprint is ever changed, the generated code can safely be updated without overwriting the user's additions. Alternately, the user can embed his desired additions or changes directly into the blueprint (embedded code). In this manner, should the blueprint ever be re-compiled, the user's changes will still be present. The partial classes technique can be used in conjunction with the embedded code technique.
摘要:
A system and methods are provided for implementing an explicit interface member in connection with a computer programming language. Thus, a mechanism is provided that prevents conflicts between independently developed interfaces, enables privately implemented interface members and enables specific versions of generic interfaces that are free from conflict.
摘要:
Performing validation of a derived virtual method includes receiving program code where the derived virtual method is derived from a virtual method of the program language used to generate the program code, compiling the program code to an intermediate language expression, generating metadata descriptive of the compiled program code, validating the use of the derived virtual method by accessing the metadata, and permitting the use of the derived virtual method if the metadata grants override permissions concerning the virtual method of the programming language. The metadata indicating access and override permissions may be generated while compiling the program code in the common language infrastructure. Alternately, the flag may use pre-existing values indicative of the access and override permissions concerning the virtual method of the programming language.
摘要:
A computer method and system for invoking a function member of an object that is exposed to a client computer program by a source computer program are provided. In a preferred embodiment, the source computer program instantiates the object which has a dispatching interface. The dispatching interface has an invoking function member for receiving a name of a function member and arguments for the function member. When a client computer program wishes to invoke the function member, the client computer program invokes the invoking function member of the dispatching interface passing the name of the function member and arguments for the function member. The invoking function member invokes the function member with the passed name passing the arguments. When the function member returns, the invoking function member returns to the client computer program.
摘要:
A computer method and system for invoking a function member of an object that is exposed to a client computer program by a source computer program are provided. In a preferred embodiment, the source computer program instantiates the object which has a dispatching interface. The dispatching interface has an invoking function member for receiving a name of a function member and arguments for the function member. When a client computer program wishes to invoke the function member, the client computer program invokes the invoking function member of the dispatching interface passing the name of the function member and arguments for the function member. The invoking function member invokes the function member with the passed name passing the arguments. When the function member returns, the invoking function member returns to the client computer program.