Ejemplo n.º 1
0
        /// <summary>
        ///     This helper function is an easy way to get a new entity type, entity set and key property in the
        ///     new entity type created in the conceptual or storage model.
        ///     NOTE: If the cpc already has an active transaction, these changes will be in that transaction
        ///     and the caller of this helper method must commit it to see these changes commited.
        /// </summary>
        /// <param name="cpc"></param>
        /// <param name="name">The name of the new entity</param>
        /// <param name="setName">The name of the new set</param>
        /// <param name="createKeyProperty">A flag whether to create a new key property or not (sending false creates no new property)</param>
        /// <param name="propertyName">The name of the new property</param>
        /// <param name="propertyType">The type of the new property</param>
        /// <param name="modelSpace">Either Conceptual or Storage</param>
        /// <param name="uniquifyName">Flag whether the name should be checked for uniqueness and then changed as required</param>
        /// <param name="isDefaultName">Flag whether the name is the default for new entity types/sets</param>
        /// <returns>The new EntityType</returns>
        internal static EntityType CreateEntityTypeAndEntitySetAndProperty(
            CommandProcessorContext cpc,
            string name, string setName, bool createKeyProperty, string propertyName,
            string propertyType, string propertyStoreGeneratedPattern, ModelSpace modelSpace, bool uniquifyNames, bool isDefaultName = false)
        {
            var cp = new CommandProcessor(cpc);

            var cet = new CreateEntityTypeCommand(name, modelSpace, uniquifyNames);

            cet.CreateWithDefaultName = isDefaultName;
            cp.EnqueueCommand(cet);

            var ces = new CreateEntitySetCommand(setName, cet, modelSpace, uniquifyNames);

            cp.EnqueueCommand(ces);

            if (createKeyProperty)
            {
                var cpcd = new CreatePropertyCommand(propertyName, cet, propertyType, false);
                cpcd.IsIdProperty = true;
                cp.EnqueueCommand(cpcd);

                var skpc = new SetKeyPropertyCommand(cpcd, true);
                cp.EnqueueCommand(skpc);

                var ssgpc = new SetStoreGeneratedPatternCommand(cpcd, propertyStoreGeneratedPattern);
                cp.EnqueueCommand(ssgpc);
            }

            cp.Invoke();

            return(cet.EntityType);
        }
        /// <summary>
        ///     Creates an inheritance so that 'baseType' becomes the base type of the new entity being
        ///     created by the CreateEntityTypeCommand.
        /// </summary>
        /// <param name="prereqCommand">Must be non-null</param>
        /// <param name="baseType">Must be non-null and a c-space entity</param>
        internal CreateInheritanceCommand(CreateEntityTypeCommand prereqCommand, ConceptualEntityType baseType)
        {
            ValidatePrereqCommand(prereqCommand);
            CommandValidation.ValidateConceptualEntityType(baseType);

            BaseType = baseType;

            AddPreReqCommand(prereqCommand);
        }
        /// <summary>
        ///     Creates an inheritance so that 'baseType' becomes the base type of the new entity being
        ///     created by the CreateEntityTypeCommand.
        /// </summary>
        /// <param name="prereqCommand">Must be non-null</param>
        /// <param name="baseType">Must be non-null and a c-space entity</param>
        internal CreateInheritanceCommand(CreateEntityTypeCommand prereqCommand, ConceptualEntityType baseType)
        {
            ValidatePrereqCommand(prereqCommand);
            CommandValidation.ValidateConceptualEntityType(baseType);

            BaseType = baseType;

            AddPreReqCommand(prereqCommand);
        }
