Dynamic Class Generation for Runtime Serialization
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Existing methods cannot create dynamic objects that can perform strongly typed operations and be serialized at runtime, as the type of a dynamic object is either unknown at compile time or cannot implement the necessary interface for serialization.
Innovation Solution
A method is developed using reflection and a static 'dynamic' class to create a compiled class definition at runtime, allowing for the instantiation of a partially strongly typed object that can be serialized and perform strongly typed operations, by obtaining a class name and property list from a data store, writing an uncompiled class definition implementing a known interface, adding serialization attributes, and compiling the class definition to create a new assembly.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Adaptability or versatility
If a dynamic object is created without specifying its type at compile time, then the object can be flexible and adaptable at runtime, but the object cannot perform strongly typed operations because the type is unknown
Solution Approach 1:
The patent implements dynamic class generation where the class definition is constructed at runtime based on reflection of a data model, allowing the object type to be determined dynamically while still enabling strongly typed operations through the generated class structure
Solution Approach 2:
The patent introduces an intermediary compilation step that generates a class definition from reflected data model information, serving as a bridge between dynamic runtime object creation and static strongly typed operation requirements
2Reliability
If the object type is known ahead of time and code is compiled for that class, then strongly typed operations can be performed, but the object is not dynamic at runtime and cannot be adapted when the program is running
Solution Approach 1:
The system dynamically generates class definitions at runtime by reflecting the data model structure, allowing the class to adapt to different data models while maintaining strongly typed operation capabilities through the generated class interface
Solution Approach 2:
The patent changes the parameter of class definition timing from compile-time to runtime, allowing the class structure to be determined by the actual data model being processed rather than being fixed in advance
3Ease of manufacture
If a class definition is compiled before execution, then the class can be instantiated and used, but the class cannot be made serializable after compilation because serialization attributes cannot be added to the class definition after compilation
Solution Approach 1:
The patent applies serialization attributes to the dynamically generated class definition before compilation occurs, ensuring that the class is pre-configured with serialization capabilities before it is instantiated and used at runtime
Solution Approach 2:
The system dynamically adds serialization attributes to the class definition during the runtime class generation process, allowing the class to be both instantiable and serializable without requiring pre-compilation
4Reliability
If an interface is defined to specify methods and properties, then a class can implement the interface and perform operations, but the interface itself cannot be instantiated and cannot be serialized
Solution Approach 1:
The patent segments the interface definition from the class implementation, where the interface defines the contract and the dynamically generated class provides the instantiation-capable implementation that also supports serialization
Data Source
AI summary
A method that includes obtaining, by an application executing on a computing system, a list of properties defining at least one property. The executing application writes an uncompiled class definition implementing a compiled interface and writes one or more properties of the compiled interface into the uncompiled class definition. The executing application writes the at least one property and at least one serialization attribute into the uncompiled class definition. The executing application causes the uncompiled class definition to be compiled, loads the compiled class definition, and creates an object by instantiating the compiled class definition. The object is serializable. The executing application may reflect on the compiled interface to obtain the one or more properties. Each of the one or more properties is strongly typed.


