Exemplo n.º 1
0
        /// <summary>
        /// </summary>
        /// <param name="fsDriver">
        /// the IO Driver; can be null;
        /// </param>
        public DatabaseDriver(IFileSystemDriver fsDriver)
        {
            this.fsDriver = fsDriver;
            ISerializer standardSerializer   = new SerializerVersion0();
            ISerializer objectTypeSerializer = new SerializerVersion1();

            standardVectorSerializer = new VectorDataSerializer(fsDriver, standardSerializer);
            IVectorDataSerializer objectTypeVectorSerializer = new VectorDataSerializer(fsDriver, objectTypeSerializer);
            IVectorDataSerializer versionedVectorSerializer  = new VersionManager(objectTypeVectorSerializer, standardVectorSerializer);

            gridDatabaseDriver     = new GridDatabaseDriver(versionedVectorSerializer, fsDriver);
            sessionsDatabaseDriver = new SessionDatabaseDriver(standardSerializer, fsDriver);
            timestepDatabaseDriver = new TimeStepDatabaseDriver(standardVectorSerializer, fsDriver);
        }
 public VectorDataSerializer(IFileSystemDriver driver, ISerializer serializer)
 {
     this.serializer = serializer;
     m_fsDriver      = driver;
 }
Exemplo n.º 3
0
        /// <summary>
        /// Creates the appropriate file system driver for accessing the given
        /// <paramref name="path"/>
        /// </summary>
        /// <param name="path">
        /// A fully qualified path.
        /// </param>
        /// <returns>
        /// If <paramref name="path"/> starts with 'sftp', an
        /// <see cref="SFTPFileSystemDriver"/> will be used. If the path is
        /// null, <see cref="NullFileSystemDriver"/> will be used. Otherwise,
        /// a local path will be assumed, which thus makes use of
        /// <see cref="StandardFsDriver"/>
        /// </returns>
        public static IFileSystemDriver GetFileSystemDriver(string path)
        {
            if (fsDrivers.ContainsKey(path))
            {
                if (fsDrivers[path].IsDisposed)
                {
                    fsDrivers.Remove(path);
                }
                else
                {
                    return(fsDrivers[path]);
                }
            }
            IFileSystemDriver fsDriver   = null;
            string            sftpString = "sftp://";

            if (path.StartsWith(sftpString))
            {
                try {
                    string s    = path.Substring(sftpString.Length);
                    string user = s.Substring(0, s.IndexOf('@'));

                    s = s.Substring(s.IndexOf('@') + 1);
                    int hostPartEnd = s.IndexOf(':');

                    string host;
                    string relPath;
                    if (hostPartEnd >= 0)
                    {
                        host    = s.Substring(0, hostPartEnd);
                        relPath = s.Substring(s.IndexOf(':') + 1);
                    }
                    else
                    {
                        host    = s;
                        relPath = "/";
                    }

                    KeyboardInteractiveConnectionInfo ci =
                        new KeyboardInteractiveConnectionInfo(host, user);
                    ci.AuthenticationPrompt +=
                        delegate(object sender, AuthenticationPromptEventArgs arg) {
                        var prompt = arg.Prompts.SingleOrDefault(p => p.Request == "Password: "******"@" + host);
                        }
                    };
                    ci.Timeout = TimeSpan.FromSeconds(15);

                    fsDriver = new SFTPFileSystemDriver(ci, relPath);
                } catch (Exception) {
                    throw new ArgumentException(String.Format(
                                                    "Given path '{0}' has an invalid format", path));
                }
            }
            else
            {
                bool fi = File.Exists(path);
                bool di = Directory.Exists(path);
                if (fi || di)
                {
                    fsDriver = new StandardFsDriver(path);
                }
                else if (path == null)
                {
                    fsDriver = NullFileSystemDriver.Instance;
                }
                else
                {
                    string ErrMsg = String.Format("Could not find or access a database located at '{0}'", path);
                    throw new IOException(ErrMsg);
                    //Console.WriteLine("GetFilesystemDriver: 10 ");
                }
            }


            fsDrivers.Add(path, fsDriver);
            return(fsDriver);
        }
Exemplo n.º 4
0
 public GridDatabaseDriver(IVectorDataSerializer driver, IFileSystemDriver FsDriver)
 {
     fsDriver      = FsDriver;
     Driver        = driver;
     dynamicDriver = new ReflectionVectorDataSerializer(driver);
 }
Exemplo n.º 5
0
 public TimeStepDatabaseDriver(IVectorDataSerializer driver, IFileSystemDriver FsDriver)
 {
     fsDriver = FsDriver;
     Driver   = driver;
 }
Exemplo n.º 6
0
 public SessionDatabaseDriver(ISerializer driver, IFileSystemDriver FsDriver)
 {
     fsDriver = FsDriver;
     Driver   = driver;
 }