diff --git a/src/SIL.LCModel/DomainImpl/FactoryAdditions.cs b/src/SIL.LCModel/DomainImpl/FactoryAdditions.cs index b6c49a58..24a6225d 100644 --- a/src/SIL.LCModel/DomainImpl/FactoryAdditions.cs +++ b/src/SIL.LCModel/DomainImpl/FactoryAdditions.cs @@ -1604,30 +1604,46 @@ internal partial class CmTranslationFactory /// Create a well-formed ICmTranslation which has the owner and Type property set. /// public ICmTranslation Create(IStTxtPara owner, ICmPossibility translationType) + { + return Create(owner, translationType, Guid.NewGuid()); + } + /// + /// Create a well-formed ICmTranslation which has the owner and Type property set. + /// + public ICmTranslation Create(IStTxtPara owner, ICmPossibility translationType, Guid guid) { if (owner == null) throw new ArgumentNullException("owner"); if (translationType == null) throw new ArgumentNullException("translationType"); - return Create(owner.TranslationsOC, translationType); + return Create(owner.TranslationsOC, translationType, guid); } /// /// Create a well-formed ICmTranslation which has the owner and Type property set. /// public ICmTranslation Create(ILexExampleSentence owner, ICmPossibility translationType) + { + return Create(owner, translationType, Guid.NewGuid()); + } + + /// + /// Create a well-formed ICmTranslation which has the owner and Type property set. + /// + public ICmTranslation Create(ILexExampleSentence owner, ICmPossibility translationType, Guid guid) { if (owner == null) throw new ArgumentNullException("owner"); if (translationType == null) throw new ArgumentNullException("translationType"); - return Create(owner.TranslationsOC, translationType); + return Create(owner.TranslationsOC, translationType, guid); } /// /// Do the real work for both smart Create methods. /// - private ICmTranslation Create(ICollection owningVector, ICmPossibility translationType) + private ICmTranslation Create(ICollection owningVector, ICmPossibility translationType, Guid guid) { - var newbie = new CmTranslation(); + if (guid == Guid.Empty) guid = Guid.NewGuid(); + var newbie = new CmTranslation(m_cache, m_cache.InternalServices.DataReader.GetNextRealHvo(), guid); owningVector.Add(newbie); newbie.TypeRA = translationType; return newbie; diff --git a/src/SIL.LCModel/FactoryInterfaceAdditions.cs b/src/SIL.LCModel/FactoryInterfaceAdditions.cs index 7b55a56e..bfa49c6b 100644 --- a/src/SIL.LCModel/FactoryInterfaceAdditions.cs +++ b/src/SIL.LCModel/FactoryInterfaceAdditions.cs @@ -38,10 +38,20 @@ public partial interface ICmTranslationFactory /// ICmTranslation Create(IStTxtPara owner, ICmPossibility translationType); + /// + /// Create a well-formed ICmTranslation which has an owner and Type property set + /// + ICmTranslation Create(IStTxtPara owner, ICmPossibility translationType, Guid guid); + /// /// Create a well-formed ICmTranslation which has an owner and Type property set /// ICmTranslation Create(ILexExampleSentence owner, ICmPossibility translationType); + + /// + /// Create a well-formed ICmTranslation which has an owner and Type property set + /// + ICmTranslation Create(ILexExampleSentence owner, ICmPossibility translationType, Guid guid); } public partial interface ICmTranslation