Esempio n. 1
0
		/// <summary>
		/// Called by the base class in it's constructor, this is the method that
		/// reads the contents and gathers the sfm information.
		/// </summary>
		protected override void Init()
		{
			m_sfmFollowedBy = new Dictionary<string, Dictionary<string, int>>();
			m_followedByInfo = new Dictionary<string,FollowedByInfo>();
			try
			{
				string sfm;
				string sfmLast = null;
				byte[] sfmData;
				byte[] badSfmData;
				while (GetNextSfmMarkerAndData(out sfm, out sfmData, out badSfmData))
				{
					if (sfm.Length == 0)
						continue; // no action if empty sfm - case where data before first marker
					if (m_sfmUsage.ContainsKey(sfm))
					{
						int val = m_sfmUsage[sfm] + 1;
						m_sfmUsage[sfm] = val;
					}
					else
					{
						if (sfm.Length > m_longestSfmSize)
							m_longestSfmSize = sfm.Length;
						//// LT-1926 Ignore all markers that start with underscore (shoebox markers)
						//if (sfm.StartsWith("_"))
						//    continue;
						m_sfmUsage.Add(sfm, 1);
						m_sfmOrder.Add(sfm);
					}

					// handle the marker and following counts
					int count;
					if (sfmLast != null)
					{
						Dictionary<string, int> markerHash;
						if (m_sfmFollowedBy.TryGetValue(sfmLast, out markerHash))
						{
							if (markerHash.TryGetValue(sfm, out count))
							{
								count++;
								markerHash[sfm] = count;
							}
							else
							{
								markerHash[sfm] = 1;
							}
						}
						else
						{
							markerHash = new Dictionary<string, int>();
							markerHash[sfm] = 1;
							m_sfmFollowedBy[sfmLast] = markerHash;
						}

						// new logic with List container
						string key = BuildKey(sfmLast, sfm);
						FollowedByInfo fbi;
						if (m_followedByInfo.TryGetValue(key, out fbi))
						{
							fbi.IncCount();
							m_followedByInfo[key] = fbi;
						}
						else
						{
							m_followedByInfo[key] = new FollowedByInfo(sfmLast, sfm);
						}

					}
					sfmLast = sfm;
				}
			}
			catch
			{
				// just eat the exception sense the data members will be empty
			}
		}
Esempio n. 2
0
        /// <summary>
        /// Called by the base class in it's constructor, this is the method that
        /// reads the contents and gathers the sfm information.
        /// </summary>
        protected override void Init()
        {
            m_sfmFollowedBy  = new Dictionary <string, Dictionary <string, int> >();
            m_followedByInfo = new Dictionary <string, FollowedByInfo>();
            try
            {
                string sfm;
                string sfmLast = null;
                byte[] sfmData;
                byte[] badSfmData;
                while (GetNextSfmMarkerAndData(out sfm, out sfmData, out badSfmData))
                {
                    if (sfm.Length == 0)
                    {
                        continue;                         // no action if empty sfm - case where data before first marker
                    }
                    if (m_sfmUsage.ContainsKey(sfm))
                    {
                        int val = m_sfmUsage[sfm] + 1;
                        m_sfmUsage[sfm] = val;
                    }
                    else
                    {
                        if (sfm.Length > m_longestSfmSize)
                        {
                            m_longestSfmSize = sfm.Length;
                        }
                        //// LT-1926 Ignore all markers that start with underscore (shoebox markers)
                        //if (sfm.StartsWith("_"))
                        //    continue;
                        m_sfmUsage.Add(sfm, 1);
                        m_sfmOrder.Add(sfm);
                    }

                    // handle the marker and following counts
                    int count;
                    if (sfmLast != null)
                    {
                        Dictionary <string, int> markerHash;
                        if (m_sfmFollowedBy.TryGetValue(sfmLast, out markerHash))
                        {
                            if (markerHash.TryGetValue(sfm, out count))
                            {
                                count++;
                                markerHash[sfm] = count;
                            }
                            else
                            {
                                markerHash[sfm] = 1;
                            }
                        }
                        else
                        {
                            markerHash               = new Dictionary <string, int>();
                            markerHash[sfm]          = 1;
                            m_sfmFollowedBy[sfmLast] = markerHash;
                        }

                        // new logic with List container
                        string         key = BuildKey(sfmLast, sfm);
                        FollowedByInfo fbi;
                        if (m_followedByInfo.TryGetValue(key, out fbi))
                        {
                            fbi.IncCount();
                            m_followedByInfo[key] = fbi;
                        }
                        else
                        {
                            m_followedByInfo[key] = new FollowedByInfo(sfmLast, sfm);
                        }
                    }
                    sfmLast = sfm;
                }
            }
            catch
            {
                // just eat the exception sense the data members will be empty
            }
        }