Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

object serialize

Status
Not open for further replies.

leangross

IS-IT--Management
Jul 3, 2002
84
PH
is there a way not to include those properties with empty string value during serialization?

 
are the strings empty or "NOTHING"

-The answer to your problem may not be the answer to your question.
 
Try the following for Design time consideration. For Run time processing I think you need to implement ISerializable which exposes a couple methods you can then use to handle your situation. Good Luck!
Code:
Private Sub ResetYourPropertyName()
    YourPropertyName = yourValue
End Sub 'ResetYourPropertyName

Private Function ShouldSerializeYourPropertyName() As Boolean
    If YourPropertyName Is Nothing OrElse YourPropertyName.ToString.Trim.Length = 0 Then
        Return False
    Else
        Return True
    End If
End Function 'ShouldSerializeYourPropertyName
 
Lean, i was trying to get at whether or not the serialization was failing, or if you literally didn't want the properties packaged when the object is serialized and sent.

If you are getting a equivalent of a null reference, or object not set to an instance, then you have a problem with a property not being initialized first, usually fixed with a "= New String(String.Empty)"

If you dont want the property to be packaged up then you should probably set the property to an equivalent of NOT SERIALIZABLE, so that it won't get packaged. If you don't want it to get packaged only some of the time then i would have to suggest you reconsider what you are trying to do, because i dont believe you can get a property set of conditionally serializable.

-The answer to your problem may not be the answer to your question.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top