예제 #1
0
파일: ElementApi.cs 프로젝트: E01D/Base
        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());
        }
예제 #2
0
        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);
        }
예제 #3
0
파일: TypeBaseApi.cs 프로젝트: E01D/Base
        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);
        }
예제 #4
0
        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);
        }
예제 #5
0
        public object GetApi <T>()
        {
            var typeId = XTypes.GetTypeId <T>();

            return(typeId.Value == 0 ? null : GetApi(typeId));
        }
예제 #6
0
파일: TypeBaseApi.cs 프로젝트: E01D/Base
 private TypeId_I GetTypeId(Type type)
 {
     return(XTypes.GetTypeId(type));
 }