Beispiel #1
0
        public static void LogMsg(IConfiguration config, int code, string msg)
        {
            Config4Impl c4i = (Config4Impl)config;

            if (c4i.MessageLevel() > Const4.None)
            {
                new MessageOutput(msg, code, c4i.OutStream());
            }
        }
		public void TestCSAliases()
		{
			Config4Impl config = new Config4Impl();
			JavaSupport javaSupport = new JavaSupport();

			javaSupport.Prepare(config);

			string resolvedName = config.ResolveAliasRuntimeName(UnversionedNameFor(typeof(ClassInfo)));
			Assert.AreEqual("com.db4o.cs.internal.ClassInfo", resolvedName);
		}
        /// <exception cref="Db4objects.Db4o.Ext.OldFormatException"></exception>
        public static IEmbeddedObjectContainer OpenObjectContainer(IEmbeddedConfiguration
                                                                   config, string databaseFileName)
        {
            IConfiguration legacyConfig = Db4oLegacyConfigurationBridge.AsLegacy(config);

            Config4Impl.AssertIsNotTainted(legacyConfig);
            EmitDebugInfo();
            IEmbeddedObjectContainer oc = new IoAdaptedObjectContainer(legacyConfig, databaseFileName
                                                                       );

            ((EmbeddedConfigurationImpl)config).ApplyConfigurationItems(oc);
            Db4objects.Db4o.Internal.Messages.LogMsg(legacyConfig, 5, databaseFileName);
            return(oc);
        }
 internal void InitEncryption(Config4Impl a_config)
 {
     if (a_config.Encrypt() && a_config.Password() != null && a_config.Password().Length
         > 0)
     {
         i_encrypt   = true;
         i_encryptor = new byte[a_config.Password().Length];
         for (int i = 0; i < i_encryptor.Length; i++)
         {
             i_encryptor[i] = (byte)(a_config.Password()[i] & unchecked ((int)(0xff)));
         }
         i_lastEncryptorByte = a_config.Password().Length - 1;
         return;
     }
     OldEncryptionOff();
 }
Beispiel #5
0
        /// <exception cref="Db4objects.Db4o.Ext.OldFormatException"></exception>
        /// <exception cref="Db4objects.Db4o.Ext.DatabaseReadOnlyException"></exception>
        protected sealed override void OpenImpl()
        {
            Config4Impl configImpl = ConfigImpl;
            IStorage    storage    = configImpl.Storage;
            bool        isNew      = !storage.Exists(FileName());

            if (isNew)
            {
                LogMsg(14, FileName());
                CheckReadOnly();
                _handlers.OldEncryptionOff();
            }
            bool readOnly = configImpl.IsReadOnly();
            bool lockFile = Debug4.lockFile && configImpl.LockFile() && (!readOnly);

            if (NeedsLockFileThread())
            {
                IBin fileBin = storage.Open(new BinConfiguration(FileName(), false, 0, false, configImpl
                                                                 .BlockSize()));
                IBin synchronizedBin = new SynchronizedBin(fileBin);
                _file = new BlockAwareBin(synchronizedBin);
            }
            else
            {
                IBin bin = storage.Open(new BinConfiguration(FileName(), lockFile, 0, readOnly, configImpl
                                                             .BlockSize()));
                if (configImpl.AsynchronousSync())
                {
                    bin = new ThreadedSyncBin(bin);
                }
                _file = new BlockAwareBin(bin);
            }
            if (isNew)
            {
                ConfigureNewFile();
                if (configImpl.ReservedStorageSpace() > 0)
                {
                    Reserve(configImpl.ReservedStorageSpace());
                }
                CommitTransaction();
                WriteHeader(true, false);
            }
            else
            {
                ReadThis();
            }
        }
        public object DeepClone(object param)
        {
            Config4Impl ret = new Config4Impl();

            Config4Impl.ConfigDeepCloneContext context = new Config4Impl.ConfigDeepCloneContext
                                                             (this, ret);
            ret._config        = (KeySpecHashtable4)_config.DeepClone(context);
            ret._internStrings = _internStrings;
            ret._messageLevel  = _messageLevel;
            ret._readOnly      = _readOnly;
            if (_registeredTypeHandlers != null)
            {
                ret._registeredTypeHandlers = (Collection4)_registeredTypeHandlers.DeepClone(context
                                                                                             );
            }
            return(ret);
        }
 public TypeHandlerConfiguration(Config4Impl config)
 {
     _config = config;
 }
		public TypeHandlerConfiguration(Config4Impl config)
		{
			_config = config;
		}
		public object DeepClone(object param)
		{
			Config4Impl ret = new Config4Impl();
			Config4Impl.ConfigDeepCloneContext context = new Config4Impl.ConfigDeepCloneContext
				(this, ret);
			ret._config = (KeySpecHashtable4)_config.DeepClone(context);
			ret._internStrings = _internStrings;
			ret._messageLevel = _messageLevel;
			ret._readOnly = _readOnly;
			if (_registeredTypeHandlers != null)
			{
				ret._registeredTypeHandlers = (Collection4)_registeredTypeHandlers.DeepClone(context
					);
			}
			return ret;
		}
