Esempio n. 1
0
        private static PropertyAccessor CreateAccessor(DomainObject domainObject, string shortIdentifier)
        {
            string propertyIdentifier = domainObject.GetPublicDomainObjectType().FullName + "." + shortIdentifier;
            var    data = new PropertyAccessorData(domainObject.ID.ClassDefinition, propertyIdentifier);

            return(new PropertyAccessor(domainObject, data, ClientTransaction.Current));
        }
Esempio n. 2
0
        private void CleanupCreatedObject(ObjectID objectID, DomainObject domainObject, Exception creationException)
        {
            try
            {
                Delete(domainObject);
            }
            catch (Exception deleteException)
            {
                var message = string.Format(
                    "While cleaning up an object of type '{0}' that threw an exception of type "
                    + "'{1}' from its constructor, another exception of type '{2}' was encountered. "
                    + "Cleanup was therefore aborted, and a partially constructed object with ID '{3}' remains within the ClientTransaction '{4}'."
                    + " Rollback the transaction to get rid of the partially constructed instance." + Environment.NewLine
                    + "Message of original exception: {5}" + Environment.NewLine
                    + "Message of exception occurring during cleanup: {6}",
                    domainObject.GetPublicDomainObjectType(),
                    creationException.GetType(),
                    deleteException.GetType(),
                    objectID,
                    _clientTransaction,
                    creationException.Message,
                    deleteException.Message);
                throw new ObjectCleanupException(message, objectID, creationException, deleteException);
            }

            _enlistedDomainObjectManager.DisenlistDomainObject(domainObject);
        }
Esempio n. 3
0
 private void CheckItemType(DomainObject domainObject, string argumentName)
 {
     if (_requiredItemType != null && !_requiredItemType.IsInstanceOfType(domainObject))
     {
         string message = string.Format(
             "Values of type '{0}' cannot be added to this collection. Values must be of type '{1}' or derived from '{1}'.",
             domainObject.GetPublicDomainObjectType(),
             _requiredItemType);
         throw new ArgumentException(message, argumentName);
     }
 }
 private T ConvertLoadedDomainObject <T> (DomainObject domainObject) where T : DomainObject
 {
     if (domainObject == null || domainObject is T)
     {
         return((T)domainObject);
     }
     else
     {
         var message = string.Format(
             "The query returned an object of type '{0}', but a query result of type '{1}' was expected.",
             domainObject.GetPublicDomainObjectType(),
             typeof(T));
         throw new UnexpectedQueryResultException(message);
     }
 }
Esempio n. 5
0
        private static int CompareTypeNames(DomainObject x, DomainObject y)
        {
// ReSharper disable PossibleNullReferenceException
            return(x.GetPublicDomainObjectType().FullName.CompareTo(y.GetPublicDomainObjectType().FullName));
// ReSharper restore PossibleNullReferenceException
        }