Re: Reflection and order of the fields

From: Frank D Lombardo (Frank_at_NoSpam.com)
Date: 03/08/04


Date: Mon, 8 Mar 2004 13:22:23 -0500

I guess I didn't tell you all of the requirements. The device at the other
end is an instrument I am trying to control. My code needs to run on both
the full framework and the compact framework. The objects I want to send
are command objects that have different data fields depending on the nature
of the command.

Because of my specific serialization requirements, I was hoping to write my
own generic command serializer that would use reflection to determine the
run-time data fields of the command and send them over the wire. I'm just
not sure if I can rely on the declarative order of the fields being the
order that they are returned from GetFields().

-- 
Frank D. Lombardo
Turning Point Technology, Inc.
Frank_AT_TurningPointOnline_DOT_com
"Nicholas Paldino [.NET/C# MVP]" <mvp@spam.guard.caspershouse.com> wrote in
message news:%233PBFgTBEHA.892@tk2msftngp13.phx.gbl...
> Frank,
>
>     I am curious, if you are sending an object over the wire, then why not
> just use serialization (assuming that .NET is on the other side of the
> wire).
>
>     The order of the fields is not guaranteed.  Some reasonable
assumptions
> would be to get them in declarative order, and alphabetical, but I am not
> sure.  If you need a specific order, I would recommend getting the
specific
> fields and then ordering them yourself.
>
>     Hope this helps.
>
>
> -- 
>                - Nicholas Paldino [.NET/C# MVP]
>                - mvp@spam.guard.caspershouse.com
>
> "Frank D Lombardo" <Frank@NoSpam.com> wrote in message
> news:O8nyEXTBEHA.1548@TK2MSFTNGP12.phx.gbl...
> > I am attempting to use Reflection to send an object over a serial port.
I
> > won't know the exact type of the object until run-time.  If I call
> > GetFields(), is there any guarantee on the order the fields are
returned?
> > Would it help if I used a struct instead of a class?  I need to send the
> > fields in a known and consistent order.  I would also like this code to
> work
> > on the Compact Framework.
> >
> >
> > Thanks,
> > -- 
> > Frank D. Lombardo
> > Turning Point Technology, Inc.
> > Frank_AT_TurningPointOnline_DOT_com
> >
> >
> >
> >
>
>


Relevant Pages

  • Re: Reflection and order of the fields
    ... My code needs to run on both ... are command objects that have different data fields depending on the nature ... Because of my specific serialization requirements, I was hoping to write my ... Frank D. Lombardo ...
    (microsoft.public.dotnet.framework)
  • Re: Reflection and order of the fields
    ... My code needs to run on both ... are command objects that have different data fields depending on the nature ... Because of my specific serialization requirements, I was hoping to write my ... Frank D. Lombardo ...
    (microsoft.public.dotnet.general)
  • Re: Reflection and order of the fields
    ... My code needs to run on both ... are command objects that have different data fields depending on the nature ... Because of my specific serialization requirements, I was hoping to write my ... Frank D. Lombardo ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Reflection and order of the fields
    ... AFAIK the CF does not support serialization, ... An idea that comes to my head is declaring an ... Command nextCommand = CommandFactory.CreateCommand( ... "Frank D Lombardo" wrote in message ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Reflection and order of the fields
    ... AFAIK the CF does not support serialization, ... An idea that comes to my head is declaring an ... Command nextCommand = CommandFactory.CreateCommand( ... "Frank D Lombardo" wrote in message ...
    (microsoft.public.dotnet.framework)