Beispiel #10
0
		private void InitializeReferenceSystemFactory(Config4Impl config)
		{
			_referenceSystemFactory = config.ReferenceSystemFactory();
		}
 public TypeHandlerConfigurationDotNet(Config4Impl config) : base(config)
 {
     ListTypeHandler(new CollectionTypeHandler());
     MapTypeHandler(new MapTypeHandler());
 }
Beispiel #12
0
		private IEnvironment CreateEnvironment(Config4Impl config)
		{
			ArrayList bindings = new ArrayList();
			Sharpen.Collections.AddAll(bindings, config.EnvironmentContributions());
			bindings.Add(this);
			// my(ObjectContainer.class)
			bindings.Add(config);
			// my(Configuration.class)
			return Environments.NewConventionBasedEnvironment(Sharpen.Collections.ToArray(bindings
				));
		}
Beispiel #13
0
		internal virtual void Rename(Config4Impl config)
		{
			bool renamedOne = false;
			if (config.Rename() != null)
			{
				renamedOne = ApplyRenames(config);
			}
			_classCollection.CheckChanges();
			if (renamedOne)
			{
				Reboot();
			}
		}
 public ConfigDeepCloneContext(Config4Impl orig, Config4Impl cloned)
 {
     _orig   = orig;
     _cloned = cloned;
 }
 //  TODO: consider setting default to 8, it's more efficient with freespace.
 public object Evaluate()
 {
     return(Config4Impl.DefaultClientServerFactory());
 }
Beispiel #16
0
		protected override bool ApplyRenames(Config4Impl config)
		{
			LogMsg(58, null);
			return false;
		}
		public CommonConfigurationImpl(Config4Impl config)
		{
			_config = config;
		}
Beispiel #18
0
        public virtual object DeepClone(object param)
        {
            Config4Impl parentConfig = ((Config4Impl.ConfigDeepCloneContext)param)._cloned;

            return(new Db4objects.Db4o.Internal.Config4Class(parentConfig, _config));
        }
Beispiel #19
0
 protected Config4Class(Config4Impl configuration, KeySpecHashtable4 config) : base
         (config)
 {
     _configImpl = configuration;
 }
Beispiel #20
0
 internal Config4Class(Config4Impl a_configuration, string a_name)
 {
     _configImpl = a_configuration;
     SetName(a_name);
 }
Beispiel #21
0
 public TypeHandlerConfigurationDotNet(Config4Impl config) : base(config)
 {
     ListTypeHandler(new CollectionTypeHandler());
     MapTypeHandler(new MapTypeHandler());
 }
 protected override long MaximumDatabaseFileSize(Config4Impl configImpl)
 {
     return(int.MaxValue);
 }
Beispiel #23
0
 protected virtual long MaximumDatabaseFileSize(Config4Impl configImpl)
 {
     return(configImpl.MaximumDatabaseFileSize());
 }
		public IdSystemConfigurationImpl(Config4Impl config)
		{
			_config = config;
		}
Beispiel #25
0
		internal void InitEncryption(Config4Impl a_config)
		{
			if (a_config.Encrypt() && a_config.Password() != null && a_config.Password().Length
				 > 0)
			{
				i_encrypt = true;
				i_encryptor = new byte[a_config.Password().Length];
				for (int i = 0; i < i_encryptor.Length; i++)
				{
					i_encryptor[i] = (byte)(a_config.Password()[i] & unchecked((int)(0xff)));
				}
				i_lastEncryptorByte = a_config.Password().Length - 1;
				return;
			}
			OldEncryptionOff();
		}
			public override void Configure(Config4Impl config)
			{
				Db4oLegacyConfigurationBridge.AsIdSystemConfiguration(config).UsePointerBasedSystem
					();
			}
			public override void Configure(Config4Impl config)
			{
				Db4oLegacyConfigurationBridge.AsIdSystemConfiguration(config).UseInMemorySystem();
			}
			public abstract void Configure(Config4Impl config);
