473,394 Members | 2,168 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Dictionary Object name/value pair

I'm trying to replicate the behaviour of the Commerce.Dictionary object that
was found in Commerce Server 3.0

By using a hashtable or creating a custom class that implements IDictionary,
you have to add elements by using the following syntax.

DictionaryObject.Add("key","value");

However, the old Commerce Server Dictionary object used the following
syntax.

DictionaryObject.Name = "Fred"

In this instance, the dictionary object creates a new element key called
"Name" and assigns the value of "Fred" to it.

Any thoughts on how to replicate this?
Mar 13 '07 #1
15 7908
VJ
What are probably looking to do is create a Dictionary Object and then a
Collection of Dictionary Object, so more like

Public class MyDictObj
{
// has member name
}

public class CMyDictObj : CollectionBase
{
// represents collection of MyDictObj
}

HTH
VJ

"Dave Young" <da***************@softwarespectrum.comwrote in message
news:OB**************@TK2MSFTNGP02.phx.gbl...
I'm trying to replicate the behaviour of the Commerce.Dictionary object
that was found in Commerce Server 3.0

By using a hashtable or creating a custom class that implements
IDictionary, you have to add elements by using the following syntax.

DictionaryObject.Add("key","value");

However, the old Commerce Server Dictionary object used the following
syntax.

DictionaryObject.Name = "Fred"

In this instance, the dictionary object creates a new element key called
"Name" and assigns the value of "Fred" to it.

Any thoughts on how to replicate this?

Mar 13 '07 #2
It's not perfect, but you could use an indexer to reduce the amount of
modification.

private Dictionary<string, stringhash = new Dictionary<string, string>();

public string this[string key]
{
get
{
return hash[key];
}
set
{
hash[key] = value;
}
}

Which means that instead of:

DictionaryObject.Name = "Fred"

you do:

DictionaryObject["Name"] = "Fred";

I think it's not possible to dynamically create properties as C# is a
statically typed language and you will get a compiler error if the property
you are asking for does not exist.

If you REALLY want it to work like this and don't care about bloat you could
write a codeGen to create a class file with every single alphabetical
combination created as a property.
As an example of A:

public string A
{
get
{
return hash["A"];
}
set
{
hash["A"] = value;
}
}

But that would be a seriously LONG file.

HTH

Simon

"Dave Young" <da***************@softwarespectrum.comwrote in message
news:OB**************@TK2MSFTNGP02.phx.gbl...
I'm trying to replicate the behaviour of the Commerce.Dictionary object
that
was found in Commerce Server 3.0

By using a hashtable or creating a custom class that implements
IDictionary,
you have to add elements by using the following syntax.

DictionaryObject.Add("key","value");

However, the old Commerce Server Dictionary object used the following
syntax.

DictionaryObject.Name = "Fred"

In this instance, the dictionary object creates a new element key called
"Name" and assigns the value of "Fred" to it.

Any thoughts on how to replicate this?


Mar 13 '07 #3
I don't really understand the point.

Can't you just use a database?

Is SQL Server more complex than this?

-Todos

On Mar 13, 11:16 am, "Dave Young"
<dave.young.nos...@softwarespectrum.comwrote:
I'm trying to replicate the behaviour of the Commerce.Dictionary object that
was found in Commerce Server 3.0

By using a hashtable or creating a custom class that implements IDictionary,
you have to add elements by using the following syntax.

DictionaryObject.Add("key","value");

However, the old Commerce Server Dictionary object used the following
syntax.

DictionaryObject.Name = "Fred"

In this instance, the dictionary object creates a new element key called
"Name" and assigns the value of "Fred" to it.

Any thoughts on how to replicate this?

Mar 13 '07 #4
I believe that the OP is asking about an in-memory data structure, not
a long-term storage option.

On Mar 13, 1:49 pm, "Todos Menos [MSFT]"
<todos_menos_m...@hotmail.comwrote:
I don't really understand the point.

Can't you just use a database?

Is SQL Server more complex than this?

-Todos

On Mar 13, 11:16 am, "Dave Young"