Ejemplo n.º 4
0
        /// <summary>
        ///     Creates an EntitySet of a new type being created in either the conceptual or the storage model.
        /// </summary>
        /// <param name="name">The name to use for this set</param>
        /// <param name="prereq">The CreateEntityTypeCommand that is creating the new type</param>
        /// <param name="modelSpace">Either Conceptual or Storage</param>
        /// <param name="uniquifyName">Flag whether the name should be checked for uniqueness and then changed as required</param>
        internal CreateEntitySetCommand(string name, CreateEntityTypeCommand prereq, ModelSpace modelSpace, bool uniquifyName)
        {
            ValidatePrereqCommand(prereq);
            ValidateString(name);

            Name            = name;
            ModelSpaceValue = modelSpace;
            UniquifyName    = uniquifyName;

            AddPreReqCommand(prereq);
        }
        /// <summary>
        ///     Creates an EntitySet of a new type being created in either the conceptual or the storage model.
        /// </summary>
        /// <param name="name">The name to use for this set</param>
        /// <param name="prereq">The CreateEntityTypeCommand that is creating the new type</param>
        /// <param name="modelSpace">Either Conceptual or Storage</param>
        /// <param name="uniquifyName">Flag whether the name should be checked for uniqueness and then changed as required</param>
        internal CreateEntitySetCommand(string name, CreateEntityTypeCommand prereq, ModelSpace modelSpace, bool uniquifyName)
        {
            ValidatePrereqCommand(prereq);
            ValidateString(name);

            Name = name;
            ModelSpaceValue = modelSpace;
            UniquifyName = uniquifyName;

            AddPreReqCommand(prereq);
        }
        /// <summary>
        ///     Creates a property in the entity being created by the passed in command
        /// </summary>
        /// <param name="name">The name of the new property</param>
        /// <param name="prereqCommand">Must be non-null</param>
        /// <param name="type">The type of the property</param>
        /// <param name="nullable">Flag whether the property is nullable or not</param>
        internal CreatePropertyCommand(string name, CreateEntityTypeCommand prereqCommand, string type, bool?nullable)
            : base(PrereqId)
        {
            ValidatePrereqCommand(prereqCommand);
            ValidateString(name);
            ValidateString(type);

            Name     = name;
            Type     = type;
            Nullable = nullable;

            AddPreReqCommand(prereqCommand);
        }
        /// <summary>
        ///     Creates a property in the entity being created by the passed in command
        /// </summary>
        /// <param name="name">The name of the new property</param>
        /// <param name="prereqCommand">Must be non-null</param>
        /// <param name="type">The type of the property</param>
        /// <param name="nullable">Flag whether the property is nullable or not</param>
        internal CreatePropertyCommand(string name, CreateEntityTypeCommand prereqCommand, string type, bool? nullable)
            : base(PrereqId)
        {
            ValidatePrereqCommand(prereqCommand);
            ValidateString(name);
            ValidateString(type);

            Name = name;
            Type = type;
            Nullable = nullable;

            AddPreReqCommand(prereqCommand);
        }
Ejemplo n.º 8
0
        /// <summary>
        ///     This helper function creates a new entity in the conceptual model that is derived from the
        ///     passed in entity.
        ///     NOTE: If the cpc already has an active transaction, these changes will be in that transaction
        ///     and the caller of this helper method must commit it to see these changes commited.
        /// </summary>
        /// <param name="cpc"></param>
        /// <param name="name">The name of the new, derived entity</param>
        /// <param name="baseType">The entity that this new type should derive from</param>
        /// <param name="uniquifyName">Flag whether the name should be checked for uniqueness and then changed as required</param>
        /// <returns>The new EntityType</returns>
        internal static ConceptualEntityType CreateDerivedEntityType(
            CommandProcessorContext cpc, string name, ConceptualEntityType baseType, bool uniquifyName)
        {
            var cet = new CreateEntityTypeCommand(name, uniquifyName);
            var inh = new CreateInheritanceCommand(cet, baseType);

            var cp = new CommandProcessor(cpc, cet, inh);

            cp.Invoke();

            var derivedType = cet.EntityType as ConceptualEntityType;

            Debug.Assert(derivedType != null, "EntityType is not ConceptualEntityType");
            return(derivedType);
        }
