Click here to Skip to main content
15,891,976 members
Home / Discussions / C#
   

C#

 
GeneralRe: WebService not returning Color Pin
Luc Pattyn25-Sep-10 12:51
sitebuilderLuc Pattyn25-Sep-10 12:51 
GeneralRe: WebService not returning Color Pin
PIEBALDconsult25-Sep-10 14:00
mvePIEBALDconsult25-Sep-10 14:00 
GeneralRe: WebService not returning Color Pin
Luc Pattyn25-Sep-10 14:18
sitebuilderLuc Pattyn25-Sep-10 14:18 
GeneralRe: WebService not returning Color Pin
PIEBALDconsult25-Sep-10 15:16
mvePIEBALDconsult25-Sep-10 15:16 
GeneralRe: WebService not returning Color Pin
Luc Pattyn25-Sep-10 15:26
sitebuilderLuc Pattyn25-Sep-10 15:26 
GeneralRe: WebService not returning Color Pin
PIEBALDconsult25-Sep-10 16:20
mvePIEBALDconsult25-Sep-10 16:20 
GeneralRe: WebService not returning Color Pin
Luc Pattyn25-Sep-10 17:26
sitebuilderLuc Pattyn25-Sep-10 17:26 
AnswerRe: WebService not returning Color Pin
PIEBALDconsult25-Sep-10 17:34
mvePIEBALDconsult25-Sep-10 17:34 
Sooo... my Colour class didn't help.

I now have a kludge working that passes the Argb as a string and parses it on the other side. Fugly fugly fugly, but here it is.
(This is the class I was using last spring.)


Using a partial class, I have only those properties that are to be serialized in Record.cs:

namespace Junk.Types
{
    [System.Runtime.Serialization.DataContractAttribute()]
    public sealed partial class Record 
    {
        [System.Runtime.Serialization.DataMemberAttribute()]
        public System.Guid ID { get ; set ; }

        [System.Runtime.Serialization.DataMemberAttribute()]
        public string LastName { get ; set ; }

        [System.Runtime.Serialization.DataMemberAttribute()]
        public string FirstName { get ; set ; }

        [System.Runtime.Serialization.DataMemberAttribute()]
        public Junk.Types.Gender Gender { get ; set ; }

        [System.Runtime.Serialization.DataMemberAttribute()]
        private string colourstring { get ; set ; }
    }
}


Note that the colourstring is private.


Other members of the class are in RecordPlus.cs:

namespace Junk.Types
{
    using PIEBALD.Lib.LibExt.ParseColor ;

    public partial class Record 
    {
        private System.Drawing.Color? favouritecolour = null ;

        public Record
        (
        ) 
        {   
            return ;
        }

        public Record
        (
            System.Guid          ID
        ,
            string               LastName
        ,
            string               FirstName
        ,
            Junk.Types.Gender    Gender
        ,
            System.Drawing.Color FavouriteColour
        )
        {
            this.ID              = ID              ;
            this.LastName        = LastName        ;
            this.FirstName       = FirstName       ;
            this.Gender          = Gender          ;
            this.FavouriteColour = FavouriteColour ;

            return ;
        }

        public System.Drawing.Color FavouriteColour
        { 
            get
            {
                if ( !this.favouritecolour.HasValue )
                {
                    this.favouritecolour = this.colourstring.ParseColor() ;
                }

                return ( this.favouritecolour.Value ) ;
            }
            
            set
            {
                this.favouritecolour = value ;
                this.colourstring = "#" + value.ToArgb().ToString( "X8" ) ;

                return ;
            }
        }

        public string
        FullName
        {
            get
            {
                return ( System.String.Format
                (
                    "{0}, {1}"
                ,
                    this.LastName
                ,
                    this.FirstName
                ) ) ;
            }
        }

        public override string
        ToString
        (
        )
        {
            return ( System.String.Format
            ( 
                "{0} {1} {2}"
            ,
                this.FullName 
            ,
                this.Gender
            ,
                this.colourstring
            ) ) ;
        }
    }
}


(ParseColor is an Extension Method.)


On the server side, the code uses the class as defined in these two files.
On the client side, the code uses the second file and the proxy file, which has its own version of the first file.


That's all the jiggery-pokery I've been doing, and it works fine for the types I've been using.


As for non-.net practitioners, they'd see the #FFFFFFFF and deal with it however they need to.
GeneralRe: WebService not returning Color Pin
Luc Pattyn25-Sep-10 17:44
sitebuilderLuc Pattyn25-Sep-10 17:44 
GeneralRe: WebService not returning Color Pin
PIEBALDconsult25-Sep-10 17:52
mvePIEBALDconsult25-Sep-10 17:52 
GeneralRe: WebService not returning Color Pin
Luc Pattyn25-Sep-10 18:01
sitebuilderLuc Pattyn25-Sep-10 18:01 
GeneralRe: WebService not returning Color Pin
PIEBALDconsult25-Sep-10 18:04
mvePIEBALDconsult25-Sep-10 18:04 
GeneralRe: WebService not returning Color Pin
Luc Pattyn25-Sep-10 18:10
sitebuilderLuc Pattyn25-Sep-10 18:10 
GeneralRe: WebService not returning Color [modified] Pin
PIEBALDconsult25-Sep-10 18:44
mvePIEBALDconsult25-Sep-10 18:44 
AnswerRe: WebService not returning Color Pin
AspDotNetDev25-Sep-10 21:35
protectorAspDotNetDev25-Sep-10 21:35 
GeneralRe: WebService not returning Color Pin
PIEBALDconsult26-Sep-10 5:01
mvePIEBALDconsult26-Sep-10 5:01 
AnswerRe: WebService not returning Color Pin
PIEBALDconsult26-Sep-10 7:31
mvePIEBALDconsult26-Sep-10 7:31 
GeneralRe: WebService not returning Color Pin
Luc Pattyn26-Sep-10 7:47
sitebuilderLuc Pattyn26-Sep-10 7:47 
GeneralRe: WebService not returning Color Pin
PIEBALDconsult26-Sep-10 9:37
mvePIEBALDconsult26-Sep-10 9:37 
GeneralRe: WebService not returning Color Pin
Luc Pattyn26-Sep-10 9:48
sitebuilderLuc Pattyn26-Sep-10 9:48 
GeneralRe: WebService not returning Color Pin
PIEBALDconsult26-Sep-10 10:10
mvePIEBALDconsult26-Sep-10 10:10 
GeneralRe: WebService not returning Color Pin
Luc Pattyn26-Sep-10 10:18
sitebuilderLuc Pattyn26-Sep-10 10:18 
GeneralRe: WebService not returning Color Pin
PIEBALDconsult26-Sep-10 12:41
mvePIEBALDconsult26-Sep-10 12:41 
AnswerRe: WebService not returning Color Pin
PIEBALDconsult27-Sep-10 16:26
mvePIEBALDconsult27-Sep-10 16:26 
GeneralRe: WebService not returning Color Pin
Luc Pattyn28-Sep-10 2:35
sitebuilderLuc Pattyn28-Sep-10 2:35 

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.