private void WriteVersion(XmlWriter xmlWriter) { ISequenceTypeModuleInstance sequenceTypeModule = _GetSequenceTypeModule(_fileType); int version = sequenceTypeModule.ObjectVersion; xmlWriter.WriteAttributeString("version", version.ToString(CultureInfo.InvariantCulture)); }
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()); }
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); }
public IContentMigrator CreateSequenceContentMigrator(string filePath) { ISequenceTypeModuleInstance sequenceTypeModule = SequenceTypeService.Instance.CreateSequenceFactory(filePath); if (sequenceTypeModule == null) { return(null); } return(sequenceTypeModule.CreateMigrator()); }
private ISequence _CreateSequenceInstance(string fileType) { ISequenceTypeModuleInstance sequenceFactory = SequenceTypeService.Instance.CreateSequenceFactory(fileType); if (sequenceFactory != null) { return(sequenceFactory.CreateSequence()); } return(null); }
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); }
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); }
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)); }
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())); }
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); }
private ISequenceTypeDataModel _GenerateSequenceData(XElement xmlContent) { ISequenceTypeModuleInstance sequenceTypeModule = _GetSequenceTypeModule(_fileType); return(_GenerateSequenceDataModel(sequenceTypeModule, xmlContent)); }