/// <summary>
        /// Converts to a <see cref="XElement"/> instance.
        /// </summary>
        /// <param name="includeExtraMetada">Include or not extra metadata.</param>
        /// <returns>A <see cref="XElement"/> instance.</returns>
        public new XElement ToXElement(bool includeExtraMetada = false)
        {
            // Metadata
            List <XAttribute> metadatas = new List <XAttribute> {
                new XAttribute(nameof(Name), Name),
                new XAttribute(nameof(CreatedAt), CreatedAt.ToString("yyyy-MM-dd HH:mm:ss zzz"))
            };

            if (includeExtraMetada)
            {
                metadatas.Add(new XAttribute(nameof(UUID), UUID));
                metadatas.Add(new XAttribute(nameof(LastLaunchedAt), LastLaunchedAt.ToString("yyyy-MM-dd HH:mm:ss zzz")));
            }

            return(new XElement(RootNodeName,
                                // Metadata
                                metadatas.ToArray(),
                                //VGPU
                                new XElement(nameof(VGpu), VGpu.ToString()),
                                // Networking
                                new XElement(nameof(Networking), Networking.ToString()),
                                // Mapped Folders
                                new XElement(nameof(MappedFolders),
                                             MappedFolders.Select(mf =>
                                                                  new XElement(nameof(MappedFolder),
                                                                               new XElement(nameof(mf.HostFolder), mf.HostFolder),
                                                                               new XElement(nameof(mf.ReadOnly), mf.ReadOnly.ToString().ToLower())
                                                                               )
                                                                  )
                                             ),
                                // Logon Command
                                new XElement(nameof(LogonCommand),
                                             new XElement(nameof(LogonCommand.Command), LogonCommand.Command)
                                             ),
                                // Audio Input
                                new XElement(nameof(AudioInput), AudioInput.ToString()),
                                // Video Input
                                new XElement(nameof(VideoInput), VideoInput.ToString()),
                                // Protected Client
                                new XElement(nameof(ProtectedClient), ProtectedClient.ToString()),
                                // Printer Redirection
                                new XElement(nameof(PrinterRedirection), PrinterRedirection.ToString()),
                                // Clipboard Redirection
                                new XElement(nameof(ClipboardRedirection), ClipboardRedirection.ToString()),
                                // Memory in MB
                                new XElement(nameof(MemoryInMB),
                                             new XElement(nameof(MemoryInMB.AmountInMB), MemoryInMB.AmountInMB.ToString()),
                                             new XElement(nameof(MemoryInMB.Enabled), MemoryInMB.Enabled.ToString())
                                             )
                                ));
        }
Beispiel #2
0
 /// <summary>
 /// Converts to a <see cref="XElement"/> instance.
 /// </summary>
 /// <param name="includeExtraMetada">Include or not extra metadata.</param>
 /// <returns>A <see cref="XElement"/> instance.</returns>
 public virtual XElement ToXElement(bool includeExtraMetada = false) =>
 new XElement(RootNodeName,
              //VGPU
              new XElement(nameof(VGpu), VGpu.ToString()),
              // Networking
              new XElement(nameof(Networking), Networking.ToString()),
              // Mapped Folders
              new XElement(nameof(MappedFolders),
                           MappedFolders.Select(mf =>
                                                new XElement(nameof(MappedFolder),
                                                             new XElement(nameof(mf.HostFolder), mf.HostFolder),
                                                             new XElement(nameof(mf.ReadOnly), mf.ReadOnly.ToString().ToLower())
                                                             )
                                                )
                           ),
              // Logon Command
              new XElement(nameof(LogonCommand),
                           new XElement(nameof(LogonCommand.Command), LogonCommand.Command)
                           )
              );
        /// <summary>
        /// Converts to a <see cref="XElement"/> instance.
        /// </summary>
        /// <param name="includeExtraMetada">Include or not extra metadata.</param>
        /// <returns>A <see cref="XElement"/> instance.</returns>
        public XElement ToXElement(bool includeExtraMetada = false)
        {
            List <XElement> nodes = new List <XElement>
            {
                //VGPU
                new XElement(nameof(VGpu), VGpu.ToString()),
                // Networking
                new XElement(nameof(Networking), Networking.ToString()),
                // Mapped Folders
                new XElement(nameof(MappedFolders),
                             MappedFolders.Select(mf =>
                                                  new XElement(nameof(MappedFolder),
                                                               new XElement(nameof(mf.HostFolder), mf.HostFolder),
                                                               new XElement(nameof(mf.ReadOnly), mf.ReadOnly.ToString().ToLower())
                                                               )
                                                  )
                             ),
                // Logon Command
                new XElement(nameof(LogonCommand),
                             new XElement(nameof(LogonCommand.Command), LogonCommand.Command)
                             ),
                // Audio Input
                new XElement(nameof(AudioInput), AudioInput.ToString()),
                // Video Input
                new XElement(nameof(VideoInput), VideoInput.ToString()),
                // Protected Client
                new XElement(nameof(ProtectedClient), ProtectedClient.ToString()),
                // Printer Redirection
                new XElement(nameof(PrinterRedirection), PrinterRedirection.ToString()),
                // Clipboard Redirection
                new XElement(nameof(ClipboardRedirection), ClipboardRedirection.ToString()),
            };

            if (MemoryInMB.Enabled && MemoryInMB.AmountInMB > 0)
            {
                // Memory in MB
                nodes.Add(new XElement(nameof(MemoryInMB), MemoryInMB.AmountInMB.ToString()));
            }

            return(new XElement(RootNodeName, nodes));
        }
        /// <summary>
        /// Converts to a <see cref="XElement"/> instance.
        /// </summary>
        /// <param name="includeExtraMetada">Include or not extra metadata.</param>
        /// <returns>A <see cref="XElement"/> instance.</returns>
        public override XElement ToXElement(bool includeExtraMetada = false)
        {
            // Metadata
            List <XAttribute> metadatas = new List <XAttribute> {
                new XAttribute(nameof(Name), Name),
                new XAttribute(nameof(CreatedAt), CreatedAt.ToString("yyyy-MM-dd HH:mm:ss zzz"))
            };

            if (includeExtraMetada)
            {
                metadatas.Add(new XAttribute(nameof(UUID), UUID));
                metadatas.Add(new XAttribute(nameof(LastLaunchedAt), LastLaunchedAt.ToString("yyyy-MM-dd HH:mm:ss zzz")));
            }

            return(new XElement(RootNodeName,
                                // Metadata
                                metadatas.ToArray(),
                                //VGPU
                                new XElement(nameof(VGpu), VGpu.ToString()),
                                // Networking
                                new XElement(nameof(Networking), Networking.ToString()),
                                // Mapped Folders
                                new XElement(nameof(MappedFolders),
                                             MappedFolders.Select(mf =>
                                                                  new XElement(nameof(MappedFolder),
                                                                               new XElement(nameof(mf.HostFolder), mf.HostFolder),
                                                                               new XElement(nameof(mf.ReadOnly), mf.ReadOnly.ToString().ToLower())
                                                                               )
                                                                  )
                                             ),
                                // Logon Command
                                new XElement(nameof(LogonCommand),
                                             new XElement(nameof(LogonCommand.Command), LogonCommand.Command)
                                             )
                                ));
        }