Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions src/SIL.LCModel/DomainImpl/FactoryAdditions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1604,30 +1604,46 @@ internal partial class CmTranslationFactory
/// Create a well-formed ICmTranslation which has the owner and Type property set.
/// </summary>
public ICmTranslation Create(IStTxtPara owner, ICmPossibility translationType)
{
return Create(owner, translationType, Guid.NewGuid());
}
/// <summary>
/// Create a well-formed ICmTranslation which has the owner and Type property set.
/// </summary>
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);
}

/// <summary>
/// Create a well-formed ICmTranslation which has the owner and Type property set.
/// </summary>
public ICmTranslation Create(ILexExampleSentence owner, ICmPossibility translationType)
{
return Create(owner, translationType, Guid.NewGuid());
}

/// <summary>
/// Create a well-formed ICmTranslation which has the owner and Type property set.
/// </summary>
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);
}

/// <summary>
/// Do the real work for both smart Create methods.
/// </summary>
private ICmTranslation Create(ICollection<ICmTranslation> owningVector, ICmPossibility translationType)
private ICmTranslation Create(ICollection<ICmTranslation> 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;
Expand Down
10 changes: 10 additions & 0 deletions src/SIL.LCModel/FactoryInterfaceAdditions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,20 @@ public partial interface ICmTranslationFactory
/// </summary>
ICmTranslation Create(IStTxtPara owner, ICmPossibility translationType);

/// <summary>
/// Create a well-formed ICmTranslation which has an owner and Type property set
/// </summary>
ICmTranslation Create(IStTxtPara owner, ICmPossibility translationType, Guid guid);

/// <summary>
/// Create a well-formed ICmTranslation which has an owner and Type property set
/// </summary>
ICmTranslation Create(ILexExampleSentence owner, ICmPossibility translationType);

/// <summary>
/// Create a well-formed ICmTranslation which has an owner and Type property set
/// </summary>
ICmTranslation Create(ILexExampleSentence owner, ICmPossibility translationType, Guid guid);
}

public partial interface ICmTranslation
Expand Down
Loading