private void AssertFullyQualifiedName(Type clazz) { var reflectClass = Platform4.ReflectorForType(clazz).ForClass(clazz); Assert.AreEqual(ReflectPlatform.FullyQualifiedName(clazz), reflectClass.GetName() ); }
/// <summary>Returns a ReflectClass instance for the specified class</summary> /// <param name="clazz">class</param> /// <returns>a ReflectClass instance for the specified class</returns> /// <seealso cref="Db4objects.Db4o.Reflect.IReflectClass">Db4objects.Db4o.Reflect.IReflectClass /// </seealso> public virtual IReflectClass ForClass(Type clazz) { if (clazz == null) { return(null); } IReflectClass claxx = (IReflectClass)_classByClass.Get(clazz); if (claxx != null) { return(claxx); } if (!clazz.IsArray && ReflectPlatform.IsNamedClass(clazz)) { claxx = ForName(ReflectPlatform.FullyQualifiedName(clazz)); if (claxx != null) { _classByClass.Put(clazz, claxx); return(claxx); } } claxx = _delegate.ForClass(clazz); if (claxx == null) { return(null); } claxx = EnsureDelegate(claxx); _classByClass.Put(clazz, claxx); return(claxx); }
public virtual void TestRemovedField() { var targetClazz = typeof(RemovedFieldData); RenameClass(typeof(OriginalData), ReflectPlatform.FullyQualifiedName (targetClazz)); AssertField(targetClazz, FieldName, FieldType, FieldValue); }
public void FallBackIfTypeNotFound() { var runtimeType = ReflectPlatform.FullyQualifiedName(typeof(string)); var type = toTest.ForName(runtimeType); Assert.AreEqual(runtimeType, type.GetName()); }
public virtual void TestRetypedField() { Type targetClazz = typeof(AccessOldFieldVersionsTestCase.RetypedFieldData); RenameClass(typeof(AccessOldFieldVersionsTestCase.OriginalData), ReflectPlatform. FullyQualifiedName(targetClazz)); AssertField(targetClazz, FieldName, OrigType, OrigValue); }
public override IReflectClass ForClass(Type forType) { if (null == forType) { return(null); } return(ResolveByTypeName(ReflectPlatform.FullyQualifiedName(forType), () => FallbackResolve(forType))); }
private string GetVersion() { #if !CF && !SILVERLIGHT CrossDomainRef <object> returnValue = new CrossDomainRef <object>(); _domain.DoCallBack(new MethodInvoker(returnValue, ReflectPlatform.FullyQualifiedName(typeof(Db4oFactory)), "Version").InvokeStaticMethod); return((string)returnValue.Value); #else return(null); #endif }
public object InvokeInstanceMethod(Type type, string methodName, params object[] args) { #if !CF && !SILVERLIGHT CrossDomainRef <object> returnValue = new CrossDomainRef <object>(); _domain.DoCallBack(new MethodInvoker(returnValue, ReflectPlatform.FullyQualifiedName(type), methodName, args).InvokeInstanceMethod); return(returnValue.Value); #else return(null); #endif }
private static void ConfigureReflector(ICommonConfigurationProvider configuration, IEnumerable <KeyValuePair <ITypeDescription, Type> > types) { var reflector = DynamicGeneratedTypesReflector.CreateInstance(); configuration.Common.ReflectWith(reflector); foreach (var typeInfo in types.Where(t => t.Key.TypeName.FullName != ReflectPlatform.FullyQualifiedName(t.Value))) { reflector.AddType(typeInfo.Key.TypeName.FullName, typeInfo.Value); } }
public virtual void TestDiagnostic() { Store(new ClassHasNoFieldsTestCase.Item()); IList diagnostics = NativeCollections.Filter(_collector.Diagnostics(), new _IPredicate4_34 ()); Assert.AreEqual(1, diagnostics.Count); ClassHasNoFields diagnostic = (ClassHasNoFields)((IDiagnostic)diagnostics[0]); Assert.AreEqual(ReflectPlatform.FullyQualifiedName(typeof(ClassHasNoFieldsTestCase.Item )), diagnostic.Reason()); }
public void AddType(string name, Type type) { if (type.IsArray) { return; } lock (sync) { specialTypes[name] = type; renames[ReflectPlatform.FullyQualifiedName(type)] = Tuple.Create(name, type); } }
private void AssertPilotAndCarMissing(IList classesNotFound) { IList excluded = Arrays.AsList(new string[] { ReflectPlatform.FullyQualifiedName( typeof(MissingClassDiagnosticsTestCase.Pilot)), ReflectPlatform.FullyQualifiedName (typeof(MissingClassDiagnosticsTestCase.Car)) }); Assert.AreEqual(excluded.Count, classesNotFound.Count); for (IEnumerator candidateIter = excluded.GetEnumerator(); candidateIter.MoveNext ();) { string candidate = ((string)candidateIter.Current); Assert.IsTrue(classesNotFound.Contains(candidate)); } }
public void Aliasing() { DB.Store(new ClassWithFields()); Reopen(c => c.Common.AddAlias( new TypeAlias( ReflectPlatform.FullyQualifiedName(typeof(ClassWithFields)), ReflectPlatform.FullyQualifiedName(typeof(Base)) ))); var result = from b in DB.AsQueryable <Base>() select b; Assert.AreEqual(1, result.Count()); }
public virtual void TestDiagnostic() { IQuery query = NewQuery(typeof(DescendIntoTranslatorTestCase.Item)); query.Descend("_name").Constrain("foo").StartsWith(true); query.Execute(); IList diagnostics = NativeCollections.Filter(_collector.Diagnostics(), new _IPredicate4_36 ()); Assert.AreEqual(1, diagnostics.Count); DescendIntoTranslator diagnostic = (DescendIntoTranslator)((IDiagnostic)diagnostics [0]); Assert.AreEqual(ReflectPlatform.FullyQualifiedName(typeof(DescendIntoTranslatorTestCase.Item )) + "." + "_name", diagnostic.Reason()); }
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); }
/// <summary> /// This is to ensure that reflector.forObject(GenericArray) returns an instance of GenericArrayClass instead of GenericClass /// http://tracker.db4o.com/jira/browse/COR-376 /// </summary> public virtual void TestGenericArrayClass() { IExtObjectContainer oc = Fixture().Db(); InitGenericObjects(); IReflectClass elementType = oc.Reflector().ForName(PersonClassname); object array = Reflector().Array().NewInstance(elementType, 5); IReflectClass arrayClass = oc.Reflector().ForObject(array); Assert.IsTrue(arrayClass.IsArray()); Assert.IsTrue(arrayClass is GenericArrayClass); arrayClass = oc.Reflector().ForName(array.GetType().FullName); Assert.IsTrue(arrayClass.IsArray()); Assert.IsTrue(arrayClass is GenericArrayClass); arrayClass = oc.Reflector().ForClass(array.GetType()); Assert.IsTrue(arrayClass.IsArray()); Assert.IsTrue(arrayClass is GenericArrayClass); Assert.AreEqual(arrayClass.GetName(), ReflectPlatform.FullyQualifiedName(array.GetType ())); Assert.AreEqual("(GA) " + elementType.GetName(), array.ToString()); }
public static string FullyQualifiedName(Type klass) { return(ReflectPlatform.FullyQualifiedName(klass)); }
private static string FullyQualifiedName(Type type) { return(ReflectPlatform.FullyQualifiedName(type)); }
public TypeAlias(Type storedClass, Type runtimeClass) : this(ReflectPlatform.FullyQualifiedName (storedClass), ReflectPlatform.FullyQualifiedName(runtimeClass)) { }
private string FullyQualifiedName(System.Type clazz) { return(ReflectPlatform.FullyQualifiedName(clazz)); }
public void GetsGenericTypeFromCurrentAssembly() { var dynamicType = new [] { TestMetaData.CreateGenericType() }; var dynamicAssembly = CodeGenerator.Create(dynamicType, TestUtils.NewName()); var typeToFind = dynamicAssembly.Types[dynamicType.Single(t => t.IsBusinessEntity)]; var found = TypeLoader.Create(new string[0])(TypeNameParser.ParseString(ReflectPlatform.FullyQualifiedName(typeToFind))); Assert.AreEqual(typeToFind, found.Value); }
private static void RegisterPrimitive(Type primitive) { Primitives.Put(ReflectPlatform.FullyQualifiedName(Platform4.NullableTypeFor(primitive )), primitive); }
private bool IsKnownClass(Type klass) { return(IsKnownClass(ReflectPlatform.FullyQualifiedName(klass))); }
private IReflectClass ByDbName(Type arg) { return(Parent().ForName(ReflectPlatform.FullyQualifiedName(arg))); }