Beispiel #1
0
        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);
        }
		private GenericField[] Fields(GenericClass personClass, GenericReflector reflector
			)
		{
			return new GenericField[] { new GenericField("surname", reflector.ForClass(typeof(
				string)), false), new GenericField("birthdate", reflector.ForClass(typeof(DateTime
				)), false), new GenericField("bestFriend", personClass, false), new GenericField
				("nArray", reflector.ForClass(typeof(int[][])), true) };
		}
Beispiel #3
0
		public virtual Db4objects.Db4o.Reflect.Generic.GenericClass ArrayClass()
		{
			if (_array != null)
			{
				return _array;
			}
			_array = new GenericArrayClass(_reflector, this, _name, _superclass);
			return _array;
		}
Beispiel #4
0
		public virtual IReflectClass CreateClass(string name, IReflectClass superClass, int
			 fieldCount)
		{
			IReflectClass nativeClass = _delegate.ForName(name);
			GenericClass clazz = new GenericClass(_reflector, nativeClass, name, (GenericClass
				)superClass);
			clazz.SetDeclaredFieldCount(fieldCount);
			return clazz;
		}
 public GenericClass(GenericReflector reflector, IReflectClass delegateClass, string
                     name, Db4objects.Db4o.Reflect.Generic.GenericClass superclass)
 {
     _reflector  = reflector;
     _delegate   = delegateClass;
     _name       = name;
     _superclass = superclass;
     _hashCode   = _name.GetHashCode();
 }
 public virtual Db4objects.Db4o.Reflect.Generic.GenericClass ArrayClass()
 {
     if (_array != null)
     {
         return(_array);
     }
     _array = new GenericArrayClass(_reflector, this, _name, _superclass);
     return(_array);
 }
Beispiel #7
0
		public GenericClass(GenericReflector reflector, IReflectClass delegateClass, string
			 name, Db4objects.Db4o.Reflect.Generic.GenericClass superclass)
		{
			_reflector = reflector;
			_delegate = delegateClass;
			_name = name;
			_superclass = superclass;
			_hashCode = _name.GetHashCode();
		}
		/// <summary>todo: Move the GenericClass creation into a utility/factory class.</summary>
		/// <remarks>todo: Move the GenericClass creation into a utility/factory class.</remarks>
		/// <returns></returns>
		public virtual GenericClass InitGenericClass()
		{
			GenericReflector reflector = new GenericReflector(null, Platform4.ReflectorForType
				(typeof(GenericObjectsTest)));
			GenericClass _objectIClass = (GenericClass)reflector.ForClass(typeof(object));
			GenericClass result = new GenericClass(reflector, null, PersonClassname, _objectIClass
				);
			result.InitFields(Fields(result, reflector));
			return result;
		}
        public Db4oStoredClass(Db4objects.Db4o.Ext.IStoredClass clazz, Db4oLocalConnection connection)
        {
            this.connection = connection;
            Name = clazz.GetName();
            genericClass = connection.GetGenericClass(clazz.GetName());
            List<Field> list = new List<Field>();

            IStoredField[] storedFields = clazz.GetStoredFields();
            foreach (IStoredField field in storedFields)
            {
                list.Add(new Db4oField(field));
            }
            Fields = list;
        }
Beispiel #10
0
        public Db4oStoredClass(GenericClass clazz)
        {
            this.genericClass = clazz;
            Name = clazz.GetName();
            var list = new List<Field>();

            IReflectField[] declaredFields = clazz.GetDeclaredFields();

            foreach (IReflectField field in declaredFields)
            {
                list.Add(new Db4oField(field));
            }

            Fields = list;
        }
