Click here to Skip to main content
15,921,840 members
Home / Discussions / C#
   

C#

 
QuestionAllowing a webservice to invoke a function from a windows application Pin
ZeinaBaG13-Jul-06 0:23
ZeinaBaG13-Jul-06 0:23 
Questionbinlllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll Pin
arun.m13-Jul-06 0:19
arun.m13-Jul-06 0:19 
AnswerRe: binlllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll Pin
Corinna John13-Jul-06 0:39
Corinna John13-Jul-06 0:39 
AnswerRe: binl... Pin
Ravi Bhavnani13-Jul-06 2:48
professionalRavi Bhavnani13-Jul-06 2:48 
AnswerRe: binlllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll Pin
LongRange.Shooter13-Jul-06 3:33
LongRange.Shooter13-Jul-06 3:33 
QuestionProblem with C++ wchar_t To C# ... Pin
SD312-Jul-06 23:56
SD312-Jul-06 23:56 
Questionreadonly List members Pin
GDavy12-Jul-06 23:36
GDavy12-Jul-06 23:36 
AnswerRe: readonly List members [modified] Pin
Roger Alsing13-Jul-06 0:01
Roger Alsing13-Jul-06 0:01 
You can either make your SomeObject immutable.

eg:
class SomeObject<br />
{<br />
private bool immutable = false;<br />
private int aProp;<br />
public int ACertainProp<br />
{<br />
get { return aProp; }<br />
set { if (!immutable) aProp = value; } //or throw an error when immutable<br />
}<br />
<br />
public void MakeImmutable()<br />
{<br />
   immutable = true;<br />
}<br />
}



however this might not be what you are looking for? this makes the object immutable for every consumer.

another approach might be to simply clone your objects and fill the list with clones.
the clones wont be readonly (unless also supporting immutable)
this might be useful if your main concern is just to avoid that people change your data.

you could also try making wrappers for your objects, where the wrapper and the SomeObject shares the same interface.

either way, there is no good approach to make an object readonly out of the box, you have to write a bit of code no matter what approach you select.

Id probably go for immutable clones.

foreach (SomeObject obj in realList)<br />
{<br />
   SomeObject clone = obj.clone();<br />
   clone.MakeImmutable();<br />
   resultList.add(clone);<br />
}


//Roger

http://www.puzzleframework.com

[edit]

forgot to say , wrappers have an edge over clones because a wrapper will always reflect the real values of the real objects properties.

a clone will just reflect the values of the properties of the real object when the cloning was done.
QuestionDateTime from String Pin
V.12-Jul-06 23:32
professionalV.12-Jul-06 23:32 
AnswerRe: DateTime from String Pin
Stefan Troschuetz12-Jul-06 23:54
Stefan Troschuetz12-Jul-06 23:54 
GeneralRe: DateTime from String Pin
V.13-Jul-06 0:06
professionalV.13-Jul-06 0:06 
GeneralRe: DateTime from String Pin
Guffa13-Jul-06 0:16
Guffa13-Jul-06 0:16 
GeneralRe: DateTime from String Pin
V.13-Jul-06 0:30
professionalV.13-Jul-06 0:30 
QuestionConvert hex char to byte Pin
bluish12-Jul-06 23:18
bluish12-Jul-06 23:18 
AnswerRe: Convert hex char to byte [modified] Pin
sjembek13-Jul-06 0:20
sjembek13-Jul-06 0:20 
AnswerRe: Convert hex char to byte [modified] Pin
stancrm13-Jul-06 0:27
stancrm13-Jul-06 0:27 
GeneralRe: Convert hex char to byte Pin
bluish13-Jul-06 3:13
bluish13-Jul-06 3:13 
GeneralRe: Convert hex char to byte Pin
stancrm13-Jul-06 3:32
stancrm13-Jul-06 3:32 
QuestionMulti Threading Pin
kulile12-Jul-06 22:57
kulile12-Jul-06 22:57 
AnswerRe: Multi Threading Pin
Corinna John12-Jul-06 23:07
Corinna John12-Jul-06 23:07 
GeneralRe: Multi Threading Pin
Roger Alsing13-Jul-06 1:41
Roger Alsing13-Jul-06 1:41 
GeneralRe: Multi Threading Pin
Not Active13-Jul-06 2:48
mentorNot Active13-Jul-06 2:48 
GeneralRe: Multi Threading Pin
Corinna John13-Jul-06 3:36
Corinna John13-Jul-06 3:36 
GeneralRe: Multi Threading Pin
Not Active13-Jul-06 3:48
mentorNot Active13-Jul-06 3:48 
GeneralRe: Multi Threading Pin
Roger Alsing13-Jul-06 20:29
Roger Alsing13-Jul-06 20:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.