本文整理汇总了C#中IDomainObjectDTORepository.GetDirectlyOwnedDTOs方法的典型用法代码示例。如果您正苦于以下问题:C# IDomainObjectDTORepository.GetDirectlyOwnedDTOs方法的具体用法?C# IDomainObjectDTORepository.GetDirectlyOwnedDTOs怎么用?C# IDomainObjectDTORepository.GetDirectlyOwnedDTOs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDomainObjectDTORepository
的用法示例。
在下文中一共展示了IDomainObjectDTORepository.GetDirectlyOwnedDTOs方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PerformMigration
/// <summary>
/// Updates the Data Notebook RecordTypes possibilities to use specific GUIDs.
/// </summary>
/// <param name="domainObjectDtoRepository">Repository of all CmObject DTOs available for one migration step.</param>
public void PerformMigration(IDomainObjectDTORepository domainObjectDtoRepository)
{
DataMigrationServices.CheckVersionNumber(domainObjectDtoRepository, 7000010);
DomainObjectDTO nbkDto = domainObjectDtoRepository.AllInstancesSansSubclasses("RnResearchNbk").First();
XElement nbkElem = XElement.Parse(nbkDto.Xml);
var recTypesGuid = (string) nbkElem.XPathSelectElement("RnResearchNbk/RecTypes/objsur").Attribute("guid");
var stack = new Stack<DomainObjectDTO>(domainObjectDtoRepository.GetDirectlyOwnedDTOs(recTypesGuid));
IEnumerable<DomainObjectDTO> recDtos = domainObjectDtoRepository.AllInstancesSansSubclasses("RnGenericRec");
IEnumerable<DomainObjectDTO> overlayDtos = domainObjectDtoRepository.AllInstancesSansSubclasses("CmOverlay");
while (stack.Count > 0)
{
DomainObjectDTO dto = stack.Pop();
foreach (DomainObjectDTO childDto in domainObjectDtoRepository.GetDirectlyOwnedDTOs(dto.Guid))
stack.Push(childDto);
XElement posElem = XElement.Parse(dto.Xml);
XElement uniElem = posElem.XPathSelectElement("CmPossibility/Abbreviation/AUni[@ws='en']");
if (uniElem != null)
{
string newGuid = null;
switch (uniElem.Value)
{
case "Con":
newGuid = "B7B37B86-EA5E-11DE-80E9-0013722F8DEC";
break;
case "Intv":
newGuid = "B7BF673E-EA5E-11DE-9C4D-0013722F8DEC";
break;
case "Str":
newGuid = "B7C8F092-EA5E-11DE-8D7D-0013722F8DEC";
break;
case "Uns":
newGuid = "B7D4DC4A-EA5E-11DE-867C-0013722F8DEC";
break;
case "Lit":
newGuid = "B7E0C7F8-EA5E-11DE-82CC-0013722F8DEC";
break;
case "Obs":
newGuid = "B7EA5156-EA5E-11DE-9F9C-0013722F8DEC";
break;
case "Per":
newGuid = "B7F63D0E-EA5E-11DE-9F02-0013722F8DEC";
break;
case "Ana":
newGuid = "82290763-1633-4998-8317-0EC3F5027FBD";
break;
}
if (newGuid != null)
DataMigrationServices.ChangeGuid(domainObjectDtoRepository, dto, newGuid, recDtos.Concat(overlayDtos));
}
}
DomainObjectDTO recTypesDto = domainObjectDtoRepository.GetDTO(recTypesGuid);
DataMigrationServices.ChangeGuid(domainObjectDtoRepository, recTypesDto, "D9D55B12-EA5E-11DE-95EF-0013722F8DEC", overlayDtos);
DataMigrationServices.IncrementVersionNumber(domainObjectDtoRepository);
}
示例2: 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);
}
示例3: ChangeClassOfOwnerAndChildren
void ChangeClassOfOwnerAndChildren(IDomainObjectDTORepository dtoRepo, DomainObjectDTO dtoToChange, string oldClassname, string newClassname)
{
// bail out if we've already changed the class name (assume we've already changed its children too).
if (!TryChangeOwnerClass(dtoRepo, dtoToChange, oldClassname, newClassname))
return;
foreach (var dtoChild in dtoRepo.GetDirectlyOwnedDTOs(dtoToChange.Guid))
{
ChangeClassOfOwnerAndChildren(dtoRepo, dtoChild, oldClassname, newClassname);
}
}
示例4: ChangeGuid
/// <summary>
/// Changes the GUID of the specified DTO. It updates the owner and all specified referrers to point to the new GUID.
/// </summary>
/// <param name="dtoRepos">The dto repos.</param>
/// <param name="dto">The dto.</param>
/// <param name="newGuid">The new GUID.</param>
/// <param name="possibleReferrers">The possible referrers.</param>
internal static void ChangeGuid(IDomainObjectDTORepository dtoRepos, DomainObjectDTO dto, string newGuid,
IEnumerable<DomainObjectDTO> possibleReferrers)
{
// if the DTO already has the new GUID, don't do anything
if (dto.Guid.ToLowerInvariant() == newGuid.ToLowerInvariant())
return;
XElement rtElem = XElement.Parse(dto.Xml);
rtElem.Attribute("guid").Value = newGuid;
dtoRepos.Add(new DomainObjectDTO(newGuid, dto.Classname, rtElem.ToString()));
foreach (DomainObjectDTO ownedDto in dtoRepos.GetDirectlyOwnedDTOs(dto.Guid))
{
XElement ownedElem = XElement.Parse(ownedDto.Xml);
ownedElem.Attribute("ownerguid").Value = newGuid;
UpdateDTO(dtoRepos, ownedDto, ownedElem.ToString());
}
var ownerDto = dtoRepos.GetOwningDTO(dto);
if (ownerDto != null)
UpdateObjSurElement(dtoRepos, ownerDto, dto.Guid, newGuid);
if (possibleReferrers != null)
{
foreach (DomainObjectDTO referrer in possibleReferrers)
UpdateObjSurElement(dtoRepos, referrer, dto.Guid, newGuid);
}
dtoRepos.Remove(dto);
}
示例5: RemoveMultipleIncludingOwnedObjects
/// <summary>
/// Remove a number of objects with a common owner, and everything they own.
/// </summary>
internal static void RemoveMultipleIncludingOwnedObjects(IDomainObjectDTORepository dtoRepos,
List<DomainObjectDTO> goners, DomainObjectDTO ownerDto)
{
if (ownerDto != null)
{
var ownerElement = XElement.Parse(ownerDto.Xml);
foreach (var goner in goners)
{
var goner1 = goner;
var ownObjSurElement = (from objSurNode in ownerElement.Descendants("objsur")
where
objSurNode.Attribute("t").Value == "o" &&
objSurNode.Attribute("guid").Value.ToLower() == goner1.Guid.ToLower()
select objSurNode).FirstOrDefault(); // Ought not be null, but play it safe.
if (ownObjSurElement != null)
ownObjSurElement.Remove();
}
if (!RemoveEmptyPropertyElements(dtoRepos, ownerDto, ownerElement))
{
// No empty property elememtns removed, so we have to do the update.
UpdateDTO(dtoRepos, ownerDto, ownerElement.ToString());
}
}
foreach (var goner in goners)
{
foreach (var ownedDto in dtoRepos.GetDirectlyOwnedDTOs(goner.Guid))
RemoveIncludingOwnedObjects(dtoRepos, ownedDto, false);
dtoRepos.Remove(goner);
}
}
示例6: RemoveIncludingOwnedObjects
/// <summary>
/// Remove <paramref name="goner"/> and everything it owns.
/// Be sure to include removing goner from its optional owning property.
/// </summary>
internal static void RemoveIncludingOwnedObjects(IDomainObjectDTORepository dtoRepos, DomainObjectDTO goner, bool removeFromOwner)
{
DomainObjectDTO gonerActual;
if (!dtoRepos.TryGetValue(goner.Guid, out gonerActual))
return; // Not in repos.
if (removeFromOwner)
{
var ownerDto = dtoRepos.GetOwningDTO(goner);
if (ownerDto != null)
{
var ownerElement = XElement.Parse(ownerDto.Xml);
var ownObjSurElement = (from objSurNode in ownerElement.Descendants("objsur")
where objSurNode.Attribute("t").Value == "o" && objSurNode.Attribute("guid").Value.ToLower() == goner.Guid.ToLower()
select objSurNode).FirstOrDefault(); // Ought not be null, but play it safe.
if (ownObjSurElement != null)
ownObjSurElement.Remove();
if (!RemoveEmptyPropertyElements(dtoRepos, ownerDto, ownerElement))
{
// No empty property elements removed, so we have to do the update.
UpdateDTO(dtoRepos, ownerDto, ownerElement.ToString());
}
}
}
foreach (var ownedDto in dtoRepos.GetDirectlyOwnedDTOs(goner.Guid))
RemoveIncludingOwnedObjects(dtoRepos, ownedDto, false);
dtoRepos.Remove(goner);
}
示例7: FixOwnershipOfSubtypes
private void FixOwnershipOfSubtypes(IDomainObjectDTORepository repoDto)
{
var types = repoDto.AllInstancesWithSubclasses("LexEntryType");
var cFixedFirst = 0;
foreach (var dto in types)
{
var xml = dto.Xml;
var fFixed = false;
foreach (var badGuid in m_mapBadGoodGuids.Keys)
{
if (xml.Contains(badGuid))
{
var bad = String.Format("guid=\"{0}\"", badGuid);
var good = String.Format("guid=\"{0}\"", m_mapBadGoodGuids[badGuid]);
xml = xml.Replace(bad, good);
var bad2 = String.Format("guid='{0}'", badGuid);
var good2 = String.Format("guid='{0}'", m_mapBadGoodGuids[badGuid]);
xml = xml.Replace(bad2, good2); // probably pure paranoia...
fFixed = true;
}
}
if (fFixed)
{
dto.Xml = xml;
repoDto.Update(dto);
++cFixedFirst;
}
var cFixed = 0;
foreach (var dtoSub in repoDto.GetDirectlyOwnedDTOs(dto.Guid))
{
DomainObjectDTO dtoOwner;
if (!repoDto.TryGetOwner(dtoSub.Guid, out dtoOwner) || dtoOwner != dto)
{
// we have a broken ownership link -- fix it!
var xeSub = XElement.Parse(dtoSub.Xml);
var xaOwner = xeSub.Attribute("ownerguid");
if (xaOwner == null)
xeSub.Add(new XAttribute("ownerguid", dto.Guid));
else
xaOwner.Value = dto.Guid;
dtoSub.Xml = xeSub.ToString();
repoDto.Update(dtoSub);
++cFixed;
}
}
}
}
示例8: CollectItems
/// <summary>
/// Add to weatherItems the guids of all the things owned directly or indirectly by dtoRoot.
/// Does not include the root itself.
/// </summary>
private void CollectItems(IDomainObjectDTORepository repoDTO, DomainObjectDTO dtoRoot, HashSet<string> guidCollector)
{
foreach (var dto in repoDTO.GetDirectlyOwnedDTOs(dtoRoot.Guid))
{
guidCollector.Add(dto.Guid);
CollectItems(repoDTO, dto, guidCollector);
}
}
示例9: GatherDeadObjects
private void GatherDeadObjects(IDomainObjectDTORepository repoDTO, DomainObjectDTO dtoDead,
List<DomainObjectDTO> rgdtoDead)
{
rgdtoDead.Add(dtoDead);
foreach (var dto in repoDTO.GetDirectlyOwnedDTOs(dtoDead.Guid))
GatherDeadObjects(repoDTO, dto, rgdtoDead);
}
示例10: VerifyEntryTypeOwners
/// <summary>
/// Verify that every LexEntryType points back to a valid owner after migration, and that
/// the owner points to the LexEntryType.
/// </summary>
/// <param name="repoDto"></param>
private static void VerifyEntryTypeOwners(IDomainObjectDTORepository repoDto)
{
foreach (var dto in repoDto.AllInstancesWithSubclasses("LexEntryType"))
{
DomainObjectDTO dtoOwner;
Assert.IsTrue(repoDto.TryGetOwner(dto.Guid, out dtoOwner), "All entry types should have valid owners!");
DomainObjectDTO dtoOwnedOk = null;
foreach (var dtoT in repoDto.GetDirectlyOwnedDTOs(dtoOwner.Guid))
{
if (dtoT == dto)
{
dtoOwnedOk = dtoT;
break;
}
}
Assert.AreEqual(dto, dtoOwnedOk, "The owner should own the entry type!");
}
}
示例11: VerifyOwner
private void VerifyOwner(IDomainObjectDTORepository repoDTO, DomainObjectDTO dtoTest, string sguidOwner)
{
bool fFound = false;
foreach (DomainObjectDTO dto in repoDTO.GetDirectlyOwnedDTOs(sguidOwner))
{
if (dto.Guid == dtoTest.Guid && dto.Xml == dtoTest.Xml)
{
fFound = true;
break;
}
}
Assert.IsTrue(fFound);
}