Beispiel #11
0
        private Db4objects.Db4o.Reflect.Generic.GenericClass GenericClass(IReflectClass clazz
                                                                          )
        {
            Db4objects.Db4o.Reflect.Generic.GenericClass ret;
            string name = clazz.GetName();

            if (name.Equals(ReflectPlatform.FullyQualifiedName(typeof(GenericArray))))
            {
                // special case, comparing name because can't compare class == class directly with ReflectClass
                ret = new GenericArrayClass(this, clazz, name, null);
            }
            else
            {
                ret = new Db4objects.Db4o.Reflect.Generic.GenericClass(this, clazz, name, null);
            }
            return(ret);
        }
 public override bool Equals(object obj)
 {
     if (this == obj)
     {
         return(true);
     }
     if (obj == null || GetType() != obj.GetType())
     {
         return(false);
     }
     Db4objects.Db4o.Reflect.Generic.GenericClass otherGC = (Db4objects.Db4o.Reflect.Generic.GenericClass
                                                             )obj;
     if (_hashCode != otherGC.GetHashCode())
     {
         return(false);
     }
     return(_name.Equals(otherGC._name));
 }
        public virtual IReflectClass GetSuperclass()
        {
            if (_superclass != null)
            {
                return(_superclass);
            }
            if (_delegate == null)
            {
                return(_reflector.ForClass(typeof(object)));
            }
            IReflectClass delegateSuperclass = _delegate.GetSuperclass();

            if (delegateSuperclass != null)
            {
                _superclass = _reflector.EnsureDelegate(delegateSuperclass);
            }
            return(_superclass);
        }
Beispiel #14
0
 internal virtual Db4objects.Db4o.Reflect.Generic.GenericClass EnsureDelegate(IReflectClass
                                                                              clazz)
 {
     if (clazz == null)
     {
         return(null);
     }
     Db4objects.Db4o.Reflect.Generic.GenericClass claxx = (Db4objects.Db4o.Reflect.Generic.GenericClass
                                                           )_repository.LookupByName(clazz.GetName());
     if (claxx == null)
     {
         //  We don't have to worry about the superclass, it can be null
         //  because handling is delegated anyway
         claxx = GenericClass(clazz);
         _repository.Register(claxx);
     }
     return(claxx);
 }
Beispiel #15
0
		public virtual object DeepClone(object obj)
		{
			GenericReflector reflector = (GenericReflector)obj;
			Db4objects.Db4o.Reflect.Generic.GenericClass superClass = null;
			if (_superclass != null)
			{
				_superclass = (Db4objects.Db4o.Reflect.Generic.GenericClass)reflector.ForName(_superclass
					.GetName());
			}
			Db4objects.Db4o.Reflect.Generic.GenericClass ret = new Db4objects.Db4o.Reflect.Generic.GenericClass
				(reflector, _delegate, _name, superClass);
			GenericField[] fields = new GenericField[_fields.Length];
			for (int i = 0; i < fields.Length; i++)
			{
				fields[i] = (GenericField)_fields[i].DeepClone(reflector);
			}
			ret.InitFields(fields);
			return ret;
		}
        public virtual object DeepClone(object obj)
        {
            GenericReflector reflector = (GenericReflector)obj;

            Db4objects.Db4o.Reflect.Generic.GenericClass superClass = null;
            if (_superclass != null)
            {
                _superclass = (Db4objects.Db4o.Reflect.Generic.GenericClass)reflector.ForName(_superclass
                                                                                              .GetName());
            }
            Db4objects.Db4o.Reflect.Generic.GenericClass ret = new Db4objects.Db4o.Reflect.Generic.GenericClass
                                                                   (reflector, _delegate, _name, superClass);
            GenericField[] fields = new GenericField[_fields.Length];
            for (int i = 0; i < fields.Length; i++)
            {
                fields[i] = (GenericField)_fields[i].DeepClone(reflector);
            }
            ret.InitFields(fields);
            return(ret);
        }
