Exemple #1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Get all directly owned objects of the specified <paramref name="guid"/>.
        /// </summary>
        /// <param name="guid">The owning guid.</param>
        /// <returns>
        /// An enumeration of zero, or more <see cref="DomainObjectDTO"/> owned objects.
        /// </returns>
        /// <exception cref="ArgumentException">
        /// Thrown if the Guid is not in the repository.
        /// </exception>
        /// ------------------------------------------------------------------------------------
        IEnumerable <DomainObjectDTO> IDomainObjectDTORepository.GetDirectlyOwnedDTOs(string guid)
        {
            var dto         = AsInterface.GetDTO(guid);
            var rootElement = XElement.Parse(dto.Xml);

            return((from ownedSurrogates in rootElement.Descendants("objsur")
                    where ownedSurrogates.Attribute("t").Value == "o"
                    select AsInterface.GetDTO(ownedSurrogates.Attribute("guid").Value)).ToArray());
        }
Exemple #2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Get the owner <see cref="DomainObjectDTO"/> for the specified object.
        /// </summary>
        /// <param name="ownedObj">The owned <see cref="DomainObjectDTO"/>.</param>
        /// <returns>
        /// The owner <see cref="DomainObjectDTO"/> for the given <paramref name="ownedObj"/>,
        /// or null, if there is no owner.
        /// </returns>
        /// <exception cref="ArgumentException">
        /// Thrown if the owned object is not in the repository.
        /// </exception>
        /// ------------------------------------------------------------------------------------
        DomainObjectDTO IDomainObjectDTORepository.GetOwningDTO(DomainObjectDTO ownedObj)
        {
            if (ownedObj == null)
            {
                throw new ArgumentNullException("ownedObj");
            }

            var ownIdx = ownedObj.XmlBytes.IndexOfSubArray(OwnerGuid);

            return((ownIdx < 0)
                                ? null
                                : AsInterface.GetDTO(Encoding.UTF8.GetString(ownedObj.XmlBytes.SubArray(ownIdx + 11, 36))));
        }
Exemple #3
0
        /// <summary>
        /// Let the Repository know that <paramref name="dirtball"/> has been modified,
        /// by at least a change of class.
        /// </summary>
        /// <param name="dirtball">The object that was modified.</param>
        /// <param name="oldClassStructure">Previous superclass structure</param>
        /// <param name="newClassStructure">New class structure</param>
        /// <remarks>
        /// The underlying CmObject won't be changed, until the end of the current
        /// migration is finished.
        /// </remarks>
        public void Update(DomainObjectDTO dirtball, ClassStructureInfo oldClassStructure, ClassStructureInfo newClassStructure)
        {
            if (oldClassStructure == null)
            {
                throw new ArgumentNullException("oldClassStructure");
            }
            if (newClassStructure == null)
            {
                throw new ArgumentNullException("newClassStructure");
            }
            if (dirtball.Classname != newClassStructure.m_className)
            {
                throw new ArgumentException("Mis-match between class names in 'dirtball' and 'newClassStructure'");
            }

            AsInterface.Update(dirtball);
            RemoveFromClassList(dirtball, oldClassStructure.m_className);
            AddToClassList(dirtball);
        }