HighTechTalks DotNet Forums  

Custom CodeDomSerializer issues

Dotnet Framework (WinForms DesignTime) microsoft.public.dotnet.framework.windowsforms.designtime


Discuss Custom CodeDomSerializer issues in the Dotnet Framework (WinForms DesignTime) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Lionel
 
Posts: n/a

Default Custom CodeDomSerializer issues - 09-24-2007 , 12:04 PM






Hi All,

I wrote a custom CodeDom serializer class that first invokes default
serialization for a class, after which it does some custom code
generation.

public override object Serialize(IDesignerSerializationManager
manager, object value)
{
CodeDomSerializer baseSerializer =
(CodeDomSerializer)manager.GetSerializer(myBaseTyp e,
typeof(CodeDomSerializer));
object codeObject = baseSerializer.Serialize(manager, value);

//custom code gen here...
}

My class uses the following attributes to specify the above
serializer:

[DesignerSerializer(typeof(MyCustomSerializer),
typeof(CodeDomSerializer))]
public partial class MyClass : UserControl
{
......
}

The custom code looks fine, but the MyClass instance variable is being
generated local to the InitializeComponent() method:

private void InitializeComponent()
{
MyControls.MyClass myClass1 = new MyControls.MyClass();
....
//
// MyClass code generator
// Updated on Monday, September 24, 2007 at 4:40:42 PM
//
myClass1.ShowImage = true;
myClass1.Location = new System.Drawing.Point(149, 3);
....
}

I want the instance to be defined as a class level variable, rather
than inside InitializeComponent(). I have read that an
InstanceDescriptor can help specify this, but am as yet unable to get
it working.

Would appreciate any insights you have on doing so.

Thanks,
Lionel


Reply With Quote
  #2  
Old   
G Himangi
 
Posts: n/a

Default Re: Custom CodeDomSerializer issues - 09-25-2007 , 04:36 AM






I think a local variable will be generated only if you create it through the
IDesignerHost.CreateComponent method.

---------
- G Himangi, Sky Software http://www.ssware.com
Shell MegaPack : GUI Controls For Drop-In Windows Explorer like Shell
Browsing Functionality For Your App (.Net & ActiveX Editions).
EZNamespaceExtensions.Net : Develop namespace extensions rapidly in .Net
EZShellExtensions.Net : Develop all shell extensions,explorer bars and BHOs
rapidly in .Net
---------



"Lionel" <lioneljlobo (AT) gmail (DOT) com> wrote

Quote:
Hi All,

I wrote a custom CodeDom serializer class that first invokes default
serialization for a class, after which it does some custom code
generation.

public override object Serialize(IDesignerSerializationManager
manager, object value)
{
CodeDomSerializer baseSerializer =
(CodeDomSerializer)manager.GetSerializer(myBaseTyp e,
typeof(CodeDomSerializer));
object codeObject = baseSerializer.Serialize(manager, value);

//custom code gen here...
}

My class uses the following attributes to specify the above
serializer:

[DesignerSerializer(typeof(MyCustomSerializer),
typeof(CodeDomSerializer))]
public partial class MyClass : UserControl
{
.....
}

The custom code looks fine, but the MyClass instance variable is being
generated local to the InitializeComponent() method:

private void InitializeComponent()
{
MyControls.MyClass myClass1 = new MyControls.MyClass();
...
//
// MyClass code generator
// Updated on Monday, September 24, 2007 at 4:40:42 PM
//
myClass1.ShowImage = true;
myClass1.Location = new System.Drawing.Point(149, 3);
...
}

I want the instance to be defined as a class level variable, rather
than inside InitializeComponent(). I have read that an
InstanceDescriptor can help specify this, but am as yet unable to get
it working.

Would appreciate any insights you have on doing so.

Thanks,
Lionel




Reply With Quote
  #3  
Old   
Lionel
 
Posts: n/a

Default Re: Custom CodeDomSerializer issues - 09-25-2007 , 05:24 AM



Thanks for your reply. Where should I use
IDesignerHost.CreateComponent in the serialization process?

When commenting out the [DesignerSerializer] attribute on my class I
see that VS.NET automatically creates the myClass1 variable external
to InitializeComponent(), at class scope.

//[DesignerSerializer(typeof(MyCustomSerializer),
typeof(CodeDomSerializer))]
public partial class MyClass :UserControl
{
......
}

But by adding the attribute the variable is once again created inside
InitializeComponent(), so I assume theres something I'm not specifying
correctly in my custom serializer code?

I would have expected Serialize(manager, value); to have a flag
indicating if I'd like it serialized locally, or at class level.

Thanks,
Lionel


On Sep 25, 9:36 am, "G Himangi" <i... (AT) ssware (DOT) com> wrote:
Quote:
I think alocalvariable will be generated only if you create it through the
IDesignerHost.CreateComponent method.

