Exemple #1
0
        /// <summary>
        /// Static helper method to simplify reading from file
        /// </summary>
        /// <param name="photonDatabaseFileName">The filename for the PhotonDataPoint database (no ".txt")</param>
        /// <param name="collisionInfoDatabaseFileName">The filename for the CollisionInfo database (no ".txt")</param>
        /// <returns>A new instance of PhotonDatabase</returns>
        public static pMCDatabase FromFile(string photonDatabaseFileName, string collisionInfoDatabaseFileName)
        {
            var photonDatabase = PhotonDatabase.FromFile(photonDatabaseFileName);

            var collisionInfoDatabase = CollisionInfoDatabase.FromFile(collisionInfoDatabaseFileName);

            var zippedDataPoints = Enumerable.Zip(
                photonDatabase.DataPoints,
                collisionInfoDatabase.DataPoints,
                (photonDataPoint, collisionInfo) => new pMCDataPoint(photonDataPoint, collisionInfo));

            var pMCDatabase = new pMCDatabase(photonDatabase, collisionInfoDatabase);

            pMCDatabase.SetDataPoints(zippedDataPoints);

            return(pMCDatabase);
        }
Exemple #2
0
        /// <summary>
        /// Method to read database from file in resources.
        /// </summary>
        /// <param name="photonDatabaseFileName">PhotonDataPoint database name</param>
        /// <param name="collisionInfoDatabaseFileName">CollisionInfo database name</param>
        /// <param name="projectName">project name where the databases reside</param>
        /// <returns>pMCDatabase</returns>
        public static pMCDatabase FromFileInResources(
            string photonDatabaseFileName,
            string collisionInfoDatabaseFileName,
            string projectName)
        {
            var photonDatabase = PhotonDatabase
                                 .FromFileInResources(photonDatabaseFileName, projectName);

            var collisionInfoDatabase = CollisionInfoDatabase
                                        .FromFileInResources(collisionInfoDatabaseFileName, projectName);

            var pMCDatabase = new pMCDatabase(photonDatabase, collisionInfoDatabase);

            // sew the two things together in a lightweight pMCDataPoint object
            // (only exists in memory, the two database records are stored separately)
            var zippedDataPoints = Enumerable.Zip(
                photonDatabase.DataPoints,
                collisionInfoDatabase.DataPoints,
                (photonDataPoint, collisionInfo) => new pMCDataPoint(photonDataPoint, collisionInfo));

            pMCDatabase.SetDataPoints(zippedDataPoints);

            return(pMCDatabase);
        }