Beispiel #17
0
            public object Run()
            {
                Db4objects.Db4o.Reflect.Generic.GenericClass existing = (Db4objects.Db4o.Reflect.Generic.GenericClass
                                                                         ) this._enclosing._repository.LookupByID(id);
                if (existing != null)
                {
                    if (null != converter)
                    {
                    }
                    else
                    {
                        //						existing.setSecondClass();
                        existing.SetConverter(null);
                    }
                    return(null);
                }
                IReflectClass clazz = this._enclosing._delegate.ForName(name);

                Db4objects.Db4o.Reflect.Generic.GenericClass claxx = null;
                if (clazz != null)
                {
                    claxx = this._enclosing.EnsureDelegate(clazz);
                }
                else
                {
                    claxx = new Db4objects.Db4o.Reflect.Generic.GenericClass(this._enclosing, null, name
                                                                             , null);
                    this._enclosing.Register(claxx);
                    claxx.InitFields(new GenericField[] { new GenericField(null, null, true) });
                    claxx.SetConverter(converter);
                }
                //			    claxx.setSecondClass();
                claxx.SetPrimitive();
                this._enclosing._repository.Register(id, claxx);
                return(null);
            }
Beispiel #18
0
		public virtual IReflectClass GetSuperclass()
		{
			if (_superclass != null)
			{
				return _superclass;
			}
			if (_delegate == null)
			{
				return _reflector.ForClass(typeof(object));
			}
			IReflectClass delegateSuperclass = _delegate.GetSuperclass();
			if (delegateSuperclass != null)
			{
				_superclass = _reflector.EnsureDelegate(delegateSuperclass);
			}
			return _superclass;
		}
Beispiel #19
0
 /// <summary>Register a class</summary>
 /// <param name="clazz">class</param>
 public virtual void Register(GenericClass clazz)
 {
     WithLock(new _IClosure4_303(this, clazz));
 }
Beispiel #20
0
 public GenericArrayClass(GenericReflector reflector, IReflectClass delegateClass,
                          string name, GenericClass superclass) : base(reflector, delegateClass, name, superclass
                                                                       )
 {
 }
		public virtual GenericClass ClassMetaToGenericClass(GenericReflector reflector, ClassInfo
			 classMeta)
		{
			if (classMeta.IsSystemClass())
			{
				return (GenericClass)reflector.ForName(classMeta.GetClassName());
			}
			string className = classMeta.GetClassName();
			// look up from generic class table.
			GenericClass genericClass = LookupGenericClass(className);
			if (genericClass != null)
			{
				return genericClass;
			}
			IReflectClass reflectClass = reflector.ForName(className);
			if (reflectClass != null)
			{
				return (GenericClass)reflectClass;
			}
			GenericClass genericSuperClass = null;
			ClassInfo superClassMeta = classMeta.GetSuperClass();
			if (superClassMeta != null)
			{
				genericSuperClass = ClassMetaToGenericClass(reflector, superClassMeta);
			}
			genericClass = new GenericClass(reflector, null, className, genericSuperClass);
			RegisterGenericClass(className, genericClass);
			FieldInfo[] fields = classMeta.GetFields();
			GenericField[] genericFields = new GenericField[fields.Length];
			for (int i = 0; i < fields.Length; ++i)
			{
				ClassInfo fieldClassMeta = fields[i].GetFieldClass();
				string fieldName = fields[i].GetFieldName();
				GenericClass genericFieldClass = ClassMetaToGenericClass(reflector, fieldClassMeta
					);
				genericFields[i] = new GenericField(fieldName, genericFieldClass, fields[i]._isPrimitive
					);
			}
			genericClass.InitFields(genericFields);
			return genericClass;
		}
		private void RegisterGenericClass(string className, GenericClass classMeta)
		{
			_genericClassTable.Put(className, classMeta);
			((GenericReflector)classMeta.Reflector()).Register(classMeta);
		}
Beispiel #23
0
 private GenericClass GenericClass(IReflectClass clazz
     )
 {
     GenericClass ret;
     var name = clazz.GetName();
     if (name.Equals(ReflectPlatform.FullyQualifiedName(typeof (GenericArray))))
     {
         // special case, comparing name because can't compare class == class directly with ReflectClass
         ret = new GenericArrayClass(this, clazz, name, null);
     }
     else
     {
         ret = new GenericClass(this, clazz, name, null);
     }
     return ret;
 }
Beispiel #24
0
		public GenericArrayClass(GenericReflector reflector, IReflectClass delegateClass, 
			string name, GenericClass superclass) : base(reflector, delegateClass, name, superclass
			)
		{
		}
