M
Mark Olbert
I have a situation where I want to serialize the properties of a custom component. I've played
around with TypeConverters and InstanceDescriptors, but I think I need to go whole hog into the
actual code generation to handle my situation.
Here's what I'm dealing with: I have a component that has a DataSet as one of its fields (which is
exposed as a property of the component). The DataSet is created by the component at designtime based
on selections made by the programmer. The component also has various collections in it which refer
back to that custom dataset. For example, there are objects (that are part of a collection) which
expose the datatype of each database column. They do this by returning the datatype of their
associated DataColumn.
So the component contains objects which must refer to an instance of the custom DataSet. If I were
writing this by hand in c#, it might look something like this:
Component theComponent = new CustomComponent();
// the custom dataset referenced below is constructed by the
// CustomComponent at design time.
theComponent.DataSet = new CustomDataSet();
theComponent.TableList.Add( new TableInfoObject(theComponent.DataSet, <other parameters>);
theComponent.TableList.Add( new TableInfoObject(theComponent.DataSet, <other parameters>);
theComponent.TableList.Add( new TableInfoObject(theComponent.DataSet, <other parameters>);
....
Having to refer to a property of the component seems to make this pattern incompatible with the
InstanceDescriptor approach. On the other hand, the pattern itself looks like it would be reasonably
straightforward to translate into the CodeDom generator system. But if there's an easier way I
wouldn't mind pursuing it
Suggestions, leads and thoughts would all be most appreciated!
- Mark
around with TypeConverters and InstanceDescriptors, but I think I need to go whole hog into the
actual code generation to handle my situation.
Here's what I'm dealing with: I have a component that has a DataSet as one of its fields (which is
exposed as a property of the component). The DataSet is created by the component at designtime based
on selections made by the programmer. The component also has various collections in it which refer
back to that custom dataset. For example, there are objects (that are part of a collection) which
expose the datatype of each database column. They do this by returning the datatype of their
associated DataColumn.
So the component contains objects which must refer to an instance of the custom DataSet. If I were
writing this by hand in c#, it might look something like this:
Component theComponent = new CustomComponent();
// the custom dataset referenced below is constructed by the
// CustomComponent at design time.
theComponent.DataSet = new CustomDataSet();
theComponent.TableList.Add( new TableInfoObject(theComponent.DataSet, <other parameters>);
theComponent.TableList.Add( new TableInfoObject(theComponent.DataSet, <other parameters>);
theComponent.TableList.Add( new TableInfoObject(theComponent.DataSet, <other parameters>);
....
Having to refer to a property of the component seems to make this pattern incompatible with the
InstanceDescriptor approach. On the other hand, the pattern itself looks like it would be reasonably
straightforward to translate into the CodeDom generator system. But if there's an easier way I
wouldn't mind pursuing it
Suggestions, leads and thoughts would all be most appreciated!
- Mark