Ejemplo n.º 1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Parse the existing Contents to determine the object match criteria and set member
        /// data needed by MatchesCriteria.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public void ParseObjectMatchCriteria()
        {
            lock (SyncRoot)
            {
                string criteria = Contents.Text;
                m_comparisonType = ComparisonTypes.kUndefined;
                m_matchValue     = 0;
                m_matchSubitems  = criteria.IndexOf("+subitems", StringComparison.Ordinal) >= 0;
                m_matchEmpty     = criteria.IndexOf("Empty", StringComparison.Ordinal) >= 0;

                if (criteria.IndexOf("Matches", StringComparison.Ordinal) >= 0)
                {
                    m_comparisonType = ComparisonTypes.kMatches;
                }
                else if (m_matchEmpty)
                {
                    m_comparisonType = ComparisonTypes.kEmpty;
                }

                Debug.Assert(m_comparisonType != ComparisonTypes.kUndefined);

                m_matchValues = null;

                // Check to see whether the criteria specifies a specific (default) object.
                if (criteria.IndexOf(StringUtils.kChObject) >= 0)
                {
                    ITsTextProps ttp     = Contents.get_Properties(1);                 //assume second run
                    string       objData = ttp.GetStrPropValue((int)FwTextPropType.ktptObjData);
                    if (objData[0] == (char)FwObjDataTypes.kodtNameGuidHot)
                    {
                        Guid                     guid = MiscUtils.GetGuidFromObjData(objData.Substring(1));
                        ICmPossibility           poss;
                        ICmPossibilityRepository repo = Cache.ServiceLocator.GetInstance <ICmPossibilityRepository>();
                        if (repo.TryGetObject(guid, out poss))
                        {
                            m_matchValue = poss.Hvo;
                        }
                    }

                    InitializeMatchValuesArray();
                }
            }
        }