private int CompareByField(int x, int y, IList path) { object xFieldValue = GetFieldValue(x, path); object yFieldValue = GetFieldValue(y, path); FieldMetadata field = ((FieldMetadata)path[path.Count - 1]); return(field.PrepareComparison(_transaction.Context(), xFieldValue).CompareTo(yFieldValue )); }
internal virtual IPreparedComparison PrepareComparison(ObjectContainerBase container , object constraint) { IContext context = container.Transaction.Context(); if (_fieldMetadata != null) { return(_fieldMetadata.PrepareComparison(context, constraint)); } if (_classMetadata != null) { return(_classMetadata.PrepareComparison(context, constraint)); } IReflector reflector = container.Reflector(); Db4objects.Db4o.Internal.ClassMetadata classMetadata = null; if (_bytes != null) { classMetadata = container.ProduceClassMetadata(reflector.ForObject(constraint)); } else { if (_member != null) { classMetadata = container.ClassMetadataForReflectClass(reflector.ForObject(_member )); } } if (classMetadata != null) { if (_member != null && _member.GetType().IsArray) { ITypeHandler4 arrayElementTypehandler = classMetadata.TypeHandler(); if (reflector.Array().IsNDimensional(MemberClass())) { MultidimensionalArrayHandler mah = new MultidimensionalArrayHandler(arrayElementTypehandler , false); return(mah.PrepareComparison(context, _member)); } ArrayHandler ya = new ArrayHandler(arrayElementTypehandler, false); return(ya.PrepareComparison(context, _member)); } return(classMetadata.PrepareComparison(context, constraint)); } return(null); }
internal virtual IPreparedComparison PrepareComparison(IContext context, object obj ) { if (_fieldMetadata != null) { return(_fieldMetadata.PrepareComparison(context, obj)); } if (obj == null) { return(Null.Instance); } ClassMetadata yc = i_trans.Container().ProduceClassMetadata(i_trans.Reflector().ForObject (obj)); FieldMetadata yf = yc.FieldMetadataForName(Name()); if (yf != null) { return(yf.PrepareComparison(context, obj)); } return(null); }