Beispiel #1
0
 public AddSoundChoiceAction(TreeNode parent, IBackgroundSounds bgSounds, IXmlWritable importedElement, NodeCreator nodeCreator, out TreeNode node)
 {
     m_Parent  = parent;
     m_Element = bgSounds.AddImportedElement(importedElement);
     m_Node    = nodeCreator(m_Element);
     m_Index   = m_Parent.Nodes.Count;
     bgSounds.RemoveElement(m_Element.Id);
     node       = m_Node;
     m_BGSounds = bgSounds;
 }
Beispiel #2
0
        public IList <IElement> AddGeneralImportedElement(IXmlWritable writable)
        {
            List <IElement> result  = new List <IElement>();
            IElement        element = AddImportedElement(writable);

            if (element != null)
            {
                result.Add(element);
            }
            return(result);
        }
Beispiel #3
0
 private void ReadElements(IList <IXmlWritable> elements, XmlReader reader, String fileName)
 {
     while (reader.IsStartElement())
     {
         IXmlWritable element = ReadElement(reader, fileName);
         if (element != null)
         {
             elements.Add(element);
         }
     }
 }
Beispiel #4
0
        public IList <IElement> AddGeneralImportedElement(IXmlWritable element)
        {
            List <IElement> result = new List <IElement>();

            if (element is IChoiceElement)
            {
                IChoiceElement choice = element as IChoiceElement;
                if (choice.InnerElement is IFileElement)
                {
                    result.AddRange(m_ThirdContainer.AddGeneralImportedElement(element));
                    return(result);
                }
            }
            foreach (IFileElement fileElement in element.GetFileElements())
            {
                result.Add(m_ThirdContainer.AddElement(fileElement));
            }
            return(result);
        }
        public IList <IElement> AddGeneralImportedElement(IXmlWritable element)
        {
            List <IElement> result = new List <IElement>();

            if (element is ISequentialElement)
            {
                ISequentialElement sequential = element as ISequentialElement;
                if (sequential.InnerElement is IFileElement)
                {
                    result.AddRange(m_SecondContainer.AddGeneralImportedElement(element));
                    return(result);
                }
            }
            foreach (IFileElement fileElement in element.GetFileElements())
            {
                result.Add(m_SecondContainer.AddElement(fileElement));
            }
            return(result);
        }
Beispiel #6
0
        /// <summary>
        /// Converts an <see cref="IXmlWritable" /> to an XML string.
        /// </summary>
        /// <param name="xmlWritable">
        /// The object that can be converted to XML.
        /// </param>
        /// <param name="serializer">
        /// A serializer that can serialize custom content, in case the object
        /// contains custom content.
        /// </param>
        /// <param name="settings">
        /// Settings that control how the XML is formatted.
        /// </param>
        /// <returns>
        /// A string of characters containing XML corresponding to the data in
        /// the object.
        /// </returns>
        public static string ToXmlString(
            this IXmlWritable xmlWritable,
            IContentSerializer serializer,
            XmlWriterSettings settings)
        {
            if (xmlWritable == null)
            {
                throw new ArgumentNullException("xmlWritable");
            }

            var sb = new StringBuilder();

            using (var w = XmlWriter.Create(sb, settings))
            {
                xmlWritable.WriteTo(w, serializer);
                w.Flush();
                return(sb.ToString());
            }
        }
Beispiel #7
0
        public IBackgroundSoundChoice AddImportedElement(IXmlWritable writable)
        {
            ImportedChoice choice = writable as ImportedChoice;

            if (choice == null)
            {
                return(null);
            }
            BackgroundSoundChoice bgChoice        = choice.SoundChoice;
            IParallelElement      parallelElement = m_Container.AddElement(bgChoice);

            parallelElement.FixedStartDelay                = choice.ChoiceData.FixedStartDelay;
            parallelElement.FixedIntermediateDelay         = choice.ChoiceData.FixedIntermediateDelay;
            parallelElement.MaximumRandomStartDelay        = choice.ChoiceData.MaximumRandomStartDelay;
            parallelElement.MaximumRandomIntermediateDelay = choice.ChoiceData.MaximumRandomIntermediateDelay;
            parallelElement.RepeatCount = choice.ChoiceData.RepeatCount;
            bgChoice.ParallelElement    = parallelElement;
            m_Elements.Add(bgChoice);
            return(bgChoice);
        }
Beispiel #8
0
        public IList <IElement> AddGeneralImportedElement(IXmlWritable element)
        {
            List <IElement> result = new List <IElement>();
            T wrapper = element as T;

            if (wrapper != null)
            {
                m_Elements.Add(wrapper);
                result.Add(wrapper);
            }
            else if (element is IContainerElement)
            {
                return(AddGeneralImportedElement((element as IContainerElement).InnerElement));
            }
            else
            {
                I added = AddElement(element as IElement);
                if (added != null)
                {
                    result.Add(added);
                }
            }
            return(result);
        }
Beispiel #9
0
 public IList <IElement> AddGeneralImportedElement(IXmlWritable element)
 {
     throw new NotImplementedException();
 }
Beispiel #10
0
 public XmlFileWriter(IXmlWritable writeXml)
 {
     this.writeXml = writeXml;
 }
Beispiel #11
0
 private static IList <IFileElement> GetFileElements(HashSet <IXmlWritable> checkedReferences, IXmlWritable element)
 {
     if (element is IGeneralElementContainer)
     {
         return(GetFileElements(checkedReferences, (element as IGeneralElementContainer)));
     }
     else if (element is IContainerElement)
     {
         return(GetFileElements(checkedReferences, (element as IContainerElement).InnerElement));
     }
     else if (element is IReferenceElement)
     {
         if (!checkedReferences.Contains(element))
         {
             checkedReferences.Add(element);
             IElement             referencedElement = DataModule.ElementRepository.GetElement((element as IReferenceElement).ReferencedId);
             IList <IFileElement> result;
             if (referencedElement != null)
             {
                 result = GetFileElements(checkedReferences, referencedElement);
             }
             else
             {
                 result = new List <IFileElement>();
             }
             checkedReferences.Remove(element);
             return(result);
         }
         else
         {
             return(new List <IFileElement>());
         }
     }
     else
     {
         IList <IFileElement> result      = new List <IFileElement>();
         IFileElement         fileElement = element as IFileElement;
         if (fileElement != null)
         {
             result.Add(fileElement);
         }
         return(result);
     }
 }
Beispiel #12
0
 public static IList <IFileElement> GetFileElements(this IXmlWritable element)
 {
     return(GetFileElements(new HashSet <IXmlWritable>(), element));
 }
Beispiel #13
0
 /// <summary>
 /// Converts an <see cref="IXmlWritable" /> to an XML string.
 /// </summary>
 /// <param name="xmlWritable">
 /// The object that can be converted to XML.
 /// </param>
 /// <param name="serializer">
 /// A serializer that can serialize custom content, in case the object
 /// contains custom content.
 /// </param>
 /// <returns>
 /// A string of characters containing XML corresponding to the data in
 /// the object.
 /// </returns>
 /// <seealso cref="ToXmlString(IXmlWritable, IContentSerializer, XmlWriterSettings)" />
 public static string ToXmlString(
     this IXmlWritable xmlWritable,
     IContentSerializer serializer)
 {
     return(xmlWritable.ToXmlString(serializer, new XmlWriterSettings()));
 }