<dave.young.nos...@softwarespectrum.comwrote:
I'm trying to replicate the behaviour of the Commerce.Dictionary object that
was found in Commerce Server 3.0
By using a hashtable or creating a custom class that implements IDictionary,
you have to add elements by using the following syntax.
DictionaryObject.Add("key","value");
However, the old Commerce Server Dictionary object used the following
syntax.
DictionaryObject.Name = "Fred"
In this instance, the dictionary object creates a new element key called
"Name" and assigns the value of "Fred" to it.
Any thoughts on how to replicate this?
Mar 13 '07 #5
I "think" he's trying to prop up existing code by re-writing this library.
If the API changes then more code needs to be re-written.
That's why I think he's not using a database.

I could be wrong though, if that's the case then you're right a database is
definately the best course of action. Because trying to create a dynamic
type in a statically typed language is like putting a square peg in a round
hole.
"Todos Menos [MSFT]" <to**************@hotmail.comwrote in message
news:11*********************@b75g2000hsg.googlegro ups.com...
I don't really understand the point.

Can't you just use a database?

Is SQL Server more complex than this?

-Todos

On Mar 13, 11:16 am, "Dave Young"
<dave.young.nos...@softwarespectrum.comwrote:
I'm trying to replicate the behaviour of the Commerce.Dictionary object
that
was found in Commerce Server 3.0

By using a hashtable or creating a custom class that implements
IDictionary,
you have to add elements by using the following syntax.

DictionaryObject.Add("key","value");

However, the old Commerce Server Dictionary object used the following
syntax.

DictionaryObject.Name = "Fred"

In this instance, the dictionary object creates a new element key called
"Name" and assigns the value of "Fred" to it.

Any thoughts on how to replicate this?


Mar 13 '07 #6
Simon Tamman <i_**********************************@NOSPAMhotmai l.com>
wrote:
I "think" he's trying to prop up existing code by re-writing this library.
If the API changes then more code needs to be re-written.
That's why I think he's not using a database.

I could be wrong though, if that's the case then you're right a database is
definately the best course of action. Because trying to create a dynamic
type in a statically typed language is like putting a square peg in a round
hole.
"Todos" isn't trying to make serious points - he's just trolling. Best
to ignore.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Mar 13 '07 #7
Thanks for the tip. :D

No chance I could get your opinion on my wierd bug I posted yesterday is
there?
I did include a "short but complete" example to demonstrate the problem. :D

"Jon Skeet [C# MVP]" <sk***@pobox.comwrote in message
news:MP************************@msnews.microsoft.c om...
Simon Tamman <i_**********************************@NOSPAMhotmai l.com>
wrote:
I "think" he's trying to prop up existing code by re-writing this
library.
If the API changes then more code needs to be re-written.
That's why I think he's not using a database.

I could be wrong though, if that's the case then you're right a database
is
definately the best course of action. Because trying to create a dynamic
type in a statically typed language is like putting a square peg in a
round
hole.

"Todos" isn't trying to make serious points - he's just trolling. Best
to ignore.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too

Mar 13 '07 #8
I just think that we should be teaching these Newbies about DATABASES
and not all this ADO.net and XML _CRAP_

that is why we outsource all this crap to india-- because there aren't
enough kids in the good old USA that know how to speak SQL



On Mar 13, 2:00 pm, "Bruce Wood" <brucew...@canada.comwrote:
I believe that the OP is asking about an in-memory data structure, not
a long-term storage option.

On Mar 13, 1:49 pm, "Todos Menos[MSFT]"

<todos_menos_m...@hotmail.comwrote:
I don't really understand the point.
Can't you just use a database?
Is SQL Server more complex than this?
-Todos
On Mar 13, 11:16 am, "Dave Young"
<dave.young.nos...@softwarespectrum.comwrote:
I'm trying to replicate the behaviour of the Commerce.Dictionary object that
was found in Commerce Server 3.0
By using a hashtable or creating a custom class that implements IDictionary,
you have to add elements by using the following syntax.
DictionaryObject.Add("key","value");
However, the old Commerce Server Dictionary object used the following
syntax.
DictionaryObject.Name = "Fred"
In this instance, the dictionary object creates a new element key called
"Name" and assigns the value of "Fred" to it.
Any thoughts on how to replicate this?- Hide quoted text -

- Show quoted text -

Mar 13 '07 #9
Simon Tamman <i_**********************************@NOSPAMhotmai l.com>
wrote:
Thanks for the tip. :D

