Have A Dynamic URL In Generic Class?

Apr 22, 2009

I need to have a dynamic URL preferably from a Test Classformatting this design pattern to handle dynamic links from tests. instead of a constant HomePageURL.

Namespace TestDesign
Public Class HomePage
Inherits IE

[code].....

View 1 Replies


ADVERTISEMENT

Overload Operator In Generic Class With Generic Interface Of Super Class And Inherit Class?

Jan 21, 2010

I can do this without problem.

Class A
End Class
Class B : Inherit A
End Class
Dim Obj1 As A = New B

View 4 Replies

.net - Can A Generic Version Of A Derived Class Override A Base Method Using The Generic Type

Apr 13, 2012

Consider:

Public MustInherit Class Column
Public ReadOnly Property ReturnSomethingUseful() As Object
Get
'return something useful

[code]....

But this gives the following error:

Public Overrides Function ParseValue(sValue As String) As Boolean'
cannot override 'Public Overridable Function ParseValue(sValue As String) As Object'
because they differ by their return types.

I accept that you can't do this, but I'd like to be able to preserve the semantics of what I'm. trying to do, which is to have an untyped version that deals with Object, but a typed version in derived classes that knows about the specific type T.

View 2 Replies

.net - Determining A Generic Type At Runtime In Non-Generic Class

Aug 14, 2010

I have a Journal that records entries for different types: Journal(Of ParentT)

[Code]....

View 2 Replies

Construct A Generic Interface Class With Generic Functions

Nov 25, 2011

I am trying to construct a generic interface class with generic functions. My goal was to use this to implement multiple worker classes for database interaction that have the same basic functionality. Each class will deal with different object for example, category, product or supplier but unless the the functions in the interface are generic that this won't work.This is the interface code that I have but I don't know if I have done it correctly. [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

Class With Dynamic Arrays Inside Another Class Which Also Has Dynamic Arrays?

Nov 15, 2011

Below you will find a code sample that I have dummied up to try and demonstrate the issue I am having. However, this is just a dummied up piece of code. The actual program has noting to do with STUDENTS or TEACHERS. Basically, the problem I'm having is trying to have a CLASS within another CLASS each of which contain ARRAYS that need to be dynamic in size. The sample has a CLASS called STUDENTS that can have in theory many students, the number of which are unknown to the CLASS. I need to be able to add STUDENTS to the ARRAY programmatically.

The CLASSROOM Class should also be an Array since each TEACHER will have MANY Students. There will be only 1 Teacher for a given classroom but the SCHOOL will have MANY CLASSROOMS. Again, I need to programmatically add Teachers and Students without having predefined Array sizes. The code I have listed below will NOT work but it demonstrates what I am trying to achieve. I want to be able to reference the CLASS by using something like this ...

School(iTeacherIndex).Student(iStudentIndex) = "Rick Smith"

I feel like I should be able to use ARRAYLIST in both classes but haven't been able to get it to work. I've tried DIM'ing as ARRAY and can't get that to work either.If I can get ARRAYLIST to work then I shouldn't need to worry about expanding the array via UBOUND (if it's even possible).The REAL question is "How do I have a CLASS within a CLASS, each of which has ARRAYS that need to be dynamic in nature so they can be expanded as needed? The size of the array cannot be determined ahead of time".

REMEMBER . . . the actual program has nothing to do with Students and Teachers. This was just my way of demonstrating the issue using an analogy that I thought everyone could understand. The actual Class is much more involved.I have purposely hardcoded some values just to make the sample easier to work with. This is NOT how I normally program but is just here to hopefully make things a little more clear.

Here is the sample code . . .
'***********************************************************************************
'***********************************************************************************
'***********************************************************************************

'Here is the code that is in the form - This obviously doesn't work

Private Sub TeacherTestDemo()
Dim iTeacherIndex As Byte
Dim iStudentIndex As Byte

[code]....

View 2 Replies

Recognize A Generic Class?

Mar 19, 2010

How can I recognize (.NET 2) a generic class?

Class A(Of T)
End Class
' not work '
If TypeOf myObject Is A Then

View 2 Replies

Inherit From A Generic Class Without Specifying A Type?

Apr 29, 2009

I have the following sample code in a VB.NET console application. It compiles and works, but feels like a hack. Is there a way to define EmptyChild so that it inherits from Intermediate(Of T As Class) without using the dummy EmptyClass?

Module Module1
Sub Main()
Dim Child1 = New RealChild()[code].....

The other way to do this would be to move the generic code out of the Base class and then create 2 Intermediate classes like this [code]...

Then RealChild would inherit from the generic Intermediate and EmptyChild would inherit from the non-generic Intermediate. My problem with that solution is that the Base class is in a separate assembly and I need to keep the code that handles the generic type in that assembly. And there is functionality in the Intermediate class that does not belong in the assembly with the Base class.

View 1 Replies

Add Custom Class To A Generic List?

May 10, 2010

