Пример #1
0
        /// <summary>
        /// Load a session from file.
        /// </summary>
        /// <param name="fileName">file with extension <c>.SES</c></param>
        /// <returns>
        /// Returns a session of type;
        /// <list type="bullet">
        /// <item>Dvtk.Sessions.ScriptSession</item>
        /// <item>Dvtk.Sessions.EmulatorSession</item>
        /// <item>Dvtk.Sessions.MediaSession</item>
        /// </list>
        /// </returns>
        /// <remarks>
        /// The type of session is dynamically determined.
        /// </remarks>
        public Session Load(FileName fileName)
        {
            if (fileName == null)
            {
                throw new ArgumentNullException();
            }
            System.IO.FileInfo fileInfo = new System.IO.FileInfo(fileName);
            if (!fileInfo.Exists)
            {
                throw new ArgumentException();
            }
            //
            // Transform fileName to fully qualified file name.
            //
            fileName = fileInfo.FullName;
            Session session = null;

            Wrappers.MBaseSession adaptee =
                Wrappers.MSessionFactory.Load(fileName);
            switch (adaptee.SessionType)
            {
            case Wrappers.SessionType.SessionTypeEmulator:
                session = new EmulatorSession(adaptee);
                break;

            case Wrappers.SessionType.SessionTypeMedia:
                session = new MediaSession(adaptee);
                break;

            case Wrappers.SessionType.SessionTypeScript:
                session = new ScriptSession(adaptee);
                break;

            case Wrappers.SessionType.SessionTypeSniffer:
                session = new SnifferSession(adaptee);
                break;

            case Wrappers.SessionType.SessionTypeUnknown:
                // Unknown Wrappers.SessionType
                throw new System.NotImplementedException();
            }
            return(session);
        }
Пример #2
0
        /// <summary>
        /// Copy all settings from the supplied EmulatorSession to this EmulatorSession.
        /// </summary>
        /// <param name="emulatorSession">The EmulatorSession to copy the settings from.</param>
        public virtual void CopySettingsFrom(EmulatorSession emulatorSession)
        {
            base.CopySettingsFrom(emulatorSession);

            AddGroupLength = emulatorSession.AddGroupLength;
            AutoType2Attributes = emulatorSession.AutoType2Attributes;
            DefineSqLength = emulatorSession.DefineSqLength;

            // DvtSystemSettings.
            DvtSystemSettings.AeTitle = emulatorSession.DvtSystemSettings.AeTitle;
            DvtSystemSettings.ImplementationClassUid = emulatorSession.DvtSystemSettings.ImplementationClassUid;
            DvtSystemSettings.ImplementationVersionName = emulatorSession.DvtSystemSettings.ImplementationVersionName;
            DvtSystemSettings.MaximumLengthReceived = emulatorSession.DvtSystemSettings.MaximumLengthReceived;
            DvtSystemSettings.Port = emulatorSession.DvtSystemSettings.Port;
            DvtSystemSettings.SocketTimeout = emulatorSession.DvtSystemSettings.SocketTimeout;

            // Printer. All properties are read-only. The only two properties that can indirectly be set
            // by a method call are Status and StatusInfo.
            Printer.ApplyStatus(emulatorSession.Printer.Status, emulatorSession.Printer.StatusInfo, false);

            ScpEmulatorType = emulatorSession.ScpEmulatorType;
            ScuEmulatorType = emulatorSession.ScuEmulatorType;

            if (emulatorSession.SecuritySettings.SecureSocketsEnabled)
            {
                // SecuritySettings.
                SecuritySettings.CacheTlsSessions = emulatorSession.SecuritySettings.CacheTlsSessions;
                SecuritySettings.CertificateFileName = emulatorSession.SecuritySettings.CertificateFileName;
                SecuritySettings.CheckRemoteCertificate = emulatorSession.SecuritySettings.CheckRemoteCertificate;
                SecuritySettings.CipherFlags = emulatorSession.SecuritySettings.CipherFlags;
                SecuritySettings.CredentialsFileName = emulatorSession.SecuritySettings.CredentialsFileName;
                SecuritySettings.SecureSocketsEnabled = emulatorSession.SecuritySettings.SecureSocketsEnabled;
                SecuritySettings.TlsCacheTimeout = emulatorSession.SecuritySettings.TlsCacheTimeout;
                SecuritySettings.TlsPassword = emulatorSession.SecuritySettings.TlsPassword;
                SecuritySettings.TlsVersionFlags = emulatorSession.SecuritySettings.TlsVersionFlags;
            }
            foreach(DvtkData.Dul.TransferSyntax transferSyntax in emulatorSession.SupportedTransferSyntaxSettings.SupportedTransferSyntaxes)
            {
                SupportedTransferSyntaxSettings.SupportedTransferSyntaxes.Add(transferSyntax);
            }

            // SutSystemSettings.
            SutSystemSettings.AeTitle = emulatorSession.SutSystemSettings.AeTitle;
            SutSystemSettings.CommunicationRole = emulatorSession.SutSystemSettings.CommunicationRole;
            SutSystemSettings.HostName = emulatorSession.SutSystemSettings.HostName;
            SutSystemSettings.ImplementationClassUid = emulatorSession.SutSystemSettings.ImplementationClassUid;
            SutSystemSettings.ImplementationVersionName = emulatorSession.SutSystemSettings.ImplementationVersionName;
            SutSystemSettings.MaximumLengthReceived = emulatorSession.SutSystemSettings.MaximumLengthReceived;
            SutSystemSettings.Port = emulatorSession.SutSystemSettings.Port;
        }