No chance I could get your opinion on my wierd bug I posted yesterday is
there?
I did include a "short but complete" example to demonstrate the problem. :D
Unfortunately I don't know a lot about the details of Windows Forms.
Have you asked in the Windows Forms newsgroup?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Mar 13 '07 #10
You are correct sir. There an old asp application that our company uses
that was originally built upon Site Server 3.0 and Commerce Server 3.0.

Well, one company aquisition and a datacenter migration tends to make one
want to eliminate, or at least reduce, the number of 3rd party applications
that need to be re-installed. I've been able to migrate all of the
previously used CS and SS dlls that were being used, to C#, but this one
eludes me. I originally attacked it by giving them (the asp dudes) a simple
implementation of IDictionary, but that didn't give them the same usage as
the original. Thus, my post.

If it can't be done, then I'll just tell them so and they can go back and
change their code to use the implementation I gave them.

Thanks
Dave

"Simon Tamman" <i_**********************************@NOSPAMhotmai l.com>
wrote in message news:In***************@newsfe4-gui.ntli.net...
>I "think" he's trying to prop up existing code by re-writing this library.
If the API changes then more code needs to be re-written.
That's why I think he's not using a database.

I could be wrong though, if that's the case then you're right a database
is
definately the best course of action. Because trying to create a dynamic
type in a statically typed language is like putting a square peg in a
round
hole.
"Todos Menos [MSFT]" <to**************@hotmail.comwrote in message
news:11*********************@b75g2000hsg.googlegro ups.com...
>I don't really understand the point.

Can't you just use a database?

Is SQL Server more complex than this?

-Todos

On Mar 13, 11:16 am, "Dave Young"
<dave.young.nos...@softwarespectrum.comwrote:
I'm trying to replicate the behaviour of the Commerce.Dictionary object
that
was found in Commerce Server 3.0

By using a hashtable or creating a custom class that implements
IDictionary,
you have to add elements by using the following syntax.

DictionaryObject.Add("key","value");

However, the old Commerce Server Dictionary object used the following
syntax.

DictionaryObject.Name = "Fred"

In this instance, the dictionary object creates a new element key
called
"Name" and assigns the value of "Fred" to it.

Any thoughts on how to replicate this?



Mar 14 '07 #11
yeah 'I dont know Windows forms'

the funny thing is that Iknow of about a hundred PHP kids that can
just flat out-develop these ASP.net fags

-Todos

