예제 #1
0
        /// <summary>
        /// Represents an OML file with manipulable OML headers and XML fragments.
        /// </summary>
        /// <param name="omlStream">Input stream containing the OML file contents.</param>
        public Oml(Stream omlStream)
        {
            if (AssemblyUtility.PlatformVersion == null)
            {
                throw new Exception("Platform version must be defined before loading the OML content.");
            }

            PlatformVersion = AssemblyUtility.PlatformVersion;
            Type assemblyType = AssemblyUtility.GetAssemblyType("OutSystems.Common", "OutSystems.Oml.Oml");

            try
            {
                _instance = Activator.CreateInstance(assemblyType, new object[] { omlStream, false, null, null });
                Header    = new OmlHeader(this);
            }
            catch (Exception e)
            {
                if (e.GetBaseException() is AssemblyUtilityException)
                {
                    throw e.GetBaseException();
                }
                else if (e.InnerException != null && e.InnerException.GetType().Name.Equals("UnsupportedNewerVersion"))
                {
                    throw e.InnerException;
                }
                else
                {
                    throw new Exception("Unable to load OML. Make sure the given OML content is valid.", e);
                }
            }

            // Set OML version to the current version
            Header.Version = PlatformVersion.Version;
        }
예제 #2
0
 /// <summary>
 /// Creates an fragment XML reader instance.
 /// </summary>
 /// <param name="oml">OML instance which owns the fragment.</param>
 /// <param name="fragmentName">Name of the fragment to be written.</param>
 public OmlFragmentWriter(Oml oml, string fragmentName)
 {
     _instance = AssemblyUtility.ExecuteInstanceMethod <object>(oml._instance, "GetFragmentXmlWriter", new object[] { fragmentName });
 }
예제 #3
0
 /// <summary>
 /// Closes the writer.
 /// </summary>
 public void Close()
 {
     AssemblyUtility.ExecuteInstanceMethod <object>(_instance, "Close");
 }
예제 #4
0
 /// <summary>
 /// Writes XML to the fragment.
 /// </summary>
 /// <param name="fragment">XML to be written to the fragment.</param>
 public void Write(XElement fragment)
 {
     AssemblyUtility.ExecuteInstanceMethod <object>(_instance, "Replace", new object[] { fragment });
 }
예제 #5
0
 /// <summary>
 /// Class representing the main headers of the OML, allowing value modifications.
 /// </summary>
 /// <param name="oml">OML instance from which the header belongs to.</param>
 public OmlHeader(Oml oml)
 {
     _instance = AssemblyUtility.GetInstanceField <object>(oml._instance, "Header");
 }
예제 #6
0
 /// <summary>
 /// Exports the OML contents to an OML stream.
 /// </summary>
 /// <param name="outputStream">Destination stream to write the OML file contents to.</param>
 public void Save(Stream outputStream)
 {
     AssemblyUtility.ExecuteInstanceMethod <object>(_instance, "WriteTo", new object[] { outputStream });
 }
예제 #7
0
 /// <summary>
 /// Returns a list of available fragment names.
 /// </summary>
 /// <returns>List of availabel fragment names.</returns>
 public List <string> GetFragmentNames()
 {
     return(AssemblyUtility.ExecuteInstanceMethod <IEnumerable <string> >(_instance, "DumpFragmentsNames").ToList());
 }
 /// <summary>
 /// Returns XML element of the fragment.
 /// </summary>
 /// <returns>XML element of the fragment.</returns>
 public XElement GetXElement()
 {
     return(AssemblyUtility.ExecuteInstanceMethod <XElement>(_instance, "ToXElement"));
 }