protected virtual void RegisterCommandNotifications()
        {
            // cvar value changed
            m_notificationCenter.Register(CCommandNotifications.CVarValueChanged, delegate(CNotification n)
            {
                bool manual = n.Get <bool>(CCommandNotifications.KeyManualMode);

                CVar cvar = n.Get <CVar>(CCommandNotifications.CVarValueChangedKeyVar);
                CAssert.IsNotNull(cvar);

                OnCVarValueChanged(cvar, manual);
            });

            // binding changed
            m_notificationCenter.Register(CCommandNotifications.CBindingsChanged, delegate(CNotification n)
            {
                bool manual = n.Get <bool>(CCommandNotifications.KeyManualMode);
                OnCBindingsChanged(manual);
            });

            // alias changed
            m_notificationCenter.Register(CCommandNotifications.CAliasesChanged, delegate(CNotification n)
            {
                bool manual = n.Get <bool>(CCommandNotifications.KeyManualMode);
                OnCAliasesChanged(manual);
            });
        }
Example #2
0
        internal void Layout(ICTextMeasure measure, float contentWidth, float maxWidth)
        {
            if (this.IsPlain)
            {
                if (this.level == CLogLevel.Exception)
                {
                    CStackTraceLine[] stackLines = this.data as CStackTraceLine[];
                    if (stackLines == null && this.stackTrace != null)
                    {
                        stackLines = CEditorStackTrace.ParseStackTrace(this.stackTrace);
                        this.data  = stackLines;
                    }

                    LayoutException(measure, stackLines, maxWidth);
                }
                else
                {
                    LayoutPlain(measure, maxWidth);
                }
            }
            else if (this.IsTable)
            {
                string[] table = this.Table;
                CAssert.IsNotNull(table);

                LayoutTable(measure, table, contentWidth, maxWidth);
            }
            else
            {
                throw new NotImplementedException("Unexpected entry type");
            }
        }
Example #3
0
        public static T Cast <T>(object obj) where T : class
        {
            CAssert.IsNotNull(obj);
            CAssert.IsInstanceOfType <T>(obj);

            return(obj as T);
        }
Example #4
0
        //////////////////////////////////////////////////////////////////////////////

        #region URL handling

        internal static bool HandleURL(string urlString)
        {
            CAssert.IsNotEmpty(urlString);

            try
            {
                Uri    uri    = new Uri(urlString);
                string scheme = uri.Scheme;

                CURLHandler handler = FindURLHandler(scheme);
                if (handler == null)
                {
                    CLog.e("Can't find URL handler for scheme: '{0}'", scheme);
                    return(false);
                }

                return(handler(urlString));
            }
            catch (Exception e)
            {
                Debug.LogException(e);
            }

            return(false);
        }
Example #5
0
        protected virtual void InsertItem(CFastListNode item, CFastListNode prev, CFastListNode next)
        {
            CAssert.IsNull(item.m_list);

            if (next != null)
            {
                next.m_listPrev = item;
            }
            else
            {
                m_listLast = item;
            }

            if (prev != null)
            {
                prev.m_listNext = item;
            }
            else
            {
                m_listFirst = item;
            }

            item.m_listPrev = prev;
            item.m_listNext = next;
            item.m_list     = this;
            ++m_size;
        }
Example #6
0
        public virtual void RemoveItem(T item)
        {
            CAssert.Greater(m_size, 0);
            CAssert.AreSame(this, item.m_list);

            CFastListNode prev = item.m_listPrev;
            CFastListNode next = item.m_listNext;

            if (prev != null)
            {
                prev.m_listNext = next;
            }
            else
            {
                m_listFirst = next;
            }

            if (next != null)
            {
                next.m_listPrev = prev;
            }
            else
            {
                m_listLast = prev;
            }

            item.m_listNext = item.m_listPrev = null;
            item.m_list     = null;
            --m_size;
        }
Example #7
0
        public virtual void Recycle(CObjectsPoolEntry e)
        {
            CAssert.IsInstanceOfType <T>(e);
            CAssert.AreSame(this, e.pool);

            AddLastItem(e);
        }
        private void PostCallback(CTimer timer)
        {
            CNotification notification = timer.userData as CNotification;

            CAssert.IsNotNull(notification);

            PostImmediately(notification);
        }
Example #9
0
        public virtual bool Add(T e)
        {
            if (e == null)
            {
                throw new ArgumentNullException("e");
            }

            CAssert.NotContains(e, list);
            list.Add(e);

            return(true);
        }
Example #10
0
        public void Recycle()
        {
            if (pool != null)
            {
                CAssert.IsFalse(recycled);
                recycled = true;

                pool.Recycle(this);
            }

            OnRecycleObject();
        }
        internal void Init(Object sender, string name, params object[] pairs)
        {
            Sender = sender;
            Name   = name;

            CAssert.IsTrue(pairs.Length % 2 == 0);
            for (int i = 0; i < pairs.Length;)
            {
                string key   = CClassUtils.Cast <string>(pairs [i++]);
                object value = pairs [i++];

                this.Set(key, value);
            }
        }
Example #12
0
        private void AddTimer(CTimer timer)
        {
            CAssert.AreSame(this, timer.manager);
            ++timersCount;

            if (rootTimer != null)
            {
                // if timer has the least remaining time - it goes first
                if (timer.fireTime < rootTimer.fireTime)
                {
                    timer.next     = rootTimer;
                    rootTimer.prev = timer;
                    rootTimer      = timer;

                    return;
                }

                // try to insert in a sorted order
                CTimer tail = rootTimer;
                for (CTimer t = rootTimer.next; t != null; tail = t, t = t.next)
                {
                    if (timer.fireTime < t.fireTime)
                    {
                        CTimer prev = t.prev;
                        CTimer next = t;

                        timer.prev = prev;
                        timer.next = next;

                        next.prev = timer;
                        prev.next = timer;

                        return;
                    }
                }

                // add timer at the end of the list
                tail.next  = timer;
                timer.prev = tail;
            }
            else
            {
                rootTimer = timer; // timer is root now
            }
        }
Example #13
0
        public static List <MethodInfo> ListMethods(List <MethodInfo> outList, Type type, CMethodsFilter filter, BindingFlags flags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static)
        {
            CAssert.IsNotNull(type, "Type is null");

            MethodInfo[] methods = type.GetMethods(flags);

            if (filter == null)
            {
                outList.AddRange(methods);
                return(outList);
            }

            foreach (MethodInfo m in methods)
            {
                if (filter(m))
                {
                    outList.Add(m);
                }
            }
            return(outList);
        }
Example #14
0
        private void RemoveTimer(CTimer timer)
        {
            CAssert.AreSame(this, timer.manager);
            CAssert.Greater(timersCount, 0);
            --timersCount;

            CTimer prev = timer.prev;
            CTimer next = timer.next;

            if (prev != null)
            {
                prev.next = next;
            }
            else
            {
                rootTimer = next;
            }

            if (next != null)
            {
                next.prev = prev;
            }
        }
Example #15
0
 protected void Unlock()
 {
     CAssert.IsTrue(locked);
     ClearRemoved();
     locked = false;
 }
Example #16
0
 protected void Lock()
 {
     CAssert.IsFalse(locked);
     locked = true;
 }
 public override bool Add(CNotificationDelegate del)
 {
     CAssert.IsFalse(Contains(del));
     return(base.Add(del));
 }