dotnet windows forms designtime:
I've derived from CodeDomDesignerLoader in order to generate VB code for forms that I've designed in a custom designer. My current implementation of Parse is essentially just the following, which creates a shell form with a base type specified: codeCompileUnit = new CodeCompileUnit(); codeCompileUnit.ReferencedAssemblies.Add(this.baseType.Assembly.Location); this.typeResolutionService.ReferenceAssembly(this.baseType.Assembly.GetName()); CodeNamespace codeNamespace = new CodeNamespace("Elsinore.CustomForms"); codeCompileUnit.Namespaces.Add(codeNamespace); CodeTypeDeclaration codeType = new CodeTypeDeclaration(this.baseType.Name + "Ex"); codeType.BaseTypes.Add(new CodeTypeReference(this.baseType)); codeNamespace.Types.Add(codeType); // constructor will be made private if not explicitly added CodeConstructor codeConstructor = new CodeConstructor(); codeConstructor.Attributes = MemberAttributes.Public; codeType.Members.Add(codeConstructor); My implementation of Write looks like the following: StringWriter stringWriter = new StringWriter(); this.codeProvider.GenerateCodeFromCompileUnit(unit, stringWriter, null); this.sourceCode = stringWriter.ToString(); This works to some extent. The problem is that the CodeCompileUnit passed into Write has ALL members of the form declared, including those that were already declared on the base form. I've looked at creating my own TypeCodeDomSerializer for the form to do the filtering of statements, but I can't help but think that this filtering is already built into the framework somehow. So, how do I get the CodeDomDesignerLoader to only generate declarations and statements for the derived form? Thanks in advance! Jake
I solved this by using the DesignSurface component now included in .NET 2.0. It must provide an extra service that I wasn't before. Now I get a problem loading a form that references controls declared "protected" in a base form. The exception says for example: The type 'X' has no property named 'Y'. I figure here I need to create a new TypeDecriptor for it?
Don't see what you're looking for? Try a search.
|