Example #1
0
        /// <summary>
        /// Calculate metatable statistics for each broker type
        /// </summary>
        /// <param name="factoryName"></param>
        /// <returns></returns>

        public static int UpdateStats(
            string factoryName)
        {
            int total = 0;

            if (Lex.Eq(factoryName, "Generic") || Lex.IsNullOrEmpty(factoryName))
            {
                if (Instance == null)
                {
                    Instance = new MetaTableFactory();
                }
                total += Instance.UpdateMetaTableStatistics();
            }

            for (int i1 = 0; i1 < MetaFactories.Count; i1++)
            {
                MetaTableFactoryRef mtfr = MetaFactories[i1];

                if (!String.IsNullOrEmpty(factoryName) && Lex.Ne(mtfr.Name, factoryName))
                {
                    continue;                     // skip if name supplied and this isn't it
                }
                int cnt = mtfr.MetaTableFactory.UpdateMetaTableStatistics();
                total += cnt;
            }

            return(total);
        }
Example #2
0
        /// <summary>
        /// Register a new factory
        /// </summary>
        /// <param name="name"></param>
        /// <param name="factory"></param>

        public static void RegisterFactory(
            string name,
            IMetaFactory factory)
        {
            MetaTableFactoryRef mtfr = new MetaTableFactoryRef();

            mtfr.Name             = name;
            mtfr.MetaTableFactory = factory;
            MetaFactories.Add(mtfr);
            return;
        }
Example #3
0
        /// <summary>
        /// Lookup a MetaTable by name throwing any exceptions from underlying factories
        /// </summary>
        /// <param name="name"></param>
        /// <returns>MetaTable or null if not found</returns>
        ///

        public MetaTable GetMetaTable(
            String name)
        {
            MetaTable mt;

            if (RestrictedMetaTables.MetatableIsRestricted(name))
            {
                return(null);
            }

            if (RestrictedMetatable.MetatableIsGenerallyRestricted(name))
            {
                return(null);
            }

            name = name.Trim().ToUpper();

            if (MetaTableCollection.TableMap.ContainsKey(name))
            {             // see if in collection already
                mt = MetaTableCollection.TableMap[name];
                return(mt);
            }

            for (int i1 = 0; i1 < MetaFactories.Count; i1++)
            {
                MetaTableFactoryRef mtfr = MetaFactories[i1];
                mt = mtfr.MetaTableFactory.GetMetaTable(name);

                if (mt != null)
                {
                    NormalizeMetaTable(mt);
                    return(mt);
                }
            }

            // Check to see if this is a summary table that can be created from an unsummarized version of itself

            if (!Lex.EndsWith(name, MetaTable.SummarySuffix))
            {
                return(null);                                                          // see if named as summary table
            }
            string    name2 = name.Substring(0, name.Length - MetaTable.SummarySuffix.Length);
            MetaTable mt2   = MetaTableCollection.Get(name2);

            if (mt2 == null || !mt2.SummarizedExists)
            {
                return(null);
            }
            mt = mt2.Clone();
            AdjustForSummarization(mt, true);
            return(mt);
        }
Example #4
0
        /// <summary>
        /// Load metatable stats for tables associated with each factory
        /// </summary>
        /// <returns></returns>

        public static int LoadMetaTableStats()
        {
            int cnt;

            TableStats = new Dictionary <string, MetaTableStats>();

            int total = 0;

            for (int i1 = 0; i1 < MetaFactories.Count; i1++)
            {
                MetaTableFactoryRef mtfr = MetaFactories[i1];
                cnt    = mtfr.MetaTableFactory.LoadMetaTableStats(TableStats);
                total += cnt;
            }

            // Load generic persisted metatable stats

            string fileName = MetaTableXmlFolder + @"\GenericMetaTableStats.txt";

            cnt    = LoadMetaTableStats(fileName, TableStats);
            total += cnt;

            return(total);
        }