示例#1
0
        public BaseObject CreateObject(ObjectID objectID)
        {
            if (objectID == ObjectID.NullObjectID || objectID == ObjectID.AnyObjectID)
            {
                throw new ArgumentException();
            }

            if (m_objects.Contains(objectID))
            {
                throw new Exception();
            }

            var ob = ConstructObject(objectID);

            m_objects.Add(ob);

            m_rootObjects.Add(ob);

            var env = ob as EnvironmentObject;

            if (env != null)
            {
                m_environments.Add(env);
            }

            var movable = ob as MovableObject;

            if (movable != null)
            {
                movable.PropertyChanged += MovablePropertyChanged;
            }

            ob.Destructed += ObjectDestructed;

            return(ob);
        }
示例#2
0
        public BaseObject GetObject(ObjectID objectID)
        {
            var ob = FindObject(objectID);

            if (ob == null)
            {
#if TRACK_DESTRUCTED_OBJECTS
                if (m_destructedObjects.Contains(objectID))
                {
                    ob = m_destructedObjects[objectID];
                    throw new Exception(String.Format("Getting destructed object {0}", ob));
                }
#endif
                throw new Exception();
            }

            return(ob);
        }
示例#3
0
        void MovablePropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (e.PropertyName != "Container")
            {
                return;
            }

            var ob = (MovableObject)sender;

            if (ob.Container == null)
            {
                if (m_rootObjects.Contains(ob))
                {
                    return;
                }

                m_rootObjects.Add(ob);
            }
            else
            {
                m_rootObjects.Remove(ob);
            }
        }