Exemplo n.º 1
0
 //when new word is picked
 public void ResetGame()
 {
     TheWordText.Text     = "The Word Being Guessed:";
     PossibleText.Text    = "# of Possible Words Left:";
     LettersLeftText.Text = "Letters Left:";
     BadGuessesText.Text  = "Bad Guesses:";
     GoodGuessesText.Text = "Good Guesses:";
     GuessesLeftText.Text = "Guesses Left:";
     GoodGuessesText.Hide();
     GuessCount           = 9;
     GameStarted          = true;
     GuessCountLabel.Text = GuessCount.ToString();
     GuessCountLabel.Show();
     WinningGif.Hide();
     RightButton.Show();
     WrongButton.Show();
     GuessText.Show();
     GoodGuesses     = "";
     BadGuesses      = "";
     PossibleLetters = "etainoshrdlucmfwygpbvkqjxz"; //most popular letters based on https://en.oxforddictionaries.com/explore/which-letters-are-used-most
     GuessesSoFar    = "";
     label1.Text     = "";
     label2.Text     = "";
     test.Text       = "";
     TheWord         = "";
     Guess           = PossibleLetters[0].ToString();
     label2.Text     = Guess;
     IndexButton.Hide();
     IndexInfo.Hide();
     TipText.Hide();
 }
        private void VisitIndexInfo(IndexInfo primaryIndex, IndexInfo index)
        {
            TableInfo table          = currentTable;
            var       secondaryIndex = CreateSecondaryIndex(table, index.MappingName, index);

            secondaryIndex.IsUnique = index.IsUnique;
            var isClustered = index.IsClustered && providerInfo.Supports(ProviderFeatures.ClusteredIndexes);

            secondaryIndex.IsClustered = isClustered;
            foreach (KeyValuePair <ColumnInfo, Direction> pair in index.KeyColumns)
            {
                string            columName = GetPrimaryIndexColumnName(primaryIndex, pair.Key, index);
                StorageColumnInfo column    = table.Columns[columName];
                new KeyColumnRef(secondaryIndex, column,
                                 providerInfo.Supports(ProviderFeatures.KeyColumnSortOrder)
            ? pair.Value
            : Direction.Positive);
            }
            // At least SQL Server does not support clustered indexes with included columns.
            // For now this is the only RDBMS that have support for clustered indexes in DO.
            // Let's omit additional checks for ServerFeatures here
            // and simply ignore included columns for clustered indexes.
            if (providerInfo.Supports(ProviderFeatures.IncludedColumns) && !isClustered)
            {
                foreach (var includedColumn in index.IncludedColumns)
                {
                    string            columName = GetPrimaryIndexColumnName(primaryIndex, includedColumn, index);
                    StorageColumnInfo column    = table.Columns[columName];
                    new IncludedColumnRef(secondaryIndex, column);
                }
            }
            secondaryIndex.PopulatePrimaryKeyColumns();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Fires the specified info to each subscribed <see cref="IAnalysisWriter"/>.
        /// </summary>
        /// <param name="info">The info to pass to each subscriber.</param>
        public static void Fire(IndexInfo info)
        {
            List <IAnalysisWriter> writers = null;

            lock (syncRoot)
                writers = new List <IAnalysisWriter>(analysisWriters);
            if (writers == null)
            {
                return;
            }

            int totalWriters = writers.Count;

            if (totalWriters == 0)
            {
                return;
            }

            if (totalWriters % 2 == 1)
            {
                writers[totalWriters - 1].AddIndexInfo(info);
                totalWriters--;
            }

            for (int i = 0; i < totalWriters; i += 2)
            {
                writers[i].AddIndexInfo(info);
                writers[i + 1].AddIndexInfo(info);
            }
        }
 public static void Dump(this IndexInfo index)
 {
     Console.WriteLine("----------------------------------------");
     Console.WriteLine("Index dump");
     Console.WriteLine("----------------------------------------");
     Dump(index, 0);
 }
Exemplo n.º 5
0
        void createIndex(EntityDB.IDatabaseService database, string table, IndexInfo indexinfo)
        {
            table = table.ToLower();
            //alter table table_name add unique key `new_uk_name` (`col1`,`col2`);
            var    columns    = indexinfo.ColumnNames.OrderBy(m => m).Select(m => m.ToLower()).ToArray();
            string columnsStr = "";
            string name       = table + "_ej_" + columns.ToSplitString("_");

            for (int i = 0; i < columns.Length; i++)
            {
                columnsStr += "`" + columns[i] + "`";
                if (i < columns.Length - 1)
                {
                    columnsStr += ",";
                }
            }
            string type = "";

            //if (indexinfo.IsClustered)
            //    throw new Exception("MySql不支持定义聚集索引");
            if (indexinfo.IsUnique || indexinfo.IsClustered)
            {
                type += "unique ";
            }
            database.ExecSqlString(string.Format("alter table `{0}` add {3} key `{1}` ({2})", table, name, columnsStr, type));
        }
Exemplo n.º 6
0
        private IndexInfo CreateIndex(DataRow row, TableInfo table)
        {
            IndexInfo index = new IndexInfo()
            {
                Table     = table,
                IndexType = string.Empty
            };

            string def = row["indexdef"].ToString();

            index.IndexKeys = def.Split('(')[1].TrimEnd(')');

            // if (index.IndexType.Contains("clustered") && index.IndexType.Contains("unique") && index.IndexType.Contains("primary"))
            // CREATE UNIQUE INDEX loginusers_pkey ON public.loginusers USING btree (clusterid)
            if (def.Contains("_pkey"))
            {
                index.IndexType = "clustered unique primary";
            }
            else if (def.ToLower().Contains("unique"))
            {
                index.IndexType = "unique";
            }

            return(index);
        }
Exemplo n.º 7
0
        protected virtual void SetupIndexes(Type indexType)
        {
            indexes = new TableIndex[TableInfo.Columns.Count];
            for (int i = 0; i < TableInfo.Columns.Count; i++)
            {
                var columnName = TableInfo.Columns[i].ColumnName;
                var indexInfo  = new IndexInfo($"#COLIDX_{i}", TableInfo.TableName, columnName);

                if (indexType == typeof(BlindSearchIndex))
                {
                    indexes[i] = new BlindSearchIndex(indexInfo, this);
                }
                else if (indexType == typeof(InsertSearchIndex))
                {
                    indexes[i] = new InsertSearchIndex(indexInfo, this);
                }
                else
                {
                    var index = Activator.CreateInstance(indexType, indexInfo, this) as TableIndex;
                    if (index == null)
                    {
                        throw new InvalidOperationException();
                    }

                    indexes[i] = index;
                }
            }
        }
Exemplo n.º 8
0
        public void CommitTo(SequentialFileWriter dataFile, SequentialFileWriter indexFile)
        {
            Flush();

            int memLength = (int)_memStream.Position;

            if (memLength > 0)
            {
                byte[] memBuffer = _memStream.GetBuffer();

                long actualPosition = dataFile.Position;

                dataFile.Write(memBuffer, 0, memLength);        //The buffer contains the data from many items.

                //Console.WriteLine("Writing {0} bytes starting at {1}, with {2} things", memLength, actualPosition, _orderedIndexInfo.Count);

                byte[] indexBuffer = new byte[20];

                //int indexWritten = _orderedIndexInfo.Count * indexBuffer.Length;
                //int totalWritten = memLength + indexWritten

                for (int i = 0; i < _orderedIndexInfo.Count; i++)
                {
                    IndexInfo info = _orderedIndexInfo[i];

                    int typeCode = info.typeCode;
                    int serial   = info.serial;
                    int length   = info.size;

                    indexBuffer[0] = (byte)(info.typeCode);
                    indexBuffer[1] = (byte)(info.typeCode >> 8);
                    indexBuffer[2] = (byte)(info.typeCode >> 16);
                    indexBuffer[3] = (byte)(info.typeCode >> 24);

                    indexBuffer[4] = (byte)(info.serial);
                    indexBuffer[5] = (byte)(info.serial >> 8);
                    indexBuffer[6] = (byte)(info.serial >> 16);
                    indexBuffer[7] = (byte)(info.serial >> 24);

                    indexBuffer[8]  = (byte)(actualPosition);
                    indexBuffer[9]  = (byte)(actualPosition >> 8);
                    indexBuffer[10] = (byte)(actualPosition >> 16);
                    indexBuffer[11] = (byte)(actualPosition >> 24);
                    indexBuffer[12] = (byte)(actualPosition >> 32);
                    indexBuffer[13] = (byte)(actualPosition >> 40);
                    indexBuffer[14] = (byte)(actualPosition >> 48);
                    indexBuffer[15] = (byte)(actualPosition >> 56);

                    indexBuffer[16] = (byte)(info.size);
                    indexBuffer[17] = (byte)(info.size >> 8);
                    indexBuffer[18] = (byte)(info.size >> 16);
                    indexBuffer[19] = (byte)(info.size >> 24);

                    indexFile.Write(indexBuffer, 0, indexBuffer.Length);

                    actualPosition += info.size;
                }
            }
            Close();    //We're done with this writer.
        }
Exemplo n.º 9
0
        private void PrepIndex(object propertyToIndexObj)
        {
            Expect.IsTrue(propertyToIndexObj is string, "ProperytToIndex must be a string");

            string propertyToIndex = propertyToIndexObj as string;
            TDao   proxy           = new TDao();
            string q          = "SELECT {0} as ID,{1} as Value FROM {2} ORDER BY {0} ASC";
            string idColumn   = proxy.IdColumnName;
            string columnName = proxy.GetPropertyToColumnMap()[propertyToIndex];
            string tableName  = proxy.TableName;

            Expect.IsNotNullOrEmpty(idColumn, "No ID Column was found on table " + tableName + ", regeneration may be required.");

            string    sql     = string.Format(q, idColumn, columnName, tableName);
            DataTable results = this.agent.GetDataTableFromSql(sql);

            foreach (DataRow row in results.Rows)
            {
                IndexInfo info = new IndexInfo();
                info.HydrateFromDataRow(row);
                this.index.Add(info);
            }

            this.Ready = true;
            this.OnIndexReady();
        }
Exemplo n.º 10
0
        public void GetIndexInformationOneIndex()
        {
            string           indexname = "myindex";
            string           indexdef  = "+ascii\0\0";
            CreateIndexGrbit grbit     = CreateIndexGrbit.IndexUnique;

            Api.JetBeginTransaction(this.sesid);
            Api.JetCreateIndex(this.sesid, this.tableid, indexname, grbit, indexdef, indexdef.Length, 100);
            IEnumerable <IndexInfo> indexes = Api.GetTableIndexes(this.sesid, this.tableid);

            // There should be only one index
            IndexInfo info = indexes.Single();

            Assert.AreEqual(indexname, info.Name);
            Assert.AreEqual(grbit, info.Grbit);

            // The index has no stats
            Assert.AreEqual(0, info.Keys);
            Assert.AreEqual(0, info.Entries);
            Assert.AreEqual(0, info.Pages);

            Assert.AreEqual(1, info.IndexSegments.Count);
            Assert.AreEqual("ascii", info.IndexSegments[0].ColumnName, true);
            Assert.IsTrue(info.IndexSegments[0].IsAscending);
            Assert.AreEqual(JET_coltyp.LongText, info.IndexSegments[0].Coltyp);
            Assert.IsTrue(info.IndexSegments[0].IsASCII);

            Api.JetRollback(this.sesid, RollbackTransactionGrbit.None);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Indexer
        /// </summary>
        /// <param name="index">Index</param>
        /// <returns>Generic T</returns>
        public T this[int index]
        {
            get
            {
                if (index < 0 || index >= Count)
                {
                    throw new IndexOutOfRangeException();
                }

                IndexInfo info = GetIndexInfo(index);
                this.prevIndex = index;
                return(info.Current);
            }
            set
            {
                if (index < 0 || index >= Count)
                {
                    throw new IndexOutOfRangeException();
                }

                IndexInfo info = GetIndexInfo(index);
                info.Current   = value;
                this.prevIndex = index;
            }
        }
Exemplo n.º 12
0
 /// <summary>
 /// Adds a <see cref="IndexLibrary.IndexInfo"/> to the analysis stack
 /// </summary>
 /// <param name="info">The information being reported.</param>
 public void AddIndexInfo(IndexInfo info)
 {
     if (this.trackIndexes)
     {
         this.writes.Enqueue(info);
     }
 }
Exemplo n.º 13
0
        public IndexingCompletedEvent(IndexInfo indexInfo, bool wasRebuilt)
        {
            Guard.NotNull(indexInfo, nameof(indexInfo));

            IndexInfo  = indexInfo;
            WasRebuilt = wasRebuilt;
        }
Exemplo n.º 14
0
        public List <IndexInfo> GetCurrentIndexes(IDatabaseService db, string tablename)
        {
            List <IndexInfo> result = new List <IndexInfo>();
            var dbnameMatch         = System.Text.RegularExpressions.Regex.Match(db.ConnectionString, @"database=(?<dname>(\w)+)", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
            var dbname = dbnameMatch.Groups["dname"].Value;
            var table  = db.SelectTable($"SELECT *  FROM  information_schema.statistics WHERE TABLE_SCHEMA='{dbname}' and table_name='{tablename}' and INDEX_NAME<>'PRIMARY'");

            foreach (var row in table.Rows)
            {
                string    indexName = row["INDEX_NAME"].ToSafeString();
                bool      unique    = !Convert.ToBoolean(row["NON_UNIQUE"]);
                IndexInfo indexInfo = result.FirstOrDefault(m => m.Name == indexName);
                if (indexInfo == null)
                {
                    indexInfo = new IndexInfo()
                    {
                        Name        = indexName,
                        IsUnique    = unique,
                        ColumnNames = new string[0],
                    };
                    result.Add(indexInfo);
                }
                string columnName  = row["COLUMN_NAME"].ToSafeString();
                var    columnNames = new List <string>(indexInfo.ColumnNames);
                columnNames.Add(columnName);
                indexInfo.ColumnNames = columnNames.OrderBy(m => m).ToArray();
            }

            return(result);
        }
Exemplo n.º 15
0
        /// <summary>
        /// Writes read methods implementation for the specified index.
        /// </summary>
        /// <param name="index">The index to write methods for.</param>
        public void WriteIndexDataProviderImplementation(IndexInfo index)
        {
            var            signature = MethodSignature.GetIndexSignature(index);
            IMethodBuilder builder   = new IndexMethodBuilder(index);

            WrapMethodBody(signature, builder);
        }
Exemplo n.º 16
0
        public void GetIndexInformationOneIndexWithStats()
        {
            string           indexname = "nonuniqueindex";
            string           indexdef  = "+ascii\0\0";
            CreateIndexGrbit grbit     = CreateIndexGrbit.None;

            Api.JetBeginTransaction(this.sesid);
            Api.JetCreateIndex(this.sesid, this.tableid, indexname, grbit, indexdef, indexdef.Length, 100);

            // Insert 9 records with 3 of each key value
            for (int i = 0; i < 3; ++i)
            {
                this.InsertRecordWithString("ascii", "foo", Encoding.ASCII);
                this.InsertRecordWithString("ascii", "bar", Encoding.ASCII);
                this.InsertRecordWithString("ascii", "baz", Encoding.ASCII);
            }

            Api.JetComputeStats(this.sesid, this.tableid);
            IEnumerable <IndexInfo> indexes = Api.GetTableIndexes(this.sesid, this.tableid);

            // There should be only one index
            IndexInfo info = indexes.Single();

            Assert.AreEqual(indexname, info.Name);

            // The index has 3 unique keys, 9 entries and everything should fit on one page.
            Assert.AreEqual(3, info.Keys);
            Assert.AreEqual(9, info.Entries);
            Assert.AreEqual(1, info.Pages);

            Api.JetRollback(this.sesid, RollbackTransactionGrbit.None);
        }
Exemplo n.º 17
0
        public void GetIndexInformationOneIndexMultipleSegments()
        {
            string           indexname = "multisegmentindex";
            string           indexdef  = "+ascii\0-boolean\0\0";
            CreateIndexGrbit grbit     = CreateIndexGrbit.IndexUnique;

            Api.JetBeginTransaction(this.sesid);
            Api.JetCreateIndex(this.sesid, this.tableid, indexname, grbit, indexdef, indexdef.Length, 100);
            IEnumerable <IndexInfo> indexes = Api.GetTableIndexes(this.sesid, this.tableid);

            // There should be only one index
            IndexInfo info = indexes.Single();

            Assert.AreEqual(indexname, info.Name);
            Assert.AreEqual(grbit, info.Grbit);

            Assert.AreEqual(2, info.IndexSegments.Length);
            Assert.AreEqual("ascii", info.IndexSegments[0].ColumnName, true);
            Assert.IsTrue(info.IndexSegments[0].IsAscending);
            Assert.AreEqual(JET_coltyp.LongText, info.IndexSegments[0].Coltyp);
            Assert.IsTrue(info.IndexSegments[0].IsASCII);

            Assert.AreEqual("boolean", info.IndexSegments[1].ColumnName, true);
            Assert.IsFalse(info.IndexSegments[1].IsAscending);
            Assert.AreEqual(JET_coltyp.Bit, info.IndexSegments[1].Coltyp);

            Api.JetRollback(this.sesid, RollbackTransactionGrbit.None);
        }
Exemplo n.º 18
0
    private IndexInfo MoveOnX(IndexInfo previous, bool calculateCircular = false)
    {
        if (previous == null)
        {
            return(null);
        }

        IndexInfo result = new IndexInfo();

        result.OriginalXDiff = 1 - Mathf.Abs(previous.OriginalXDiff);

        if (!calculateCircular && previous.OriginalXDiff % VerticesXCount
            > result.OriginalXDiff % VerticesXCount)
        {
            ///skip index on next row
            result = null;
        }
        else
        {
            int delta = (int)Mathf.Sign(previous.OriginalXDiff);
            result.index         = previous.index + delta;
            result.OriginalZDiff = previous.OriginalZDiff;
            result.xIndex        = previous.xIndex + delta;
            result.zIndex        = previous.zIndex;
        }

        return(result);
    }
Exemplo n.º 19
0
        private void LoadData()
        {
            string category = string.Empty;

            if (this.type == 2)
            {
                category = this.UserDep;
            }
            DynamicJson courseList   = RestRC.BACARepository.Request(ApiList.courseList, string.Empty).AsDynamicJson();
            dynamic     categoryList = RestRC.BACARepository.Request(ApiList.categoryList, string.Empty).ToDynamicJson().list;

            if (categoryList != null)
            {
                foreach (DynamicJson item in categoryList)
                {
                    IndexInfo catelogElement = new IndexInfo()
                    {
                        model = item
                    };
                    catelogElement.Title.Content = item.GetStr("title");

                    foreach (var course in courseList.Get("list") as IEnumerable <object> )
                    {
                        catelogElement._wpCourseItems.Children.Add(new CourseItem());
                    }

                    _sp.Children.Add(catelogElement);
                }
            }
        }
Exemplo n.º 20
0
 public void CanCreateIndexInfo()
 {
     Assert.DoesNotThrow(() =>
     {
         indexInfo = new IndexInfo("index", tableName, "Id", tableManager, statisticsManager, _transaction, 1024);
     });
 }
Exemplo n.º 21
0
    public IndexInfo GetNearestIndexInfo(Vector2 progress)
    {
        IndexInfo result          = new IndexInfo();
        int       xVerticesLenght = VerticesXCount;
        float     zIndex          = (Vertices.Length - xVerticesLenght) * progress.y;

        float indexMod = zIndex % xVerticesLenght;

        float modDiffZAxis = indexMod / xVerticesLenght;

        zIndex -= indexMod;

        result.OriginalZDiff = modDiffZAxis - Mathf.Round(modDiffZAxis);

        float xIndex = progress.x * XSize;

        result.xIndex = (int)xIndex;

        float modDiffXAxis = (xIndex % 1);

        result.OriginalXDiff = progress.x - Mathf.RoundToInt(progress.x);
        zIndex        = zIndex + Mathf.Round(modDiffZAxis) * xVerticesLenght;
        result.zIndex = (int)zIndex;
        result.index  = result.zIndex + result.xIndex;
        return(result);
    }
Exemplo n.º 22
0
    //public List<IndexInfo> GetNearestIndicies(Vector2 progress, int range, bool calculateCircular)
    //{
    //    List<IndexInfo> result = new List<IndexInfo>();
    //    List<IndexInfo> latelyAdded = new List<IndexInfo>();



    //    return result;
    //}

    //protected void ExtendIndex(System.Func<Vector2> direction, List<IndexInfo> indicies)
    //{
    //    int count = indicies.Count;
    //    for(int i = 0; i < count; i++)
    //    {
    //        indicies.Add(MoveOnX);
    //    }
    //}

    /// <summary>
    ///
    /// </summary>
    /// <param name="progress"></param>
    /// <param name="calculateCircular">will transition between outermost indicies</param>
    /// <returns></returns>
    public IndexInfo[] GetNearestIndicies(Vector2 progress, bool calculateCircular = false)
    {
        IndexInfo[] result = new IndexInfo[4];

        int xVerticesLenght = VerticesXCount;

        result[0] = GetNearestIndexInfo(progress);

        IndexInfo first = GetNearestIndexInfo(progress);

        result[0] = first;

        if (result[0].OriginalXDiff != 0)
        {
            result[1] = MoveOnX(first, calculateCircular);
        }
        if (result[0].OriginalZDiff != 0)
        {
            result[2] = MoveOnZ(first);
        }
        if (result[0].OriginalXDiff != 0 && result[0].OriginalZDiff != 0)
        {
            result[3] = MoveOnZ(result[1]);
        }

        float zIndex  = ((Vertices.Length - xVerticesLenght)) * progress.y;
        float modDiff = zIndex % xVerticesLenght;


        zIndex = (zIndex - modDiff) + Mathf.Round(modDiff / xVerticesLenght) * xVerticesLenght;
        return(result);
    }
        /// <summary>
        /// Visits primary index.
        /// </summary>
        /// <param name="index">The index.</param>
        /// <returns>Visit result.</returns>
        private IPathNode VisitPrimaryIndexInfo(IndexInfo index)
        {
            foreach (var column in index.Columns)
            {
                Visit(column);
            }

            // Support for mysql as primary indexes there always have name 'PRIMARY'
            string name = providerInfo.ConstantPrimaryIndexName;

            if (string.IsNullOrEmpty(name))
            {
                name = index.MappingName;
            }

            var primaryIndex = new PrimaryIndexInfo(currentTable, name);

            foreach (KeyValuePair <ColumnInfo, Direction> pair in index.KeyColumns)
            {
                string columName = GetPrimaryIndexColumnName(index, pair.Key, index);
                var    column    = currentTable.Columns[columName];
                new KeyColumnRef(primaryIndex, column,
                                 providerInfo.Supports(ProviderFeatures.KeyColumnSortOrder)
            ? pair.Value
            : Direction.Positive);
            }
            primaryIndex.PopulateValueColumns();
            primaryIndex.IsClustered = index.IsClustered && providerInfo.Supports(ProviderFeatures.ClusteredIndexes);

            foreach (var secondaryIndex in index.ReflectedType.Indexes.Where(i => i.IsSecondary && !i.IsVirtual))
            {
                VisitIndexInfo(index, secondaryIndex);
            }
            return(primaryIndex);
        }
Exemplo n.º 24
0
        private void MakeGuess(bool correct)
        {
            //if game has started
            if (GameStarted && GuessCount > 0)
            {
                try
                {
                    //letter is a good guess
                    if (correct)
                    {
                        IndexButton.Show();
                        IndexInfo.Show();
                        TipText.Show();
                        WrongButton.Hide();
                        RightButton.Hide();
                    }//letter is a bad guess
                    else
                    {
                        BadGuesses     += Guess;
                        PossibleLetters = PossibleLetters.Replace(Guess, "");
                        Guess           = PossibleLetters[0].ToString();
                        label2.Text     = TheWord;
                        GuessText.Text  = Guess;


                        label1.Text = BadGuesses;
                        GuessCount--;
                        GuessCountLabel.Text = GuessCount.ToString();
                        //remove words from list containing bad guessed letter
                        PossibleWordSet = new SortedSet <string>(from p in PossibleWordSet
                                                                 where !p.Contains(Guess)
                                                                 select p);
                        possible.Text          = PossibleLetters;
                        possiblewordcount.Text = PossibleWordSet.Count.ToString();
                    }



                    if (GuessCount == 0)
                    {
                        WinningGif.Show();
                        RightButton.Hide();
                        WrongButton.Hide();
                        GuessText.Hide();
                    }



                    //if (label2.Text == TheWord)
                    //{
                    //    RightButton.Hide();
                    //    WrongButton.Hide();
                    //}
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex);
                }
            }
        }
Exemplo n.º 25
0
Arquivo: Zip.cs Projeto: tommybiteme/X
        public String GetAddress(UInt32 ip)
        {
            if (_Stream == null) return "";

            Search_Index_Set = 0u;
            Search_Index_End = Index_Count - 1u;

            while (true)
            {
                Search_Set = IndexInfoAtPos(Search_Index_Set);
                Search_End = IndexInfoAtPos(Search_Index_End);
                if (ip >= Search_Set.IpSet && ip <= Search_Set.IpEnd) break;

                if (ip >= Search_End.IpSet && ip <= Search_End.IpEnd) return ReadAddressInfoAtOffset(Search_End.Offset);

                Search_Mid = IndexInfoAtPos((Search_Index_End + Search_Index_Set) / 2u);
                if (ip >= Search_Mid.IpSet && ip <= Search_Mid.IpEnd) return ReadAddressInfoAtOffset(Search_Mid.Offset);

                if (ip < Search_Mid.IpSet)
                    Search_Index_End = (Search_Index_End + Search_Index_Set) / 2u;
                else
                    Search_Index_Set = (Search_Index_End + Search_Index_Set) / 2u;
            }
            return ReadAddressInfoAtOffset(Search_Set.Offset);
        }
Exemplo n.º 26
0
        /// <summary>
        /// Adds a <see cref="IndexLibrary.IndexInfo"/> to this summary
        /// </summary>
        /// <param name="info">The info to add.</param>
        public void AddIndexInfo(IndexInfo info)
        {
            if (info == null)
            {
                throw new ArgumentNullException("info", "info cannot be null");
            }

            this.totalWrites++;

            if ((this.features & IndexInfoSummaryFeature.WriteTimeSpread) == IndexInfoSummaryFeature.WriteTimeSpread)
            {
                DateTime key = new DateTime(info.CreatedTime.Year, info.CreatedTime.Month, info.CreatedTime.Day, info.CreatedTime.Hour, info.CreatedTime.Minute, 0);
                this.timeSpread.Add(new KeyValuePair <DateTime, string>(key, info.IndexName));
            }

            if ((this.features & IndexInfoSummaryFeature.TotalReads) == IndexInfoSummaryFeature.TotalReads)
            {
                this.totalReads += info.TotalReads;
            }
            if ((this.features & IndexInfoSummaryFeature.TotalSearches) == IndexInfoSummaryFeature.TotalSearches)
            {
                this.totalSearches += info.TotalSearches;
            }

            if ((this.features & IndexInfoSummaryFeature.MostRecentIndexes) == IndexInfoSummaryFeature.MostRecentIndexes)
            {
                if (this.mostRecent.ContainsKey(info.IndexName))
                {
                    this.mostRecent.Add(info.IndexName, info);
                }
                this.mostRecent[info.IndexName] = info;
            }
        }
Exemplo n.º 27
0
        public IndexInfo Get()
        {
            var model = new IndexInfo();
            var devs  =
                ProcessInvoke <RestaurantDeviceProcess>()
                .DevicesInDistrict(Guid.Parse("B20071A6-A30E-9FAD-4C7F-4C353641A645"));
            var checkDate = DateTime.Now.AddMinutes(-2);

            foreach (var device in devs)
            {
                try
                {
                    var monitorDatas = ProcessInvoke <MonitorDataProcess>()
                                       .GetDeviceCleanerCurrent(device, checkDate);
                    if (monitorDatas?.DoubleValue == null)
                    {
                        continue;
                    }
                    var time = monitorDatas.UpdateTime.ToString("yyyy-MM-dd HH:mm:ss");
                    var fan  = new Index
                    {
                        EQUP_ID  = $"{Convert.ToUInt32(Convert.ToUInt32(device.DeviceNodeId, 16)):D6}001",
                        RMON_TIM = time,
                        EQUP_VAL = monitorDatas.DoubleValue > 0 ? "1" : "0"
                    };
                    model.data.Add(fan);
                    var cleaner = new Index
                    {
                        EQUP_ID  = $"{Convert.ToUInt32(Convert.ToUInt32(device.DeviceNodeId, 16)):D6}002",
                        RMON_TIM = time,
                        EQUP_VAL = monitorDatas.DoubleValue > 0 ? "1" : "0"
                    };
                    model.data.Add(cleaner);

                    var current = new Index
                    {
                        EQUP_ID  = $"{Convert.ToUInt32(Convert.ToUInt32(device.DeviceNodeId, 16)):D6}003",
                        RMON_TIM = time,
                        EQUP_VAL = monitorDatas.DoubleValue.Value.ToString("F4")
                    };
                    model.data.Add(current);
                }
                catch (Exception ex)
                {
                    LogService.Instance.Error("IndexInfo接口执行失败。", ex);
                    var currentException = ex;
                    while (currentException.InnerException != null)
                    {
                        LogService.Instance.Error("IndexInfo接口执行失败详细原因。", ex);
                        currentException = currentException.InnerException;
                    }

                    return(model);
                }
            }

            model.result = "success";
            return(model);
        }
Exemplo n.º 28
0
        public void MainTest()
        {
            Key key;

            using (var session = Domain.OpenSession()) {
                using (var t = session.OpenTransaction()) {
                    Book book = new Book {
                        Title = "Title", Text = "Text"
                    };
                    key = book.Key;
                    Session.Current.SaveChanges();
                    t.Complete();
                }
            }
            using (var session = Domain.OpenSession()) {
                using (session.OpenTransaction()) {
                    EntityState state = Session.Current.EntityStateCache[key, true];
                    Assert.IsNull(state);
                    IndexInfo ii = Domain.Model.Types[typeof(Book)].Indexes.PrimaryIndex;

                    var parameterContext = new ParameterContext();
                    // Select *
                    CompilableProvider rsMain = ii.GetQuery();
                    UpdateCache(session, rsMain.GetRecordSetReader(session, parameterContext));
                    state = Session.Current.EntityStateCache[key, true];
                    Assert.IsNotNull(state);
                    Assert.IsTrue(state.Tuple.GetFieldState(2).IsAvailable());
                    Assert.IsTrue(state.Tuple.GetFieldState(3).IsAvailable());
                    ResetState(state);

                    // Select Id, TypeId, Title
                    CompilableProvider rsTitle = rsMain.Select(0, 1, 2);
                    UpdateCache(session, rsTitle.GetRecordSetReader(session, parameterContext));
                    state = Session.Current.EntityStateCache[key, true];
                    Assert.IsNotNull(state);
                    Assert.IsTrue(state.Tuple.GetFieldState(2).IsAvailable());
                    Assert.IsFalse(state.Tuple.GetFieldState(3).IsAvailable());
                    ResetState(state);

                    // Select Id, TypeId, Text
                    CompilableProvider rsText = rsMain.Select(0, 1, 3);
                    UpdateCache(session, rsText.GetRecordSetReader(session, parameterContext));
                    state = Session.Current.EntityStateCache[key, true];
                    Assert.IsNotNull(state);
                    Assert.IsFalse(state.Tuple.GetFieldState(2).IsAvailable());
                    Assert.IsTrue(state.Tuple.GetFieldState(3).IsAvailable());
                    ResetState(state);

                    // Select a.Id, a.TypeId, a.Title, b.Id, b.TypeId, b.Text
                    CompilableProvider rsJoin = rsTitle.Alias("a").Join(rsText.Alias("b"), new Pair <int>(0, 0), new Pair <int>(1, 1));
                    UpdateCache(session, rsJoin.GetRecordSetReader(session, parameterContext));
                    state = Session.Current.EntityStateCache[key, true];
                    Assert.IsNotNull(state);
                    Assert.IsTrue(state.Tuple.GetFieldState(2).IsAvailable());
                    Assert.IsTrue(state.Tuple.GetFieldState(3).IsAvailable());
                    ResetState(state);
                }
            }
        }
Exemplo n.º 29
0
        /// <summary>
        /// Downloads all asset bundles from the specified URL.
        /// </summary>
        /// <returns>
        /// Info class instance or null, if an error occured.
        /// </returns>
        /// <param name='urls'>
        /// URLs to the same files from different places (mirrors).
        /// </param>
        public static IndexInfo DownloadAll(params string[] urls)
        {
            //Debug.Log("DownloadAll - Started");
            IndexInfo ret = IndexInfo.GetInstance(urls);

            //Debug.Log("DownloadAll - Finished");
            return(ret);
        }
Exemplo n.º 30
0
        public void VerifyIndexInfoSegmentsAreReadOnly()
        {
            var segments = new[] { new IndexSegment("column1", JET_coltyp.LongText, true, false) };
            var info     = new IndexInfo(
                "index", CultureInfo.InvariantCulture, CompareOptions.None, segments, CreateIndexGrbit.None, 0, 0, 0);

            info.IndexSegments[0] = new IndexSegment("column2", JET_coltyp.Short, false, false);
        }
Exemplo n.º 31
0
 /// <summary>
 /// 添加索引
 /// </summary>
 /// <param name="index">索引信息</param>
 public void AddIndex(IndexInfo index)
 {
     if (Indexes == null)
     {
         Indexes = new List <IndexInfo>();
     }
     Indexes.Add(index);
 }
Exemplo n.º 32
0
        public string BuildIndexCreateSql(TableInfo table, IndexInfo index)
        {
            var indexName = string.Format("{0}_{1}", table.OutputTableName, index.Name);

            var unique = index.IsUnique ? "UNIQUE " : "";

            return string.Format("CREATE {0}INDEX {1} ON {2} ({3});",
                                unique, _escaper(indexName), _escaper(table.OutputTableName),
                                string.Join(",", index.ColumnNames.Select(c => _escaper(c))));
        }
Exemplo n.º 33
0
        public IndexInfoViewModel(IndexInfo indexInfo, Infrastructure infrastructure, Action refreshIndexList)
        {
            Ensure.ArgumentNotNull(infrastructure, "infrastructure");
            Ensure.ArgumentNotNull(indexInfo, "indexInfo");

            _infrastructure = infrastructure;
            _refreshIndexList = refreshIndexList;
            Name = indexInfo.Name;
            IsOpen = indexInfo.IsOpen;
            Settings = indexInfo.Settings.Select(setting => new ElasticPropertyViewModel
            {
                Label = setting.Key.Humanize(LetterCasing.Sentence),
                Value = setting.Value
            });
            Types = indexInfo.Types.Select(type => new ElasticPropertyViewModel
            {
                Label = type.Key.Humanize(LetterCasing.Sentence),
                Value = type.Value
            });
        }
Exemplo n.º 34
0
        /// <summary>
        /// Fires the specified info to each subscribed <see cref="IAnalysisWriter"/>.
        /// </summary>
        /// <param name="info">The info to pass to each subscriber.</param>
        public static void Fire(IndexInfo info)
        {
            List<IAnalysisWriter> writers = null;
            lock (syncRoot)
                writers = new List<IAnalysisWriter>(analysisWriters);
            if (writers == null)
                return;

            int totalWriters = writers.Count;
            if (totalWriters == 0)
                return;

            if (totalWriters % 2 == 1) {
                writers[totalWriters - 1].AddIndexInfo(info);
                totalWriters--;
            }

            for (int i = 0; i < totalWriters; i += 2) {
                writers[i].AddIndexInfo(info);
                writers[i + 1].AddIndexInfo(info);
            }
        }
Exemplo n.º 35
0
 public TableInfo AddIndex(IndexInfo indexInfo)
 {
     _indexes.Add(indexInfo);
     return this;
 }
Exemplo n.º 36
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="TOCnode"></param>
        /// <param name="tree"></param>
        /// <param name="level"></param>
        private void FillSampleListIntern(XmlNode TOCnode, TreeNodeCollection nodes)
        {
            // Loop through all XML nodes
            int nodeID = 0;
            XmlNode node = TOCnode.FirstChild;
            while(node != null)
            {
                if(node.Name == "TOCNode")
                {
                    // Add node into the tree
                    nodeID = nodes.Add(new TreeNode(node.Attributes["Title"].Value));

                    // Add all child nodes
                    FillSampleListIntern(node, nodes[nodeID].Nodes);
                }
                else if(node.Name == "SampleConfig")
                {
                    // Add node into the tree
                    nodeID = nodes.Add(new TreeNode(node["Title"].InnerText));

                    // Create sample information object
                    if(node["SampleControl"] != null)
                    {
                        SampleInfo	sampleInfo = new SampleInfo();
                        sampleInfo.sampleControl = node["SampleControl"].InnerText;
                        sampleInfo.path = node.Attributes["Path"].Value;
                        if(node["Keywords"] != null)
                            sampleInfo.keywords = node["Keywords"].InnerText;
                        if(node["ShortBlurb"] != null)
                            sampleInfo.shortBlurb = node["ShortBlurb"].InnerText;
                        if(node["Thumbnail"] != null)
                            sampleInfo.thumbnail = node["Thumbnail"].InnerText;
                        if(node["Title"] != null)
                            sampleInfo.title = node["Title"].InnerText;

                        // Fill info pages list
                        XmlNode nodeInfoPages = node["InfoPages"];
                        if(nodeInfoPages != null && nodeInfoPages.HasChildNodes)
                        {
                            XmlNode nodeInfo = nodeInfoPages.FirstChild;
                            while(nodeInfo != null)
                            {
                                if(nodeInfo.Name == "InfoPage")
                                {
                                    InfoPage newInfoPage = new InfoPage();
                                    newInfoPage.title = nodeInfo.Attributes["Title"].Value;
                                    newInfoPage.data = nodeInfo.InnerText;
                                    sampleInfo.infoPages.Add(newInfoPage);
                                }

                                nodeInfo = nodeInfo.NextSibling;
                            }
                        }

                        // Fill keywords array
                        XmlNode nodeKeywords = node["Keywords"];
                        if(nodeKeywords != null && nodeKeywords.HasChildNodes)
                        {
                            XmlNode nodeInfo = nodeKeywords.FirstChild;
                            while(nodeInfo != null)
                            {
                                if(nodeInfo.Name == "Keyword")
                                {
                                    IndexInfo indexInfo = new IndexInfo();
                                    indexInfo.SampleInfo = sampleInfo;
                                    indexInfo.Key = nodeInfo.InnerText.Trim();

                                    // Check if string has a sub index separated with comma
                                    int commaIndex = indexInfo.Key.IndexOf(',');
                                    if(commaIndex > 0)
                                    {
                                        indexInfo.SubKey = indexInfo.Key.Substring(commaIndex + 1).Trim();
                                        indexInfo.Key = indexInfo.Key.Substring(0, commaIndex).Trim();
                                    }

                                    this.indexInfoList.Add(indexInfo);
                                }

                                nodeInfo = nodeInfo.NextSibling;
                            }
                        }

                        // Add sample information to the tree node
                        nodes[nodeID].Tag = sampleInfo;

                        // Set node image
                        int imageIndex = 2;
                        if(sampleInfo.infoPages != null &&
                            sampleInfo.infoPages.Count == 1)
                        {
                            InfoPage infoPage = (InfoPage)sampleInfo.infoPages[0];
                            if(infoPage.title == "Gallery")
                            {
                                // Set Gallery list image
                                imageIndex = 3;
                            }
                            else if(infoPage.title == "Overview")
                            {
                                // Set Gallery list image
                                imageIndex = 4;
                            }
                        }
                        nodes[nodeID].ImageIndex = imageIndex;
                        nodes[nodeID].SelectedImageIndex = imageIndex;
                    }
                }

                // Get next node
                node = node.NextSibling;
            }
        }
Exemplo n.º 37
0
        /// <summary>
        /// Prepare index info array list.
        /// </summary>
        private void PrepareIndexInfoList()
        {
            // Define item names
            for(int index = 0; index < this.indexInfoList.Count; index++)
            {
                IndexInfo indexInfo = (IndexInfo)this.indexInfoList[index];

                // Only for items with sub-key
                if(indexInfo.SubKey.Length > 0)
                {
                    indexInfo.Name = "   " + indexInfo.SubKey;

                    IndexInfo mainKeyInfo = new IndexInfo();
                    mainKeyInfo.Key = indexInfo.Key;
                    this.indexInfoList.Insert(index, mainKeyInfo);
                    ++index;
                }
            }

            // Remove duplicated items
            for(int index1 = 0; index1 < this.indexInfoList.Count; index1++)
            {
                IndexInfo indexInfo1 = (IndexInfo)this.indexInfoList[index1];
                for(int index2 = index1 + 1; index2 < this.indexInfoList.Count; index2++)
                {
                    IndexInfo indexInfo2 = (IndexInfo)this.indexInfoList[index2];

                    // Remove completly identical items
                    if(indexInfo1.Key == indexInfo2.Key &&
                        indexInfo1.SubKey == indexInfo2.SubKey)
                    {
                        if(indexInfo1.SampleInfo.sampleControl == indexInfo2.SampleInfo.sampleControl ||
                            indexInfo2.SampleInfo.sampleControl.Length == 0)
                        {
                            this.indexInfoList.RemoveAt(index2);
                            --index2;
                        }
                        else if(indexInfo1.SampleInfo.sampleControl.Length == 0)
                        {
                            this.indexInfoList.RemoveAt(index1);
                            --index1;
                            --index2;
                        }

                    }
                }

            }

            // Sort items in the list using Key + SubKey
            this.indexInfoList.Sort();
        }
Exemplo n.º 38
0
        /// <summary>
        /// Create a OfflineEntity Table with metadata information added
        /// </summary>
        internal void CreateTable(Type ty)
        {
            using (SQLiteConnection connection = new SQLiteConnection(localFilePath))
            {
                try
                {
                    // Get mapping from my type
                    var map = manager.GetMapping(ty);

                    // Create 2 tables : One for datas, one for tracking
                    var query = SQLiteConstants.CreateTable;
                    var queryTracking = SQLiteConstants.CreateTrackingTable;

                    var columnsDcl = new List<String>();
                    var columnsDclTracking = new List<String>();
                    var columnsPk = new List<String>();

                    // Foreach columns, create the tsql command to execute
                    foreach (var c in map.Columns)
                    {
                        string dec = "\"" + c.Name + "\" " + Orm.SqlType(c) + " ";

                        columnsDcl.Add(dec);

                        // If it's the PK, add it to tracking
                        if (!c.IsPK) continue;

                        columnsDclTracking.Add(dec);
                        columnsPk.Add(c.Name + " ");
                    }


                    var pkTracking = string.Join(",\n", columnsPk.ToArray());
                    // Adding metadatas to tracking table
                    columnsDclTracking.AddRange(GetOfflineEntityMetadataSQlDecl());

                    var decl = string.Join(",\n", columnsDcl.ToArray());
                    var declTracking = string.Join(",\n", columnsDclTracking.ToArray());

                    string pKeyDecl = String.Empty;
                    if (columnsDclTracking.Count > 0)
                        pKeyDecl = String.Format(",\n PRIMARY KEY ({0})", pkTracking);

                    query = String.Format(query, map.TableName, decl, pKeyDecl);
                    queryTracking = String.Format(queryTracking, map.TableName, declTracking, pKeyDecl);

                    using (var statement = connection.Prepare(query))
                    {
                        statement.Step();
                    }
                    using (var statement = connection.Prepare(queryTracking))
                    {
                        statement.Step();
                    }

                    var indexes = new Dictionary<string, IndexInfo>();
                    foreach (var c in map.Columns)
                    {
                        foreach (var i in c.Indices)
                        {
                            var iname = i.Name ?? map.TableName + "_" + c.Name;
                            IndexInfo iinfo;
                            if (!indexes.TryGetValue(iname, out iinfo))
                            {
                                iinfo = new IndexInfo
                                {
                                    //IndexName = iname,
                                    TableName = map.TableName,
                                    Unique = i.Unique,
                                    Columns = new List<IndexedColumn>()
                                };
                                indexes.Add(iname, iinfo);
                            }

                            if (i.Unique != iinfo.Unique)
                                throw new Exception(
                                    "All the columns in an index must have the same value for their Unique property");

                            iinfo.Columns.Add(new IndexedColumn
                            {
                                Order = i.Order,
                                ColumnName = c.Name
                            });
                        }
                    }

                    foreach (var indexName in indexes.Keys)
                    {
                        var index = indexes[indexName];
                        const string sqlFormat = "create {3} index if not exists \"{0}\" on \"{1}\"(\"{2}\")";
                        var columns = String.Join("\",\"",
                                                  index.Columns.OrderBy(i => i.Order).Select(i => i.ColumnName).ToArray());
                        var sql = String.Format(sqlFormat, indexName, index.TableName, columns,
                                                index.Unique ? "unique" : "");

                        using (var statement = connection.Prepare(sql))
                        {
                            statement.Step();
                        }
                    }

                    // Create Triggers
                    this.CreateTriggers(ty, connection);

                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex.Message);
                    throw;

                }
            }
        }
Exemplo n.º 39
0
 /// <summary>
 /// Adds a <see cref="IndexLibrary.IndexInfo"/> to the analysis stack
 /// </summary>
 /// <param name="info">The information being reported.</param>
 public void AddIndexInfo(IndexInfo info)
 {
     if (this.trackIndexes) this.writes.Enqueue(info);
 }
Exemplo n.º 40
0
        public AddIndexChange(TableInfo table, IndexInfo index)
			: base(table)
        {
        	_index = index;
        }
Exemplo n.º 41
0
Arquivo: Zip.cs Projeto: tommybiteme/X
 IndexInfo IndexInfoAtPos(uint Index_Pos)
 {
     var inf = new IndexInfo();
     _Stream.Position = Index_Set + 7u * Index_Pos;
     inf.IpSet = GetUInt32();
     inf.Offset = GetOffset();
     _Stream.Position = inf.Offset;
     inf.IpEnd = GetUInt32();
     return inf;
 }
            internal static Tuple<PropertyInfo, IndexInfo> ScanNext(IndexInfo LastIndex)
            {
                // scan properties
                var PropertySignature = LastIndex.GetNextTrimmedLine();

                if (!PropertySignature.Text.Contains(":"))
                    return null;

                var PropertySummary = PropertySignature.GetNextTrimmedLine();

                if (string.IsNullOrEmpty(PropertySignature.Text))
                    return null;

                var PropertyDefinedBy = PropertySummary.GetNextTrimmedLine();

                if (string.IsNullOrEmpty(PropertyDefinedBy.Text))
                    return null;

                var n = new PropertyInfo
                    {
                        Signature = PropertySignature.Text,
                        Summary = PropertySummary.Text,
                        DefinedBy = PropertyDefinedBy.Text,
                    };

                // do last minute checks here


                return new Tuple<PropertyInfo, IndexInfo>
                {
                    TValue = n,
                    FValue = PropertyDefinedBy
                };
            }
 internal static Tuple<PropertyInfo, IndexInfo> ScanNextInterfaceMember(IndexInfo LastIndex)
 {
     return ScanNext(LastIndex);
 }
            internal static Tuple<ConstantInfo, IndexInfo> ScanNext(IndexInfo LastIndex)
            {
                var Signature = LastIndex.GetNextTrimmedLine();

                if (!Signature.Text.Contains(":"))
                    return null;

                var a = Signature.Text.IndexInfoOf(":");


                var IsAirOnly = false;

                var Name = a.BeforeSubject.Trim();
                if (Name.StartsWith(KeywordAirOnly))
                {
                    Name = Name.Substring(KeywordAirOnly.Length + 1).Trim();
                    IsAirOnly = true;
                }

                var b = a.IndexInfoOf("=");

                var Type = "";
                var Value = "";

                if (b.Index == -1)
                    Type = a.AfterSubject.Trim();
                else
                {
                    Type = a.SubString(b).Trim();
                    Value = b.AfterSubject.Trim();
                }


                var Summary = Signature.GetNextTrimmedLine();

                var DefinedBy = Summary.GetNextTrimmedLine();

                var n = new ConstantInfo
                {
                    Signature = Signature.Text,
                    Summary = Summary.Text,
                    DefinedBy = DefinedBy.Text,
                    IsAirOnly = IsAirOnly,
                    Type = Type,
                    Name = Name,
                    Value = Value
                };

                return new Tuple<ConstantInfo, IndexInfo>
                {
                    TValue = n,
                    FValue = DefinedBy
                };
            }
            internal static Tuple<MethodInfo, IndexInfo> ScanNext(IndexInfo LastIndex)
            {
                // scan properties
                var Flags = LastIndex.GetNextTrimmedLine();

                if (Flags.Text != KeywordInherited)
                    if (!string.IsNullOrEmpty(Flags.Text))
                        return null;

                var Signature = Flags.GetNextTrimmedLine();

                if (!Signature.Text.Contains(")"))
                    return null;

                if (!Signature.Text.Contains("("))
                    return null;

                var Summary = Signature.GetNextTrimmedLine();

                var DefinedBy = Summary.GetNextTrimmedLine();

                // get params
                var a = Signature.Text.IndexInfoOf("(");
                var b = a.IndexInfoOf(")");
                var p = a.SubString(b);
                var r = b.IndexInfoOf(":");

                var IsConstructor = true;
                var ReturnType = "";

                if (r.Index != -1)
                {
                    IsConstructor = false;
                    ReturnType = r.AfterSubject;
                }

                var n = new MethodInfo
                {
                    Flags = Flags.Text,
                    Signature = Signature.Text,
                    Summary = Summary.Text,
                    DefinedBy = DefinedBy.Text,
                    ParametersInfo = new MethodParametersInfo(p),
                    Name = a.BeforeSubject,
                    IsConstructor = IsConstructor,
                    ReturnType = ReturnType
                };

                // do last minute checks here


                return new Tuple<MethodInfo, IndexInfo>
                {
                    TValue = n,
                    FValue = DefinedBy
                };
            }
Exemplo n.º 46
0
        public ActionResult TestIndex()
        {
            var indexer = (LuceneIndexer)ExamineManager.Instance.IndexProviderCollection["Simple2Indexer"];
            var writer = indexer.GetIndexWriter();

            var model = new IndexInfo
            {
                Docs = writer.MaxDoc(),
                Fields = writer.GetReader().GetFieldNames(IndexReader.FieldOption.ALL).Count
            };

            return View(model);
        }
Exemplo n.º 47
0
        /// <summary>
        /// Adds a <see cref="IndexLibrary.IndexInfo"/> to this summary
        /// </summary>
        /// <param name="info">The info to add.</param>
        public void AddIndexInfo(IndexInfo info)
        {
            if (info == null) throw new ArgumentNullException("info", "info cannot be null");

            this.totalWrites++;

            if ((this.features & IndexInfoSummaryFeature.WriteTimeSpread) == IndexInfoSummaryFeature.WriteTimeSpread) {
                DateTime key = new DateTime(info.CreatedTime.Year, info.CreatedTime.Month, info.CreatedTime.Day, info.CreatedTime.Hour, info.CreatedTime.Minute, 0);
                this.timeSpread.Add(new KeyValuePair<DateTime, string>(key, info.IndexName));
            }

            if ((this.features & IndexInfoSummaryFeature.TotalReads) == IndexInfoSummaryFeature.TotalReads) this.totalReads += info.TotalReads;
            if ((this.features & IndexInfoSummaryFeature.TotalSearches) == IndexInfoSummaryFeature.TotalSearches) this.totalSearches += info.TotalSearches;

            if ((this.features & IndexInfoSummaryFeature.MostRecentIndexes) == IndexInfoSummaryFeature.MostRecentIndexes) {
                if (this.mostRecent.ContainsKey(info.IndexName)) this.mostRecent.Add(info.IndexName, info);
                this.mostRecent[info.IndexName] = info;
            }
        }