RegisterType() public method

public RegisterType ( Type type ) : string
type System.Type
return string
Esempio n. 1
0
        TableInfo AutoRegisterType(Type type)
        {
            var ti = _owner.TablesInfo.FindByType(type);

            if (ti == null)
            {
                var name = _owner.Type2NameRegistry.FindNameByType(type) ?? _owner.RegisterType(type);
                ti = _owner.TablesInfo.LinkType2Name(type, name);
            }
            return(ti);
        }
Esempio n. 2
0
        TableInfo AutoRegisterType(Type type)
        {
            var ti = _owner.TablesInfo.FindByType(type);

            if (ti == null)
            {
                if (type.InheritsOrImplements(typeof(IEnumerable <>)))
                {
                    throw new InvalidOperationException("Cannot store " + type.ToSimpleName() + " type to DB directly.");
                }
                var name = _owner.Type2NameRegistry.FindNameByType(type) ?? _owner.RegisterType(type);
                ti = _owner.TablesInfo.LinkType2Name(type, name);
            }
            return(ti);
        }
Esempio n. 3
0
        TableInfo AutoRegisterType(Type type, bool forceAutoRegistration = false)
        {
            var ti = _owner.TablesInfo.FindByType(type);

            if (ti == null)
            {
                if (type.InheritsOrImplements(typeof(IEnumerable <>)))
                {
                    throw new InvalidOperationException("Cannot store " + type.ToSimpleName() + " type to DB directly.");
                }
                var name = _owner.Type2NameRegistry.FindNameByType(type);
                if (name == null)
                {
                    if (!_owner.AutoRegisterTypes && !forceAutoRegistration)
                    {
                        throw new BTDBException($"Type {type.ToSimpleName()} is not registered.");
                    }
                    name = _owner.RegisterType(type);
                }
                ti = _owner.TablesInfo.LinkType2Name(type, name);
            }
            return(ti);
        }