PC Review


Reply
Thread Tools Rate Thread

Convert "Nothing" to an empty string?

 
 
Larry Bud
Guest
Posts: n/a
 
      17th Mar 2008
Using XML serializer, if an XML field is missing, then the value in
the object is Nothing.

Is there a slick way of converting a "Nothing" to an empty string
without doing is

if x is nothing then...
 
Reply With Quote
 
 
 
 
George Ter-Saakov
Guest
Posts: n/a
 
      17th Mar 2008
Just make your default as empty string.

Example

class clsMyClass
{
public string Id="";
}

then when desirializing it with XML Serializer the field will be set to ""
(Basically left untouched)

George.

"Larry Bud" <(E-Mail Removed)> wrote in message
news:fe50ec68-5aa1-4d8f-8145-(E-Mail Removed)...
> Using XML serializer, if an XML field is missing, then the value in
> the object is Nothing.
>
> Is there a slick way of converting a "Nothing" to an empty string
> without doing is
>
> if x is nothing then...



 
Reply With Quote
 
Larry Bud
Guest
Posts: n/a
 
      17th Mar 2008
On Mar 17, 9:52*am, "George Ter-Saakov" <gt-...@cardone.com> wrote:
> Just make your default as empty string.
>
> Example
>
> class clsMyClass
> {
> * * public string Id="";
>
> }
>
> then when desirializing it with XML Serializer the field will be set to ""
> (Basically left untouched)
>
> George.
>
> "Larry Bud" <larrybud2...@yahoo.com> wrote in message
>
> news:fe50ec68-5aa1-4d8f-8145-(E-Mail Removed)...
>
>
>
> > Using XML serializer, if an XML field is missing, then the value in
> > the object is Nothing.

>
> > Is there a slick way of converting a "Nothing" to an empty string
> > without doing is

>
> > if x is nothing then...


The only problem with that is that the class file is being generated
by the XSD.EXE tool, from a very large schema (over 30 tables)
 
Reply With Quote
 
George Ter-Saakov
Guest
Posts: n/a
 
      17th Mar 2008
So? You use XSD only once are not you?
Just go and modify the source files it had generated after.

George.

"Larry Bud" <(E-Mail Removed)> wrote in message
news:2788c124-5aaa-4946-be77-(E-Mail Removed)...
On Mar 17, 9:52 am, "George Ter-Saakov" <gt-...@cardone.com> wrote:
> Just make your default as empty string.
>
> Example
>
> class clsMyClass
> {
> public string Id="";
>
> }
>
> then when desirializing it with XML Serializer the field will be set to ""
> (Basically left untouched)
>
> George.
>
> "Larry Bud" <larrybud2...@yahoo.com> wrote in message
>
> news:fe50ec68-5aa1-4d8f-8145-(E-Mail Removed)...
>
>
>
> > Using XML serializer, if an XML field is missing, then the value in
> > the object is Nothing.

>
> > Is there a slick way of converting a "Nothing" to an empty string
> > without doing is

>
> > if x is nothing then...


The only problem with that is that the class file is being generated
by the XSD.EXE tool, from a very large schema (over 30 tables)


 
Reply With Quote
 
Larry Bud
Guest
Posts: n/a
 
      17th Mar 2008
On Mar 17, 3:25*pm, "George Ter-Saakov" <gt-...@cardone.com> wrote:
> So? *You use XSD only once are not you?
> Just go and modify the source files it had generated after.
>
> George.
>
> "Larry Bud" <larrybud2...@yahoo.com> wrote in message
>
> news:2788c124-5aaa-4946-be77-(E-Mail Removed)...
> On Mar 17, 9:52 am, "George Ter-Saakov" <gt-...@cardone.com> wrote:
>
>
>
>
>
> > Just make your default as empty string.

>
> > Example

>
> > class clsMyClass
> > {
> > public string Id="";

>
> > }

>
> > then when desirializing it with XML Serializer the field will be set to ""
> > (Basically left untouched)

>
> > George.

>
> > "Larry Bud" <larrybud2...@yahoo.com> wrote in message

>
> >news:fe50ec68-5aa1-4d8f-8145-(E-Mail Removed)...

>
> > > Using XML serializer, if an XML field is missing, then the value in
> > > the object is Nothing.

>
> > > Is there a slick way of converting a "Nothing" to an empty string
> > > without doing is

>
> > > if x is nothing then...

>
> The only problem with that is that the class file is being generated
> by the XSD.EXE tool, from a very large schema (over 30 tables)- Hide quoted text -


That's true, except that our customer controls the schema, and it can
change fairly regularly. Which would mean modifying the class file
every time.


 
Reply With Quote
 
Juan T. Llibre
Guest
Posts: n/a
 
      17th Mar 2008
re:
!> except that our customer controls the schema, and it can change fairly regularly.
!> Which would mean modifying the class file every time

I'd hate to work as a programmer in a place where that happens "fairly regularly".




Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Larry Bud" <(E-Mail Removed)> wrote in message
news:b089fdff-b7dd-4a05-8eef-(E-Mail Removed)...
On Mar 17, 3:25 pm, "George Ter-Saakov" <gt-...@cardone.com> wrote:
> So? You use XSD only once are not you?
> Just go and modify the source files it had generated after.
>
> George.
>
> "Larry Bud" <larrybud2...@yahoo.com> wrote in message
>
> news:2788c124-5aaa-4946-be77-(E-Mail Removed)...
> On Mar 17, 9:52 am, "George Ter-Saakov" <gt-...@cardone.com> wrote:
>
>
>
>
>
> > Just make your default as empty string.

