Implement Singleton In Parent Class?

Nov 18, 2009

Implement singleton in a parent class.Infact what I want is that All the childs etc. should use same instance of the parent.

I have implemented singleton, Changed the scope of parent class's constructor to "Protected". But in the application when ever the new child's constructor is called i.e. "Dim abc as New Ch1()" the constructor of Parent is called (as it is Proctected and can be access from child).

View 2 Replies


ADVERTISEMENT

Implementing Singleton In Parent Class?

Nov 18, 2009

implement singleton in a parent class. Infact what I want is that All the childs etc. should use same instance of the parent.

I have implemented singleton, Changed the scope of parent class's constructor to "Protected". But in the application when ever the new child's constructor is called i.e. "Dim abc as New Ch1()" the constructor of Parent is called (as it is Proctected and can be access from child). Which is undesired behaviour.

View 2 Replies

Implement The Singleton Pattern?

Oct 16, 2009

Im trying to Implement the Singleton Pattern and im wondering if this is "Thread Safe" or if I am going to have to explicitly perform a SyncLock on the object instance? Example:

Public NotInheritable Class SingleTon
Private Shared _singleton As SingleTon
Private Sub New()

[Code].....

I tried it both ways, using the SyncLock and without, just not sure which one to be using?

View 18 Replies

Implement The Singleton Pattern For Access Via WCF?

Aug 17, 2010

I'd like to expose some functionality via a WCF service. I can configure WCF to instantiate a class per-request but am unsure how I can get a reference to a communal singleton if I were to have some functionality to store a list of calls to a method (call it LogMethod) via WCF in memory and return that list when the GetLogs method is called

I'm aware I could use a database/the file system to pass this data back an forth but in many cases, that seems to be overkill. Edit: It seems that nobody has a clear answer - I can't believe this is complex. Am I missing something obvious?

View 2 Replies

Singleton Class In Webapplication?

Jun 11, 2009

Reading about singletons classes/pattern gave me a pretty good idea for its use. But would it be a good practice to store user related variables in properties of a thread safe singleton class so i can access them by chaining?

Example
When a user logs in several variables will be assigned to a session variable like:
Session("UserID") = reader("UserID")
Session("AccessLevels") = reader("Accesslevels")
Session("UserName") = reader("UserName")
...

Now when working on my webapplication i could always access these values by calling the session() variable, but the chance to forget the session keys or erroneous write them down is significantly. So again would it be good to store these session variables in readonly properties of singleton class so I can access them like:

MySingleton.ID
MySingleton.Accesslevels
MySingleton.UserName

View 4 Replies

.net - Can't Call Serialize() On Instance Of Serializable Singleton Class?

Nov 28, 2011

I have a VB.NET singleton class which implements Serializable:

Imports System.IO
Imports System.Runtime.Serialization

<Serializable()> Public Class CoordinateHistory[code].....

My problem is that I can't actually call .Serialize() on the instance of this class, like all of the examples online show. What am I doing wrong?

View 2 Replies

Singleton Class Or Shared (static) Member Functions?

Aug 9, 2011

I would like to understand the Pro & Cons in using the commonly used methods via Singleton class against Shared (Static) members of a class in VB.Net. It could be in terms Time, Space complexity or best practices. I have a BankAccount class with methods doing some business logic.

GetBalance()
GetLast5Credits()
GetMiniStatement()

[code].....

View 4 Replies

Call A Member Through Its Parent's Type That Shadowed A Parent Class Implementation?

Aug 3, 2011

This is a challenging one that got me stumped while I was coding today. Suppose I am running the Sub Test1() and Test2() and would like to print out the value of the Shadows method of the instance of the object I am passing in to TestCall() (see below - it is clearer) using the following restrictions:

Can't change the contents of Class A, B, and C
Can't change Sub Test1() and Sub Test2()
TestCall() can't have an if, select case etc. statement that tries to figure out the type

[code].....

View 2 Replies

.net - Parent/Child Relationships Failing When Getting Data From Parent Class With Multiple Forms Open?

Jun 24, 2009

