public ClassDefinition(
            string id,
            Type classType,
            bool isAbstract,
            ClassDefinition baseClass,
            Type storageGroupType,
            IPersistentMixinFinder persistentMixinFinder,
            IDomainObjectCreator instanceCreator)
        {
            ArgumentUtility.CheckNotNullOrEmpty("id", id);
            ArgumentUtility.CheckNotNull("classType", classType);
            ArgumentUtility.CheckNotNull("persistentMixinFinder", persistentMixinFinder);

            _id = id;
            _storageGroupType = storageGroupType;

            _classType             = classType;
            _persistentMixinFinder = persistentMixinFinder;
            _isAbstract            = isAbstract;

            _propertyAccessorDataCache         = new PropertyAccessorDataCache(this);
            _cachedRelationEndPointDefinitions = new DoubleCheckedLockingContainer <RelationEndPointDefinitionCollection> (
                () => RelationEndPointDefinitionCollection.CreateForAllRelationEndPoints(this, true));
            _cachedPropertyDefinitions =
                new DoubleCheckedLockingContainer <PropertyDefinitionCollection> (
                    () => new PropertyDefinitionCollection(PropertyDefinitionCollection.CreateForAllProperties(this, true), true));

            _baseClass       = baseClass;
            _instanceCreator = instanceCreator;
            _handleCreator   = new Lazy <Func <ObjectID, IDomainObjectHandle <DomainObject> > > (BuildHandleCreator, LazyThreadSafetyMode.PublicationOnly);
        }
예제 #2
0
        public RelationEndPointDefinitionCollection CreateRelationEndPointDefinitionCollection(ClassDefinition classDefinition)
        {
            ArgumentUtility.CheckNotNull("classDefinition", classDefinition);

            var endPoints = new RelationEndPointDefinitionCollection();

            foreach (var propertyInfo in GetRelationPropertyInfos(classDefinition))
            {
                var relationEndPoint = _mappingObjectFactory.CreateRelationEndPointDefinition(classDefinition, propertyInfo);
                endPoints.Add(relationEndPoint);
            }
            return(endPoints);
        }
        public void SetRelationEndPointDefinitions(RelationEndPointDefinitionCollection relationEndPoints)
        {
            ArgumentUtility.CheckNotNull("relationEndPoints", relationEndPoints);

            if (_relationEndPoints != null)
            {
                throw new InvalidOperationException(String.Format("The relation end point definitions for class '{0}' have already been set.", ID));
            }

            if (_isReadOnly)
            {
                throw new NotSupportedException(String.Format("Class '{0}' is read-only.", ID));
            }

            CheckRelationEndPointDefinitions(relationEndPoints);

            _relationEndPoints = relationEndPoints;
            _relationEndPoints.SetReadOnly();
        }