示例#1
0
        public void AddValue(String name, Object value, Type type)
        {
            if (null == name)
            {
                throw new ArgumentNullException("name");
            }

            if (null == type)
            {
                throw new ArgumentNullException("type");
            }

            //
            // Walk until we find a member by the same name or until
            // we reach the end.  If we find a member by the same name,
            // throw.
            for (int i = 0; i < m_currMember; i++)
            {
                if (m_members[i].Equals(name))
                {
                    Debug.WriteLine("SER", "[SerializationInfo.AddValue]Tried to add ", name, " twice to the SI.");

                    throw new SerializationException(EnvironmentX.GetResourceString("Serialization_SameNameTwice"));
                }
            }

            AddValue(name, value, type, m_currMember);
        }
示例#2
0
        // Compares two Objects by calling CompareTo.  If a ==
        // b,0 is returned.  If a implements
        // IComparable, a.CompareTo(b) is returned.  If a
        // doesn't implement IComparable and b does,
        // -(b.CompareTo(a)) is returned, otherwise an
        // exception is thrown.
        //
        public int Compare(Object a, Object b)
        {
            if (a == b)
            {
                return(0);
            }
            if (a == null)
            {
                return(-1);
            }
            if (b == null)
            {
                return(1);
            }
            if (m_compareInfo != null)
            {
                String sa = a as String;
                String sb = b as String;
                if (sa != null && sb != null)
                {
                    return(m_compareInfo.Compare(sa, sb));
                }
            }

            IComparable ia = a as IComparable;

            if (ia != null)
            {
                return(ia.CompareTo(b));
            }

            throw new ArgumentException(EnvironmentX.GetResourceString("Argument_ImplementIComparable"));
        }
示例#3
0
 public RedHttpServerSubscriptionApi(Red.RedHttpServer server, int mustReceiveHeartbeatMillis = 5000, string path = "/ws", Func <string, string, object> getAuthToken = null, Func <string, string, Task <object> > getAuthTokenAsync = null, Func <object, string> getId = null, Func <object, Task <string> > getIdAsync = null) : base(mustReceiveHeartbeatMillis, getAuthToken, getAuthTokenAsync, getId, getIdAsync)
 {
     if (EnvironmentX.IsRunningOnMono())
     {
         throw new Exception("Unfortunately, RedHttpServer does not support WebSockets on Mono");
     }
     this.server = server;
     this.path   = path;
 }
示例#4
0
        public override void init()
        {
            Gun     = new MeinGun();
            Tileset = EnvironmentX.Load("Maps/ij.txt");
            me      = new Tank(Tileset.getTilePosition(5, 5), uManager.CManager.Load <Texture2D>("Tank//OrangeTank"), 100, Gun);
            this.Attach(me.sensor);
            Vector2 tileIX = Tileset.PositionToTileIndex(me.transform.position.X, me.transform.position.Y);

            this.addChild(me);
            base.init();
            uManager.WinHeight = 576;
            uManager.WinWidth  = 768;
        }
示例#5
0
        /*==================================GetElement==================================
        **Action: Use FindElement to get the location of a particular member and then return
        **        the value of the element at that location.  The type of the member is
        **        returned in the foundType field.
        **Returns: The value of the element at the position associated with name.
        **Arguments: name -- the name of the element to find.
        **           foundType -- the type of the element associated with the given name.
        **Exceptions: None.  FindElement does null checking and throws for elements not
        **            found.
        ** ==============================================================================*/
        private Object GetElement(String name, out Type foundType)
        {
            int index = FindElement(name);

            if (index == -1)
            {
                throw new SerializationException(String.Format(CultureInfo.CurrentCulture, EnvironmentX.GetResourceString("Serialization_NotFound"), name));
            }

            Debug.Assert(index < m_data.Length, "[SerializationInfo.GetElement]index<m_data.Length");
            Debug.Assert(index < m_types.Length, "[SerializationInfo.GetElement]index<m_types.Length");

            foundType = m_types[index];
            Debug.Assert(foundType != null, "[SerializationInfo.GetElement]foundType!=null");
            return(m_data[index]);
        }
示例#6
0
 public GameScene(string n)
     : base(n)
 {
     Tileset   = null;
     observers = new List <Observer>();
 }