Exemplo n.º 1
0
        public SystemContext LoadFromFile(string filePath)
        {
            IFileReader          fileReader      = FileReaderFactory.Instance.CreateFileReader();
            IObjectContentWriter contentWriter   = ObjectContentWriterFactory.Instance.CreateSystemContextContentWriter();
            IContentMigrator     contentMigrator = ContentMigratorFactory.Instance.CreateSystemContextContentMigrator();
            SystemContext        obj             = MigratingObjectLoaderService.Instance.LoadFromFile <SystemContext>(filePath, fileReader, contentWriter, contentMigrator, ObjectVersion.SystemContext);

            return(obj);
        }
Exemplo n.º 2
0
        public ElementNodeTemplate LoadFromFile(string filePath)
        {
            IFileReader          fileReader      = FileReaderFactory.Instance.CreateFileReader();
            IObjectContentWriter contentWriter   = ObjectContentWriterFactory.Instance.CreateElementNodeTemplateContentWriter();
            IContentMigrator     contentMigrator = ContentMigratorFactory.Instance.CreateElementNodeTemplateContentMigrator();
            ElementNodeTemplate  obj             = MigratingObjectLoaderService.Instance.LoadFromFile <ElementNodeTemplate>(filePath, fileReader, contentWriter, contentMigrator, ObjectVersion.ElementNodeTemplate);

            return(obj);
        }
Exemplo n.º 3
0
        public ISequence LoadFromFile(string filePath)
        {
            if (filePath == null)
            {
                throw new InvalidOperationException("Cannot load from a null file path.");
            }
            if (!File.Exists(filePath))
            {
                throw new InvalidOperationException("File does not exist.");
            }

            IFileReader fileReader = FileReaderFactory.Instance.CreateFileReader();

            if (fileReader == null)
            {
                return(null);
            }

            IObjectContentWriter contentWriter = ObjectContentWriterFactory.Instance.CreateSequenceContentWriter(filePath);

            if (contentWriter == null)
            {
                return(null);
            }

            IContentMigrator contentMigrator = ContentMigratorFactory.Instance.CreateSequenceContentMigrator(filePath);

            if (contentMigrator == null)
            {
                return(null);
            }

            ISequenceTypeModuleInstance sequenceTypeModule = SequenceTypeService.Instance.CreateSequenceFactory(filePath);

            if (sequenceTypeModule == null)
            {
                return(null);
            }

            ISequence sequence = sequenceTypeModule.CreateSequence();

            if (sequence == null)
            {
                return(null);
            }

            sequence = MigratingObjectLoaderService.Instance.LoadFromFile(sequence, filePath, fileReader, contentWriter,
                                                                          contentMigrator, sequenceTypeModule.ObjectVersion);

            if (sequence != null)
            {
                sequence.FilePath = filePath;
            }

            return(sequence);
        }
Exemplo n.º 4
0
        public Program LoadFromFile(string filePath)
        {
            IFileReader          fileReader      = FileReaderFactory.Instance.CreateFileReader();
            IObjectContentWriter contentWriter   = ObjectContentWriterFactory.Instance.CreateProgramContentWriter();
            IContentMigrator     contentMigrator = ContentMigratorFactory.Instance.CreateProgramContentMigrator();
            Program obj = MigratingObjectLoaderService.Instance.LoadFromFile <Program>(filePath, fileReader, contentWriter, contentMigrator, ObjectVersion.Program);

            if (obj != null)
            {
                obj.FilePath = filePath;
            }

            return(obj);
        }
Exemplo n.º 5
0
        public SystemConfig LoadFromFile(string filePath)
        {
            IFileReader          fileReader      = FileReaderFactory.Instance.CreateFileReader();
            IObjectContentWriter contentWriter   = ObjectContentWriterFactory.Instance.CreateSystemConfigContentWriter();
            IContentMigrator     contentMigrator = ContentMigratorFactory.Instance.CreateSystemConfigContentMigrator();
            SystemConfig         obj             = MigratingObjectLoaderService.Instance.LoadFromFile <SystemConfig>(filePath, fileReader, contentWriter, contentMigrator, ObjectVersion.SystemConfig);

            if (obj != null)
            {
                obj.LoadedFilePath = filePath;
            }

            return(obj);
        }
Exemplo n.º 6
0
        public ModuleStore LoadFromFile(string filePath)
        {
            IFileReader          fileReader      = FileReaderFactory.Instance.CreateFileReader();
            IObjectContentWriter contentWriter   = ObjectContentWriterFactory.Instance.CreateModuleStoreContentWriter();
            IContentMigrator     contentMigrator = ContentMigratorFactory.Instance.CreateModuleStoreContentMigrator();
            ModuleStore          obj             = MigratingObjectLoaderService.Instance.LoadFromFile <ModuleStore>(filePath, fileReader, contentWriter, contentMigrator, ObjectVersion.ModuleStore);

            if (obj != null)
            {
                obj.LoadedFilePath = filePath;
            }

            return(obj);
        }
Exemplo n.º 7
0
        public object LoadFromFile(string filePath)
        {
            if (filePath == null)
            {
                throw new InvalidOperationException("Cannot load from a null file path.");
            }
            if (!File.Exists(filePath))
            {
                throw new InvalidOperationException("File does not exist.");
            }

            IFileReader fileReader = FileReaderFactory.Instance.CreateBinaryFileReader();

            if (fileReader == null)
            {
                return(null);
            }

            IObjectContentWriter contentWriter = ObjectContentWriterFactory.Instance.CreateSequenceCacheContentWriter(filePath);

            if (contentWriter == null)
            {
                return(null);
            }

            ISequenceCache sequenceCache = SequenceService.Instance.CreateNewCache(filePath);

            if (sequenceCache == null)
            {
                return(null);
            }

            object content = fileReader.ReadFile(sequenceCache.CacheFilePath);

            if (content == null)
            {
                return(null);
            }

            var cacheContainer = new CacheContainer();

            cacheContainer.SequenceCache = sequenceCache;
            contentWriter.WriteContentToObject(content, cacheContainer);

            return(cacheContainer.SequenceCache);
        }
Exemplo n.º 8
0
        public T LoadFromFile <T>(T objectToPopulate, string filePath, IFileReader fileReader,
                                  IObjectContentWriter contentWriter, IContentMigrator contentMigrator,
                                  int currentObjectVersion)
            where T : class
        {
            object content = fileReader.ReadFile(filePath);

            if (content == null)
            {
                return(null);
            }

            try {
                content = ObjectMigratorService.Instance.MigrateObject(content, contentMigrator,
                                                                       contentWriter.GetContentVersion(content),
                                                                       currentObjectVersion, filePath);
                contentWriter.WriteContentToObject(content, objectToPopulate);
            }
            catch (Exception ex) {
                Logging.Error(string.Format("Error when migrating file {0} to the current version.", filePath), ex);
            }

            return(objectToPopulate);
        }
Exemplo n.º 9
0
 public T LoadFromFile <T>(string filePath, IFileReader fileReader, IObjectContentWriter contentWriter,
                           IContentMigrator contentMigrator, int currentObjectVersion)
     where T : class, new()
 {
     return(LoadFromFile(new T(), filePath, fileReader, contentWriter, contentMigrator, currentObjectVersion));
 }