示例#1
0
        public PythonTypeDatabase(
            PythonInterpreterFactoryWithDatabase factory,
            IEnumerable <string> databaseDirectories = null,
            PythonTypeDatabase innerDatabase         = null
            )
        {
            if (innerDatabase != null && factory.Configuration.Version != innerDatabase.LanguageVersion)
            {
                throw new InvalidOperationException("Language versions do not match");
            }

            _factory = factory;
            if (innerDatabase != null)
            {
                _sharedState = new SharedDatabaseState(innerDatabase._sharedState);
            }
            else
            {
                _sharedState = new SharedDatabaseState(_factory?.Configuration.Version ?? new Version());
            }

            if (databaseDirectories != null)
            {
                foreach (var d in databaseDirectories)
                {
                    LoadDatabase(d);
                }
            }

            _sharedState.ListenForCorruptDatabase(this);
        }
示例#2
0
 internal SharedDatabaseState(SharedDatabaseState inner)
 {
     _inner       = inner;
     _langVersion = _inner.LanguageVersion;
     if (_inner.BuiltinModule != null)
     {
         _builtinName = _inner.BuiltinModule.Name;
     }
     else
     {
         _builtinName = BuiltinTypeId.Unknown.GetModuleName(_langVersion);
     }
 }
示例#3
0
 private PythonTypeDatabase(
     PythonInterpreterFactoryWithDatabase factory,
     string databaseDirectory,
     bool isDefaultDatabase,
     Version version = null
     )
 {
     _factory     = factory;
     _sharedState = new SharedDatabaseState(
         version ?? factory?.Configuration.Version ?? new Version(),
         databaseDirectory,
         defaultDatabase: isDefaultDatabase
         );
 }