public static AttachmentPoint StateToAttachmentPoint(uint state) { const uint ATTACHMENT_MASK = 0xF0; uint fixedState = (((byte)state & ATTACHMENT_MASK) >> 4) | (((byte)state & ~ATTACHMENT_MASK) << 4); return (AttachmentPoint)fixedState; }