Beispiel #25
0
		public GenericObject(GenericClass clazz)
		{
			_class = clazz;
		}
Beispiel #26
0
 public GenericArray(GenericClass clazz, int size)
 {
     _clazz = clazz;
     _data = new object[size];
 }
Beispiel #27
0
 public _IClosure4_303(GenericReflector _enclosing, Db4objects.Db4o.Reflect.Generic.GenericClass
                       clazz)
 {
     this._enclosing = _enclosing;
     this.clazz      = clazz;
 }
Beispiel #28
0
 public _IClosure4_303(GenericReflector _enclosing, GenericClass
     clazz)
 {
     this._enclosing = _enclosing;
     this.clazz = clazz;
 }
Beispiel #29
0
 /// <summary>Register a class</summary>
 /// <param name="clazz">class</param>
 public virtual void Register(Db4objects.Db4o.Reflect.Generic.GenericClass clazz)
 {
     WithLock(new _IClosure4_303(this, clazz));
 }
Beispiel #30
0
 public GenericObject(GenericClass clazz)
 {
     _class = clazz;
 }
Beispiel #31
0
 public GenericArray(GenericClass clazz, int size)
 {
     _clazz = clazz;
     _data  = new object[size];
 }
 public GenericField(string name, IReflectClass clazz, bool primitive)
 {
     _name      = name;
     _type      = (GenericClass)clazz;
     _primitive = primitive;
 }
Beispiel #33
0
 public _IClosure4_303(GenericReflector _enclosing, GenericClass
                       clazz)
 {
     this._enclosing = _enclosing;
     this.clazz      = clazz;
 }
Beispiel #34
0
			public object Run()
			{
				Db4objects.Db4o.Reflect.Generic.GenericClass existing = (Db4objects.Db4o.Reflect.Generic.GenericClass
					)this._enclosing._repository.LookupByID(id);
				if (existing != null)
				{
					if (null != converter)
					{
					}
					else
					{
						//						existing.setSecondClass();
						existing.SetConverter(null);
					}
					return null;
				}
				IReflectClass clazz = this._enclosing._delegate.ForName(name);
				Db4objects.Db4o.Reflect.Generic.GenericClass claxx = null;
				if (clazz != null)
				{
					claxx = this._enclosing.EnsureDelegate(clazz);
				}
				else
				{
					claxx = new Db4objects.Db4o.Reflect.Generic.GenericClass(this._enclosing, null, name
						, null);
					this._enclosing.Register(claxx);
					claxx.InitFields(new GenericField[] { new GenericField(null, null, true) });
					claxx.SetConverter(converter);
				}
				//			    claxx.setSecondClass();
				claxx.SetPrimitive();
				this._enclosing._repository.Register(id, claxx);
				return null;
			}
Beispiel #35
0
 /// <summary>Register a class</summary>
 /// <param name="clazz">class</param>
 public virtual void Register(GenericClass clazz)
 {
     WithLock(new _IClosure4_303(this, clazz));
 }
Beispiel #36
0
		public GenericField(string name, IReflectClass clazz, bool primitive)
		{
			_name = name;
			_type = (GenericClass)clazz;
			_primitive = primitive;
		}
Beispiel #37
0
 public object Run()
 {
     var existing = (GenericClass
         ) _enclosing._repository.LookupByID(id);
     if (existing != null)
     {
         if (null != converter)
         {
         }
         else
         {
             //						existing.setSecondClass();
             existing.SetConverter(null);
         }
         return null;
     }
     var clazz = _enclosing._delegate.ForName(name);
     GenericClass claxx = null;
     if (clazz != null)
     {
         claxx = _enclosing.EnsureDelegate(clazz);
     }
     else
     {
         claxx = new GenericClass(_enclosing, null, name
             , null);
         _enclosing.Register(claxx);
         claxx.InitFields(new[] {new GenericField(null, null, true)});
         claxx.SetConverter(converter);
     }
     //			    claxx.setSecondClass();
     claxx.SetPrimitive();
     _enclosing._repository.Register(id, claxx);
     return null;
 }