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. Singleton Pattern [modified]

Singleton Pattern [modified]

Scheduled Pinned Locked Moved C#
questionregexxml
4 Posts 3 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.
  • L Offline
    L Offline
    Legolas_Bilbao
    wrote on last edited by
    #1

    Hi People¡¡ i have a question with Singleton pattern i dont use multithread development and the singleton structure that i use is that public static GestorBD Instance { get { if (instance == null) instance = new GestorBD(); return instance; } } but in new GestorBD(), i´d like to pass a parameter how can i do it??becouse i received "0" or "1" i have to read and xml or other xml thanks for all -- modified at 5:50 Tuesday 1st August, 2006

    Dios creo un equipo perfecto a los demas los lleno de extranjeros

    C X 2 Replies Last reply
    0
    • L Legolas_Bilbao

      Hi People¡¡ i have a question with Singleton pattern i dont use multithread development and the singleton structure that i use is that public static GestorBD Instance { get { if (instance == null) instance = new GestorBD(); return instance; } } but in new GestorBD(), i´d like to pass a parameter how can i do it??becouse i received "0" or "1" i have to read and xml or other xml thanks for all -- modified at 5:50 Tuesday 1st August, 2006

      Dios creo un equipo perfecto a los demas los lleno de extranjeros

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      Legolas_Bilbao wrote:

      but in new GestorBD(), i´d like to pass a parameter how can i do it??becouse i received "0" or "1" i have to read and xml or other xml

      If you pass a parameter to the constructor then what you are implicitly saying is that it may not be a singleton. If it is still a valid case for a singleton then create a property or method to take the parameter which will change the existing state of the object.


      Scottish Developers events: * .NET debugging, tracing and instrumentation by Duncan Edwards Jones and Code Coverage in .NET by Craig Murphy * Developer Day Scotland: are you interested in speaking or attending? My: Website | Blog

      1 Reply Last reply
      0
      • L Legolas_Bilbao

        Hi People¡¡ i have a question with Singleton pattern i dont use multithread development and the singleton structure that i use is that public static GestorBD Instance { get { if (instance == null) instance = new GestorBD(); return instance; } } but in new GestorBD(), i´d like to pass a parameter how can i do it??becouse i received "0" or "1" i have to read and xml or other xml thanks for all -- modified at 5:50 Tuesday 1st August, 2006

        Dios creo un equipo perfecto a los demas los lleno de extranjeros

        X Offline
        X Offline
        Xodiak
        wrote on last edited by
        #3

        the one thing that the Singleton pattern ensures as that only one instance of the object exists in your application at any given time. you have a private parameterless constructor that instanciates that object if it doesnt exist (lazy loaded) and thats it. you want to rethink your design if you are having to pass in a parameter to the constructor. Why not have a method inside the GestorBD class called ReadXML(string xmlString)/ReadXML(int method) to do the reading of the xml? Its difficlut to say what is correct without looking at the entire purpose of your class.

        L 1 Reply Last reply
        0
        • X Xodiak

          the one thing that the Singleton pattern ensures as that only one instance of the object exists in your application at any given time. you have a private parameterless constructor that instanciates that object if it doesnt exist (lazy loaded) and thats it. you want to rethink your design if you are having to pass in a parameter to the constructor. Why not have a method inside the GestorBD class called ReadXML(string xmlString)/ReadXML(int method) to do the reading of the xml? Its difficlut to say what is correct without looking at the entire purpose of your class.

          L Offline
          L Offline
          Legolas_Bilbao
          wrote on last edited by
          #4

          thanks i understand it thanks for all -- modified at 13:59 Tuesday 1st August, 2006

          Dios creo un equipo perfecto a los demas los lleno de extranjeros

          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