private IReflectClass ForGenericObject(GenericObject genericObject) { Db4objects.Db4o.Reflect.Generic.GenericClass claxx = genericObject._class; if (claxx == null) { throw new InvalidOperationException(); } string name = claxx.GetName(); if (name == null) { throw new InvalidOperationException(); } Db4objects.Db4o.Reflect.Generic.GenericClass existingClass = (Db4objects.Db4o.Reflect.Generic.GenericClass )ForName(name); if (existingClass == null) { _repository.Register(claxx); return(claxx); } // TODO: Using .equals() here would be more consistent with // the equals() method in GenericClass. if (existingClass != claxx) { throw new InvalidOperationException(); } return(claxx); }
public Db4oObject(GenericObject genericObject) { this.genericObject = genericObject; GenericClass genericClass = genericObject.GetGenericClass(); clazz = new Db4oStoredClass(genericClass); IReflectField[] fields = genericClass.GetDeclaredFields(); this.fields = new object[fields.Length]; int index = 0; while (index < fields.Length) { GenericField field = (GenericField) fields[index]; object o = field.Get(genericObject); // object o = genericObject.Get(index); // if (o == null) // { // GenericClass fieldType = (GenericClass) field.GetFieldType(); // o = fieldType.GetName(); // } // else if (o is GenericObject) o = new Db4oObject((GenericObject)o); this.fields[index] = o; index++; } }
private IReflectClass ForGenericObject(GenericObject genericObject) { var claxx = genericObject._class; if (claxx == null) { throw new InvalidOperationException(); } var name = claxx.GetName(); if (name == null) { throw new InvalidOperationException(); } var existingClass = (GenericClass ) ForName(name); if (existingClass == null) { _repository.Register(claxx); return claxx; } // TODO: Using .equals() here would be more consistent with // the equals() method in GenericClass. if (existingClass != claxx) { throw new InvalidOperationException(); } return claxx; }