本文整理汇总了C#中IDomainObjectDTORepository类的典型用法代码示例。如果您正苦于以下问题:C# IDomainObjectDTORepository类的具体用法?C# IDomainObjectDTORepository怎么用?C# IDomainObjectDTORepository使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IDomainObjectDTORepository类属于命名空间,在下文中一共展示了IDomainObjectDTORepository类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PerformMigration
/// ------------------------------------------------------------------------------------
/// <summary>
/// Change any bogus non-owning footnote links in the vernacular (but NOT in the BT)
/// to be owning links
/// </summary>
/// <param name="domainObjectDtoRepository">
/// Repository of all CmObject DTOs available for one migration step.
/// </param>
/// ------------------------------------------------------------------------------------
public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepository)
{
DataMigrationServices.CheckVersionNumber(domainObjectDtoRepository, 7000034);
foreach (var scrTxtPara in domainObjectDtoRepository.AllInstancesSansSubclasses("ScrTxtPara"))
{
XElement para = XElement.Parse(scrTxtPara.Xml);
XElement contents = para.Element("Contents");
if (contents == null)
continue;
XElement str = contents.Element("Str");
if (str == null)
continue;
foreach (XElement run in str.Elements("Run"))
{
XAttribute linkAttr = run.Attribute("link");
if (linkAttr == null)
continue; // Run doesn't contain an unowned hot-link
XAttribute ownedLinkAttr = new XAttribute("ownlink", linkAttr.Value);
run.Add(ownedLinkAttr);
linkAttr.Remove();
DataMigrationServices.UpdateDTO(domainObjectDtoRepository, scrTxtPara, para.ToString());
}
}
DataMigrationServices.IncrementVersionNumber(domainObjectDtoRepository);
}
示例2: PerformMigration
/// ------------------------------------------------------------------------------------
/// <summary>
/// Change all guids to lowercase to help the Chorus diff/merge code.
/// </summary>
/// ------------------------------------------------------------------------------------
public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepository)
{
DataMigrationServices.CheckVersionNumber(domainObjectDtoRepository, 7000024);
const string dateCreated = "DateCreated";
var properties = new List<string> { dateCreated, "DateModified" };
ConvertClassAndSubclasses(domainObjectDtoRepository, domainObjectDtoRepository.AllInstancesWithSubclasses("CmProject"), properties); // Tested
ConvertClassAndSubclasses(domainObjectDtoRepository, domainObjectDtoRepository.AllInstancesWithSubclasses("CmMajorObject"), properties); // Tested
ConvertClassAndSubclasses(domainObjectDtoRepository, domainObjectDtoRepository.AllInstancesWithSubclasses("CmPossibility"), properties); // Tested
ConvertClassAndSubclasses(domainObjectDtoRepository, domainObjectDtoRepository.AllInstancesWithSubclasses("CmAnnotation"), properties); // Tested
ConvertClassAndSubclasses(domainObjectDtoRepository, domainObjectDtoRepository.AllInstancesWithSubclasses("StJournalText"), properties); // Tested
ConvertClassAndSubclasses(domainObjectDtoRepository, domainObjectDtoRepository.AllInstancesWithSubclasses("LexEntry"), properties); // Tested
ConvertClassAndSubclasses(domainObjectDtoRepository, domainObjectDtoRepository.AllInstancesWithSubclasses("RnGenericRec"), properties); // Tested
// Since ScrScriptureNote derives from CmBaseAnnotation, which has already had it DateCreated & DateModified updated,
// we have to clear those two out of the dictioanry, or they will be updated twice, and the test on ScrScriptureNote will fail.
properties.Clear();
properties.Add("DateResolved");
ConvertClassAndSubclasses(domainObjectDtoRepository, domainObjectDtoRepository.AllInstancesWithSubclasses("ScrScriptureNote"), properties); // Tested
properties.Clear();
properties.Add(dateCreated);
ConvertClassAndSubclasses(domainObjectDtoRepository, domainObjectDtoRepository.AllInstancesWithSubclasses("ScrDraft"), properties);
properties.Clear();
properties.Add("RunDate");
ConvertClassAndSubclasses(domainObjectDtoRepository, domainObjectDtoRepository.AllInstancesWithSubclasses("ScrCheckRun"), properties);
DataMigrationServices.IncrementVersionNumber(domainObjectDtoRepository);
}
示例3: PerformMigration
/// ------------------------------------------------------------------------------------
/// <summary>
/// Makes LexEntries be unowned.
/// </summary>
/// <param name="domainObjectDtoRepository">
/// Repository of all CmObject DTOs available for one migration step.
/// </param>
/// <remarks>
/// The method must add/remove/update the DTOs to the repository,
/// as it adds/removes objects as part of it work.
///
/// Implementors of this interface should ensure the Repository's
/// starting model version number is correct for the step.
/// Implementors must also increment the Repository's model version number
/// at the end of its migration work.
///
/// The method also should normally modify the xml string(s)
/// of relevant DTOs, since that string will be used by the main
/// data migration calling client (ie. BEP).
/// </remarks>
/// ------------------------------------------------------------------------------------
public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepository)
{
DataMigrationServices.CheckVersionNumber(domainObjectDtoRepository, 7000027);
var lexDbDto = domainObjectDtoRepository.AllInstancesSansSubclasses("LexDb").First();
var lexDb = XElement.Parse(lexDbDto.Xml);
var entries = lexDb.Element("Entries");
if (entries != null)
{
entries.Remove();
DataMigrationServices.UpdateDTO(domainObjectDtoRepository, lexDbDto, lexDb.ToString());
}
foreach (var entryDto in domainObjectDtoRepository.AllInstancesSansSubclasses("LexEntry"))
{
XElement entry = XElement.Parse(entryDto.Xml);
var ownerAttr = entry.Attribute("ownerguid");
if (ownerAttr != null)
{
ownerAttr.Remove();
DataMigrationServices.UpdateDTO(domainObjectDtoRepository, entryDto, entry.ToString());
}
}
DataMigrationServices.IncrementVersionNumber(domainObjectDtoRepository);
}
示例4: PerformMigration
public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepository)
{
DataMigrationServices.CheckVersionNumber(domainObjectDtoRepository, 7000062);
var wmbLangProjList = domainObjectDtoRepository.AllInstancesSansSubclasses("LangProject");
var wmbLangProj = wmbLangProjList.First();
var wmbLangProjElt = XElement.Parse(wmbLangProj.Xml);
// get the default vernacular ws - it's the 1st in the list of current ones.
var vernWss = wmbLangProjElt.Element("CurVernWss"); // has to be only one
// a new project migrates before adding writing systems to the cache, so if there are no CurVernWss, bail out
if (vernWss != null)
{
var vernWssUni = vernWss.Element("Uni"); // only one
var vernWsList = vernWssUni.Value.Split(' '); // at least one
var vernDefault = vernWsList[0]; // the default
// Create the new property
var sb = new StringBuilder();
sb.Append("<HomographWs>");
sb.AppendFormat("<Uni>{0}</Uni>", vernDefault);
sb.Append("</HomographWs>");
var hgWsElt = XElement.Parse(sb.ToString());
wmbLangProjElt.Add(hgWsElt);
DataMigrationServices.UpdateDTO(domainObjectDtoRepository, wmbLangProj, wmbLangProjElt.ToString());
}
DataMigrationServices.IncrementVersionNumber(domainObjectDtoRepository);
}
示例5: DeleteWeatherListAndField
/// <summary>
/// The Weather list is never used, so delete it (and remove any empty Weather elements
/// from the RnGenericRec elements).
/// </summary>
private void DeleteWeatherListAndField(IDomainObjectDTORepository repoDTO)
{
// Remove the Weather list.
DomainObjectDTO dtoLP = GetDtoLangProj(repoDTO);
string sWeatherListGuid = RemoveWeatherConditionsElement(dtoLP).ToLowerInvariant();
repoDTO.Update(dtoLP);
DomainObjectDTO dtoDeadList = null;
foreach (var dto in repoDTO.AllInstancesWithSubclasses("CmPossibilityList"))
{
if (dto.Guid.ToLowerInvariant() == sWeatherListGuid)
{
dtoDeadList = dto;
break;
}
}
List<DomainObjectDTO> rgdtoDead = new List<DomainObjectDTO>();
GatherDeadObjects(repoDTO, dtoDeadList, rgdtoDead);
foreach (var dto in rgdtoDead)
repoDTO.Remove(dto);
// Remove any empty Weather elements in the RnGenericRec objects.
foreach (var dto in repoDTO.AllInstancesWithSubclasses("RnGenericRec"))
{
string sXml = dto.Xml;
int idx = sXml.IndexOf("<Weather");
if (idx > 0)
{
dto.Xml = RemoveEmptyWeather(sXml, idx);
repoDTO.Update(dto);
}
}
}
示例6: PerformMigration
/// ------------------------------------------------------------------------------------
/// <summary>
/// Changes all StFootnotes to ScrFootnotes
/// </summary>
/// <param name="domainObjectDtoRepository">
/// Repository of all CmObject DTOs available for one migration step.
/// </param>
/// <remarks>
/// The method must add/remove/update the DTOs to the repository,
/// as it adds/removes objects as part of it work.
///
/// Implementors of this interface should ensure the Repository's
/// starting model version number is correct for the step.
/// Implementors must also increment the Repository's model version number
/// at the end of its migration work.
///
/// The method also should normally modify the xml string(s)
/// of relevant DTOs, since that string will be used by the main
/// data migration calling client (ie. BEP).
/// </remarks>
/// ------------------------------------------------------------------------------------
public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepository)
{
DataMigrationServices.CheckVersionNumber(domainObjectDtoRepository, 7000002);
var footnotesToChangeClasses = new List<DomainObjectDTO>();
foreach (var footnote in domainObjectDtoRepository.AllInstancesSansSubclasses("StFootnote"))
{
XElement footnoteEl = XElement.Parse(footnote.Xml);
footnoteEl.Attribute("class").Value = "ScrFootnote";
// Add the empty ScrFootnote element to the ScrFootnote
footnoteEl.Add(new XElement("ScrFootnote"));
// Update the object XML
footnote.Xml = footnoteEl.ToString();
footnote.Classname = "ScrFootnote";
footnotesToChangeClasses.Add(footnote);
}
// Udate the repository
var startingStructure = new ClassStructureInfo("StText", "StFootnote");
var endingStructure = new ClassStructureInfo("StFootnote", "ScrFootnote");
foreach (var changedPara in footnotesToChangeClasses)
domainObjectDtoRepository.Update(changedPara,
startingStructure,
endingStructure);
DataMigrationServices.IncrementVersionNumber(domainObjectDtoRepository);
}
示例7: VerifyReplace
private void VerifyReplace(IDomainObjectDTORepository dtoRepos, string guid, bool expectReplace, int numOfPubs)
{
var dto = dtoRepos.GetDTO(guid);
var xElt = XElement.Parse(dto.Xml);
Assert.That(xElt.Attribute("class").Value == "LexEntry", "Giud not representing a LexEntry after migration to 7000041.");
var hasDoNotShow = xElt.Element("DoNotShowMainEntryIn");
string expect = "";
if (!expectReplace)
expect = "not ";
Assert.That(expectReplace == (hasDoNotShow != null),
"LexEntry " + guid + " did " + expect + "expect ExcludeAsHeadword to be replaced by DoNotShowMainEntryIn, but it didn't happen in migration to 7000041.");
if (expectReplace)
{ // Check that each publication is referenced
var noShows = SurrogatesIn(xElt, "DoNotShowMainEntryIn", numOfPubs);
var dtoPubist = dtoRepos.GetDTO(CmPossibilityListTags.kguidPublicationsList.ToString());
Assert.That(dtoPubist != null, "This project has no Publications list after migration 7000041");
var xPubist = XElement.Parse(dtoPubist.Xml);
var cfElements = SurrogatesIn(xPubist, "Possibilities", numOfPubs);
foreach (var xObj in cfElements)
{ // there must be 1 to 1 map of objsur's in hasDoNotShow and xPubist
string pubGuid = xObj.Attribute("guid").Value;
int n = 0;
foreach (var yObj in noShows)
{
if (pubGuid == yObj.Attribute("guid").Value)
{
Assert.That(yObj.Attribute("t").Value == "r", "7000041 Migrated test XML pub list items are not references");
break;
}
}
}
}
}
示例8: PerformMigration
/// ------------------------------------------------------------------------------------
/// <summary>
/// Perform one increment migration step.
///
/// In this case, the migration is not related to a model change,
/// but is a simple data change that removes the class elements in the xml.
/// The end resujlt xml will have the top-level 'rt' element and zero, or more,
/// property level elements.
/// </summary>
/// ------------------------------------------------------------------------------------
public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepository)
{
DataMigrationServices.CheckVersionNumber(domainObjectDtoRepository, 7000014);
// No. We need to convert all instances, even if they are no longer part of the model.
// DM19, for example, removes LgWritingSystem instances and the class form the model,
// but it tries to access the data as if it had been properly processed by DM15,
// *but* this code would leave out LgWritingSystem instnaces form being processed here.
//foreach (var dto in domainObjectDtoRepository.AllInstancesWithSubclasses("CmObject"))
foreach (var dto in domainObjectDtoRepository.AllInstances())
{
var rtElement = XElement.Parse(dto.Xml);
// Removes all current child nodes (class level),
// and replaces them with the old property nodes (if any).
#if !__MonoCS__
rtElement.ReplaceNodes(rtElement.Elements().Elements());
dto.Xml = rtElement.ToString();
#else // FWNX-165: work around mono bug https://bugzilla.novell.com/show_bug.cgi?id=592435
var copy = new XElement(rtElement);
copy.ReplaceNodes(rtElement.Elements().Elements());
dto.Xml = copy.ToString();
#endif
domainObjectDtoRepository.Update(dto);
}
DataMigrationServices.IncrementVersionNumber(domainObjectDtoRepository);
}
示例9: PerformMigration
public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepository)
{
DataMigrationServices.CheckVersionNumber(domainObjectDtoRepository, 7000050);
var newGuidValue = Guid.NewGuid().ToString().ToLowerInvariant();
const string className = "LangProject";
var lpDto = domainObjectDtoRepository.AllInstancesSansSubclasses(className).First();
var ownedDtos = domainObjectDtoRepository.GetDirectlyOwnedDTOs(lpDto.Guid).ToList();
var data = lpDto.Xml;
domainObjectDtoRepository.Remove(lpDto); // It is pretty hard to change an immutable Guid identifier in BEP-land, so nuke it, and make a new one.
var lpElement = XElement.Parse(data);
lpElement.Attribute("guid").Value = newGuidValue;
var newLpDto = new DomainObjectDTO(newGuidValue, className, lpElement.ToString());
domainObjectDtoRepository.Add(newLpDto);
// Change ownerguid attr for each owned item to new guid.
foreach (var ownedDto in ownedDtos)
{
var ownedElement = XElement.Parse(ownedDto.Xml);
ownedElement.Attribute("ownerguid").Value = newGuidValue;
ownedDto.Xml = ownedElement.ToString();
domainObjectDtoRepository.Update(ownedDto);
}
DataMigrationServices.IncrementVersionNumber(domainObjectDtoRepository);
}
示例10: PerformMigration
/// ------------------------------------------------------------------------------------
/// <summary>
/// Looks for CmFile objects included in LangProject. If found, will look for CmFile in
/// correct location and replace reference on CmPicture with that new CmFile.
/// </summary>
/// <param name="repoDto">
/// Repository of all CmObject DTOs available for one migration step.
/// </param>
/// <remarks>
/// Implementors of this interface should ensure the Repository's
/// starting model version number is correct for the step.
/// Implementors must also increment the Repository's model version number
/// at the end of its migration work.
///
/// The method also should normally modify the xml string(s)
/// of relevant DTOs, since that string will be used by the main
/// data migration calling client (ie. BEP).
/// </remarks>
/// ------------------------------------------------------------------------------------
public void PerformMigration(IDomainObjectDTORepository repoDto)
{
DataMigrationServices.CheckVersionNumber(repoDto, 7000033);
var langProj = repoDto.AllInstancesSansSubclasses("LangProject").First();
var langProjElement = XElement.Parse(langProj.Xml);
var pictures = langProjElement.Element("Pictures");
if (pictures != null && pictures.Elements().Count() > 1)
{
DomainObjectDTO folder = null;
bool foundFiles = false;
foreach (var x in pictures.Elements())
{
var xObj = repoDto.GetDTO(x.Attribute("guid").Value);
if (xObj.Classname == "CmFolder")
{
// empty folders can just be removed
var xObjElement = XElement.Parse(xObj.Xml);
if (xObjElement.Element("Files") == null)
DataMigrationServices.RemoveIncludingOwnedObjects(repoDto, xObj, true);
else if (folder == null)
folder = xObj;
else
MoveFileReferences(repoDto, langProj, xObj, folder);
}
else
foundFiles = true;
}
if (folder != null && foundFiles)
RemoveInvalidFiles(repoDto, langProj, folder);
}
DataMigrationServices.IncrementVersionNumber(repoDto);
}
示例11: PerformMigration
/// ------------------------------------------------------------------------------------
/// <summary>
/// Changes all StTxtParas that are owned by Scripture to be ScrTxtParas
/// </summary>
/// <param name="domainObjectDtoRepository">
/// Repository of all CmObject DTOs available for one migration step.
/// </param>
/// <remarks>
/// The method must add/remove/update the DTOs to the repository,
/// as it adds/removes objects as part of it work.
///
/// Implementors of this interface should ensure the Repository's
/// starting model version number is correct for the step.
/// Implementors must also increment the Repository's model version number
/// at the end of its migration work.
///
/// The method also should normally modify the xml string(s)
/// of relevant DTOs, since that string will be used by the main
/// data migration calling client (ie. BEP).
/// </remarks>
/// ------------------------------------------------------------------------------------
public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepository)
{
DataMigrationServices.CheckVersionNumber(domainObjectDtoRepository, 7000001);
var parasToChangeClasses = new List<DomainObjectDTO>();
foreach (var stTxtPara in domainObjectDtoRepository.AllInstancesSansSubclasses("StTxtPara"))
{
var paraOwner = domainObjectDtoRepository.GetOwningDTO(stTxtPara);
if (paraOwner.Classname != "StText" && paraOwner.Classname != "StFootnote")
{
continue; // Paragraph is not owned by an StText or StFootnote (shouldn't ever happen)
}
var textOwner = domainObjectDtoRepository.GetOwningDTO(paraOwner);
if (textOwner.Classname != "ScrBook" && textOwner.Classname != "ScrSection")
{
continue; // StText is not part of Scripture, don't change.
}
// Its one of the paragraphs that we care about. We just need to change the
// class in the xml to be a ScrTxtPara and change the objectsByClass map.
DataMigrationServices.ChangeToSubClass(stTxtPara, "StTxtPara", "ScrTxtPara");
parasToChangeClasses.Add(stTxtPara);
}
// Udate the repository
var startingStructure = new ClassStructureInfo("StPara", "StTxtPara");
var endingStructure = new ClassStructureInfo("StTxtPara", "ScrTxtPara");
foreach (var changedPara in parasToChangeClasses)
domainObjectDtoRepository.Update(changedPara,
startingStructure,
endingStructure);
DataMigrationServices.IncrementVersionNumber(domainObjectDtoRepository);
}
示例12: PerformMigration
/// <summary>
/// Remove the owningFlid attribute from every "rt" element.
/// </summary>
/// <param name="domainObjectDtoRepository"></param>
public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepository)
{
DataMigrationServices.CheckVersionNumber(domainObjectDtoRepository, 7000008);
foreach (var dto in domainObjectDtoRepository.AllInstancesWithValidClasses())
{
byte[] contents = dto.XmlBytes;
int index = contents.IndexOfSubArray(owningFlidTag);
if (index >= 0)
{
contents = contents.ReplaceSubArray(index,
Array.IndexOf(contents, closeQuote, index + owningFlidTag.Length) - index + 1,
new byte[0]);
}
int index2 = contents.IndexOfSubArray(owningOrdTag);
if (index2 >= 0)
{
contents = contents.ReplaceSubArray(index2,
Array.IndexOf(contents, closeQuote, index2 + owningOrdTag.Length) - index2 + 1,
new byte[0]);
}
if (index >= 0 || index2 >= 0)
{
DataMigrationServices.UpdateDTO(domainObjectDtoRepository, dto, contents);
}
}
DataMigrationServices.IncrementVersionNumber(domainObjectDtoRepository);
}
示例13: PerformMigration
/// ------------------------------------------------------------------------------------
/// <summary>
/// Perform one increment migration step.
/// </summary>
/// <param name="domainObjectDtoRepository">
/// Repository of all CmObject DTOs available for one migration step.
/// </param>
/// <remarks>
/// The method must add/remove/update the DTOs to the repository,
/// as it adds/removes objects as part of it work.
///
/// Implementors of this interface should ensure the Repository's
/// starting model version number is correct for the step.
/// Implementors must also increment the Repository's model version number
/// at the end of its migration work.
///
/// The method also should normally modify the xml string(s)
/// of relevant DTOs, since that string will be used by the main
/// data migration calling client (ie. BEP).
/// </remarks>
/// ------------------------------------------------------------------------------------
public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepository)
{
DataMigrationServices.CheckVersionNumber(domainObjectDtoRepository, 7000000);
DataMigrationServices.Delint(domainObjectDtoRepository);
var lpDto = domainObjectDtoRepository.AllInstancesSansSubclasses("LangProject").First();
// 1. Remove property from LangProg.
var lpElement = XElement.Parse(lpDto.Xml);
lpElement.Descendants("WordformInventory").Remove();
DataMigrationServices.UpdateDTO(domainObjectDtoRepository, lpDto, lpElement.ToString());
// 2. Remove three owner-related attributes from each WfiWordform.
// (There may be zero, or more, instances to upgrade.)
foreach (var wordformDto in domainObjectDtoRepository.AllInstancesSansSubclasses("WfiWordform"))
{
var wfElement = XElement.Parse(wordformDto.Xml);
wfElement.Attribute("ownerguid").Remove();
var flidAttr = wfElement.Attribute("owningflid");
if (flidAttr != null)
flidAttr.Remove();
var ordAttr = wfElement.Attribute("owningord");
if (ordAttr != null)
ordAttr.Remove();
DataMigrationServices.UpdateDTO(domainObjectDtoRepository, wordformDto, wfElement.ToString());
}
// 3. Remove WordformInventory instance.
domainObjectDtoRepository.Remove(
domainObjectDtoRepository.AllInstancesSansSubclasses("WordformInventory").First());
// There are no references to the WFI, so don't fret about leaving dangling refs to it.
DataMigrationServices.IncrementVersionNumber(domainObjectDtoRepository);
}
示例14: VerifyEntryRef
private XElement[] VerifyEntryRef(IDomainObjectDTORepository dtoRepos, string guid, int cfCount, int showComplexFormsInCount)
{
var dto = dtoRepos.GetDTO(guid);
var xElt = XElement.Parse(dto.Xml);
SurrogatesIn(xElt, "ComponentLexemes", cfCount);
SurrogatesIn(xElt, "PrimaryLexemes", showComplexFormsInCount);
var cfElements = SurrogatesIn(xElt, "ShowComplexFormsIn", showComplexFormsInCount);
return cfElements.ToArray();
}
示例15: RemoveUnwantedOverlays
private void RemoveUnwantedOverlays(IDomainObjectDTORepository repoDTO, List<DomainObjectDTO> collectOverlaysToRemove)
{
DomainObjectDTO dtoLP = GetDtoLangProj(repoDTO);
foreach (var dto in collectOverlaysToRemove)
{
RemoveOverlayElement(dtoLP, dto.Guid);
repoDTO.Remove(dto);
}
}