Beispiel #29
0
		protected ObjectContainerBase(IConfiguration config)
		{
			// Collection of all classes
			// if (_classCollection == null) the engine is down.
			// the Configuration context for this ObjectContainer
			// Counts the number of toplevel calls into YapStream
			// currently used to resolve self-linking concurrency problems
			// in cylic links, stores only ClassMetadata objects
			// a value greater than 0 indicates class implementing the
			// "Internal" interface are visible in queries and can
			// be used.
			// used for ClassMetadata and ClassMetadataRepository
			// may be parent or equal to i_trans
			// used for Objects
			// all the per-YapStream references that we don't
			// want created in YapobjectCarrier
			// One of three constants in ReplicationHandler: NONE, OLD, NEW
			// Detailed replication variables are stored in i_handlers.
			// Call state has to be maintained here, so YapObjectCarrier (who shares i_handlers) does
			// not accidentally think it operates in a replication call. 
			// weak reference management
			_lock = new object();
			_config = (Config4Impl)config;
			_environment = CreateEnvironment(_config);
			_maxStackDepth = _config.MaxStackDepth();
		}
			public override void Configure(Config4Impl config)
			{
				// config.freespace().useRamSystem();
				config.Freespace().UseBTreeSystem();
			}
Beispiel #31
0
		protected virtual void Initialize1(IConfiguration config)
		{
			_config = InitializeConfig(config);
			_handlers = new HandlerRegistry(this, ConfigImpl.Encoding(), ConfigImpl.Reflector
				());
			if (_references != null)
			{
				Gc();
				_references.Stop();
			}
			_references = WeakReferenceSupportFactory.ForObjectContainer(this);
			if (HasShutDownHook())
			{
				Platform4.AddShutDownHook(this);
			}
			_handlers.InitEncryption(ConfigImpl);
			_stillToSet = null;
		}
			public override void Configure(Config4Impl config)
			{
				Db4oLegacyConfigurationBridge.AsIdSystemConfiguration(config).UseStackedBTreeSystem
					();
			}
Beispiel #33
0
		protected virtual bool ApplyRenames(Config4Impl config)
		{
			bool renamed = false;
			IEnumerator i = config.Rename().GetEnumerator();
			while (i.MoveNext())
			{
				Rename ren = (Rename)i.Current;
				if (AlreadyApplied(ren))
				{
					continue;
				}
				if (ApplyRename(ren))
				{
					renamed = true;
				}
			}
			return renamed;
		}
			public override void Configure(Config4Impl config)
			{
				config.Freespace().UseRamSystem();
			}
Beispiel #35
0
		private int Frequency(Config4Impl config)
		{
			return Math.Min(config.TimeoutClientSocket(), config.TimeoutServerSocket()) / 4;
		}
		public CacheConfigurationImpl(Config4Impl config)
		{
			_config = config;
		}
		public ClassInfoHelper(Config4Impl config)
		{
			_config = config;
		}
Beispiel #38
0
 public ReflectorConfigurationImpl(Config4Impl config)
 {
     _config = config;
 }
			public ConfigDeepCloneContext(Config4Impl orig, Config4Impl cloned)
			{
				_orig = orig;
				_cloned = cloned;
			}
		public ServerConfigurationImpl(Config4Impl config) : base(config)
		{
		}
		public FileConfigurationImpl(Config4Impl config)
		{
			_config = config;
		}
Beispiel #42
0
		private Config4Impl PrepareConfig(Config4Impl originalConfig, IStorage storage, bool
			 readOnly)
		{
			Config4Impl sourceConfig = (Config4Impl)originalConfig.DeepClone(null);
			sourceConfig.WeakReferences(false);
			sourceConfig.Storage = storage;
			sourceConfig.ReadOnly(readOnly);
			return sourceConfig;
		}
Beispiel #43
0
        internal static void GetDefaultConfiguration(Config4Impl config)
        {
            if (IsCompact())
            {
                config.SingleThreadedClient(true);
            }

            Translate(config, typeof(Delegate), new TNull());
            Translate(config, typeof(Type), new TType()); // TODO: unnecessary?
            Translate(config, typeof(Type).GetType(), new TType());

#if !CF && !SILVERLIGHT
            if (IsMono())
            {

				Translate(config, new Exception(), new TSerializable());
            }
#endif

#if !SILVERLIGHT
            Translate(config, new ArrayList(), new TList());
            Translate(config, new Hashtable(), new TDictionary());
            Translate(config, new Queue(), new TQueue());
            Translate(config, new Stack(), new TStack());
#endif
			Translate(config, CultureInfo.InvariantCulture, new TCultureInfo());

            if (!IsCompact())
            {
				Translate(config, "System.Collections.SortedList, mscorlib", new TDictionary());
            }

            new TypeHandlerConfigurationDotNet(config).Apply();

        	config.ObjectClass(typeof (ActivatableBase)).Indexed(false);
        }
 public NetworkingConfigurationProviderImpl(Config4Impl config)
 {
     _networking = new NetworkingConfigurationImpl(config);
 }
		public EmbeddedConfigurationImpl(IConfiguration legacy)
		{
			_legacy = (Config4Impl)legacy;
		}
Beispiel #46
0
        internal LocalObjectContainer(IConfiguration config) : base(config)
        {
            Config4Impl configImpl = (Config4Impl)config;

            _maximumDatabaseFileSize = MaximumDatabaseFileSize(configImpl);
        }