>
> > Example

>
> > class clsMyClass
> > {
> > public string Id="";

>
> > }

>
> > then when desirializing it with XML Serializer the field will be set to ""
> > (Basically left untouched)

>
> > George.

>
> > "Larry Bud" <larrybud2...@yahoo.com> wrote in message

>
> >news:fe50ec68-5aa1-4d8f-8145-(E-Mail Removed)...

>
> > > Using XML serializer, if an XML field is missing, then the value in
> > > the object is Nothing.

>
> > > Is there a slick way of converting a "Nothing" to an empty string
> > > without doing is

>
> > > if x is nothing then...

>
> The only problem with that is that the class file is being generated
> by the XSD.EXE tool, from a very large schema (over 30 tables)- Hide quoted text -


That's true, except that our customer controls the schema, and it can
change fairly regularly. Which would mean modifying the class file
every time.



 
Reply With Quote
 
George Ter-Saakov
Guest
Posts: n/a
 
      17th Mar 2008
Well, you out of luck then.

Write your own initialization function that sets defaults right after
deserialization.

George.

"Larry Bud" <(E-Mail Removed)> wrote in message
news:b089fdff-b7dd-4a05-8eef-(E-Mail Removed)...
On Mar 17, 3:25 pm, "George Ter-Saakov" <gt-...@cardone.com> wrote:
> So? You use XSD only once are not you?
> Just go and modify the source files it had generated after.
>
> George.
>
> "Larry Bud" <larrybud2...@yahoo.com> wrote in message
>
> news:2788c124-5aaa-4946-be77-(E-Mail Removed)...
> On Mar 17, 9:52 am, "George Ter-Saakov" <gt-...@cardone.com> wrote:
>
>
>
>
>
> > Just make your default as empty string.

>
> > Example

>
> > class clsMyClass
> > {
> > public string Id="";

>
> > }

>
> > then when desirializing it with XML Serializer the field will be set to
> > ""
> > (Basically left untouched)

>
> > George.

>
> > "Larry Bud" <larrybud2...@yahoo.com> wrote in message

>
> >news:fe50ec68-5aa1-4d8f-8145-(E-Mail Removed)...

>
> > > Using XML serializer, if an XML field is missing, then the value in
> > > the object is Nothing.

>
> > > Is there a slick way of converting a "Nothing" to an empty string
> > > without doing is

>
> > > if x is nothing then...

>
> The only problem with that is that the class file is being generated
> by the XSD.EXE tool, from a very large schema (over 30 tables)- Hide
> quoted text -


That's true, except that our customer controls the schema, and it can
change fairly regularly. Which would mean modifying the class file
every time.



 
Reply With Quote
 
Larry Bud
Guest
Posts: n/a
 
      17th Mar 2008
On Mar 17, 4:53*pm, "George Ter-Saakov" <gt-...@cardone.com> wrote:
> Well, you out of luck then.
>
> Write your own initialization function that sets defaults right after
> deserialization.
>
> George.
>
> "Larry Bud" <larrybud2...@yahoo.com> wrote in message
>
> news:b089fdff-b7dd-4a05-8eef-(E-Mail Removed)...
> On Mar 17, 3:25 pm, "George Ter-Saakov" <gt-...@cardone.com> wrote:
>
>
>
>
>
> > So? You use XSD only once are not you?
> > Just go and modify the source files it had generated after.

>
> > George.

>
> > "Larry Bud" <larrybud2...@yahoo.com> wrote in message

>
> >news:2788c124-5aaa-4946-be77-(E-Mail Removed)...
> > On Mar 17, 9:52 am, "George Ter-Saakov" <gt-...@cardone.com> wrote:

>
> > > Just make your default as empty string.

>
> > > Example

>
> > > class clsMyClass
> > > {
> > > public string Id="";

>
> > > }

>
> > > then when desirializing it with XML Serializer the field will be set to
> > > ""
> > > (Basically left untouched)

>
> > > George.

>
> > > "Larry Bud" <larrybud2...@yahoo.com> wrote in message

>
> > >news:fe50ec68-5aa1-4d8f-8145-(E-Mail Removed)....

>
> > > > Using XML serializer, if an XML field is missing, then the value in
> > > > the object is Nothing.

>
> > > > Is there a slick way of converting a "Nothing" to an empty string
> > > > without doing is

>
> > > > if x is nothing then...

>
> > The only problem with that is that the class file is being generated
> > by the XSD.EXE tool, from a very large schema (over 30 tables)- Hide
> > quoted text -

>
> That's true, except that our customer controls the schema, and it can
> change fairly regularly. *Which would mean modifying the class file
> every time.- Hide quoted text -
>
> - Show quoted text -


Is there a semi-easy way of doing that, such as iterating through each
object?
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: convert "Text" into "Number" for null or empty value John Spencer Microsoft Access 0 7th Dec 2009 02:59 PM
Re: convert "Text" into "Number" for null or empty value Douglas J. Steele Microsoft Access 0 7th Dec 2009 01:00 PM
Convert.Int32("0")causes{"Input string was not in a correct format =?Utf-8?B?SmFtZXMgUG9zZQ==?= Microsoft Dot NET 1 23rd Feb 2006 03:01 AM
Convert "char" into "string" in java privetv7 Microsoft VC .NET 2 27th Dec 2004 09:27 PM
Response.Write(String.Format("{0:#,###.##}",0)); returns empty string Von Shean Microsoft C# .NET 2 10th Nov 2003 06:17 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:07 AM.