---------
- G Himangi, Sky Software http://www.ssware.com
Shell MegaPack : GUI Controls For Drop-In Windows Explorer like Shell
Browsing Functionality For Your App (.Net & ActiveX Editions).
EZNamespaceExtensions.Net : Develop namespace extensions rapidly in .Net
EZShellExtensions.Net : Develop all shell extensions,explorer bars and BHOs
rapidly in .Net
---------

"Lionel" <lioneljl... (AT) gmail (DOT) com> wrote in message

news:1190649883.245521.135700 (AT) o80g2000hse (DOT) googlegroups.com...

Hi All,

I wrote a customCodeDomserializer class that first invokes default
serialization for a class, after which it does some custom code
generation.

public override object Serialize(IDesignerSerializationManager
manager, object value)
{
CodeDomSerializer baseSerializer =
(CodeDomSerializer)manager.GetSerializer(myBaseTyp e,
typeof(CodeDomSerializer));
object codeObject = baseSerializer.Serialize(manager, value);

//custom code gen here...
}

My class uses the following attributes to specify the above
serializer:

[DesignerSerializer(typeof(MyCustomSerializer),
typeof(CodeDomSerializer))]
public partial class MyClass :UserControl
{
.....
}

The custom code looks fine, but the MyClass instance variable is being
generatedlocalto theInitializeComponent() method:

private voidInitializeComponent()
{
MyControls.MyClass myClass1 = new MyControls.MyClass();
...
//
// MyClass code generator
// Updated on Monday, September 24, 2007 at 4:40:42 PM
//
myClass1.ShowImage = true;
myClass1.Location = new System.Drawing.Point(149, 3);
...
}

I want the instance to be defined as a class level variable, rather
than insideInitializeComponent(). I have read that an
InstanceDescriptor can help specify this, but am as yet unable to get
it working.

Would appreciate any insights you have on doing so.

Thanks,
Lionel



Reply With Quote
  #4  
Old   
Lionel
 
Posts: n/a

Default Re: Custom CodeDomSerializer issues - 09-25-2007 , 09:23 AM



Never mind, solved it...

On Sep 24, 5:04 pm, Lionel <lioneljl... (AT) gmail (DOT) com> wrote:
Quote:
Hi All,

I wrote a custom CodeDom serializer class that first invokes default
serialization for a class, after which it does some custom code
generation.

public override object Serialize(IDesignerSerializationManager
manager, object value)
{
CodeDomSerializer baseSerializer =
(CodeDomSerializer)manager.GetSerializer(myBaseTyp e,
typeof(CodeDomSerializer));
object codeObject = baseSerializer.Serialize(manager, value);

//custom code gen here...

}

My class uses the following attributes to specify the above
serializer:

[DesignerSerializer(typeof(MyCustomSerializer),
typeof(CodeDomSerializer))]
public partial class MyClass : UserControl
{
.....

}

The custom code looks fine, but the MyClass instance variable is being
generated local to the InitializeComponent() method:

private void InitializeComponent()
{
MyControls.MyClass myClass1 = new MyControls.MyClass();
...
//
// MyClass code generator
// Updated on Monday, September 24, 2007 at 4:40:42 PM
//
myClass1.ShowImage = true;
myClass1.Location = new System.Drawing.Point(149, 3);
...

}

I want the instance to be defined as a class level variable, rather
than inside InitializeComponent(). I have read that an
InstanceDescriptor can help specify this, but am as yet unable to get
it working.

Would appreciate any insights you have on doing so.

Thanks,
Lionel



Reply With Quote
  #5  
Old   
schneider
 
Posts: n/a

Default Re: Custom CodeDomSerializer issues - 09-25-2007 , 09:58 AM



Would be nice to know...

"Lionel" <lioneljlobo (AT) gmail (DOT) com> wrote

Quote:
Never mind, solved it...

On Sep 24, 5:04 pm, Lionel <lioneljl... (AT) gmail (DOT) com> wrote:
Hi All,

I wrote a custom CodeDom serializer class that first invokes default
serialization for a class, after which it does some custom code
generation.

public override object Serialize(IDesignerSerializationManager
manager, object value)
{
CodeDomSerializer baseSerializer =
(CodeDomSerializer)manager.GetSerializer(myBaseTyp e,
typeof(CodeDomSerializer));
object codeObject = baseSerializer.Serialize(manager, value);

//custom code gen here...

}

My class uses the following attributes to specify the above
serializer:

[DesignerSerializer(typeof(MyCustomSerializer),
typeof(CodeDomSerializer))]
public partial class MyClass : UserControl
{
.....

}

The custom code looks fine, but the MyClass instance variable is being
generated local to the InitializeComponent() method:

private void InitializeComponent()
{
MyControls.MyClass myClass1 = new MyControls.MyClass();
...
//
// MyClass code generator
// Updated on Monday, September 24, 2007 at 4:40:42 PM
//
myClass1.ShowImage = true;
myClass1.Location = new System.Drawing.Point(149, 3);
...

}

I want the instance to be defined as a class level variable, rather
than inside InitializeComponent(). I have read that an
InstanceDescriptor can help specify this, but am as yet unable to get
it working.

Would appreciate any insights you have on doing so.

Thanks,
Lionel





Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.