Showing posts with label retrive. Show all posts
Showing posts with label retrive. Show all posts

Saturday, March 24, 2012

Serializing Collections with Interface members

I have a collection class and in order to make it type safe etc , I only add
and retrive members of Interface types.
But during XMLSerialization I get errors.
Is there any workaround ?
public class OrgRatingCollection:CollectionBase
{
public void Add(IRating item)
{
this.List.Add(item);
}
public IRating this[int index]
{
get
{
return (IRating) this.List[index];
}
set
{
this.List[index] = value;
}
}
}
}to serialize a collection, all object in the collection must be
serializable. defining a interface has no impact.
-- bruce (sqlwork.com)
"Akshay Kumar" <akshay349@.hotmail.com> wrote in message
news:OkVn0Q6wFHA.3720@.TK2MSFTNGP11.phx.gbl...
>I have a collection class and in order to make it type safe etc , I only
>add
> and retrive members of Interface types.
> But during XMLSerialization I get errors.
> Is there any workaround ?
>
> public class OrgRatingCollection:CollectionBase
> {
> public void Add(IRating item)
> {
> this.List.Add(item);
> }
>
> public IRating this[int index]
> {
> get
> {
>
> return (IRating) this.List[index];
> }
> set
> {
>
> this.List[index] = value;
> }
> }
> }
> }
>

Serializing Collections with Interface members

I have a collection class and in order to make it type safe etc , I only add
and retrive members of Interface types.

But during XMLSerialization I get errors.

Is there any workaround ?

public class OrgRatingCollection:CollectionBase

{

public void Add(IRating item)

{

this.List.Add(item);

}

public IRating this[int index]

{

get

{

return (IRating) this.List[index];

}

set

{

this.List[index] = value;

}

}

}

}to serialize a collection, all object in the collection must be
serializable. defining a interface has no impact.

-- bruce (sqlwork.com)

"Akshay Kumar" <akshay349@.hotmail.com> wrote in message
news:OkVn0Q6wFHA.3720@.TK2MSFTNGP11.phx.gbl...
>I have a collection class and in order to make it type safe etc , I only
>add
> and retrive members of Interface types.
> But during XMLSerialization I get errors.
> Is there any workaround ?
>
> public class OrgRatingCollection:CollectionBase
> {
> public void Add(IRating item)
> {
> this.List.Add(item);
> }
>
> public IRating this[int index]
> {
> get
> {
>
> return (IRating) this.List[index];
> }
> set
> {
>
> this.List[index] = value;
> }
> }
> }
> }