예제 #1
0
        private void WriteVersion(XmlWriter xmlWriter)
        {
            ISequenceTypeModuleInstance sequenceTypeModule = _GetSequenceTypeModule(_fileType);
            int version = sequenceTypeModule.ObjectVersion;

            xmlWriter.WriteAttributeString("version", version.ToString(CultureInfo.InvariantCulture));
        }
예제 #2
0
        internal static DataContractSerializer GetSequenceTypeDataSerializer(ISequenceTypeModuleInstance sequenceTypeModule)
        {
            if (sequenceTypeModule == null) return null;
            if (sequenceTypeModule.Descriptor == null) return null;
            if (sequenceTypeModule.Descriptor.ModuleDataClass == null) return null;

            return new DataContractSerializer(sequenceTypeModule.Descriptor.ModuleDataClass, _GetAllModuleDataTypes());
        }
예제 #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);
        }
예제 #4
0
        public IContentMigrator CreateSequenceContentMigrator(string filePath)
        {
            ISequenceTypeModuleInstance sequenceTypeModule = SequenceTypeService.Instance.CreateSequenceFactory(filePath);

            if (sequenceTypeModule == null)
            {
                return(null);
            }
            return(sequenceTypeModule.CreateMigrator());
        }
예제 #5
0
        private ISequence _CreateSequenceInstance(string fileType)
        {
            ISequenceTypeModuleInstance sequenceFactory = SequenceTypeService.Instance.CreateSequenceFactory(fileType);

            if (sequenceFactory != null)
            {
                return(sequenceFactory.CreateSequence());
            }
            return(null);
        }
예제 #6
0
        private ISequenceTypeDataModel _GenerateSequenceDataModel(ISequenceTypeModuleInstance sequenceTypeModule,
            XElement xmlContent)
        {
            DataContractSerializer serializer = SequenceTypeService.GetSequenceTypeDataSerializer(sequenceTypeModule);
            if (serializer == null) return null;

            using (XmlReader xmlReader = xmlContent.CreateReader()) {
                object sequenceData = serializer.ReadObject(xmlReader);
                return (ISequenceTypeDataModel) sequenceData;
            }
        }
        public int GetContentVersion(object content)
        {
            XElement xmlContent = content as XElement;

            if (xmlContent == null)
            {
                throw new InvalidOperationException("Content must be an XElement.");
            }

            ISequenceTypeModuleInstance sequenceTypeModule = _GetSequenceTypeModule(_fileType);

            return(sequenceTypeModule.ClassVersion);
        }
예제 #8
0
        private ISequenceTypeDataModel _GenerateSequenceDataModel(ISequenceTypeModuleInstance sequenceTypeModule, XElement xmlContent)
        {
            DataContractSerializer serializer = SequenceTypeService.GetSequenceTypeDataSerializer(sequenceTypeModule);

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

            using (XmlReader xmlReader = xmlContent.CreateReader()) {
                object sequenceData = serializer.ReadObject(xmlReader);
                return((ISequenceTypeDataModel)sequenceData);
            }
        }
        private void _WriteSequenceDataToXmlWriter(ISequence sequence, XmlWriter xmlWriter)
        {
            ISequenceTypeModuleInstance sequenceTypeModule = _GetSequenceTypeModule(_fileType);
            DataContractSerializer      serializer         = SequenceTypeService.GetSequenceTypeDataSerializer(sequenceTypeModule);

            if (serializer == null)
            {
                throw new Exception(string.Format("Can't save sequence {0}, no serializer present. ", sequence.Name));
            }

            serializer.WriteStartObject(xmlWriter, sequence.SequenceData);
            _WriteKnownNamespaces(xmlWriter);
            serializer.WriteObjectContent(xmlWriter, sequence.SequenceData);
            serializer.WriteEndObject(xmlWriter);
        }
예제 #10
0
        object IObjectLoader.LoadFromFile(string filePath)
        {
            ISequenceTypeModuleInstance sequenceTypeModule = SequenceTypeService.Instance.CreateSequenceFactory(filePath);

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

            if (sequenceTypeModule.IsCustomSequenceLoader)
            {
                return(sequenceTypeModule.LoadSequenceFromFile(filePath));
            }

            return(LoadFromFile(filePath));
        }
예제 #11
0
        static internal DataContractSerializer GetSequenceTypeDataSerializer(ISequenceTypeModuleInstance sequenceTypeModule)
        {
            if (sequenceTypeModule == null)
            {
                return(null);
            }
            if (sequenceTypeModule.Descriptor == null)
            {
                return(null);
            }
            if (sequenceTypeModule.Descriptor.ModuleDataClass == null)
            {
                return(null);
            }

            return(new DataContractSerializer(sequenceTypeModule.Descriptor.ModuleDataClass, _GetAllModuleDataTypes()));
        }
예제 #12
0
        private ISequenceTypeDataModel _CreateSequenceDataInstance(string fileType)
        {
            ISequenceTypeModuleInstance sequenceFactory = SequenceTypeService.Instance.CreateSequenceFactory(fileType);

            if (sequenceFactory != null)
            {
                IModuleDataModel sequenceTypeData = ModuleLocalDataSet.CreateModuleDataInstance(sequenceFactory);
                if (sequenceTypeData != null && !(sequenceTypeData is ISequenceTypeDataModel))
                {
                    VixenSystem.Logging.Warning("Could not create appropriate sequence data for new sequence due to the object type.  File type: " + fileType);
                }
                else
                {
                    if (sequenceTypeData != null)
                    {
                        sequenceTypeData.ModuleTypeId     = sequenceFactory.TypeId;
                        sequenceTypeData.ModuleInstanceId = sequenceFactory.InstanceId;
                    }
                    return((ISequenceTypeDataModel)sequenceTypeData);
                }
            }
            return(null);
        }
예제 #13
0
        private ISequenceTypeDataModel _GenerateSequenceData(XElement xmlContent)
        {
            ISequenceTypeModuleInstance sequenceTypeModule = _GetSequenceTypeModule(_fileType);

            return(_GenerateSequenceDataModel(sequenceTypeModule, xmlContent));
        }