ReadonlyErr.
Inheritance: Err
Example #1
0
        public new static ReadonlyErr make(string msg, Err cause)
        {
            ReadonlyErr err = new ReadonlyErr();

            make_(err, msg, cause);
            return(err);
        }
Example #2
0
        public virtual void set(object instance, object value, bool checkConst)
        {
            m_parent.finish();

            // check const
            if ((m_flags & FConst.Const) != 0)
            {
                if (checkConst)
                {
                    throw ReadonlyErr.make("Cannot set const field " + qname()).val;
                }
                else if (value != null && !isImmutable(value))
                {
                    throw ReadonlyErr.make("Cannot set const field " + qname() + " with mutable value").val;
                }
            }

            // check static
            if ((m_flags & FConst.Static) != 0)
            {
                throw ReadonlyErr.make("Cannot set static field " + qname()).val;
            }

            // check generic type (the .NET runtime will check non-generics)
            if (m_type.isGenericInstance() && value != null)
            {
                if (!@typeof(value).@is(m_type.toNonNullable()))
                {
                    throw ArgErr.make("Wrong type for field " + qname() + ": " + m_type + " != " + @typeof(value)).val;
                }
            }

            if (m_setter != null)
            {
                m_setter.invoke(instance, new object[] { value });
                return;
            }

            try
            {
                m_reflect.SetValue(instance, unbox(value));
            }
            catch (ArgumentException e)
            {
                throw ArgErr.make(e).val;
            }
            catch (Exception e)
            {
                if (m_reflect == null)
                {
                    throw Err.make("Field not mapped to System.Reflection correctly").val;
                }

                throw Err.make(e).val;
            }
        }
Example #3
0
        private void modify()
        {
            // if readonly then throw readonly exception
            if (m_isReadonly)
            {
                throw ReadonlyErr.make("Map is readonly").val;
            }

            // if we have a cached m_readonlyMap, then detach
            // it so it remains m_immutable
            if (m_readonlyMap != null)
            {
                m_readonlyMap.m_map = cloneMap(m_map);
                m_readonlyMap       = null;
            }
        }
Example #4
0
        private void modify()
        {
            // if readonly then throw readonly exception
            if (m_isReadonly)
            {
                throw ReadonlyErr.make("List is readonly").val;
            }

            // if we have a cached readonlyList, then detach
            // it so it remains immutable
            if (m_readonlyList != null)
            {
                object[] temp = new object[m_size];
                Array.Copy(m_values, temp, m_size);
                m_readonlyList.m_values = temp;
                m_readonlyList          = null;
            }
        }
Example #5
0
 public static void make_(ReadonlyErr self, string msg, Err cause)
 {
     Err.make_(self, msg, cause);
 }
Example #6
0
 public static void make_(ReadonlyErr self, string msg)
 {
     make_(self, msg, null);
 }
Example #7
0
 public static void make_(ReadonlyErr self)
 {
     make_(self, null);
 }
Example #8
0
 public static void make_(ReadonlyErr self, string msg, Err cause)
 {
     Err.make_(self, msg, cause);
 }
Example #9
0
 public static void make_(ReadonlyErr self, string msg)
 {
     make_(self, msg, null);
 }
Example #10
0
 public static void make_(ReadonlyErr self)
 {
     make_(self, null);
 }
Example #11
0
 public static new ReadonlyErr make(string msg, Err cause)
 {
     ReadonlyErr err = new ReadonlyErr();
       make_(err, msg, cause);
       return err;
 }