I have a main form, and some sub forms, and each sub form can have some sub forms. When I have multiple sub forms open, and I try to get data from the parent form, it returns the data from the wrong parent form.For example I have two instances of Mainform.subform running. If I do something like this in a child form of one instance of the subform. It returns data from the other subform.

dim l = Mainform.subform.listofdata

Edit:I am using visual Studio 2008. Winforms, form designed using designer. In my mainform I am doing this

Protected Friend frmMain as Mainform
frmmain = new mainform

In frmMain I am doing this

Protected Friend frmsub as new Subform'
frmsub = new subform

[code]....

View 1 Replies

Implement User Confirmation Of Exit On An MDI Parent Form?

Mar 17, 2011

We were using the parent's FormClosing event handler to get user confirmation of the exit before continuing, but have just discovered that the child windows get closed before this is run. We only want a single confirmation message box, but I guess that would require the child windows to ask the parent to confirm.

View 1 Replies

Class C Inherits Class D Is Class D A Superclass Or Parent Of Class C?

Dec 16, 2009

If Class X is within the scope of Class Y, is X a subclass of Y?If Class A is a sub Class of B, then is Class B considered a super class of A?if Class C inherits Class D is Class D a superclass or parent of Class C?if Class E extends Class F then we can consider Class E a child of F?if Class G inherits Class H and is within the scope of Class I then who is the parent of Class G? Classes that inherits Class J and classes that are within Class J are all sub classes of Class J?

View 1 Replies

VS 2008 - Implement The Mdi Parent / Child Associations Rather Than To Go And Declare Them Each One Individually

Aug 24, 2009

I have been developing an application for quite some time now. I have decided to create an mdi parent form to hold all the windows I have done so far. Is there an easy way to implement the mdi parent/ child associations rather than to go and declare them each one individually.

View 7 Replies

Add / Implement An Interface To An Existing Class Without Changing Code Anywhere That Call The Class And Functions

Mar 1, 2010

I need to create unit testing project for my current website. The currentw ebsite si written in VB. All unit testing examples are using interface to create mock object. My current VB class does not implment any interface. Can I add interface and implement it to my current class and functions without affecting or changing codes to any pages in my website that call the functions? For examples my current class is like:

[Code]...

View 2 Replies

Does An Inherited Class Automatically Implement An Interface From Its Base Class

Jun 10, 2011

Suppose I have piece of code like this:

Public Interface ISomething
....
End Interface

[code]....

View 2 Replies

Way To Implement IComparable (Of T) Or IComparer(Of T) If Class Is Not A Generic Class

Feb 19, 2010

I am working on a general helper class to sort ListView SubItems. I wrote a base class that has much of the code I need. It includes a MustOverride for the Compare method so that the various inherited classes can implment their own comparisons based upon their type. For the value types, I end up with very similar code such as the following, where x and y are ListViewItems: Public Overloads Overrides Function Compare(ByVal x As Object, ByVal y As Object, ByVal sortColumnIndex As Integer, ByVal sortOrder As System.Windows.Forms.SortOrder) As Integer [code]

View 3 Replies

Unable To Use An Instance Of The Nested Class Through A Public Variable Of The Parent Class?

Jun 7, 2012

I want to created a nested class that can only be visible to and instantiated from the parent class.But I also want to be able to use an instance of the nested class through a public variable of the parent class.I tried making the nested class private, or making the nested class' constructor private, but it won't compile.Is it possible to do this in .NET?

[Code]...

View 3 Replies

.net - Visual Studio Setting: Invoke Directly Sub/nested Class (omit Parent Class)?

Feb 5, 2011

E.g. I have a class:

Namespace Common
Public Class AClass
Public Class BClass

[code]....

How can I use BClass without saying AClass.BClass, I've see some existing code using this format, but I can't find the setting.

View 1 Replies

Get A Value Inside Parent Class From Child Class (in Nested Classes)?

Jan 1, 2012

I have Class1 and class2 which is inside class1, VB.NET code:

Public Class class1
Public varisbleX As Integer = 1
Public Class class2

[code]....

View 1 Replies

VS 2008 Reference Parent Class From Inside Child Class?

Apr 11, 2009

