Пример #1
0
        private IList <string> GetRelativePathStackInternal(SyncDatabase database)
        {
            if (database == null)
            {
                Debugger.Break();
                return(null);
            }

            SyncEntry     entry      = this;
            List <string> resultList = new List <string>();

            while (entry != null)
            {
                if (entry.ParentEntry != null)
                {
                    resultList.Add(entry.Name);
                    entry = entry.ParentEntry;
                }
                else if (entry.ParentId != null)
                {
                    resultList.Add(entry.Name);
                    entry = database.Entries.FirstOrDefault(e => e.Id == entry.ParentId.Value);
                }
                else
                {
                    break;
                }
            }

            resultList.Reverse();
            return(resultList);
        }
Пример #2
0
        public static void UpdateIfNeeded(Guid relationshipId)
        {
            string connectionString = GetConnectionStringForRelationship(relationshipId);
            bool   updateRequired;

            using (SyncDatabase db = new SyncDatabase(connectionString))
            {
                updateRequired = !db.Database.Exists() || !db.Database.CompatibleWithModel(false);
            }

            if (updateRequired)
            {
                // Create the database configuration with connection string
                SyncDatabaseConfiguration configuration = new SyncDatabaseConfiguration(
                    connectionString);

                // Create the migrator and update the database. This will also save the update.
                var migrator = new DbMigrator(configuration);
                migrator.Update();
            }
        }
Пример #3
0
 public IList <string> GetRelativePathStack(SyncDatabase database)
 {
     return(this.relativePathStack ?? (this.relativePathStack = GetRelativePathStackInternal(database)));
 }
Пример #4
0
 public string GetRelativePath(SyncDatabase database, string pathSeparator)
 {
     return(PathUtility.Join(pathSeparator, GetRelativePathStack(database)));
 }