Request For Peer-Review KeyedBindingList (Of TKey / T) Generic Collection Concept

Aug 18, 2011

There are a lot of different generic collections available, so the wisdom in creating a new one may be questionable right from the start.However, I often find myself wanting the same features from my custom generic lists, but cannot quite find all of those features in an existing object; namely, I would like to have a generic collection which works like a List or Dictionary (much like the System.Collections. ObjectModel. Keyed Collection(Of TKey, TValue)), but also works like a BindingSource does when it is bound to an ADO object (that is, it supports full sorting and filtering as well as currency).A feature I almost never need however, is transactional adds (the BindingSource's ability to 'cancel add-new').Again, with so many existing collections out there, I should take a moment to go over the reasons why none of them quite meet my needs.There is the System. ComponentModel. BindingList(Of T) which would provide some of the functionality of a BindingSource, but has strict requirements about the type {T} implementing IComparable in order to support sorting, and does not provide filtering (it is not an IBindingListView).It also only maintains a base item list by index, so does not provide keyed access.We could use simple databinding with a custom list inheriting from System.Collections. ObjectModel. Keyed Collection(Of TKey, TValue) bound to a BindingSource, but again TValue would have to implement IComparable to support sorting and we would still not have filter support.So to get all the features I was after, I decided that the best thing would be to create a new generic collection object which implemented IList, IDictionary, IBindingList, and IBindingListView (along with a few others) and would be capable of serving as a simple list, or as a binding source while providing full sorting and filtering over any newable object type.

To that end, I've created the KeyedObjectModel which contains the KeyedBindingList(Of TKey, T) generic collection/binding source. This collection can be used as a typical list, or as a binding source (you do not need an additional BindingSource component between the collection and UI controls, although you could certainly have one).Various constructors are provided in order to initialize an instance of the collection as either an enhanced list-dictionary, or as a complete BindingSource.Any object that has a public constructor which takes no arguments can be used at type {T}, providing that the object has a property of type {TKey} which will contain unique values for each entity in a given collection.If the object implements System.ComponentModel.NotifyPropertyChanged then the collection will also bubble up property changes on the current item to the collection's CurrentItemChanged event.An implementation of IComparable on type {T} is irrelevant because sorting and filtering are performed on the property values of {T} based on the type of the specified property.The current design of KeyedBindingList(Of TKey, T) is in an 'alpha' stage.The class is mostly complete from a feature implementation standpoint, however, the code has not yet been optimized and the base collections of values, keys, and view are being maintianed in generic lists of their own, rather than raw arrays.However, even without performance tuning, the collection appears to be performing quite well, up to a few thousand entries, given the amount of flexibility and funcitonality it provides.At this stage, I would really love to get some peers to try using the compiled DLL and beat up the collection a bit.Once the code has been proven and optimized, I will publish it as an example.It is a fairly complex class though (currently made up of eleven or so partial classes) so I don't really want to post the code until it has been optimized. [code]

View 4 Replies


ADVERTISEMENT

Is There A Concept Of "Generic Structure" Similar To Generic Collections, Generic Classes

Dec 16, 2009

We have migrated our Vb6 application to VB.NET using a third party tool. Now we are in a process of Refactoring and introducing object oriented concepts in the application.

In VB6, we were using structures in many places. As a part of introducing object oriented programming,

1. is it a good idea of changing all Structures to Classes? or Is there a concept of "Generic Structure" similar to Generic collections, Generic classes?

2. Can some one guide me any source containing guide lines or best practices for applications that are migrated to VB.NET from VB6 and implementing object oriented programmaing.

View 3 Replies

DB/Reporting :: Peer To Peer Network And Access Database?

May 10, 2008

1-i have a peer to peer network (every computer can be server and clinet) and i want to write a server- client program with vb 2005 and access date base to install on any comuter as a server. that serve has a data base with user name , password and credit field filled in access database .clients must connect to server and get permissin from data base field(username and password) to open an special program.

View 1 Replies

C# - Speeding Up An Algorithm That Find Patterns In A Growing Collection - Code Review Beta - Stack Exchange?

Jun 25, 2012

I want to find a way to speed up this code.if you look at the condition of If calculated Then in the code below, this is what slowing down the code.While the code provided seem fast with Const initBit = 4 try it with something over 12.

I want to be able to use this code (with calculated param as True) with initBit of 20 or more.

Beware that 20 or more might require a gig or more of ram and/or compiled as x64.

C# code (converted with an online tool from VB.NET):

[Code]...

View 2 Replies

Peer To Peer Video Streaming WPF

Jun 22, 2010

I want to implement peer-to-peer video streaming in my WPF project.Plz help me by referring any web site or sample code which i can use in my project.

View 4 Replies

Peer-to-peer Connection In Flash?

Sep 28, 2009

I know how to add flash player in vb.net, but I cannot find the tutorial for class library that make me control on flash. And I cannot find the source code for peer-to-peer connection in flash??

View 23 Replies

VS 2005 - Peer To Peer Chat Example

May 14, 2009

As it says on the tin, I need an example of a simple winforms peer to peer chat app in VB.Net 2005 as a basis for a works project I'm working on. I've scoured the net and found many C# versions, but time is a bit too limited to convert everything to VB. Does anyone know of any such example code or a link where I can get some pointers?

View 2 Replies

VS 2008 Peer To Peer Network?

May 5, 2011

i cant for the life of me get a free direct link file hosting for my updater program. what im thinking of is now creating a small peer to peer network that the user could connect to my computer and i could have a drop box with the files in it. is this a feesable solution to this problem or should i go in a different direction? if so how would i go about constructing something like this?

View 3 Replies

Convert One Generic Collection To Another?

Jan 23, 2010

I have the below code and it works fine, it's this way because I need to manually calculate some data before adding it to the Listview control.

Code:
Dim mList As List(Of ListViewItem) = mDataBase.GetRecords(LvwChecks, "CheckGroups", <Query>, GetType(CheckItem))
If mList.Count > 0 Then

[Code].....

View 6 Replies

InvalidOperationException Generic Collection?

Sep 14, 2011

I know its generally a big No-No to modify a collection that you are iterating through but unfortunately i didn't design the code that i'm trying to modify. All over the place the following is done:

for each log in Logs
logs.Delete(log.LogId)
Next

Delete pretty much just deletes the log from the database and removes it from the collection. Previously the Logs object was using a Non-Generic collection. I changed it to use a Collection(Of Log) so i can LINQify the object. Now every time i call next/.MoveNext is called after the first delete the following error happens:

InvalidOperationException:"Collection was modified; enumeration operation may not execute."

I understand why i'm getting the error but i don't understand why it never happened with the Non-Generic version. Is there anyway to get around this error? There really is no way i can take the time to change every place where the delete logs like this (codebase is large). Id like to just remove the code in the Delete function where it removes it from the current collection because i'm assuming no code does anything with the collection after its done but you know what happens when you assume.

View 3 Replies

See Properties Of A Generic Collection Object?

Apr 8, 2009

I have a class which extends HashSet(Of T).I am trying to evaluate some custom properties of this HashSet during execution and make decisions based on those values.

During debugging, I am pausing execution and adding a Watch on my instance of this HashSet.

The Watch only provides me with a view of the Count of the HashSet and the objects contained by the HashSet.How can I get the Watch to show me the other properties of the HashSet?

View 1 Replies

Serializing A Generic Collection With XMLSerializer?

Jul 11, 2009

Why won't XMLSerializer process my generic list?

Sub Main()
Serializing()
End Sub

[Code]....

I get an exception on the "Dim ser" line, saying "Testing.Module1 is inaccessible due to its protection level. Only public types can be processed." ("Testing is the name of the application, and "Module1" is the name of the module; this is a console application).

View 1 Replies

VS 2010 Generic Collection Queue?

Apr 16, 2011

Ok say I have this Dim MyQueueOfClients as new Queue (Of TcpClient) I also have two threads.

In thread one a TcpListener waits for connections then adds a connected TcpClient to MyQueueOfClients.

MyQueueOfClients.Enqueue (TcpClient)In thread two I then check to see if there are any Clients in MyQueueOfClients. If so I then remove them from the MyQueueOfClients.

MyTcpClient = MyQueueOfClients.Dequeue I think the question Im asking is this thread safe?

Can I Enqueue and Dequeue at the same time from different threads?

Well it helps if you read everything. I have just read this as well

A Queue(Of T) can support multiple readers concurrently, as long as the collection is not modified. Even so, enumerating through a collection is intrinsically not a thread-safe procedure. To guarantee thread safety during enumeration, you can lock the collection during the entire enumeration. To allow the collection to be accessed by multiple threads for reading and writing, you must implement your own synchronization.

View 4 Replies

Pick Last 1000 Elements From A Generic Collection?

Mar 1, 2011

Say a collection grow. Once it's size reach 10k, I want to get rid the first 9k. How to do so?Oh ya I could use removeRange.Is there another function that will output say, the last 1k of the element, say if I do not want to remove anything? Something like tail or something.

View 7 Replies

Index Out Of Range Exception In Custom Generic Collection?

Feb 25, 2009

I wrote a class which imports System.Collections.ObjectModel. For the management of the collection, I've written:

Default Public ReadOnly Property Item(ByVal vntIndexKey As Integer) As ItemType
Get
Return CType(mCol.Item(vntIndexKey), ItemType)

[code].....

View 4 Replies

VS 2008 Transfer A Custom Event Through The Generic Collection?

Dec 22, 2009

To the point: I need to transfer a custom object's event through a generic collection object containing these items so that any class using the collection can see that changes were made to one of the items in the collection.

I.E. An item event that triggers a collection event

[Code].....

Due to the application requirements, I need the Collection and Items to send immediate notice of various changes that occur to the Collection Class and its items. I've already got my events set-up regarding for the Collection Class, but I'm struggling with coming up with a workable solution for raising events for the items.

I've got an event for the DeviceLayer item set-up, but how do you transfer that event through the CollectionClass so that any other class using it will see that there was a change to one of the items in the collection?

View 3 Replies

Working With System.collection.generic.Ienumerable/XML Linq Queries?

Oct 22, 2009

This is really a continuation from my earlier post. I've never worked with this datatype/collection (system.collection.generic.Ienumerable) before so I'm struggling to declare the query globally so I can reference the results within other sub routines/functions. I also am struggling to convert it to other types.how I can convert the collection of xml elements/system.collection.generic.Ienumerable into an xmltextreader (I know I will have to change the query below as it select the value of the node and not the node itself) I imagine by converting the query result to system.IO.stream My first port of call was MSDN but I find the material very difficult to understand for this particular subject.

[Code]...

View 3 Replies

Alter Items Added To Generic Collection (as Property Of Custom Class)

Jun 19, 2009

I have several custom classes in a VB.NET (VS2008) project which are related to each other through generic list collections. The lower tier classes refer directly to some of the parent classes (to make it easier to refer backwards up the chain). My question is, is it possible to add the reference to the parent class when the item is added to a collection, when that collection is a property?

Below is some sampling of code to illustrate.
Public Class FlexServer
Private m_FlexLicenses As List(Of FlexLicense)
Private m_Modules As List(Of FlexModule)
Public Property FlexLicenses() As List(Of FlexLicense)
[code] .....

In the code above I have the FlexServer class which refers has two lists as properties, one for FlexLicense and one for Modules. The FlexLicense class has a property to refer back to the FlexServer class that "owns" it. In order to update this property in code, I have to add the FlexLicense to the FlexServer.FlexLicenses list AND set the FlexLicense.FlexServer property. What I am looking for is, is there a way (in the property definition or wherever) to both add the item to the list and alter it at the same time?

View 1 Replies

Using WCF Peer Channel?

Mar 9, 2012

I am architecting a program that I need some help on. I need to have a "watcher" program that will sit on a server and monitor a SQL Server. At configured intervals, the watcher will run a query on the server and create a dataset of information I want to share to any clients that are listening. I am looking at WCF Peer channel but all I can see is peer to peer chat and most of the examples I have seen are partial examples. I have looked at the example program from Microsoft but I am still a bit confused. The listener programs will receive the dataset of values from the watcher and filter the data at the local level and display the data they need and display it to the end user. I don't know if a TCP client/server would be a better solution, but the dataset may contain up to 10,000 rows of data. From what I read the WCF Peer channel will transmit at 50 mbps and should handle this load. My other option is a server/client architecture using TCP spawning a new thread for each request. Does anyone have any good examples, or articles about WCF and VB that they can point me to?

View 2 Replies

How To Declare And Use TKey That Is Pair Of Integer

Apr 28, 2010

VB2008. I would like to use a Dictionary(Of TKey, Tvalue) where the key is a pair of Integer (and TValue is String, no problem). How can I declare it ? How can I add an item ? How can I retrieve a value, knowing the key ? I can do it when the key is an Integer, but with a pair of Integer I am lost.

View 2 Replies

How To Overload Dictionary.Item(TKey)

Feb 9, 2011

I created my own Dictionary class, based on the .NET Dictionary. Now I want to overload then Item() Method. This works fine with the following code: Public Overloads Property Item(ByVal key As TKey) As TValue

[Code]...

View 1 Replies

Implement IDictionary(Of TKey, TValue) In VB?

Mar 2, 2010

I want to create an implementation of the IDictionary(Of TKey, TValue) interface to provide some wrapper functionality.

[code]...


The error is Interface 'System.Collections.Generic.ICollection(Of T) is not implemented by this class. I am not sure what to do about this error. I don't even really understand it. I trade to change the (Of T) to (Of TValue) but that didn't help.

View 1 Replies

Get The Values Of REVIEW NUM And Also The Value Of CHECK->ISSUE_DATE?

Jan 24, 2009

I have the following XML Doc.[code]....

I need to accomplish the following:

when TYPE =CH and STATUS=LI then I need to get the values of REVIEW NUM and also the value of CHECK->ISSUE_DATE. here is what I have so far that is not working very well[code]......

View 6 Replies

Opening Document In Panel For Review?

Oct 19, 2009

I have an application that I want to review existing word documents. What I mean by review is that they can look at them and print them and that is about it. I am a bit stuck on how to complete this task though. I tried using a web browser and that allows changes and with a very minor bit of work the document can be modified and saved. I also tried using process.start and that just starts up the word application as does SetParent.

Is it possible to just take snapshots of the document and view those? Or to open the document as a readonly document?

View 5 Replies

Retrieving The Index Of A Key In A Dictionary(Of Tkey - TValue)

Jun 15, 2011

Is it possible to retrieve the index number of an item/key in a Dictionary(Of TKey, TValue) object?

View 13 Replies

Database Access Pattern Code Review?

Nov 6, 2010

Anyone here kind enough to give me a code review on the following pattern that I have used for database access? I have provided one of the simpler datalayers to show the basic idea.In particular I am starting to question if using shared methods was a good idea and what problems may arise from that? Will this implementation fail in a threaded environment like ASP.Net?

Public Interface IFillable
Sub Fill(ByVal Datareader As Data.IDataReader)
End Interface

[code].....

View 1 Replies

VS 2008 Code Review (Control Making)

May 7, 2009

I downloaded this code from the web that Wierddemon gave me in my previous thread. This solution contains 2 projects (CurrencyControlTest and CurrencyTextBox) There are some things that I don't understand:

1. What's the type of form1.vb and program.vb in the CurrencyControlTest Project? Are they classes, or windows Forms or module?

2. This is the code in Program.vb

Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic

[CODE]...

What's the effect of <STAThread> code?

3. What is exactly the "Namespace" doing in this code? because when I removed the namespace, An error indicating that Form1 is not declared appeared. What is namespace? what does it do? Can anyone give sample code to emphasize the function and how and when to use the keyword "Namespace"?

4. This is code for Form1 in CurrencyControlTest Project

Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic

[CODE]...

What's with the "public partial class Form1"? what does "partial" do? When i right-clicked on the InitializeComponent(), A portion of code appeared suddenly with the header #Region. What is this? and when re-open the Form1 in "View Code" mode, they're gone.

View 7 Replies

C# - Track Changes Of Object Contained In Dictionary And Change TKey Accordingly

Nov 17, 2010

I am writing a class library to interact with a domain Active Directory. In my object model, I have the following:
Domain;
Organizational Unit;
Group;
User.

In my Domain object, I have an Entries property and an Add() method.
public class Domain {
// The ReadOnlyDictionary<TKey, TValue> is a custom wrapper over an IDictionary.
public ReadOnlyDictionary<string, IDirectoryEntry> Entries { get; }
public void Add(IDirectoryEntry entry) {
Entries.Add(entry.Name, entry);
[Code] .....

For your information, I implemented the INotifyPropertyChanged interface to ease my life, but I don't seem to find a way to make it work the way I want. Perhaps am I not doing things right somehow, as for the location of different methods, I don't know. How can I make my Domain aware of a change that occured within one of its Entries, so that the TKey value is also changed? That is wanted because one could possibly add an entry, change its name meanwhile adding a new entry with the "old" name of the actual within entry, and cause a conflict, etc. In the end, causing the test to fail. But I'd like to make it pass like it actually is. Is there another better approach or workaround?

View 1 Replies

Fill Dictionary(Of TKey, TValue) Directly In Program?

Jul 21, 2010

Is there any way to do the same in VB.NET?[code]...

View 1 Replies

Asp.net - (3 Tierish) Database Access Pattern Code Review?

Jan 19, 2011

Anyone here kind enough to give me a code review on the following pattern that I have used for database access? I have provided one of the simpler datalayers to show the basic idea.In particular I am starting to question if using shared methods was a good idea and what problems may arise from that? Will this implementation fail in a threaded environment like ASP.Net?

[Code]...

View 1 Replies







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