Beispiel #1
0
        internal static IBlockEntity InsertCore(DSCoordinateSystem contextCoordinateSystem, ref string fileName, string blockName)
        {
            string kMethodName = "DSBlock.ByCoordinateSystem ";

            if (null == contextCoordinateSystem)
            {
                throw new ArgumentNullException("contextCoordinateSystem");
            }
            if (contextCoordinateSystem.IsSheared)
            {
                throw new ArgumentException(string.Format(Properties.Resources.Sheared, "contextCoordinateSystem"), "contextCoordinateSystem");
            }
            if (string.IsNullOrEmpty(blockName))
            {
                throw new ArgumentException(string.Format(Properties.Resources.InvalidInput, blockName, kMethodName), "blockName");
            }

            fileName = DSGeometryExtension.LocateFile(fileName);
            if (!File.Exists(fileName))
            {
                throw new ArgumentException(string.Format(Properties.Resources.FileNotFound, fileName), "fileName");
            }

            IBlockHelper helper = HostFactory.Factory.GetBlockHelper();

            if (null == helper)
            {
                throw new InvalidOperationException(string.Format(Properties.Resources.OperationFailed, kMethodName));
            }

            IBlockEntity entity = helper.InsertBlockFromFile(contextCoordinateSystem.CSEntity, fileName, blockName);

            if (null == entity)
            {
                throw new System.Exception(string.Format(Properties.Resources.OperationFailed, kMethodName));
            }
            return(entity);
        }