Exemplo n.º 1
0
        public IEnumerable <T> Create(IEnumerable <string> names)
        {
            Require.ParameterNotNull(names, nameof(names));
            Require.ElementsNotNull(names, nameof(names));
            var existingName = names.FirstOrDefault(Contains);

            Require.NameDoesNotExists <T>(Contains(existingName), existingName);

            return(CreateInternal(names));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Adds Entities to the container.
        /// </summary>
        /// <param name="entities">The Entities to be added.</param>
        /// <param name="setDatabaseDefaults">True, if the database defaults should be set.</param>
        /// <exception cref="System.ArgumentNullException">Thrown when parameter  <i>entities</i> is null.</exception>
        /// <exception cref="System.Exception">Thrown when the an Entity belongs to another block or an AutoCAD error occurs.</exception>
        /// <returns>The ObjectIds of the Entities that were added.</returns>
        public IEnumerable <ObjectId> Add(IEnumerable <Entity> entities, bool setDatabaseDefaults)
        {
            Require.ParameterNotNull(entities, nameof(entities));
            Require.ElementsNotNull(entities, nameof(entities));

            foreach (var entity in entities)
            {
                Require.NewlyCreated(entity, nameof(entity));
            }

            return(AddInternal(entities, setDatabaseDefaults));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Creates a new LayerTableRecord and adds the given Entites to it.
        /// </summary>
        /// <param name="name">The name of the new LayerTableRecord.</param>
        /// <param name="entities">The Entities that should be added to the new LayerTableRecord.</param>
        /// <returns>A new instance of LayerTableRecord.</returns>
        /// <exception cref="System.ArgumentNullException">Thrown when parameters <i>name</i> or <i>entities</i> is null.</exception>
        public LayerTableRecord Create(string name, IEnumerable <Entity> entities)
        {
            Require.IsValidSymbolName(name, nameof(name));
            Require.NameDoesNotExists <BlockTableRecord>(Contains(name), name);
            Require.ElementsNotNull(entities, nameof(entities));

            var layer = CreateInternal(name);

            foreach (var entity in entities.UpgradeOpen())
            {
                entity.LayerId = layer.ObjectId;
            }

            return(layer);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Creates a new BlockTableRecord and adds the given Entites to it.
        /// </summary>
        /// <param name="name">The name of the new BlockTableRecord.</param>
        /// <param name="entities">The Entities that should be added to the BlockTableRecord.</param>
        /// <returns>A new instance of BlockTableRecord.</returns>
        /// <exception cref="System.ArgumentNullException">Thrown when parameters <i>name</i> or <i>entities</i> is null.</exception>
        public BlockTableRecord Create(string name, IEnumerable <Entity> entities)
        {
            Require.IsValidSymbolName(name, nameof(name));
            Require.NameDoesNotExists <BlockTableRecord>(Contains(name), name);
            Require.ElementsNotNull(entities, nameof(entities));

            // TODO: What about this check?
            //var alreadyInBlock = entities.FirstOrDefault(e => !e.ObjectId.IsNull);
            //if (alreadyInBlock != null) throw Error.WrongOrigin(alreadyInBlock.ObjectId);

            var block = CreateInternal(name);

            foreach (var entity in entities.UpgradeOpen())
            {
                block.AppendEntity(entity);
            }

            return(block);
        }
Exemplo n.º 5
0
        public IEnumerable <T> Create(IEnumerable <string> names)
        {
            Require.ElementsNotNull(names, nameof(names));

            return(CreateInternal(names));
        }