System.Net.GlobalLog.Assert C# (CSharp) Method

Assert() private method

private Assert ( bool condition, string messageFormat ) : void
condition bool
messageFormat string
return void
        public static void Assert(bool condition, string messageFormat, params object[] data)
        {
            if (!condition)
            {
                string fullMessage = string.Format(CultureInfo.InvariantCulture, messageFormat, data);
                int pipeIndex = fullMessage.IndexOf('|');
                if (pipeIndex == -1)
                {
                    Assert(fullMessage);
                }
                else
                {
                    int detailLength = fullMessage.Length - pipeIndex - 1;
                    Assert(fullMessage.Substring(0, pipeIndex), detailLength > 0 ? fullMessage.Substring(pipeIndex + 1, detailLength) : null);
                }
            }
        }

Same methods

GlobalLog::Assert ( string message ) : void
GlobalLog::Assert ( string message, string detailMessage ) : void

Usage Example

Beispiel #1
0
        internal void PostPop(object newOwner)
        {
            GlobalLog.Assert(!IsEmancipated, "Pooled object not in pool.");
            GlobalLog.Assert(CanBePooled, "Pooled object is not poolable.");


            lock (this) {
                if (null == m_Owner)
                {
                    m_Owner = new WeakReference(newOwner);
                }
                else
                {
                    if (null != m_Owner.Target)
                    {
                        throw new InternalException();        // pooled connection already has an owner!
                    }
                    m_Owner.Target = newOwner;
                }

                m_PooledCount--;

                if (null != Pool)
                {
                    if (0 != m_PooledCount)
                    {
                        throw new InternalException();  // popping object off stack with multiple pooledCount
                    }
                }
                else
                {
                    if (-1 != m_PooledCount)
                    {
                        throw new InternalException();  // popping object off stack with multiple pooledCount
                    }
                }
            }
        }
All Usage Examples Of System.Net.GlobalLog::Assert