Exemple #1
0
        public void LoadApis(System.Type interfaceType, Dictionary <long, object> dictionary)
        {
            TypalGlobalContext_I typal = XContextual.GetGlobal <TypalGlobalContext_I>();

            var y = XSemanticMetadata.Api.Elements.GetImplementingClasses(typal.Library.SemanticModel, interfaceType);

            foreach (var z in y)
            {
                var handle = XTypes.GetTypeHandle(z.TypeId);

                var type = System.Type.GetTypeFromHandle(handle);

                if (type.IsAbstract)
                {
                    continue;
                }

                if (type.ContainsGenericParameters)
                {
                    continue;
                }

                var implementedInterfaces = type.GetInterfaces();

                for (int i = 0; i < implementedInterfaces.Length; i++)
                {
                    //var implementedInterface = implementedInterfaces[i];

                    //if (!implementedInterface.IsGenericType) continue;

                    //var genericTypeDefinition = implementedInterface.GetGenericTypeDefinition();

                    //if (genericTypeDefinition != interfaceType) continue;

                    var instance = XNew.New(type);

                    //var arguments = implementedInterface.GenericTypeArguments;

                    //if (arguments.Length != 1) continue;

                    //XTypal.Api.Types.

                    if (!dictionary.ContainsKey(z.TypeId.Value))
                    {
                        dictionary.Add(z.TypeId.Value, instance);
                    }
                }
            }
        }