473,239 Members | 1,646 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,239 software developers and data experts.

The property is not serialized!

Hi folks,
I've got a TypeConverter, say, GraphInfoTypeConverter, that is supposed to
convert String and/or InstanceDescriptor types into a given class named
GraphInfo. On the other hand, I\ve got a property named MyProp in
MyMainControlClass, that's of type GraphInfo.
Whenever the GraphInfo's value is changed, the new values won't serialize
into "Form1.Designer.cs" where Form1 is the class hosting the
MyMainControlClass. Here's the GraphInfoTypeConverter class:

using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using System.ComponentModel.Design.Serialization;
using System.Collections;
using System.Reflection;
namespace GraphMonitor
{
public class GraphInfoTypeConverter : TypeConverter
{
String[] Delimiters = new String[] { "," };
public override bool CanConvertFrom(ITypeDescriptorContext context, Type
sourceType)
{
if (sourceType == typeof(String))
return true;
return base.CanConvertFrom(context, sourceType);
}
public override object ConvertFrom(ITypeDescriptorContext context,
System.Globalization.CultureInfo culture, object value)
{
if (value != null && value is String)
{
String[] Result = ((String)value).Split(Delimiters,
StringSplitOptions.RemoveEmptyEntries);
if (Result.Length != 1)
throw new Exception("invalid length");
return new GraphInfo(double.Parse(Result[0].Trim()));
}
return base.ConvertFrom(context, culture, value);
}
public override bool CanConvertTo(ITypeDescriptorContext context, Type
destinationType)
{
if (destinationType == typeof(String) ||
destinationType == typeof(InstanceDescriptor))
return true;
return base.CanConvertTo(context, destinationType);
}
public override object ConvertTo(ITypeDescriptorContext context,
System.Globalization.CultureInfo culture, object value, Type
destinationType)
{
if (value != null)
{
if (destinationType == typeof(String) && value is GraphInfo)
{
GraphInfo gi = (GraphInfo)value;
return gi.Value.ToString();
}
if (destinationType == typeof(InstanceDescriptor) && value is GraphInfo)
{
GraphInfo gi = (GraphInfo)value;
ConstructorInfo ctor = typeof(GraphInfo).GetConstructor(new Type[] {
typeof(Double) });
return new InstanceDescriptor(ctor, new object[] { gi.Value });
}
}
return base.ConvertTo(context, culture, value, destinationType);
}
public override bool GetPropertiesSupported(ITypeDescriptorContext context)
{
return true;
}
public override PropertyDescriptorCollection
GetProperties(ITypeDescriptorContext context, object value, Attribute[]
attributes)
{
if (value is GraphInfo)
return TypeDescriptor.GetProperties(typeof(GraphInfo), attributes);
return base.GetProperties(context, value, attributes);
}
public override bool GetCreateInstanceSupported(ITypeDescriptorContext
context)
{
return true;
}
public override object CreateInstance(ITypeDescriptorContext context,
IDictionary propertyValues)
{
return new GraphInfo((double)propertyValues["Value"]);
}
}
}
Any help would be highly appreciated,

TIA,
Mehdi
Jun 27 '08 #1
0 1077

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Prodip Saha | last post by:
Sorry about the cross-posting but I need to get attention from the ADO.Net and Web Service Gurus! I really need to use the System.Data.OleDb.OleDbParameter Class but I am getting following error...
0
by: Prodip Saha | last post by:
Sorry about the cross-posting but I need to get attention from the ADO.Net and Web Service Gurus! I really need to use the System.Data.OleDb.OleDbParameter Class but I am getting following error...
8
by: Richard Collette | last post by:
When attempting to debug a webservice, I get the error: Cannot serialize member System.Exception.Data of type System.Collections.IDictionary, because it implements IDictionary. In reading...
4
by: xke | last post by:
Why the collection property is not included in the ouput serialization ? I have a custom generic collection (implements icollection): Events of objects: Event. Event is a simple class...
2
by: Dinsdale | last post by:
We have created a object library that implements the INotifyPropertyChanged.PropertyChanged to bubble changes up to higher level classes. For instance, we have a person class that can have...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.