I created two classes. One class is StudentClass and the other is HomeroomClass. The HomeroomClass contains a readonly property as a generic list of the StudentClass. [code]...

View 6 Replies

C# - Create A Generic Method In A Class?

Apr 28, 2010

I am really trying to follow the DRY principle. I have a sub that looks like this?

Private Sub DoSupplyModel
OutputLine("ITEM SUMMARIES")
Dim ItemSumms As New SupplyModel.ItemSummaries(_currentSupplyModel, _excelRows)
ItemSumms.FillRows()

[Code]...

View 4 Replies

Creating Custom Generic Class?

Jan 1, 2011

Here are essential excerpts for the code creating the class and the page using it:

Imports System.Collections.ObjectModel
Public Class Test (Of T as xyz)
Inherits Collection (Of T)

[code].....

View 7 Replies

Generic Class's Constructors With Param

Dec 30, 2009

i've got a Class like this public Class Cart(Of Item) Public Sub New(ByVal a As Integer, ByVal ParamArray items As Item())but i do not see how to create an instance of it: Dim block_names As New Cart(Of String, 5I)i get something like "type expected" o.O

View 2 Replies

Generic Error Handling Class?

Jan 10, 2012

We are developing an application for our shop floor. This program will be tracking material through the shop and we need to capture any errors the program generates, but we don't need to stop the program for all errors. I have some code to do a screen capture and put it in a database with exception.tostring data for debugging.

What we would like to do, is create an exception from the base class, but provide additional properties to allow us to set a severity and a user friendly error message. I would like to encapsulate this in a class that we would call in the catch of a try/catch, set the properties on the class, have the class record the data to the database, then raise the exception to the main program to display only the user friendly message and severity. The main program would then determine the severity and based on the severity stop the program or just display a discreet msg and continue to process.

Does anyone have an example of a custom exception class derived from exception that does something similar, or if I heading in the wrong direction, does anyone have a better solution?

View 5 Replies

Generic Inherited Class Definition

Jan 11, 2010

I'm having trouble with the definition of an inherited generic class. I have two base classes that are defined like this:[code]

View 2 Replies

Generic List Class Cast?

Jun 10, 2010

how Inheriting List(of T) should work.It seems like what I have below should work but at runtime I get the error:[code..]

If I want to cast a List(of x) to the class xlist, how should I do that?[code...]

View 15 Replies

How To Load A Generic Class Without Loop

Jul 15, 2010

ok this is the thing I have right now which is working quite well beside its a bit slow:

Public Function GetList() As List(Of SalesOrder)
Try
Dim list As New List(Of SalesOrder)
Dim ds As DataSet
ds = cls.GetSalesOrderList 'CLS is the data access class

[Code]...

View 2 Replies

Implementing Generic IComparer Of Own Class?

Jun 17, 2012

I am trying to create a class implementing the generic IComparer of my own class "Stellungen" (which translates to positions, like on a chess or checkers board).

This is what I got:
Private Class comparer(Of Stellung)
Implements System.Collections.Generic.IComparer(Of Stellung)
Public Function Compare(x As Stellung, y As Stellung) As Integer Implements System.Collections.Generic.IComparer(Of Stellung).Compare
End Function
End Class

Problem is: inside the function I have no access to any fields of my class. If I start off with x. Intellisense will only give me .Equals, .GetHashCode - the methods you get on a type but not on an instance. Visual Studio 10 also highlights this, in the definition of the function the bits "x as Stellung" and "y as Stellung" are written in light blue, meaning it is a type and not an actual object. How do I access the things I want to compare inside my class?

View 1 Replies

Implementing IList (Of T) In Generic Class

Jun 26, 2009

I am creating a generic class that is Implementing IList(Of T) which requires that I implement the GetEnumorator of both IEnumerable(Of T) and IEnumerable. When looking at the members of IList(Of T) I see only one GetEnumorator function, yet it implements IEnumerable(Of T) and IEnumerable. How can I use one function to implement both interfaces when the function definitions only vary by return type?

View 8 Replies

Load A Generic Class Without Loop?

Jul 20, 2010

Public Function GetList() As List(Of SalesOrder)
Try
Dim list As New List(Of SalesOrder)
Dim ds As DataSet

[code]....

Now once I start retrieving more than 10000 records from the table, the loop takes long time to load values into generic class. Is there any way that I can get rid of loop? Can I do something like the following with the generic class?

txtSearch.AutoCompleteCustomSource.AddRange(Array. ConvertAll(Of DataRow, String)(BusinessLogic.ToDataTable.ConvertTo(WorkOr derList).Select(), Function(row As DataRow) row("TradeContactName")))

View 3 Replies

Serialize A Class That Contains A Generic List?

Oct 7, 2010

I am trying to serialize a class that contains a generic list, and I am finding it all works with the exception of the generic list property. That is to say the other properties are serialized fine and no error is produced.

I have in the past serialized an arraylist - but I thought it was possible to do a generic list in the same way.

Am I missing something or is it not possible to serialize/deserialize a generic list - I have read mixed comments on this..

