/// <summary> /// Fills the Db4o info. /// </summary> /// <param name="db4oInfoItem">The db4o info item.</param> /// <param name="container">The container.</param> /// <param name="fillMode">The fill mode.</param> public static void FillDB4OInfo(this IDB4OEntityInfo db4oInfoItem, IObjectContainer container, DB4OFillOptions fillMode) { if (db4oInfoItem == null || db4oInfoItem.HasDB4OEntityInfo() || !container.Ext().IsActive(db4oInfoItem)) { return; } var repositoryInfo = container.Ext().GetObjectInfo(db4oInfoItem); if (fillMode.Equals(DB4OFillOptions.FillGlobalID)) { db4oInfoItem.DB4OGlobalID = repositoryInfo.GetUUID().ConvertToString(); } if (fillMode.Equals(DB4OFillOptions.FillLocalID)) { db4oInfoItem.DB4OLocalID = repositoryInfo.GetInternalID(); } if (fillMode.Equals(DB4OFillOptions.FillVersion)) { db4oInfoItem.DB4OVersion = repositoryInfo.GetVersion(); } var entityType = db4oInfoItem.GetType(); var properties = entityType.GetProperties(); foreach (var property in properties) { var repositoryType = property.PropertyType.GetInterface(typeof(IDB4OEntityInfo).ToString()); if (repositoryType == null) { continue; } var val = property.GetValue(db4oInfoItem, null); if (val == null || !container.Ext().IsActive(val)) { continue; } var repositoryVal = val as IDB4OEntityInfo; repositoryVal.FillDB4OInfo(container); } }
/// <summary> /// Gets the activated. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="db4oInfoItem">The db4o info item.</param> /// <param name="container">The container.</param> /// <param name="activationDepth">The activation depth.</param> /// <returns></returns> public static T GetActivated <T>(this IDB4OEntityInfo db4oInfoItem, IObjectContainer container, int activationDepth) { if (!db4oInfoItem.HasDB4OEntityInfo()) { return(default(T)); } if (!String.IsNullOrEmpty(db4oInfoItem.DB4OGlobalID)) { return(db4oInfoItem.DB4OGlobalID.RecoverUUID() .GetActivated <T>(container, activationDepth)); } if (db4oInfoItem.DB4OLocalID > 0) { return(db4oInfoItem.DB4OLocalID .GetActivated <T>(container, activationDepth)); } return(default(T)); }
/// <summary> /// Activates the specified db4o info item. /// </summary> /// <param name="db4oInfoItem">The db4o info item.</param> /// <param name="container">The container.</param> /// <param name="activationDepth">The activation depth.</param> public static void Activate(this IDB4OEntityInfo db4oInfoItem, IObjectContainer container, int activationDepth) { if (!db4oInfoItem.HasDB4OEntityInfo()) { return; } if (!String.IsNullOrEmpty(db4oInfoItem.DB4OGlobalID)) { db4oInfoItem.DB4OGlobalID.RecoverUUID() .Activate(container, activationDepth); } if (db4oInfoItem.DB4OLocalID > 0) { db4oInfoItem.DB4OLocalID .Activate(container, activationDepth); } return; }