Skip to content

Commit 0e0125d

Browse files
authored
add create methods to CmTranslationFactory which take a guid (#341)
1 parent 4d3816d commit 0e0125d

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

src/SIL.LCModel/DomainImpl/FactoryAdditions.cs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1604,30 +1604,46 @@ internal partial class CmTranslationFactory
16041604
/// Create a well-formed ICmTranslation which has the owner and Type property set.
16051605
/// </summary>
16061606
public ICmTranslation Create(IStTxtPara owner, ICmPossibility translationType)
1607+
{
1608+
return Create(owner, translationType, Guid.NewGuid());
1609+
}
1610+
/// <summary>
1611+
/// Create a well-formed ICmTranslation which has the owner and Type property set.
1612+
/// </summary>
1613+
public ICmTranslation Create(IStTxtPara owner, ICmPossibility translationType, Guid guid)
16071614
{
16081615
if (owner == null) throw new ArgumentNullException("owner");
16091616
if (translationType == null) throw new ArgumentNullException("translationType");
16101617

1611-
return Create(owner.TranslationsOC, translationType);
1618+
return Create(owner.TranslationsOC, translationType, guid);
16121619
}
16131620

16141621
/// <summary>
16151622
/// Create a well-formed ICmTranslation which has the owner and Type property set.
16161623
/// </summary>
16171624
public ICmTranslation Create(ILexExampleSentence owner, ICmPossibility translationType)
1625+
{
1626+
return Create(owner, translationType, Guid.NewGuid());
1627+
}
1628+
1629+
/// <summary>
1630+
/// Create a well-formed ICmTranslation which has the owner and Type property set.
1631+
/// </summary>
1632+
public ICmTranslation Create(ILexExampleSentence owner, ICmPossibility translationType, Guid guid)
16181633
{
16191634
if (owner == null) throw new ArgumentNullException("owner");
16201635
if (translationType == null) throw new ArgumentNullException("translationType");
16211636

1622-
return Create(owner.TranslationsOC, translationType);
1637+
return Create(owner.TranslationsOC, translationType, guid);
16231638
}
16241639

16251640
/// <summary>
16261641
/// Do the real work for both smart Create methods.
16271642
/// </summary>
1628-
private ICmTranslation Create(ICollection<ICmTranslation> owningVector, ICmPossibility translationType)
1643+
private ICmTranslation Create(ICollection<ICmTranslation> owningVector, ICmPossibility translationType, Guid guid)
16291644
{
1630-
var newbie = new CmTranslation();
1645+
if (guid == Guid.Empty) guid = Guid.NewGuid();
1646+
var newbie = new CmTranslation(m_cache, m_cache.InternalServices.DataReader.GetNextRealHvo(), guid);
16311647
owningVector.Add(newbie);
16321648
newbie.TypeRA = translationType;
16331649
return newbie;

src/SIL.LCModel/FactoryInterfaceAdditions.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,20 @@ public partial interface ICmTranslationFactory
3838
/// </summary>
3939
ICmTranslation Create(IStTxtPara owner, ICmPossibility translationType);
4040

41+
/// <summary>
42+
/// Create a well-formed ICmTranslation which has an owner and Type property set
43+
/// </summary>
44+
ICmTranslation Create(IStTxtPara owner, ICmPossibility translationType, Guid guid);
45+
4146
/// <summary>
4247
/// Create a well-formed ICmTranslation which has an owner and Type property set
4348
/// </summary>
4449
ICmTranslation Create(ILexExampleSentence owner, ICmPossibility translationType);
50+
51+
/// <summary>
52+
/// Create a well-formed ICmTranslation which has an owner and Type property set
53+
/// </summary>
54+
ICmTranslation Create(ILexExampleSentence owner, ICmPossibility translationType, Guid guid);
4555
}
4656

4757
public partial interface ICmTranslation

0 commit comments

Comments
 (0)