Пример #3
0
 /// <summary>
 /// Load a session from file.
 /// </summary>
 /// <param name="fileName">file with extension <c>.SES</c></param>
 /// <returns>
 /// Returns a session of type;
 /// <list type="bullet">
 /// <item>Dvtk.Sessions.ScriptSession</item>
 /// <item>Dvtk.Sessions.EmulatorSession</item>
 /// <item>Dvtk.Sessions.MediaSession</item>
 /// </list>
 /// </returns>
 /// <remarks>
 /// The type of session is dynamically determined.
 /// </remarks>
 public Session Load(FileName fileName)
 {
     if (fileName == null) throw new ArgumentNullException();
     System.IO.FileInfo fileInfo = new System.IO.FileInfo(fileName);
     if (!fileInfo.Exists) throw new ArgumentException();
     //
     // Transform fileName to fully qualified file name.
     //
     fileName = fileInfo.FullName;
     Session session = null;
     Wrappers.MBaseSession adaptee =
         Wrappers.MSessionFactory.Load(fileName);
     switch (adaptee.SessionType)
     {
         case Wrappers.SessionType.SessionTypeEmulator:
             session = new EmulatorSession(adaptee);
             break;
         case Wrappers.SessionType.SessionTypeMedia:
             session = new MediaSession(adaptee);
             break;
         case Wrappers.SessionType.SessionTypeScript:
             session = new ScriptSession(adaptee);
             break;
         case Wrappers.SessionType.SessionTypeUnknown:
             // Unknown Wrappers.SessionType
             throw new System.NotImplementedException();
     }
     return session;
 }
Пример #4
0
 /// <summary>
 /// Method to create the instance of a session. 
 /// </summary>
 /// <param name="sessionFileName"> FileName of the EmulatorSession.</param>
 protected override void CreateSessionInstance(string sessionFileName)
 {
     if (Implementation == null) {
         Implementation = new DvtkSession.EmulatorSession();
         LoadSession();
     }
 }
Пример #5
0
 /// <summary>
 /// Method to create the instance of a EmulatorSession.
 /// </summary>
 protected override void CreateSessionInstance()
 {
     if (Implementation == null) {
         Implementation = new DvtkSession.EmulatorSession();
     }
 }