/// <summary>
 /// Construct a storage object connected to the given filename.
 /// </summary>
 /// <param name="filename"></param>
 public OnlineTransactionStorage( OnlineReaderInfo reader, string filename )
 {
     this.filename = filename;
     this.source = reader.Name;
 }
Example #2
0
        /// <summary>
        /// Gets a list of configured OnlineReaders.
        /// </summary>
        /// <returns></returns>
        public List<OnlineReaderInfo> GetReaders()
        {
            List<OnlineReaderInfo> readerList = new List<OnlineReaderInfo>();

            DirectoryInfo dirInfo = new DirectoryInfo( ConfigurationManager.AppSettings["ReaderDir"] );

            // Specify evidence to load the assembly with restricted permissions.
            object[] hostEvidence = { new Zone( SecurityZone.MyComputer ) };
            Evidence evidence = new Evidence( hostEvidence, null );

            // Enumerate each DLL in the directory
            foreach( FileInfo fileInfo in dirInfo.GetFiles( "*.dll" ) )
            {
                // Load the DLL as an assembly
                AssemblyName assemblyName = new AssemblyName();
                assemblyName.CodeBase = fileInfo.FullName;
                Assembly assembly = Assembly.Load( assemblyName, evidence );

                // Enumerate each type in the assembly looking for
                // something that implements IOnlineReader
                foreach( Type assemblyType in assembly.GetTypes() )
                {
                    if( assemblyType.GetInterface( "UvMoney.Online.IOnlineReader" ) != null )
                    {
                        // Create an instance of the reader class
                        IOnlineReader reader = (IOnlineReader)assembly.CreateInstance( assemblyType.FullName );

                        // Console.WriteLine( "Found {0}", reader.GetType().FullName );

                        // Record information about the reader
                        OnlineReaderInfo readerInfo = new OnlineReaderInfo();
                        readerInfo.Name = reader.Name;
                        readerInfo.Reader = reader;
                        readerInfo.Credentials = GetCredentials( reader.Name );
                        readerList.Add( readerInfo );
                    }
                }
            }

            return readerList;
        }