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

C#

 
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 
I have now rewritten my Colour class (as a struct) and it seems to work properly.

Record.cs as it now stands:

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()]
        public Junk.Types.Colour FavouriteColour { get ; set ; }
    }
}



Colour.cs:

namespace Junk.Types
{
    public partial struct Colour
    {
        public byte A ;
        public byte R ;
        public byte G ;
        public byte B ;
    }
}



ColourPlus.cs:

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

    public partial struct Colour
    {
        public override string 
        ToString 
        (
        )
        {
            return ( System.String.Format
            (
                "#{0:X2}{1:X2}{2:X2}{3:X2}"
            ,
                this.A
            ,
                this.R
            ,
                this.G
            ,
                this.B
            ) ) ;
        }

        public static Colour
        Parse
        (
            string Argb
        )
        {
            return ( Colour.FromArgb ( Argb.ParseArgb() ) ) ;
        }

        public int
        ToArgb
        (
        )
        {
            return ( this.A << 24 | this.R << 16 | this.G << 8 | this.B ) ;
        }

        public static Colour
        FromArgb
        (
            int Argb
        )
        {
            Colour result = new Colour() ;

            result.B = (byte) ( Argb & 0x0FF ) ;
            Argb >>= 8 ;

            result.G = (byte) ( Argb & 0x0FF ) ;
            Argb >>= 8 ;

            result.R = (byte) ( Argb & 0x0FF ) ;
            Argb >>= 8 ;

            result.A = (byte) ( Argb & 0x0FF ) ;

            return ( result ) ;
        }

        public static implicit operator System.Drawing.Color
        (
            Colour Colour
        )
        {
            return ( System.Drawing.Color.FromArgb ( Colour.ToArgb() ) ) ;
        }
        
        public static implicit operator Colour
        (
            System.Drawing.Color Color
        )
        {
            return ( Colour.FromArgb ( Color.ToArgb() ) ) ;
        }
    }
}


(ParseArgb replaces ParseColor, it returns an int.)


I haven't inspected the SOAP messages (I don't know how), but I expect they contain the four byte values; something along the lines of:

<FavouriteColour><A>256</A><R>256</R><G>256</G><B>256</B></FavouriteColour>
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 
Questionvisual studio addin - recalc dependencies before a build Pin
Jim Crafton24-Sep-10 9:21
Jim Crafton24-Sep-10 9:21 
QuestionRe: visual studio addin - recalc dependencies before a build Pin
AspDotNetDev24-Sep-10 11:04
protectorAspDotNetDev24-Sep-10 11:04 
Questionconnecting acces with udl file Pin
Erdinc2724-Sep-10 3:47
Erdinc2724-Sep-10 3:47 
AnswerRe: connecting acces with udl file Pin
PIEBALDconsult24-Sep-10 11:34
mvePIEBALDconsult24-Sep-10 11:34 
Questioncreating a pause? Pin
stephen.darling24-Sep-10 2:52
stephen.darling24-Sep-10 2:52 
AnswerRe: creating a pause? Pin
Manfred Rudolf Bihy24-Sep-10 3:04
professionalManfred Rudolf Bihy24-Sep-10 3:04 
GeneralRe: creating a pause? Pin
stephen.darling24-Sep-10 3:12
stephen.darling24-Sep-10 3:12 
GeneralRe: creating a pause? Pin
Manfred Rudolf Bihy24-Sep-10 3:25
professionalManfred Rudolf Bihy24-Sep-10 3:25 
GeneralRe: creating a pause? Pin
stephen.darling24-Sep-10 3:38
stephen.darling24-Sep-10 3:38 
GeneralRe: creating a pause? Pin
stephen.darling24-Sep-10 3:42
stephen.darling24-Sep-10 3:42 
GeneralRe: creating a pause? Pin
Manfred Rudolf Bihy24-Sep-10 3:48
professionalManfred Rudolf Bihy24-Sep-10 3:48 

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.