The relevant parts of the class that gets serialized is defined as..

<XmlInclude(GetType(cConfigUser)), _
Serializable(), XmlRoot(ElementName:="Config")> _
Public Class cConfig

[Code].....

View 3 Replies

Shared Class With Generic Methods?

Jan 28, 2010

I have created a Interface and a couple classes that implement this Interface. I am in the process of developing a Shared Class that utilizes the functions that each of the individual classes have, due to the interface implementation.What i need to know is how do i develop this Shared Class so that way each of the methods within it are restricted to a single data type. This single data type needs to be restricted to any class that has implemented the Interface.

Some examples:

Public Interface IVector(Of T)
Sub Add(ByVal v2 as T)

[code]....

As you can see it would allow me to develop one form, since i have standardized the required Subs/Functions for any class the implements the IVector interface. As i am still in developement, i was wondering if my current understanding of the method generics is correct in its current form or what i would have to do to make the Generic Shared Class work in the fashion that i am looking for in the example implementation.

View 6 Replies

Get Value From Property Member Of A Class As Generic Object?

May 29, 2010

I have a routine that accepts a List of Objects, a property name and a value to search for and simply returns whether or not it found it.The code I have hangs up at the For loop in the findit routine.[code]

View 4 Replies

Instantiate A Generic Class Using Concrete Object?

Sep 27, 2011

i've got a generic class for xml serialization and deserialization.

Public Class clsXMLHandler(Of T)
Public Sub serializeFromObject(ByVal filePath As String, ByVal [object] As T)
Dim creater As New FileStream(filePath, FileMode.Create)
Dim xml As New XmlSerializer([object].GetType)
xml.Serialize(creater, [object])

[Code]...

View 1 Replies

Recursive Generic Type Class Declaration

Mar 23, 2011

I'm a newbie to VB, and I am having difficulty understanding what the following (legacy code) class declaration actually means:
Public MustInherit Class ModelBase(Of T As {ModelBase(Of T, TIdType), New}, TIdType)

There is also a related ModelBaseCollection:
Public MustInherit Class ModelBaseCollection(Of TCollection As {ModelBaseCollection(Of TCollection, TModel, TIdType), New}, TModel As {ModelBase(Of TModel, TIdType), New}, TIdType)
Inherits Collection(Of TModel)

I have difficulty understanding the need for the ModelBaseCollection class as the ModelBase class is a generic type.

View 1 Replies

.net - Fetch A Shared Member From A Class When It Is A Generic Type?

Nov 4, 2011

I have a bunch of classes that all contain a Shared ReadOnly Dictionary. If I want to access that Dictionary when the class is a generic type (such as when I have a wrapper function that takes T as an interface that all of these classes implement), what's the way to do it?

I want to do something like GetType(T).GetMember("Dict"), but that will return a MemberInfo type, and that cannot be cast to a Dictionary of my defined type(s). For calling functions this way, one can use a delegate + CreateDelegate + GetMethod. But there doesn't seem to be an equivalent Create*for GetMember stuff. Or am I missing something?

If I plug the GetMember call into the immediate window, and then use a subscript as if it is an array, then the debug output says I am getting a Dictionary back. But if I use that same approach in the actual function that I am trying to write, then I get an error about System.Reflection.MemberInfo cannot be converted to Dictionary(X, Y)

View 2 Replies

Get The Fully Qualified Class Name Of The Type In A Generic Function?

Apr 18, 2011

Suppose I want to write a generic function that will return the fully qualified name of the data type. In other words, how would you implement the following: Public Shared Function Foo(Of T)() As String ' Return the fully qualified name of T End Function

View 1 Replies

LINQ To SQL Generic Class For Insert And Delete Operation?

Nov 27, 2009

I have been writing same code for insert, update, delete with LINQ over and over again. I want to have some sort of generic function for Insert, Update, Delete operation. I read a post here like the following :

public static void Insert<T>(T entity) where T : class
{
using (OrcasDB database = new OrcasDB())

[code].....

View 2 Replies

Passing A System.Collections.Generic.List To Another Class?

Jun 10, 2012

I am trying to pass a System.Collections.Generic.List to another class. The collection is created in class2 and then passed into class1

[code]...

However I get a 'Null Reference Exception error' when I run the program. It seems f_str in the line 'For Each s As String In f_str' is null.

View 3 Replies

Specifying Inherits / Implements On Generic Class With Multi-Constraints

Jun 7, 2010

When I write the following statement in VB.Net (C# is my normal language), I get an "end of statement expected" referring to the "Implements" statement.
<Serializable()> _
<XmlSchemaProvider("EtgSchema")> _
Public Class SerializeableEntity(Of T As {Class, ISerializable, New}) _
Implements IXmlSerializable, ISerializable
...
End Class

The C# version that I'm trying to emulate is:
[Serializable]
[XmlSchemaProvider("MySchema")]
public class SerializableEntity<T> : IXmlSerializable, ISerializable where T : class, new()
{
....
}

View 1 Replies







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