public virtual bool IsAssignableFrom(IReflectClass subclassCandidate) { if (subclassCandidate == null) { return(false); } if (Equals(subclassCandidate)) { return(true); } if (_delegate != null) { if (subclassCandidate is Db4objects.Db4o.Reflect.Generic.GenericClass) { subclassCandidate = ((Db4objects.Db4o.Reflect.Generic.GenericClass)subclassCandidate ).GetDelegate(); } return(_delegate.IsAssignableFrom(subclassCandidate)); } if (!(subclassCandidate is Db4objects.Db4o.Reflect.Generic.GenericClass)) { return(false); } return(IsAssignableFrom(subclassCandidate.GetSuperclass())); }
private void SetFieldsToNull(object @object, IReflectClass claxx) { IReflectField[] fields; fields = claxx.GetDeclaredFields(); for (int i = 0; i < fields.Length; i++) { IReflectField field = fields[i]; if (field.IsStatic()) { continue; } if (field.IsTransient()) { continue; } field.Set(@object, null); } IReflectClass superclass = claxx.GetSuperclass(); if (superclass == null) { return; } SetFieldsToNull(@object, superclass); }
private ITypeDescription CreateType(TypeName name, IReflectClass classInfo, Func <TypeName, Maybe <IReflectClass> > classLookup, IDictionary <string, ITypeDescription> knownTypes) { var knownType = typeResolver(name) .Otherwise(() => typeResolver(name.GetGenericTypeDefinition())); if (knownType.HasValue) { var systemType = KnownType.Create(knownType.Value, name.GenericArguments.Select( t => GetOrCreateTypeByName(t.Value, classLookup, knownTypes)). ToList(), IndexLookUp); knownTypes[name.FullName] = systemType; return(systemType); } return(SimpleClassDescription.Create(name, classInfo.GetSuperclass().AsMaybe().Convert(sc => GetOrCreateType(sc, classLookup, knownTypes)), t => { knownTypes[name.FullName] = t; return ExtractFields(name, classInfo, typeName => GetOrCreateType(typeName, classLookup, knownTypes)); })); }
private void CopyFieldValuesAcross(object src, object dest, IReflectClass claxx, IReplicationProviderInside sourceProvider, IReplicationProviderInside targetProvider ) { if (dest == null) { throw new InvalidOperationException("Dest cannot be null: src=" + src + ", class=" + claxx + ", source=" + sourceProvider.GetName() + ", target=" + targetProvider .GetName()); } IEnumerator fields = FieldIterators.PersistentFields(claxx); while (fields.MoveNext()) { IReflectField field = (IReflectField)fields.Current; object value = field.Get(src); field.Set(dest, FindCounterpart(value, sourceProvider, targetProvider)); } IReflectClass superclass = claxx.GetSuperclass(); if (superclass == null) { return; } CopyFieldValuesAcross(src, dest, superclass, sourceProvider, targetProvider); }
private ClassInfo MapSuperclass(IReflectClass claxx) { IReflectClass superClass = claxx.GetSuperclass(); if (superClass != null) { return GetClassMeta(superClass); } return null; }
private void TraverseSuperclass(object @object, IReflectClass claxx) { IReflectClass superclass = claxx.GetSuperclass(); if (superclass == null) { return; } TraverseAllFields(@object, superclass); }
private void TraverseSuperclass(object @object, IReflectClass claxx) { IReflectClass superclass = claxx.GetSuperclass(); if (superclass == null) { return; } TraverseAllFields(@object, superclass); }
private ClassInfo MapSuperclass(IReflectClass claxx) { IReflectClass superClass = claxx.GetSuperclass(); if (superClass != null) { return(GetClassMeta(superClass)); } return(null); }
public static void ForEachField(IReflectClass claxx, IProcedure4 procedure) { while (claxx != null) { IReflectField[] declaredFields = claxx.GetDeclaredFields(); for (int reflectFieldIndex = 0; reflectFieldIndex < declaredFields.Length; ++reflectFieldIndex) { IReflectField reflectField = declaredFields[reflectFieldIndex]; procedure.Apply(reflectField); } claxx = claxx.GetSuperclass(); } }
public static void ForEachField(IReflectClass claxx, IProcedure4 procedure) { while (claxx != null) { var declaredFields = claxx.GetDeclaredFields(); for (var reflectFieldIndex = 0; reflectFieldIndex < declaredFields.Length; ++reflectFieldIndex) { var reflectField = declaredFields[reflectFieldIndex]; procedure.Apply(reflectField); } claxx = claxx.GetSuperclass(); } }
public static IReflectField Field(IReflectClass claxx, string name) { while (claxx != null) { try { return(claxx.GetDeclaredField(name)); } catch (Exception) { } claxx = claxx.GetSuperclass(); } return(null); }
private bool HasNoActivatingFields(IReflectClass clazz) { IReflectClass curClass = clazz; while (curClass != null) { IReflectField[] fields = curClass.GetDeclaredFields(); if (!this.HasNoActivatingFields(fields)) { return(false); } curClass = curClass.GetSuperclass(); } return(true); }
public static IReflectField Field(IReflectClass claxx, string name) { while (claxx != null) { try { return claxx.GetDeclaredField(name); } catch (Exception) { } claxx = claxx.GetSuperclass(); } return null; }
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); }
public virtual IList Analyze() { IList ancestors = new ArrayList(); ClassMetadata storedAncestor = _storedClass.GetAncestor(); IReflectClass runtimeAncestor = _runtimeClass.GetSuperclass(); while (storedAncestor != null) { if (runtimeAncestor == storedAncestor.ClassReflector()) { ancestors.Add(new HierarchyAnalyzer.Same(storedAncestor)); } else { do { ancestors.Add(new HierarchyAnalyzer.Removed(storedAncestor)); storedAncestor = storedAncestor.GetAncestor(); if (null == storedAncestor) { if (IsObject(runtimeAncestor)) { return(ancestors); } ThrowUnsupportedAdd(runtimeAncestor); } if (runtimeAncestor == storedAncestor.ClassReflector()) { ancestors.Add(new HierarchyAnalyzer.Same(storedAncestor)); break; } }while (storedAncestor != null); } storedAncestor = storedAncestor.GetAncestor(); runtimeAncestor = runtimeAncestor.GetSuperclass(); } if (runtimeAncestor != null && (!IsObject(runtimeAncestor))) { ThrowUnsupportedAdd(runtimeAncestor); } return(ancestors); }
private void CopyFieldValuesAcross(object src, object dest, IReflectClass claxx, IReplicationProviderInside sourceProvider, IReplicationProviderInside targetProvider ) { IEnumerator fields = FieldIterators.PersistentFields(claxx); while (fields.MoveNext()) { IReflectField field = (IReflectField)fields.Current; object value = field.Get(src); field.Set(dest, FindCounterpart(value, sourceProvider, targetProvider)); } IReflectClass superclass = claxx.GetSuperclass(); if (superclass == null) { return; } CopyFieldValuesAcross(src, dest, superclass, sourceProvider, targetProvider); }
public static IReflectField GetDeclaredFieldInHeirarchy(IReflectClass aClass, string attribute) { try { while (aClass != null) { IReflectField refField = GetDeclaredField(aClass, attribute); if (refField != null) return refField; aClass = aClass.GetSuperclass(); } } catch (Exception e) { LoggingHelper.HandleException(e); } return null; }
public static IReflectField GetDeclaredFieldInHeirarchy(IReflectClass aClass, string attribute) { try { while (aClass != null) { IReflectField refField = GetDeclaredField(aClass, attribute); if (refField != null) { return(refField); } aClass = aClass.GetSuperclass(); } } catch (Exception e) { LoggingHelper.HandleException(e); } return(null); }
private TernaryBool CallConstructorSpecialized(IReflectClass clazz) { Config4Class clazzConfig = _config.ConfigClass(clazz.GetName()); if (clazzConfig != null) { TernaryBool res = clazzConfig.CallConstructor(); if (!res.IsUnspecified()) { return res; } } if (Platform4.IsEnum(_config.Reflector(), clazz)) { return TernaryBool.No; } IReflectClass ancestor = clazz.GetSuperclass(); if (ancestor != null) { return CallConstructorSpecialized(ancestor); } return TernaryBool.Unspecified; }
private TernaryBool CallConstructorSpecialized(IReflectClass clazz) { Config4Class clazzConfig = _config.ConfigClass(clazz.GetName()); if (clazzConfig != null) { TernaryBool res = clazzConfig.CallConstructor(); if (!res.IsUnspecified()) { return(res); } } if (Platform4.IsEnum(_config.Reflector(), clazz)) { return(TernaryBool.No); } IReflectClass ancestor = clazz.GetSuperclass(); if (ancestor != null) { return(CallConstructorSpecialized(ancestor)); } return(TernaryBool.Unspecified); }
public static List <IReflectField> GetFieldList(IReflectClass aClass) { try { if (aClass == null) { return(null); } List <IReflectField> ret = NonVirtualFieldsFor(aClass); IReflectClass parent = aClass.GetSuperclass(); if (parent != null && !(parent.GetName().StartsWith("System."))) { ret.AddRange(GetFieldList(parent)); } return(ret); } catch (Exception e) { LoggingHelper.HandleException(e); } return(null); }
internal bool CreateClassMetadata(ClassMetadata clazz, IReflectClass reflectClazz ) { bool result = false; _classMetadataCreationDepth++; try { IReflectClass parentReflectClazz = reflectClazz.GetSuperclass(); ClassMetadata parentClazz = null; if (parentReflectClazz != null && !parentReflectClazz.Equals(Container()._handlers .IclassObject)) { parentClazz = ProduceClassMetadata(parentReflectClazz); } result = Container().CreateClassMetadata(clazz, reflectClazz, parentClazz); } finally { _classMetadataCreationDepth--; } InitClassMetadataOnUp(); return(result); }
public static List<IReflectField> GetFieldList(IReflectClass aClass) { try { if (aClass == null) return null; List<IReflectField> ret = NonVirtualFieldsFor(aClass); IReflectClass parent = aClass.GetSuperclass(); if (parent != null && !(parent.GetName().StartsWith("System."))) ret.AddRange(GetFieldList(parent)); return ret; } catch (Exception e) { LoggingHelper.HandleException(e); } return null; }
public virtual bool IsAssignableFrom(IReflectClass subclassCandidate) { if (subclassCandidate == null) { return false; } if (Equals(subclassCandidate)) { return true; } if (_delegate != null) { if (subclassCandidate is Db4objects.Db4o.Reflect.Generic.GenericClass) { subclassCandidate = ((Db4objects.Db4o.Reflect.Generic.GenericClass)subclassCandidate ).GetDelegate(); } return _delegate.IsAssignableFrom(subclassCandidate); } if (!(subclassCandidate is Db4objects.Db4o.Reflect.Generic.GenericClass)) { return false; } return IsAssignableFrom(subclassCandidate.GetSuperclass()); }
private void CopyFieldValuesAcross(object src, object dest, IReflectClass claxx, IReplicationProviderInside sourceProvider, IReplicationProviderInside targetProvider ) { if (dest == null) { throw new InvalidOperationException("Dest cannot be null: src=" + src + ", class=" + claxx + ", source=" + sourceProvider.GetName() + ", target=" + targetProvider .GetName()); } IEnumerator fields = FieldIterators.PersistentFields(claxx); while (fields.MoveNext()) { IReflectField field = (IReflectField)fields.Current; object value = field.Get(src); field.Set(dest, FindCounterpart(value, sourceProvider, targetProvider)); } IReflectClass superclass = claxx.GetSuperclass(); if (superclass == null) { return; } CopyFieldValuesAcross(src, dest, superclass, sourceProvider, targetProvider); }
private void CopyFieldValuesAcross(object src, object dest, IReflectClass claxx, IReplicationProviderInside sourceProvider, IReplicationProviderInside targetProvider ) { IEnumerator fields = FieldIterators.PersistentFields(claxx); while (fields.MoveNext()) { IReflectField field = (IReflectField)fields.Current; object value = field.Get(src); field.Set(dest, FindCounterpart(value, sourceProvider, targetProvider)); } IReflectClass superclass = claxx.GetSuperclass(); if (superclass == null) { return; } CopyFieldValuesAcross(src, dest, superclass, sourceProvider, targetProvider); }
internal bool CreateClassMetadata(ClassMetadata clazz, IReflectClass reflectClazz ) { bool result = false; _classMetadataCreationDepth++; try { IReflectClass parentReflectClazz = reflectClazz.GetSuperclass(); ClassMetadata parentClazz = null; if (parentReflectClazz != null && !parentReflectClazz.Equals(Container()._handlers .IclassObject)) { parentClazz = ProduceClassMetadata(parentReflectClazz); } result = Container().CreateClassMetadata(clazz, reflectClazz, parentClazz); } finally { _classMetadataCreationDepth--; } InitClassMetadataOnUp(); return result; }
private void SetFieldsToNull(object @object, IReflectClass claxx) { IReflectField[] fields; fields = claxx.GetDeclaredFields(); for (int i = 0; i < fields.Length; i++) { IReflectField field = fields[i]; if (field.IsStatic()) { continue; } if (field.IsTransient()) { continue; } field.Set(@object, null); } IReflectClass superclass = claxx.GetSuperclass(); if (superclass == null) { return; } SetFieldsToNull(@object, superclass); }
private ITypeDescription CreateType(TypeName name, IReflectClass classInfo, Func<TypeName, Maybe<IReflectClass>> classLookup, IDictionary<string, ITypeDescription> knownTypes) { var knownType = typeResolver(name) .Otherwise(() => typeResolver(name.GetGenericTypeDefinition())); if (knownType.HasValue) { var systemType = KnownType.Create(knownType.Value, name.GenericArguments.Select( t => GetOrCreateTypeByName(t.Value, classLookup, knownTypes)). ToList(), IndexLookUp); knownTypes[name.FullName] = systemType; return systemType; } return SimpleClassDescription.Create(name, classInfo.GetSuperclass().AsMaybe().Convert(sc=>GetOrCreateType(sc, classLookup, knownTypes)), t => { knownTypes[name.FullName] = t; return ExtractFields(name, classInfo, typeName => GetOrCreateType(typeName, classLookup, knownTypes)); }); }