On Mar 13, 3:19 pm, Jon Skeet [C# MVP] <s...@pobox.comwrote:
Simon Tamman <i_am_GETRIDOFTHISJUNKanti_everyth...@NOSPAMhotmai l.com>
wrote:
Thanks for the tip. :D
No chance I could get your opinion on my wierd bug I posted yesterday is
there?
I did include a "short but complete" example to demonstrate the problem. :D

Unfortunately I don't know a lot about the details of Windows Forms.
Have you asked in the Windows Forms newsgroup?

--
Jon Skeet - <s...@pobox.com>http://www.pobox.com/~skeet Blog:http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too

Mar 14 '07 #12
I'm not trolling

I'm throwing molotov cocktails against the oppressive regime in
Redmond

TIME FOR REGIME CHANGE IN REDMOND!

-Todos
On Mar 13, 2:13 pm, Jon Skeet [C# MVP] <s...@pobox.comwrote:
Simon Tamman <i_am_GETRIDOFTHISJUNKanti_everyth...@NOSPAMhotmai l.com>
wrote:
I "think" he's trying to prop up existing code by re-writing this library.
If the API changes then more code needs to be re-written.
That's why I think he's not using a database.
I could be wrong though, if that's the case then you're right a database is
definately the best course of action. Because trying to create a dynamic
type in a statically typed language is like putting a square peg in a round
hole.

"Todos" isn't trying to make serious points - he's just trolling. Best
to ignore.

--
Jon Skeet - <s...@pobox.com>http://www.pobox.com/~skeet Blog:http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too

Mar 14 '07 #13
and really. seriously

I don't really understand the point.

Can't you just use a database?
Is SQL Server more complex than this?
-Todos


On Mar 13, 12:21 pm, "Simon Tamman"
<i_am_GETRIDOFTHISJUNKanti_everyth...@NOSPAMhotmai l.comwrote:
It's not perfect, but you could use an indexer to reduce the amount of
modification.

private Dictionary<string, stringhash = new Dictionary<string, string>();

public string this[string key]
{
get
{
return hash[key];
}
set
{
hash[key] = value;
}
}

Which means that instead of:

DictionaryObject.Name = "Fred"

you do:

DictionaryObject["Name"] = "Fred";

I think it's not possible to dynamically create properties as C# is a
statically typed language and you will get a compiler error if the property
you are asking for does not exist.

If you REALLY want it to work like this and don't care about bloat you could
write a codeGen to create a class file with every single alphabetical
combination created as a property.
As an example of A:

public string A
{
get
{
return hash["A"];}

set
{
hash["A"] = value;

}
}

But that would be a seriously LONG file.

HTH

Simon

"Dave Young" <dave.young.nos...@softwarespectrum.comwrote in message

news:OB**************@TK2MSFTNGP02.phx.gbl...
I'm trying to replicate the behaviour of the Commerce.Dictionary object
that
was found in Commerce Server 3.0
By using a hashtable or creating a custom class that implements
IDictionary,
you have to add elements by using the following syntax.
DictionaryObject.Add("key","value");
However, the old Commerce Server Dictionary object used the following
syntax.
DictionaryObject.Name = "Fred"
In this instance, the dictionary object creates a new element key called
"Name" and assigns the value of "Fred" to it.
Any thoughts on how to replicate this?- Hide quoted text -

- Show quoted text -

Mar 14 '07 #14
Well to support the current implementation is it not possible to just
collate all the properties they are using and implement those? Or are there
way too many to implement?

I mean name could be implemented like:

public string Name
{
get
{
return hash["Name"];
}
set
{
hash["Name"] = value;
}
}

I guess it depends on how many dynamic tags they're using on this object.
"Dave Young" <dm************@verizon.netwrote in message
news:eF**************@TK2MSFTNGP06.phx.gbl...
You are correct sir. There an old asp application that our company uses
that was originally built upon Site Server 3.0 and Commerce Server 3.0.

Well, one company aquisition and a datacenter migration tends to make one
want to eliminate, or at least reduce, the number of 3rd party
applications
that need to be re-installed. I've been able to migrate all of the
previously used CS and SS dlls that were being used, to C#, but this one
eludes me. I originally attacked it by giving them (the asp dudes) a
simple
implementation of IDictionary, but that didn't give them the same usage as
the original. Thus, my post.

If it can't be done, then I'll just tell them so and they can go back and
change their code to use the implementation I gave them.

Thanks
Dave

"Simon Tamman" <i_**********************************@NOSPAMhotmai l.com>
wrote in message news:In***************@newsfe4-gui.ntli.net...
I "think" he's trying to prop up existing code by re-writing this
library.
If the API changes then more code needs to be re-written.
That's why I think he's not using a database.

I could be wrong though, if that's the case then you're right a database
is
definately the best course of action. Because trying to create a dynamic
type in a statically typed language is like putting a square peg in a
round
hole.
"Todos Menos [MSFT]" <to**************@hotmail.comwrote in message
news:11*********************@b75g2000hsg.googlegro ups.com...
I don't really understand the point.

Can't you just use a database?

Is SQL Server more complex than this?

-Todos

On Mar 13, 11:16 am, "Dave Young"
<dave.young.nos...@softwarespectrum.comwrote:
I'm trying to replicate the behaviour of the Commerce.Dictionary
object
that
was found in Commerce Server 3.0

By using a hashtable or creating a custom class that implements
IDictionary,
you have to add elements by using the following syntax.

DictionaryObject.Add("key","value");

However, the old Commerce Server Dictionary object used the following
syntax.

DictionaryObject.Name = "Fred"

In this instance, the dictionary object creates a new element key
called
"Name" and assigns the value of "Fred" to it.

Any thoughts on how to replicate this?



Mar 14 '07 #15
That's one approach I hadn't thougth about.

Thanks
"Simon Tamman" <i_**********************************@NOSPAMhotmai l.com>
wrote in message news:QE***************@newsfe5-win.ntli.net...
Well to support the current implementation is it not possible to just
collate all the properties they are using and implement those? Or are
there
way too many to implement?

I mean name could be implemented like:

public string Name
{
get
{
return hash["Name"];
}
set
{
hash["Name"] = value;
}
}

I guess it depends on how many dynamic tags they're using on this object.
"Dave Young" <dm************@verizon.netwrote in message
news:eF**************@TK2MSFTNGP06.phx.gbl...
>You are correct sir. There an old asp application that our company uses
that was originally built upon Site Server 3.0 and Commerce Server 3.0.

Well, one company aquisition and a datacenter migration tends to make one
want to eliminate, or at least reduce, the number of 3rd party
applications
>that need to be re-installed. I've been able to migrate all of the
previously used CS and SS dlls that were being used, to C#, but this one
eludes me. I originally attacked it by giving them (the asp dudes) a
simple
>implementation of IDictionary, but that didn't give them the same usage
as
the original. Thus, my post.

If it can't be done, then I'll just tell them so and they can go back and
change their code to use the implementation I gave them.

Thanks
Dave

"Simon Tamman" <i_**********************************@NOSPAMhotmai l.com>
wrote in message news:In***************@newsfe4-gui.ntli.net...
>I "think" he's trying to prop up existing code by re-writing this
library.
If the API changes then more code needs to be re-written.
That's why I think he's not using a database.

I could be wrong though, if that's the case then you're right a
database
is
definately the best course of action. Because trying to create a
dynamic
type in a statically typed language is like putting a square peg in a
round
hole.
"Todos Menos [MSFT]" <to**************@hotmail.comwrote in message
news:11*********************@b75g2000hsg.googlegro ups.com...
I don't really understand the point.

Can't you just use a database?

Is SQL Server more complex than this?

-Todos

On Mar 13, 11:16 am, "Dave Young"
<dave.young.nos...@softwarespectrum.comwrote:
I'm trying to replicate the behaviour of the Commerce.Dictionary
object
that
was found in Commerce Server 3.0

By using a hashtable or creating a custom class that implements
IDictionary,
you have to add elements by using the following syntax.

DictionaryObject.Add("key","value");

However, the old Commerce Server Dictionary object used the
following
syntax.

DictionaryObject.Name = "Fred"

In this instance, the dictionary object creates a new element key
called
"Name" and assigns the value of "Fred" to it.

Any thoughts on how to replicate this?




Mar 14 '07 #16

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: boohoo | last post by:
I can't seem to do this: I want to take a query string and place two halves of the querystring into two separate dictionary objects. So... I loop through the collection of querystring items,...
2
by: orekinbck | last post by:
Hi There I am probably missing something fundamental here, but I cannot see a method to search the values of a generic dictionary so that I can find the key ? Of course I could enumerate...
2
by: jg | last post by:
I was trying to get custom dictionary class that can store generic or string; So I started with the example given by the visual studio 2005 c# online help for simpledictionay object That seem...
1
by: Martin Widmer | last post by:
Hi Folks. When I iterate through my custom designed collection, I always get the error: "Unable to cast object of type 'System.Collections.DictionaryEntry' to type...
11
by: Girish Sahani | last post by:
I wrote the following code to concatenate every 2 keys of a dictionary and their corresponding values. e.g if i have tiDict1 = tiDict1 = {'a':,'b':} i should get tiDict2={'ab':} and similarly for...
5
by: titan.nyquist | last post by:
Is there a typical way to create a dictionary (or hash table) with two values, instead of one? Currently, my data structure is TWO dictionaries, each with matching and fully sychronized keys. ...
4
by: csharpula csharp | last post by:
Hello, I was wondering if there is a way in c# to append two Dictionaries of the same type: Dictionary<string,objectdic1 and Dictionary<string,objectdic2 into one new Dictionary<string,object?...
7
by: mmm | last post by:
I found code to undo a dictionary association. def undict(dd, name_space=globals()): for key, value in dd.items(): exec "%s = %s" % (key, repr(value)) in name_space So if i run I get
4
by: =?Utf-8?B?THVpZ2k=?= | last post by:
Hi all, having a dictionary of <int, string(C# 2.0) is there a way to retrieve the key for a specific value (of type string)? Obviously I populate the Dictionary with not duplicated strings. ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.