protected override void XukInAttributes(XmlReader source) { base.XukInAttributes(source); string path = source.GetAttribute(XukStrings.OriginalRelativePath); if (String.IsNullOrEmpty(path)) { throw new XukException("The OriginalRelativePath of an ImageMediaData cannot be null or empty !"); } string uid = XukAble.ReadXukAttribute(source, DataProvider.DataProvider_NAME); if (String.IsNullOrEmpty(uid)) { throw new XukException("The DataProvider of an ImageMediaData cannot be null or empty !"); } //if (!Presentation.DataProviderManager.IsManagerOf(uid)) //{ // throw new IsNotManagerOfException( // String.Format("DataProvider cannot be found {0}", uid)); //} DataProvider prov = Presentation.DataProviderManager.GetManagedObject(uid); InitializeImage(prov, path); }
protected override void XukInAttributes(XmlReader source) { base.XukInAttributes(source); string optionalInfo = source.GetAttribute(XukStrings.OptionalInfo); string strPreserve = source.GetAttribute(XukStrings.IsPreservedForOutputFile); bool isPreserved = strPreserve == "true" ? true : false; string path = source.GetAttribute(XukStrings.OriginalRelativePath); if (isPreserved && String.IsNullOrEmpty(path)) { throw new XukException("For preserved files, the OriginalRelativePath of an ExternalFileData cannot be null or empty !"); } string uid = XukAble.ReadXukAttribute(source, DataProvider.DataProvider_NAME); if (String.IsNullOrEmpty(uid)) { throw new XukException("The DataProvider of an ExternalFileData cannot be null or empty !"); } //if (!Presentation.DataProviderManager.IsManagerOf(uid)) //{ // throw new IsNotManagerOfException( // String.Format("DataProvider cannot be found {0}", uid)); //} DataProvider prov = Presentation.DataProviderManager.GetManagedObject(uid); InitializeWithData(prov, path, isPreserved, optionalInfo); }
private void XukInExternalFileDataItem(XmlReader source, IProgressHandler handler) { ExternalFileData data = null; if (!source.IsEmptyElement) { string uid = XukAble.ReadXukAttribute(source, XukAble.Uid_NAME); while (source.Read()) { if (source.NodeType == XmlNodeType.Element) { data = Presentation.ExternalFilesDataFactory.Create_SkipManagerInitialization(source.LocalName, source.NamespaceURI); if (data != null) { string uid_ = XukAble.ReadXukAttribute(source, XukAble.Uid_NAME); data.XukIn(source, handler); if (string.IsNullOrEmpty(uid_) && !string.IsNullOrEmpty(uid)) { data.Uid = uid; } if (string.IsNullOrEmpty(data.Uid)) { throw new exception.XukException( "uid attribute is missing from mExternalFileDataItem attribute"); } Presentation.ExternalFilesDataManager.AddManagedObject_NoSafetyChecks(data, data.Uid); //if (IsManagerOf(data.Uid)) //{ // if (GetManagedObject(data.Uid) != data) // { // throw new exception.XukException( // String.Format("Another ExternalFileData exists in the manager with uid {0}", data.Uid)); // } //} //else //{ // SetUidOfManagedObject(data, data.Uid); //} } } else if (source.NodeType == XmlNodeType.EndElement) { break; } if (source.EOF) { throw new exception.XukException("Unexpectedly reached EOF"); } } } }
/// <summary> /// Reads the attributes of a XmlProperty xuk element. /// </summary> /// <param name="source">The source <see cref="XmlReader"/></param> protected override void XukInAttributes(XmlReader source) { base.XukInAttributes(source); string ln = XukAble.ReadXukAttribute(source, XukAble.LocalName_NAME); if (string.IsNullOrEmpty(ln)) { throw new exception.XukException("LocalName attribute is missing from XmlProperty element"); } string nsUri = XukAble.ReadXukAttribute(source, XukAble.NamespaceUri_NAME); SetQName(ln, nsUri == null ? "" : nsUri); }
/// <summary> /// Reads the attributes of a AbstractMedia xuk element. /// </summary> /// <param name="source">The source <see cref="XmlReader"/></param> protected override void XukInAttributes(XmlReader source) { base.XukInAttributes(source); string lang = XukAble.ReadXukAttribute(source, XukAble.Language_NAME); if (lang != null) { lang = lang.Trim(); } if (lang == "") { lang = null; } Language = lang; }
/// <summary> /// Reads the attributes of a XmlAttribute xuk element. /// </summary> /// <param name="source">The source <see cref="XmlReader"/></param> protected override void XukInAttributes(XmlReader source) { base.XukInAttributes(source); string name = XukAble.ReadXukAttribute(source, XukAble.LocalName_NAME); if (string.IsNullOrEmpty(name)) { throw new exception.XukException("LocalName attribute of XmlAttribute element is missing"); } string value = XukAble.ReadXukAttribute(source, XukAble.Value_NAME); if (value == null) { throw new exception.XukException("Value attribute of XmlAttribute element is missing"); } Value = value; string ns = XukAble.ReadXukAttribute(source, XukAble.NamespaceUri_NAME); SetQName(name, ns == null ? "" : ns); }
protected override void XukInAttributes(XmlReader source) { base.XukInAttributes(source); string name = XukAble.ReadXukAttribute(source, XukAble.Name_NAME); if (string.IsNullOrEmpty(name)) { throw new exception.XukException("Name attribute of MetadataAttribute element is missing"); } Name = name; string ns = XukAble.ReadXukAttribute(source, XukAble.NamespaceUri_NAME); NamespaceUri = ns; string value = XukAble.ReadXukAttribute(source, XukAble.Value_NAME); //if (string.IsNullOrEmpty(value)) //{ // throw new exception.XukException("Value attribute of MetadataAttribute element is missing"); //} Value = value; }
private void XukInDataProviderItem(XmlReader source, IProgressHandler handler) { if (!source.IsEmptyElement) { string uid = XukAble.ReadXukAttribute(source, XukAble.Uid_NAME); bool addedProvider = false; while (source.Read()) { if (source.NodeType == XmlNodeType.Element) { DataProvider prov = Presentation.DataProviderFactory.Create_SkipManagerInitialization("", source.LocalName, source.NamespaceURI); if (prov != null) { if (addedProvider) { throw new exception.XukException( "Multiple DataProviders within the same mDataProviderItem is not supported"); } prov.XukIn(source, handler); //string uid_ = source.GetAttribute(XukStrings.Uid); if (string.IsNullOrEmpty(prov.Uid) && !string.IsNullOrEmpty(uid)) { prov.Uid = uid; } Presentation.DataProviderManager.AddManagedObject_NoSafetyChecks(prov, prov.Uid); //if (IsManagerOf(prov.Uid)) //{ // if (GetManagedObject(prov.Uid) != prov) // { // throw new exception.XukException( // String.Format("Another DataProvider exists in the manager with uid {0}", prov.Uid)); // } //} //else //{ // SetUidOfManagedObject(prov, prov.Uid); //} if (prov is FileDataProvider) { FileDataProvider fdProv = (FileDataProvider)prov; foreach (string path in mXukedInFilDataProviderPaths) { if (path.Equals(fdProv.DataFileRelativePath, StringComparison.OrdinalIgnoreCase)) { throw new exception.XukException(String.Format( "Another FileDataProvider using data file {0} has already been Xukked in", fdProv.DataFileRelativePath)); } } if (!File.Exists(fdProv.DataFileFullPath)) { Presentation.DataProviderManager.RemoveManagedObject(fdProv); return; } mXukedInFilDataProviderPaths.Add(fdProv.DataFileRelativePath); } addedProvider = true; } else if (!source.IsEmptyElement) { source.ReadSubtree().Close(); } } else if (source.NodeType == XmlNodeType.EndElement) { break; } if (source.EOF) { throw new exception.XukException("Unexpectedly reached EOF"); } } } }
private void XukInWavClip(XmlReader source) { string clipBeginAttr = source.GetAttribute(XukStrings.ClipBegin); Time cb = Time.Zero; if (clipBeginAttr != null) { try { cb = new Time(clipBeginAttr); } catch (Exception e) { throw new exception.XukException( String.Format("Invalid clip begin time {0}", clipBeginAttr), e); } } string clipEndAttr = source.GetAttribute(XukStrings.ClipEnd); Time ce = null; if (clipEndAttr != null) { try { ce = new Time(clipEndAttr); } catch (Exception e) { throw new exception.XukException( String.Format("Invalid clip end time {0}", clipEndAttr), e); } } string dataProviderUid = XukAble.ReadXukAttribute(source, DataProvider.DataProvider_NAME); if (String.IsNullOrEmpty(dataProviderUid)) { throw new exception.XukException("dataProvider attribute is missing from WavClip element"); } //if (!Presentation.DataProviderManager.IsManagerOf(dataProviderUid)) //{ // throw new exception.IsNotManagerOfException( // String.Format("DataProvider cannot be found {0}", dataProviderUid)); //} try { DataProvider prov = Presentation.DataProviderManager.GetManagedObject(dataProviderUid); mWavClips.Add(new WavClip(prov, cb, ce)); } catch (DataMissingException ex) { // TODO: this is a temporary fix ! // Instead of ignoring the fact that the underlying audio resource is missing, // we should have a system to let the consumer of the SDK // (i.e. the host application) know about the error and decide about the processing // (i.e. abandon parsing or carry-on by ignoring the resource). // This relates to the global issue of configurable error recovery, // not only for the data attached to the XUK instance, // but also for corrupted XUK markup or values. Presentation.Project.notifyDataIsMissing(this, ex); } catch (Exception ex) //MethodParameterIsOutOfBoundsException IsNotManagerOfException { Presentation.Project.notifyDataIsMissing(this, new DataMissingException(ex.Message, ex)); } if (!source.IsEmptyElement) { source.ReadSubtree().Close(); } }
private void XukInChannelItem(XmlReader source, IProgressHandler handler) { bool foundChannel = false; if (!source.IsEmptyElement) { string uid = XukAble.ReadXukAttribute(source, XukAble.Uid_NAME); while (source.Read()) { if (source.NodeType == XmlNodeType.Element) { Channel newCh = Presentation.ChannelFactory.Create_SkipManagerInitialization(source.LocalName, source.NamespaceURI); if (newCh != null) { string uid_ = XukAble.ReadXukAttribute(source, XukAble.Uid_NAME); newCh.XukIn(source, handler); if (string.IsNullOrEmpty(uid_) && !string.IsNullOrEmpty(uid)) { newCh.Uid = uid; } if (string.IsNullOrEmpty(newCh.Uid)) { throw new exception.XukException("mChannelItem element has no uid attribute"); } Presentation.ChannelsManager.AddManagedObject_NoSafetyChecks(newCh, newCh.Uid); //if (IsManagerOf(newCh.Uid)) //{ // if (GetManagedObject(newCh.Uid) != newCh) // { // throw new exception.XukException( // String.Format("Another MediaData exists in the manager with uid {0}", newCh.Uid)); // } //} //else //{ // SetUidOfManagedObject(newCh, newCh.Uid); //} foundChannel = true; } else if (!source.IsEmptyElement) { source.ReadSubtree().Close(); } } else if (source.NodeType == XmlNodeType.EndElement) { break; } if (source.EOF) { throw new exception.XukException("Unexpectedly reached EOF"); } } } if (!foundChannel) { throw new exception.XukException("Fould no Channel inside mChannelItem"); } }