Beispiel #1
0
 protected void ValidateIndexDescription(string index)
 {
     if (!IndexingStrategy.IsValidIndexingStrategy(index))
     {
         throw new ValidationException(string.Format("Invalid index: {0}", index));
     }
 }
Beispiel #2
0
        public new void Execute(FigaroContext context, string args)
        {
            base.Execute(context, args);
            var uri  = string.Empty;
            var node = string.Empty;

            if (Uri.IsWellFormedUriString(argv[0], UriKind.Absolute))
            {
                uri = argv[0];
            }
            else
            {
                if (!IndexingStrategy.IsValidIndexingStrategy(argv[0]))
                {
                    node = argv[0];
                }
            }

            var idx = from a in argv
                      where IndexingStrategy.IsValidIndexingStrategy(a)
                      select a;

            foreach (var index in idx)
            {
                context.AddIndex(uri, node, index);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Add an indexing strategy for metadata-based lookups of different message types.
        /// </summary>
        public void ConfigureContainerIndex()
        {
            /*
             * Add an indexing strategy for our metadata lookup
             */

            // IndexingStrategy helps us build the string that defines our index.
            // See http://help.bdbxml.net/html/T_Figaro_IndexingStrategy.htm for more information.
            // (note: IndexingStrategy is not an IDisposable)
            //
            // in this case, we're building a non-unique, node path, metadata string equality index.
            var strat = new IndexingStrategy(false, IndexPathType.NodePath, IndexNodeType.Metadata, IndexKeyType.Equality, XmlDatatype.String);

            using (var tx = Manager.CreateTransaction())
            {
                try
                {
                    using (var uc = Manager.CreateUpdateContext()) { BeerDb.AddIndex(tx, META_URI, "category", strat.ToString(), uc); }
                    tx.Commit();
                }
                catch (Exception ex)
                {
                    tx.Abort();
                    Console.WriteLine($"[ConfigureContainerIndex] {ex.GetType()}: {ex.Message}");
                }
            }
        }