private void Register(string className, IReflectClass clazz) { if (LookupByName(className) != null) { throw new ArgumentException(); } _classByName.Put(className, clazz); _classes.Add(clazz); _listeners.NotifyListeners(clazz); }
private void EnsureClassRead(int id) { IReflectClass clazz = LookupByID(id); ByteArrayBuffer classreader = _stream.ReadStatefulBufferById(_trans, id); ClassMarshaller classMarshaller = MarshallerFamily()._class; RawClassSpec classInfo = classMarshaller.ReadSpec(_trans, classreader); string className = classInfo.Name(); // Having the class in the _classByName Map for now indicates // that the class is fully read. This is breakable if we start // returning GenericClass'es in other methods like forName // even if a native class has not been found if (LookupByName(className) != null) { return; } // step 2 add the class to _classByName and _classes to denote reading is completed Register(className, clazz); int numFields = classInfo.NumFields(); IReflectField[] fields = _builder.FieldArray(numFields); IFieldMarshaller fieldMarshaller = MarshallerFamily()._field; for (int i = 0; i < numFields; i++) { RawFieldSpec fieldInfo = fieldMarshaller.ReadSpec(_stream, classreader); string fieldName = fieldInfo.Name(); IReflectClass fieldClass = ReflectClassForFieldSpec(fieldInfo, _stream.Reflector( )); if (null == fieldClass && (fieldInfo.IsField() && !fieldInfo.IsVirtual())) { throw new InvalidOperationException("Could not read field type for '" + className + "." + fieldName + "'"); } fields[i] = _builder.CreateField(clazz, fieldName, fieldClass, fieldInfo.IsVirtual (), fieldInfo.IsPrimitive(), fieldInfo.IsArray(), fieldInfo.IsNArray()); } _builder.InitFields(clazz, fields); _listeners.NotifyListeners(clazz); }
public virtual void Set(int newValue) { _value = newValue; _listenerRegistry.NotifyListeners(_value); }