Ejemplo n.º 9
0
        private void CreateEntityCopyInModel(CommandProcessorContext cpc)
        {
            // get unique names for Entity and EntitySet
            var entityName = _clipboardEntity.EntityName;
            var setName    = _clipboardEntity.EntitySetName;

            _createdEntity = CreateEntityTypeCommand.CreateEntityTypeAndEntitySetAndProperty(
                cpc, entityName, setName, false, null, null, null, _modelSpace, true);

            foreach (var clipboardProperty in _clipboardEntity.Properties)
            {
                var cmd = new CopyPropertyCommand(clipboardProperty, _createdEntity);
                CommandProcessor.InvokeSingleCommand(cpc, cmd);
            }

            // Create the entity-type-shape since we need to set the fill color.
            if (_diagram != null)
            {
                CommandProcessor.InvokeSingleCommand(
                    cpc, new CreateEntityTypeShapeCommand(_diagram, _createdEntity, _clipboardEntity.EntityTypeShapeFillColor));
            }

            AddAnnotations(_clipboardEntity, _createdEntity);
        }
        /// <summary>
        ///     This helper function is an easy way to get a new entity type, entity set and key property in the
        ///     new entity type created in the conceptual or storage model.
        ///     NOTE: If the cpc already has an active transaction, these changes will be in that transaction
        ///     and the caller of this helper method must commit it to see these changes commited.
        /// </summary>
        /// <param name="cpc"></param>
        /// <param name="name">The name of the new entity</param>
        /// <param name="setName">The name of the new set</param>
        /// <param name="createKeyProperty">A flag whether to create a new key property or not (sending false creates no new property)</param>
        /// <param name="propertyName">The name of the new property</param>
        /// <param name="propertyType">The type of the new property</param>
        /// <param name="modelSpace">Either Conceptual or Storage</param>
        /// <param name="uniquifyName">Flag whether the name should be checked for uniqueness and then changed as required</param>
        /// <param name="isDefaultName">Flag whether the name is the default for new entity types/sets</param>
        /// <returns>The new EntityType</returns>
        internal static EntityType CreateEntityTypeAndEntitySetAndProperty(
            CommandProcessorContext cpc,
            string name, string setName, bool createKeyProperty, string propertyName,
            string propertyType, string propertyStoreGeneratedPattern, ModelSpace modelSpace, bool uniquifyNames, bool isDefaultName = false)
        {
            var cp = new CommandProcessor(cpc);

            var cet = new CreateEntityTypeCommand(name, modelSpace, uniquifyNames);
            cet.CreateWithDefaultName = isDefaultName;
            cp.EnqueueCommand(cet);

            var ces = new CreateEntitySetCommand(setName, cet, modelSpace, uniquifyNames);
            cp.EnqueueCommand(ces);

            if (createKeyProperty)
            {
                var cpcd = new CreatePropertyCommand(propertyName, cet, propertyType, false);
                cpcd.IsIdProperty = true;
                cp.EnqueueCommand(cpcd);

                var skpc = new SetKeyPropertyCommand(cpcd, true);
                cp.EnqueueCommand(skpc);

                var ssgpc = new SetStoreGeneratedPatternCommand(cpcd, propertyStoreGeneratedPattern);
                cp.EnqueueCommand(ssgpc);
            }

            cp.Invoke();

            return cet.EntityType;
        }
        /// <summary>
        ///     This helper function creates a new entity in the conceptual model that is derived from the
        ///     passed in entity.
        ///     NOTE: If the cpc already has an active transaction, these changes will be in that transaction
        ///     and the caller of this helper method must commit it to see these changes commited.
        /// </summary>
        /// <param name="cpc"></param>
        /// <param name="name">The name of the new, derived entity</param>
        /// <param name="baseType">The entity that this new type should derive from</param>
        /// <param name="uniquifyName">Flag whether the name should be checked for uniqueness and then changed as required</param>
        /// <returns>The new EntityType</returns>
        internal static ConceptualEntityType CreateDerivedEntityType(
            CommandProcessorContext cpc, string name, ConceptualEntityType baseType, bool uniquifyName)
        {
            var cet = new CreateEntityTypeCommand(name, uniquifyName);
            var inh = new CreateInheritanceCommand(cet, baseType);

            var cp = new CommandProcessor(cpc, cet, inh);
            cp.Invoke();

            var derivedType = cet.EntityType as ConceptualEntityType;
            Debug.Assert(derivedType != null, "EntityType is not ConceptualEntityType");
            return derivedType;
        }
Ejemplo n.º 12
0
 /// <summary>
 ///     Creates an EntitySet of a new type being created in the conceptual model.
 /// </summary>
 /// <param name="name">The name to use for this set</param>
 /// <param name="prereq">The CreateEntityTypeCommand that is creating the new type</param>
 /// <param name="uniquifyName">Flag whether the name should be checked for uniqueness and then changed as required</param>
 internal CreateEntitySetCommand(string name, CreateEntityTypeCommand prereq, bool uniquifyName)
     : this(name, prereq, ModelSpace.Conceptual, uniquifyName)
 {
 }
 /// <summary>
 ///     Creates an EntitySet of a new type being created in the conceptual model.
 /// </summary>
 /// <param name="name">The name to use for this set</param>
 /// <param name="prereq">The CreateEntityTypeCommand that is creating the new type</param>
 /// <param name="uniquifyName">Flag whether the name should be checked for uniqueness and then changed as required</param>
 internal CreateEntitySetCommand(string name, CreateEntityTypeCommand prereq, bool uniquifyName)
     : this(name, prereq, ModelSpace.Conceptual, uniquifyName)
 {
 }