Ejemplo n.º 1
0
        public LexiconSense AddSense()
        {
            LexiconSense sense       = null;
            bool         lexemeAdded = false;

            m_lexicon.UpdatingEntries = true;
            try
            {
                using (m_lexicon.ActivationContext.Activate())
                {
                    NonUndoableUnitOfWorkHelper.Do(m_lexicon.Cache.ActionHandlerAccessor, () =>
                    {
                        ILexEntry entry;
                        if (!m_lexicon.TryGetEntry(m_key, out entry))
                        {
                            entry       = m_lexicon.CreateEntry(m_key);
                            lexemeAdded = true;
                        }

                        if (entry.AllSenses.Count == 1 && entry.SensesOS[0].Gloss.StringCount == 0)
                        {
                            // An empty sense exists (probably was created during a call to AddLexeme)
                            sense = new LexSenseLexiconSense(m_lexicon, m_key, entry.SensesOS[0]);
                        }
                        else
                        {
                            ILexSense newSense = m_lexicon.Cache.ServiceLocator.GetInstance <ILexSenseFactory>().Create(
                                entry, new SandboxGenericMSA(), (string)null);
                            sense = new LexSenseLexiconSense(m_lexicon, m_key, newSense);
                        }
                    });
                }
            }
            finally
            {
                m_lexicon.UpdatingEntries = false;
            }
            if (lexemeAdded)
            {
                m_lexicon.OnLexemeAdded(this);
            }
            m_lexicon.OnLexiconSenseAdded(this, sense);
            return(sense);
        }
Ejemplo n.º 2
0
		public LexiconSense AddSense()
		{
			LexiconSense sense = null;
			bool lexemeAdded = false;
			m_lexicon.UpdatingEntries = true;
			try
			{
				using (m_lexicon.ActivationContext.Activate())
				{
					NonUndoableUnitOfWorkHelper.Do(m_lexicon.Cache.ActionHandlerAccessor, () =>
						{
							ILexEntry entry;
							if (!m_lexicon.TryGetEntry(m_key, out entry))
							{
								entry = m_lexicon.CreateEntry(m_key);
								lexemeAdded = true;
							}

							if (entry.AllSenses.Count == 1 && entry.SensesOS[0].Gloss.StringCount == 0)
							{
								// An empty sense exists (probably was created during a call to AddLexeme)
								sense = new LexSenseLexiconSense(m_lexicon, m_key, entry.SensesOS[0]);
							}
							else
							{
								ILexSense newSense = m_lexicon.Cache.ServiceLocator.GetInstance<ILexSenseFactory>().Create(
									entry, new SandboxGenericMSA(), (string)null);
								sense = new LexSenseLexiconSense(m_lexicon, m_key, newSense);
							}
						});
				}
			}
			finally
			{
				m_lexicon.UpdatingEntries = false;
			}
			if (lexemeAdded)
				m_lexicon.OnLexemeAdded(this);
			m_lexicon.OnLexiconSenseAdded(this, sense);
			return sense;
		}