Example #1
0
        public IndexedDocumentCache(CopyFromIndexComponent component, string keyXPath, string valueXPath, XmlNamespaceManager context, int cacheSize)
        {
            if (component == null)
            {
                throw new ArgumentNullException("component");
            }
            if (cacheSize < 0)
            {
                throw new ArgumentOutOfRangeException("cacheSize");
            }

            this.component = component;

            try {
                keyExpression = XPathExpression.Compile(keyXPath);
            } catch (XPathException) {
                component.WriteHelperMessage(MessageLevel.Error, String.Format("The key expression '{0}' is not a valid XPath expression.", keyXPath));
            }
            keyExpression.SetContext(context);

            try {
                valueExpression = XPathExpression.Compile(valueXPath);
            } catch (XPathException) {
                component.WriteHelperMessage(MessageLevel.Error, String.Format("The value expression '{0}' is not a valid XPath expression.", valueXPath));
            }
            valueExpression.SetContext(context);

            this.cacheSize = cacheSize;

            // set up the cache
            cache = new Dictionary <string, IndexedDocument>(cacheSize);
            queue = new Queue <string>(cacheSize);
        }
Example #2
0
        public void AddDocument(string file)
        {
            // load the document
            IndexedDocument document = new IndexedDocument(this, file);

            // record the keys
            string[] keys = document.GetKeys();
            foreach (string key in keys)
            {
                if (index.ContainsKey(key))
                {
                    component.WriteHelperMessage(MessageLevel.Warn, String.Format("Entries for the key '{0}' occur in both '{1}' and '{2}'. The last entry will be used.", key, index[key], file));
                }
                index[key] = file;
            }
        }
        public IndexedDocumentCache(CopyFromIndexComponent component, string keyXPath, string valueXPath, XmlNamespaceManager context, int cacheSize) {

            if (component == null) throw new ArgumentNullException("component");
            if (cacheSize < 0) throw new ArgumentOutOfRangeException("cacheSize");

            this.component = component;

            try {
                keyExpression = XPathExpression.Compile(keyXPath);
            } catch (XPathException) {
                component.WriteHelperMessage(MessageLevel.Error, String.Format("The key expression '{0}' is not a valid XPath expression.", keyXPath));
            }
            keyExpression.SetContext(context);

            try {
                valueExpression = XPathExpression.Compile(valueXPath);
            } catch (XPathException) {
                component.WriteHelperMessage(MessageLevel.Error, String.Format("The value expression '{0}' is not a valid XPath expression.", valueXPath));
            }
            valueExpression.SetContext(context);

            this.cacheSize = cacheSize;

            // set up the cache
            cache = new Dictionary<string, IndexedDocument>(cacheSize);
            queue = new Queue<string>(cacheSize);
        }