public List <SemanticClass_I> GetImplementingClasses(SemanticModel_I model, Type type) { //TypalContextHost_I context = _.ContextAs<TypalContextHost_I>(); var typeId = XTypes.GetTypeId(type); if (!model.Interfaces.TryGetValue(typeId.Value, out SemanticInterface symbol)) { return(new List <SemanticClass_I>()); } return(symbol.ImplementingClasses.Values.ToList()); }
public DataLayerApi_I GetApiForModel <T>() { var context = XContextual.GetGlobal <DataGlobalContext_I>(); DataLayerApi_I api = null; var modelTypeId = XTypes.GetTypeId(typeof(T)); if (context.DataApisByModelType.TryGetValue(modelTypeId.Value, out object apiObject)) { api = (DataLayerApi_I)apiObject; } return(api); }
public TTypeElement GetOrCreateElement(SemanticModel_I semanticModel, System.Type type) { TTypeElement typeElement; var storage = GetModelStorage(semanticModel); var typeHandle = type.TypeHandle; var typeId = XTypes.GetTypeId(type); if (!storage.TryGetValue(typeId.Value, out typeElement)) { typeElement = CreateAndAddElement(semanticModel, type, typeHandle, storage); } return(typeElement); }
public void LoadApis() { var context = XContextual.GetGlobal <DataGlobalContext_I>(); var dictionary = context.DataApis; XApis.Api.LoadApis(typeof(DataLayerApi_I), dictionary); foreach (var keyPair in dictionary) { var value = keyPair.Value; var type = value.GetType(); var interfaces = type.GetInterfaces(); var apiType = typeof(BasicLayerApi_I <>); for (int i = 0; i < interfaces.Length; i++) { var interface1 = interfaces[i]; if (!interface1.IsGenericType) { continue; } if (interface1.GetGenericTypeDefinition() == apiType) { var args = interface1.GenericTypeArguments; var modelType = args[0]; var modelTypeId = XTypes.GetTypeId(modelType); context.DataApisByModelType.Add(modelTypeId.Value, keyPair.Value); } } } //XApis.LoadAttributedApis(typeof(DataApiAttribute), dictionary); }
public object GetApi <T>() { var typeId = XTypes.GetTypeId <T>(); return(typeId.Value == 0 ? null : GetApi(typeId)); }
private TypeId_I GetTypeId(Type type) { return(XTypes.GetTypeId(type)); }