public void BaseHandleGetTypeInfo() { tlog.Debug(tag, $"BaseHandleGetTypeInfo START"); var testingTarget = new TextLabel(); Assert.IsNotNull(testingTarget, "null handle"); Assert.IsInstanceOf <BaseHandle>(testingTarget, "Should return BaseHandle instance."); TypeInfo typeInfo = TypeRegistry.Get().GetTypeInfo("TextLabel"); try { Assert.True(testingTarget.GetTypeInfo(typeInfo), "Should be true"); } catch (Exception e) { tlog.Error(tag, "Caught Exception" + e.ToString()); LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Caught Exception" + e.ToString()); Assert.Fail("Caught Exception" + e.ToString()); } typeInfo.Dispose(); testingTarget.Dispose(); tlog.Debug(tag, $"BaseHandleGetTypeInfo END (OK)"); }
public void TypeRegistryGet() { tlog.Debug(tag, $"TypeRegistryGet START"); var testingTarget = TypeRegistry.Get(); Assert.IsNotNull(testingTarget, "Can't create success object TypeRegistry"); Assert.IsInstanceOf <TypeRegistry>(testingTarget, "Should return TypeRegistry instance."); testingTarget.Dispose(); tlog.Debug(tag, $"TypeRegistryGet END (OK)"); }
public void TypeInfoGetPropertyCount() { tlog.Debug(tag, $"TypeInfoGetPropertyCount START"); var testingTarget = TypeRegistry.Get().GetTypeInfo("PushButton"); Assert.IsNotNull(testingTarget, "should be not null"); Assert.IsInstanceOf <TypeInfo>(testingTarget, "should be an instance of testing target class!"); Assert.Greater(testingTarget.GetPropertyCount(), 0, "The property count should greater than 0"); testingTarget.Dispose(); tlog.Debug(tag, $"TypeInfoGetPropertyCount END (OK)"); }
public void TypeInfoGetName() { tlog.Debug(tag, $"TypeInfoGetName START"); var testingTarget = TypeRegistry.Get().GetTypeInfo("PushButton"); Assert.IsNotNull(testingTarget, "should be not null"); Assert.IsInstanceOf <TypeInfo>(testingTarget, "should be an instance of testing target class!"); Assert.AreEqual("PushButton", testingTarget.GetName(), "Should be equal"); testingTarget.Dispose(); tlog.Debug(tag, $"TypeInfoGetName END (OK)"); }
public void TypeRegistryGetTypeInfo() { tlog.Debug(tag, $"TypeRegistryGetTypeInfo START"); var testingTarget = TypeRegistry.Get(); Assert.IsNotNull(testingTarget, "Can't create success object TypeRegistry"); Assert.IsInstanceOf <TypeRegistry>(testingTarget, "Should return TypeRegistry instance."); var result = testingTarget.GetTypeInfo("ImageView"); Assert.IsNotNull(result, "should be not null"); Assert.IsInstanceOf <TypeInfo>(result, "should be an instance of testing target class!"); testingTarget.Dispose(); tlog.Debug(tag, $"TypeRegistryGetTypeInfo END (OK)"); }
public void TypeInfoCreateInstance() { tlog.Debug(tag, $"TypeInfoCreateInstance START"); var testingTarget = TypeRegistry.Get().GetTypeInfo("PushButton"); Assert.IsNotNull(testingTarget, "should be not null"); Assert.IsInstanceOf <TypeInfo>(testingTarget, "should be an instance of testing target class!"); var baseHandle = testingTarget.CreateInstance(); Assert.IsNotNull(baseHandle, "should be not null"); Assert.IsInstanceOf <BaseHandle>(baseHandle, "Should be an instance of BaseHandle type."); baseHandle.Dispose(); testingTarget.Dispose(); tlog.Debug(tag, $"TypeInfoCreateInstance END (OK)"); }
public void TypeInfoConstructorWithTypeInfo() { tlog.Debug(tag, $"TypeInfoConstructorWithTypeInfo START"); var testingTarget = TypeRegistry.Get().GetTypeInfo("PushButton"); Assert.IsNotNull(testingTarget, "should be not null"); Assert.IsInstanceOf <TypeInfo>(testingTarget, "should be an instance of testing target class!"); var testingTarget2 = new TypeInfo(testingTarget); Assert.IsNotNull(testingTarget2, "should be not null"); Assert.IsInstanceOf <TypeInfo>(testingTarget2, "Should be an instance of TypeInfo type."); testingTarget2.Dispose(); testingTarget.Dispose(); tlog.Debug(tag, $"TypeInfoConstructorWithTypeInfo END (OK)"); }
public void TypeRegistryAssign() { tlog.Debug(tag, $"TypeRegistryAssign START"); var testingTarget = new TypeRegistry(); Assert.IsNotNull(testingTarget, "Can't create success object TypeRegistry"); Assert.IsInstanceOf <TypeRegistry>(testingTarget, "Should return TypeRegistry instance."); using (TypeRegistry typeRegistry = TypeRegistry.Get()) { var result = testingTarget.Assign(typeRegistry); Assert.IsNotNull(result, "Can't create success object TypeRegistry"); Assert.IsInstanceOf <TypeRegistry>(result, "Should return TypeRegistry instance."); } testingTarget.Dispose(); tlog.Debug(tag, $"TypeRegistryAssign END (OK)"); }
public void TypeInfoGetPropertyName() { tlog.Debug(tag, $"TypeInfoGetPropertyName START"); var testingTarget = TypeRegistry.Get().GetTypeInfo("ImageView"); Assert.IsNotNull(testingTarget, "should be not null"); Assert.IsInstanceOf <TypeInfo>(testingTarget, "should be an instance of testing target class!"); var view = new ImageView(); Assert.IsNotNull(view, "should be not null"); Assert.IsInstanceOf <ImageView>(view, "should be an instance of ImageView class!"); int pIndex = view.GetPropertyIndex("image"); Assert.AreEqual("image", testingTarget.GetPropertyName(pIndex), "Should be equal"); view.Dispose(); testingTarget.Dispose(); tlog.Debug(tag, $"TypeInfoGetPropertyName END (OK)"); }
public GraphTypeInfo GetType(TypeInfo typeInfo, bool isInjected = false) { if (typeInfo.IsGenericType(typeof(Task <>))) { typeInfo = typeInfo.TypeParameter(); } var type = _typeCache.GetEntity(typeInfo); if (type != null) { return(type); } type = _typeCache.AddEntity(typeInfo, new GraphTypeInfo(_typeResolver, typeInfo)); if (type.IsPrimitive && !type.IsEnumerationType) { return(type); } if (isInjected) { type.IsIgnored = true; return(type); } if (typeInfo.IsGenericParameter || typeInfo.ContainsGenericParameters) { type.IsIgnored = true; return(type); } type.EnsureTypeParameterInitialized(); var isInjectedType = type.TypeRepresentation.AsType() == typeof(IResolutionContext) || type.TypeRepresentation.AsType() == typeof(IUserContext); if (!type.IsEnumerationType && !type.IsScalarType && !type.IsInterfaceType && !type.IsUnionType && !type.IsIgnored && !isInjectedType) { DeriveInterfaces(type); } if ((!type.IsScalarType || type.IsEnumerationType) && !type.IsUnionType && !isInjectedType) { DeriveFields(type); } _metaDataHandler.DeriveMetaData(type, GetTypeInfo(typeInfo)); if (type.IsInterfaceType && !type.IsIgnored && !isInjectedType) { var iface = type.GetTypeRepresentation(); var types = TypeRegistry.Get(iface).Where(t => iface.IsAssignableFrom(t)); foreach (var t in types) { var ti = t.GetTypeInfo(); if (!ti.IsInterface && IsValidType(ti)) { GetType(ti); } } } return(type); }