protected override void AddObjectSideEffectsInternal(AddObjectEventArgs e) { if (e.Flid == RnResearchNbkTags.kflidRecords) UpdateAllRecords(); base.AddObjectSideEffectsInternal(e); }
/// ------------------------------------------------------------------------------------ /// <summary> /// This version overrides the CmObject version. Handles various Scripture side effects /// and TagsOC modifications. /// </summary> /// <param name="e"></param> /// ------------------------------------------------------------------------------------ protected override void AddObjectSideEffectsInternal(AddObjectEventArgs e) { // Prevent accidentally adding a plain StTxtPara to a Scripture text... // the ScrTxtPara subclass should always be used. // But watch out for the case (FWR-3477) where paragraph is owned by a CmPossibility first! if (e.Flid == StTextTags.kflidParagraphs && (OwnerOfClass<IScripture>() != null && !(Owner is ICmPossibility)) && !(e.ObjectAdded is ScrTxtPara)) throw new ArgumentException("Can not add object of type " + e.ObjectAdded.GetType() + " to this StText"); base.AddObjectSideEffectsInternal(e); //if (e.Flid == StTextTags.kflidTags) // TextTagCollectionChanges(true, e.ObjectAdded); if (e.Flid == StTextTags.kflidParagraphs) { if (e.ObjectAdded is IScrTxtPara) { IScrSection section = OwnerOfClass<IScrSection>(); if (section != null) ((ScrSection)section).AdjustReferences(); } if (e.Index == ParagraphsOS.Count - 1 && e.Index > 0) { int flid = Services.GetInstance<Virtuals>().StParaIsFinalParaInText; Services.GetInstance<IUnitOfWorkService>().RegisterVirtualAsModified( ParagraphsOS[e.Index - 1], flid, true, false); } } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Overridden to allow special handling to prevent moving Scripture paragraphs to a /// different book. /// </summary> /// ------------------------------------------------------------------------------------ protected override void ValidateAddObjectInternal(AddObjectEventArgs e) { if (e.Flid == StTextTags.kflidParagraphs && e.ObjectAdded.Hvo != (int)SpecialHVOValues.kHvoUninitializedObject) { IScrBook originalOwningBook = e.ObjectAdded.OwnerOfClass<IScrBook>(); if (originalOwningBook != null) { // this StText is the one that is to be the new owner. IScrBook newOwningBook = OwnerOfClass<IScrBook>(); if (newOwningBook != originalOwningBook) throw new InvalidOperationException("Scripture pargraphs cannot be moved between books."); } } base.ValidateAddObjectInternal(e); }
protected override void AddObjectSideEffectsInternal(AddObjectEventArgs e) { switch (e.Flid) { case MoInflAffMsaTags.kflidSlots: var target = ((IMoInflAffixSlot) e.ObjectAdded); var flid = m_cache.MetaDataCache.GetFieldId2(MoInflAffixSlotTags.kClassId, "Affixes", false); var newGuids = (from msa in target.Affixes select msa.Guid).ToArray(); m_cache.ServiceLocator.GetInstance<IUnitOfWorkService>().RegisterVirtualAsModified(target, flid, new Guid[0], newGuids); break; default: base.AddObjectSideEffectsInternal(e); break; } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Need this version, because the ICmObjectInternal.ValidateAddObject version /// can't be virtual, and we want subclasses to be able to override the method. /// </summary> /// <exception cref="InvalidOperationException">The addition is not valid</exception> /// ------------------------------------------------------------------------------------ protected override void ValidateAddObjectInternal(AddObjectEventArgs e) { base.ValidateAddObjectInternal(e); if (e.Flid == StTxtParaTags.kflidTranslations) { if (Cache.FullyInitializedAndReadyToRock && TranslationsOC.Count > 0) throw new InvalidOperationException("Can not have more than one CmTranslation for a paragraph (kind of makes you wonder why we have a collection)"); ICmTranslation trans = (ICmTranslation)e.ObjectAdded; if (trans.TypeRA != null && trans.TypeRA.Guid != LangProjectTags.kguidTranBackTranslation) throw new ArgumentException("Back translations are the only type of translation allowed for paragraphs"); } }
protected override void AddObjectSideEffectsInternal(AddObjectEventArgs e) { if (e.Flid == RnGenericRecTags.kflidSubRecords) { var notebook = OwnerOfClass<RnResearchNbk>(); notebook.UpdateAllRecords(); int flid = m_cache.MetaDataCache.GetFieldId2(RnGenericRecTags.kClassId, "IndexInOwnerTSS", false); ITsString dummy = m_cache.TsStrFactory.MakeString("", m_cache.DefaultAnalWs); RegisterAllSubrecordIndexTSSChanged(this.SubRecordsOS, flid, dummy); NoteSubrecordOfChanges(this, e.Index); } base.AddObjectSideEffectsInternal(e); }
protected override void AddObjectSideEffectsInternal(AddObjectEventArgs e) { switch (e.Flid) { case TextTags.kflidGenres: if (ContentsOA != null) InternalServices.UnitOfWorkService.RegisterVirtualAsModified(ContentsOA, "GenreCategories", GenresRC.Cast<ICmObject>()); return; // still do the default thing, base class has this property too. } base.AddObjectSideEffectsInternal(e); }
protected override void AddObjectSideEffectsInternal(AddObjectEventArgs e) { switch(e.Flid) { case WfiAnalysisTags.kflidEvaluations: AdjustApprovalLists((IWfiWordform)Owner); return; } base.AddObjectSideEffectsInternal(e); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Validation done before adding an object to some vector flid. /// </summary> /// <exception cref="InvalidOperationException">The addition is not valid</exception> /// ------------------------------------------------------------------------------------ protected override void ValidateAddObjectInternal(AddObjectEventArgs e) { if (e.Flid == ScrFootnoteTags.kflidParagraphs && ParagraphsOS.Count >= s_maxAllowedParagraphs) throw new InvalidOperationException("Scripture footnotes are limited to " + s_maxAllowedParagraphs + " paragraph(s)."); base.ValidateAddObjectInternal(e); }