context: // The OpenSplice DDS Community Edition project.
  //
  // Copyright (C) 2006 to 2011 PrismTech Limited and its licensees.
  // Copyright (C) 2009  L-3 Communications / IS
  // 
  //  This library is free software; you can redistribute it and/or
  //  modify it under the terms of the GNU Lesser General Public
  //  License Version 3 dated 29 June 2007, as published by the
  //  Free Software Foundation.
  // 
  //  This library is distributed in the hope that it will be useful,
  //  but WITHOUT ANY WARRANTY; without even the implied warranty of
  //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  //  Lesser General Public License for more details.
  // 
  //  You should have received a copy of the GNU Lesser General Public
  //  License along with OpenSplice DDS Community Edition; if not, write to the Free Software
  //  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  
  // Csharp backend
  // PTF C# mapping for IDL
  // File /Users/Jcm/Documents/Ecllipse_WS/CSharpDDS/generated/dds_dcps.cs
  // Generated on 2008-11-11 13:36:00
  // from dds_dcps.idl
  
  using System;
  using System.Runtime.InteropServices;
  
  namespace DDS
  {
      // ----------------------------------------------------------------------
      // Types & Pre-defined values
      // ----------------------------------------------------------------------
      [StructLayout(LayoutKind.Sequential)]
      public struct Duration
      {
          [MarshalAs(UnmanagedType.I4)]
          private int sec;
          public int Sec
          {
              get { return sec; }
              set { sec = value; }
          }
  
          [MarshalAs(UnmanagedType.U4)]
          private uint nanosec;
          public uint NanoSec
          {
              get { return nanosec; }
              set { nanosec = value; }
          }
  
          public const int InfiniteSec = 0x7fffffff;
          public const uint InfiniteNanoSec = 0x7fffffff;
  
          public const int ZeroSec = 0;
          public const uint ZeroNanoSec = 0;
  
          public static readonly Duration Infinite = new Duration(InfiniteSec, InfiniteNanoSec);
          public static readonly Duration Zero = new Duration(ZeroSec, ZeroNanoSec);
  
          public static Duration FromTimeSpan(TimeSpan value)
          {
              return FromMilliseconds(value.TotalMilliseconds);
          }
  
          public static Duration FromMilliseconds(double value)
          {
              return new Duration((int)(value / 1000),
                  (uint)((Math.Abs(value) % 1000) * 1000000));
          }
  
          public Duration(int seconds, uint nanoSeconds)
          {
              sec = seconds;
              nanosec = nanoSeconds;
          }
  
          public override bool Equals(object obj)
          {
              if (!(obj is Duration))
                  return false;
  
              return ((Duration)obj).sec == sec && ((Duration)obj).nanosec == nanosec;
          }
  
          public override int GetHashCode()
          {
              return (int)nanosec;
          }
  
          public static bool operator ==(Duration duration1, Duration duration2)
          {
              return (duration1.sec == duration2.sec && duration1.nanosec == duration2.nanosec);
          }
  
          public static bool operator !=(Duration duration1, Duration duration2)
          {
              return !(duration1 == duration2);
          }
  
          public override string ToString()
          {
              return string.Format("{0}.{1}", sec, nanosec);
          }
      }
  
      [StructLayout(LayoutKind.Sequential)]
      public struct Time
      {
          [MarshalAs(UnmanagedType.I4)]
          private int sec;
          public int Sec
          {
              get { return sec; }
              set { sec = value; }
          }
  
          [MarshalAs(UnmanagedType.U4)]
          private uint nanosec;
          public uint NanoSec
          {
              get { return nanosec; }
              set { nanosec = value; }
          }
  
          public const int InvalidSec = -1;
          public const uint InvalidNanoSec = 0xffffffff;
  
          public static readonly Time Invalid = new Time(InvalidSec, InvalidNanoSec);
  
          public static Time FromDateTime(DateTime value)
          {
              DateTime origin = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
              TimeSpan diff = value - origin;
              return new Time((int)Math.Floor(diff.TotalSeconds), (uint)(diff.Milliseconds * 1000000));
          }
  
          public DateTime ToDatetime()
          {
              DateTime origin = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
              return origin.AddSeconds(sec).AddTicks(nanosec / 100);
          }
  
          public Time(int _sec, uint _nanosec)
          {
              sec = _sec;
              nanosec = _nanosec;
          }
  
          public override bool Equals(object obj)
          {
              if (!(obj is Time))
                  return false;
  
              return ((Time)obj).sec == sec && ((Time)obj).nanosec == nanosec;
          }
  
          public override int GetHashCode()
          {
              return (int)nanosec;
          }
  
          public static bool operator ==(Time left, Time right)
          {
              return (left.sec == right.sec && left.nanosec == right.nanosec);
          }
  
          public static bool operator !=(Time left, Time right)
          {
              return !(left == right);
          }
  
          public static bool operator >(Time left, Time right)
          {
              return (left.sec > right.sec) || (left.sec == right.sec && left.nanosec > right.nanosec);
          }
  
          public static bool operator <(Time left, Time right)
          {
              return right > left;
          }
  
          public static bool operator >=(Time left, Time right)
          {
              return (left.sec >= right.sec) || (left.sec == right.sec && left.nanosec >= right.nanosec);
          }
  
          public static bool operator <=(Time left, Time right)
          {
              return right >= left;
          }
  
          public override string ToString()
          {
              return string.Format("{0}.{1}", sec, nanosec);
          }
      }
      
      // This marshals as an int or 32-bit integer
      public struct DomainId
      {
          private int value;
  
          public static readonly DomainId Default = new DomainId(0x7fffffff);
  
          public DomainId(int id)
          {
              value = id;
          }
  
          public override bool Equals(object obj)
          {
  
gt:             if (!(obj is DomainId))