public virtual object toImmutable() { if (@typeof().isConst()) { return(this); } throw NotImmutableErr.make(@typeof().ToString()).val; }
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); }
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; }
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; }
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()]); } }
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); }
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); }
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); }
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(); }
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); }