I have a 'property management class' that contains several functions and properties. I have several other classes that use the 'management class' as a property to derive the value of several of its other properties.Is there a way for me to reference the outer class from the 'management class' functions without having to pass it as a parameter? I ask because several different classes can have this 'management class' as a property and am having a hard time typing the parameter.

View 7 Replies

Class Inherit From Another Class And Implement An Interface?

Jun 18, 2009

class inherit from another class and implement an interface?

View 4 Replies

Access Members Of A Sub Class Through A Property Of The Parent Class?

Mar 30, 2010

This is a bit of a continuation from a previous post for which AtmaWeapon was very informative.

Problem:
A parent class has a sub class with various properties. A property of the parent class is a List(of T) with T = the sub class The issue is how to store data in the sub class of the instantiated parent

Some example code (hopefully formatted correctly):

Code:
'=========== Class Definitions =============
Public Class courseClass
Public Class timeTableClass

[Code].....

View 7 Replies

Reference A Parent Class Object From A Child Class?

Jan 2, 2010

I have a Parent Class Called Fuselage that containsfour child classes called Forebody, CenterBody, AftBody, and CrossSection. CrossSection classcontains objects common to Forebody, CenterBody, and Aftbody (example: width). How do I access thewidth property in CrossSection from within the classForebody?

Public Class Fuselage
Dim Forebody As ClsSection
Dim Centerbody As ClsSection

[code].....

View 6 Replies

How To Use The Values From A Child Class In Parent Class

Mar 31, 2012

I have a problem that is frustrating me to no end, I have a overrideable function in a parent class, and the override function in the child class, like below:

[Code]...

When i debug, the value is produced, but it doesn't carry over to the parent class of ski.RetailPrice()what seems to be the problem here?

View 1 Replies

Implement Class Constructor In VB?

Jul 19, 2010

I just would like to know how to implement class constructor in this language.

View 2 Replies

Implement New Array Class

Nov 21, 2009

I want to modify the base Array class by creating a new class called "FileArray".I have some text files that are read into a string array. Each element in the array is a line from the text file. I want to update the GetValue method by overloading it or overriding it so that it will update some value that will give an indication to what the last line was. I have a couple of ideas on how I can do this:

1) Use a public integer, like intLine, that gets updated everytime GetValue is called.

2) Create a new property of Array, such as "LastLine" that would return the last line number (which would basically be the last index value +1) and then use a public array to store the files (though this is less desirable as the array may be used by several different functions)

An easier way would be to be able to determine the last element that was returned, which is basically what I think I am describing above.

View 2 Replies

What Interface Class Implement

Dec 23, 2009

Say I want to know more about a class mshtml.htmlinputelement for example.Say I want to know. What is his parent classes? What interface the class implement? How do I do so through object browser?

View 1 Replies

Build A Useful Class And Implement It In An Application?

Apr 16, 2009

I am trying to build a class. I am having a difficult time conceptualizing how a class is built and how it works. I want to be able to build a USEFUL class and implement it in an application.

View 1 Replies

Implement The Player Class Through Plug-ins?

Mar 16, 2009

I've never actually used Reflection, but I've been warned in the past that using it may cause slow performance. My question is what part(s) of it is/are slow.

I'm thinking about creating a board game and I wanted to implement the player class through plug-ins. That way there could be several different player classes (i.e. human players, and several configurable AI classes). If implemented this way, where should I expect performance hits? Only when initializing the player class? When passing arguments to methods in the player class? In the entirety of execution of methods from the player class? Or is it going to affect the whole application?

The reason I ask is that the AI will be extremely processor intensive. Through testing it seems like it may take around 1-30 seconds to determine a move on my quad core (Core 2 Q6600) processor, depending on the effort spent to optimize the move and testing different branches on separate threads.

My concern is that if I implement the AI via a plug-in, the move determination would slow down considerably to the point where it wasn't playable on lesser hardware.

View 2 Replies

Implement Variable Class Instantiation?

Nov 22, 2011

I have several similar classes but only want to instantiate one of these classes dependant on a selection from my main form.

View 4 Replies

Make A Class And Implement Tostring?

Jan 10, 2010

If we make a class and implement tostring, should we support some interface?

View 5 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved