コード例 #1
0
        static void LoadVersionToTablesIndex()
        {
            m_VersionToTablesIndex = new Dictionary <SoftwareVersion, ITableNames>();

            List <Type> types = new List <Type>(Assembly.GetCallingAssembly().GetTypes());

            /**
             * roll through this assembly (Common) and load and index
             * implementers of itablenames with a version attribute
             */
            foreach (Type type in types)
            {
                if (typeof(ITableNames).IsAssignableFrom(type))
                {
                    DatabaseVersionAttribute[] attribs = (DatabaseVersionAttribute[])type.GetCustomAttributes(typeof(DatabaseVersionAttribute), false);
                    if (attribs.Length > 0)
                    {
                        ITableNames names = (type.GetConstructor(new Type[] {})).Invoke(new Object[] {}) as ITableNames;
                        m_VersionToTablesIndex.Add(((DatabaseVersionAttribute)attribs[0]).Versions[0], names);
                    }
                }
            }
        }
コード例 #2
0
        bool TryLoadAppropriateTableNames(out ITableNames tableNames)
        {
            /** get the highest version of the database we support */
            tableNames = null;
            SoftwareVersion highestTablesVersionSupported = new SoftwareVersion();
            SoftwareVersion highestDataSourceVersion      = Versions.Max();

            foreach (SoftwareVersion tableNamesVersion in m_VersionToTablesIndex.Keys)
            {
                if (highestDataSourceVersion >= tableNamesVersion && tableNamesVersion > highestTablesVersionSupported)
                {
                    highestTablesVersionSupported = tableNamesVersion;
                    tableNames = m_VersionToTablesIndex[highestTablesVersionSupported];
                }
            }

            if (tableNames == null)
            {
                tableNames = m_VersionToTablesIndex[m_VersionToTablesIndex.Keys.Min()];
            }

            return(tableNames != null);
        }
コード例 #3
0
 public DataSourceCachedInfo(List <SoftwareVersion> versions, ITableNames tableNames)
 {
     Versions   = versions;
     TableNames = tableNames;
 }