public static Type ResolveDynamicTypeByInteropId(Guid id)
        {
            if (!_types.ContainsKey(id))
            {
                try
                {
                    var contentTypeRepo     = new ContentTypeMetadataRepository();
                    var contentTypeMetadata = contentTypeRepo.Find().Single(x => x.TypeResolverId == id);

                    Type repoType;
                    if (!string.IsNullOrWhiteSpace(contentTypeMetadata.CustomAssemblyQualifiedTypeName))
                    {
                        repoType = Type.GetType(contentTypeMetadata.CustomAssemblyQualifiedTypeName);
                    }
                    else
                    {
                        repoType = Type.GetType(contentTypeMetadata.AssemblyQualifiedTypeName);
                    }

                    _types.Add(id, repoType);
                }
                catch (Exception)
                {
                    var entityType = WarpCoreIlGenerator.CreateDynamicContentEntity(id);

                    _types.Add(id, entityType);
                }
            }

            return(_types[id]);
        }
Ejemplo n.º 2
0
        public static Type ResolveTypeByApiId(Guid id)
        {
            if (!_types.ContainsKey(id))
            {
                try
                {
                    Type repoType = ResolveMetadataDefinedRepositoryType(id);
                    _types.Add(id, repoType);
                }
                catch (Exception)
                {
                    var entityType = WarpCoreIlGenerator.CreateDynamicContentEntity(id);
                    Activator.CreateInstance(entityType);

                    Type repoType = WarpCoreIlGenerator.CreateDynamicRepository(entityType);
                    Activator.CreateInstance(repoType);

                    _types.Add(id, repoType);
                }
            }

            return(_types[id]);
        }