Example #1
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;
		}
Example #2
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 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;
		}
Example #4
0
		public virtual void InitFields(GenericField[] fields)
		{
			int startIndex = 0;
			if (_superclass != null)
			{
				startIndex = _superclass.GetFieldCount();
			}
			_fields = fields;
			for (int i = 0; i < _fields.Length; i++)
			{
				_fields[i].SetIndex(startIndex + i);
			}
		}