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); }); }
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"); } }
public static T Cast <T>(object obj) where T : class { CAssert.IsNotNull(obj); CAssert.IsInstanceOfType <T>(obj); return(obj as T); }
////////////////////////////////////////////////////////////////////////////// #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); }
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; }
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; }
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); }
public virtual bool Add(T e) { if (e == null) { throw new ArgumentNullException("e"); } CAssert.NotContains(e, list); list.Add(e); return(true); }
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); } }
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 } }
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); }
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; } }
protected void Unlock() { CAssert.IsTrue(locked); ClearRemoved(); locked = false; }
protected void Lock() { CAssert.IsFalse(locked); locked = true; }
public override bool Add(CNotificationDelegate del) { CAssert.IsFalse(Contains(del)); return(base.Add(del)); }