NotImmutableErr
Inheritance: Err
Esempio n. 1
0
        public new static NotImmutableErr make(string msg, Err cause)
        {
            NotImmutableErr err = new NotImmutableErr();

            make_(err, msg, cause);
            return(err);
        }
Esempio n. 2
0
 public virtual object toImmutable()
 {
     if (@typeof().isConst())
     {
         return(this);
     }
     throw NotImmutableErr.make(@typeof().ToString()).val;
 }
Esempio n. 3
0
        public override object toImmutable()
        {
            if (m_immutable)
            {
                return(this);
            }

            // make safe copy
            IDictionary temp;

            if (caseInsensitive())
            {
                temp = new Hashtable(new CIEqualityComparer());
            }
            else if (ordered())
            {
                temp = new OrderedDictionary();
            }
            else
            {
                temp = new Hashtable();
            }

            IDictionaryEnumerator en = m_map.GetEnumerator();

            while (en.MoveNext())
            {
                object key = en.Key;
                object val = en.Value;

                if (val != null)
                {
                    if (val is List)
                    {
                        val = ((List)val).toImmutable();
                    }
                    else if (val is Map)
                    {
                        val = ((Map)val).toImmutable();
                    }
                    else if (!isImmutable(val))
                    {
                        throw NotImmutableErr.make("Item [" + key + "] not immutable " + @typeof(val)).val;
                    }
                }

                temp[key] = val;
            }

            // return new m_immutable m_map
            Map ro = new Map(m_type, temp);

            ro.m_isReadonly      = true;
            ro.m_immutable       = true;
            ro.m_caseInsensitive = m_caseInsensitive;
            ro.m_def             = m_def;
            return(ro);
        }
Esempio n. 4
0
 public void def(object v)
 {
     modify();
     if (v != null && !isImmutable(v))
     {
         throw NotImmutableErr.make("def must be immutable: " + @typeof(v)).val;
     }
     this.m_def = v;
 }
Esempio n. 5
0
 public static object toImmutable(object self)
 {
     if (self is FanObj)
     {
         return(((FanObj)self).toImmutable());
     }
     else if (FanUtil.isDotnetImmutable(self.GetType()))
     {
         return(self);
     }
     throw NotImmutableErr.make(self.GetType().ToString()).val;
 }
Esempio n. 6
0
        public static void addHandler(Func func)
        {
            if (!func.isImmutable())
            {
                throw NotImmutableErr.make("handler must be immutable").val;
            }

            lock (lockObj)
            {
                List temp = new List(Sys.FuncType, m_handlers).add(func);
                m_handlers = (Func[])temp.toArray(new Func[temp.sz()]);
            }
        }
Esempio n. 7
0
 public Map set(object key, object val)
 {
     modify();
     if (key == null)
     {
         throw NullErr.make("key is null").val;
     }
     if (!isImmutable(key))
     {
         throw NotImmutableErr.make("key is not immutable: " + @typeof(key)).val;
     }
     m_map[key] = val;
     return(this);
 }
Esempio n. 8
0
        public static void makeCoalescing_(Actor self, ActorPool pool, Func k, Func c, Func r)
        {
            if (k != null && !k.isImmutable())
            {
                throw NotImmutableErr.make("Coalescing toKey func not immutable: " + k).val;
            }

            if (c != null && !c.isImmutable())
            {
                throw NotImmutableErr.make("Coalescing coalesce func not immutable: " + c).val;
            }

            make_(self, pool, r);
            self.m_queue = new CoalescingQueue(k, c);
        }
Esempio n. 9
0
 public Map add(object key, object val)
 {
     modify();
     if (key == null)
     {
         throw NullErr.make("key is null").val;
     }
     if (!isImmutable(key))
     {
         throw NotImmutableErr.make("key is not immutable: " + @typeof(key)).val;
     }
     if (containsKey(key))
     {
         throw ArgErr.make("Key already mapped: " + key).val;
     }
     m_map[key] = val;
     return(this);
 }
Esempio n. 10
0
        public static void make_(Actor self, ActorPool pool, Func receive)
        {
            // check pool
            if (pool == null)
            {
                throw NullErr.make("pool is null").val;
            }

            // check receive method
            if (receive == null && self.@typeof().qname() == "concurrent::Actor")
            {
                throw ArgErr.make("must supply receive func or subclass Actor").val;
            }
            if (receive != null && !receive.isImmutable())
            {
                throw NotImmutableErr.make("Receive func not immutable: " + receive).val;
            }

            // init
            self.m_pool    = pool;
            self.m_receive = receive;
            self.m_queue   = new Queue();
        }
Esempio n. 11
0
        public override object toImmutable()
        {
            if (m_immutable)
            {
                return(this);
            }

            // make safe copy
            object[] temp = new object[m_size];
            for (int i = 0; i < m_size; i++)
            {
                object item = m_values[i];
                if (item != null)
                {
                    if (item is List)
                    {
                        item = ((List)item).toImmutable();
                    }
                    else if (item is Map)
                    {
                        item = ((Map)item).toImmutable();
                    }
                    else if (!isImmutable(item))
                    {
                        throw NotImmutableErr.make("Item [" + i + "] not immutable " + @typeof(item)).val;
                    }
                }
                temp[i] = item;
            }

            // return new immutable list
            List ro = new List(m_of, temp);

            ro.m_isReadonly = true;
            ro.m_immutable  = true;
            return(ro);
        }
Esempio n. 12
0
 public static void make_(NotImmutableErr self)
 {
     make_(self, null);
 }
Esempio n. 13
0
 public static new NotImmutableErr make(string msg, Err cause)
 {
     NotImmutableErr err = new NotImmutableErr();
       make_(err, msg, cause);
       return err;
 }
Esempio n. 14
0
 public static void make_(NotImmutableErr self, string msg, Err cause)
 {
     Err.make_(self, msg, cause);
 }
Esempio n. 15
0
 public static void make_(NotImmutableErr self, string msg)
 {
     make_(self, msg, null);
 }
Esempio n. 16
0
 public static void make_(NotImmutableErr self, string msg)
 {
     make_(self, msg, null);
 }
Esempio n. 17
0
 public static void make_(NotImmutableErr self, string msg, Err cause)
 {
     Err.make_(self, msg, cause);
 }
Esempio n. 18
0
 public static void make_(NotImmutableErr self)
 {
     make_(self, null);
 }