Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. XmlSerializer and interfaces

XmlSerializer and interfaces

Scheduled Pinned Locked Moved C#
helpquestion
7 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Ryan Cromwell
    wrote on last edited by
    #1

    Does anyone know if there is a problem with using an interface type as the type in the XmlSerializer constructor?

    A L 2 Replies Last reply
    0
    • R Ryan Cromwell

      Does anyone know if there is a problem with using an interface type as the type in the XmlSerializer constructor?

      A Offline
      A Offline
      Andy Smith
      wrote on last edited by
      #2

      I doubt it will work... considering that interfaces don't include constructors, and the xmlserializer requires one.

      1 Reply Last reply
      0
      • R Ryan Cromwell

        Does anyone know if there is a problem with using an interface type as the type in the XmlSerializer constructor?

        L Offline
        L Offline
        leppie
        wrote on last edited by
        #3

        Hi, im not to sure what u are asking, but in the methods of my option library http://www.codeproject.com/useritems/OptionLib.asp mite see how to get around this, by breaking the class (interface) down into properties and serializing that. Hope this help :) MYrc : A .NET IRC client with C# Plugin Capabilities. See http://sourceforge.net/projects/myrc for more info. :-D

        R 1 Reply Last reply
        0
        • L leppie

          Hi, im not to sure what u are asking, but in the methods of my option library http://www.codeproject.com/useritems/OptionLib.asp mite see how to get around this, by breaking the class (interface) down into properties and serializing that. Hope this help :) MYrc : A .NET IRC client with C# Plugin Capabilities. See http://sourceforge.net/projects/myrc for more info. :-D

          R Offline
          R Offline
          Ryan Cromwell
          wrote on last edited by
          #4

          XmlSerializer will not allow typeof(IMyInterface) as its reflected type. Its understandable as XmlSerializer does not use properties but only actual members. I guess this makes sense under the presumption of using get/set value members as interpreted values (ie they are generated from some other value in the class). Uhoh - they expect me to be logical... whats that crap about. ie private int mynumber; //serialized private int myothernumber { //not serialized get { return mynumber; } set { mynumber = value; } }

          L 1 Reply Last reply
          0
          • R Ryan Cromwell

            XmlSerializer will not allow typeof(IMyInterface) as its reflected type. Its understandable as XmlSerializer does not use properties but only actual members. I guess this makes sense under the presumption of using get/set value members as interpreted values (ie they are generated from some other value in the class). Uhoh - they expect me to be logical... whats that crap about. ie private int mynumber; //serialized private int myothernumber { //not serialized get { return mynumber; } set { mynumber = value; } }

            L Offline
            L Offline
            leppie
            wrote on last edited by
            #5

            Cromwell wrote: private int mynumber; //serialized private int myothernumber { //not serialized get { return mynumber; } set { mynumber = value; } } What the point of a private property, if it is not used? Sure , internal, protected and public have there reason, but I cannot see the purpose of a private property. Just my 2 cents :) MYrc : A .NET IRC client with C# Plugin Capabilities. See http://sourceforge.net/projects/myrc for more info. :-D

            J R 2 Replies Last reply
            0
            • L leppie

              Cromwell wrote: private int mynumber; //serialized private int myothernumber { //not serialized get { return mynumber; } set { mynumber = value; } } What the point of a private property, if it is not used? Sure , internal, protected and public have there reason, but I cannot see the purpose of a private property. Just my 2 cents :) MYrc : A .NET IRC client with C# Plugin Capabilities. See http://sourceforge.net/projects/myrc for more info. :-D

              J Offline
              J Offline
              James T Johnson
              wrote on last edited by
              #6

              leppie wrote: I cannot see the purpose of a private property. I would use them to wrap other operations that need to be performed when setting the value. Pretty much the same reason you would use any property in the first place ;) James "And we are all men; apart from the females." - Colin Davies

              1 Reply Last reply
              0
              • L leppie

                Cromwell wrote: private int mynumber; //serialized private int myothernumber { //not serialized get { return mynumber; } set { mynumber = value; } } What the point of a private property, if it is not used? Sure , internal, protected and public have there reason, but I cannot see the purpose of a private property. Just my 2 cents :) MYrc : A .NET IRC client with C# Plugin Capabilities. See http://sourceforge.net/projects/myrc for more info. :-D

                R Offline
                R Offline
                Ryan Cromwell
                wrote on last edited by
                #7

                leppie wrote: What the point of a private property, if it is not used? Sure , internal, protected and public have there reason, but I cannot see the purpose of a private property. 1) I was just showing that because an interface cannot define actual member variables only methods, it makes sense that you cannot use them for XmlSerializer. 2) Oh my lordy - really! Private properties are sooo useful. Often over used by lazy (vb6 uhum :P - no offense just hate it) developers, but none-the-less important.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups