/// <summary>
        /// Visits the specified entity.
        /// See the <see cref="IEntityVisitor"/> for more details.
        /// </summary>
        public override void Visit(DxfInsert insert)
        {
            InsertInfo info           = insertStack.Peek();
            BlockData  blockData      = blockDataByName[insert.Block.Name];
            DxfLayer   effectiveLayer = info.GetEffectiveLayer(insert);
            DxfBlock   block          = blockData.GetBlock(effectiveLayer);

            if (block.Entities.Count == 0)
            {
                // no need to keep insert if block is empty
                info.currentCollection.RemoveAt(info.currentIndex);
            }
            else
            {
                // overwrite block with reduced one
                insert.Block = block;
                // take care of attributes
                for (int a = insert.Attributes.Count - 1; a >= 0; --a)
                {
                    DxfAttribute attrib      = insert.Attributes[a];
                    DxfLayer     attribLayer = attrib.Layer.IsZeroLayer
                                               ? effectiveLayer
                                               : attrib.Layer;
                    if (IsRemovedLayer(attribLayer))
                    {
                        insert.Attributes.RemoveAt(a);
                    }
                }
            }
        }
        /// <summary>
        /// Handles a simple entity.
        /// </summary>
        /// <remarks>
        /// This just evaluates the effective layer and removes the entity if the layer is not the keep layer.
        /// </remarks>
        /// <param name="entity">The entity.</param>
        /// <returns><c>true</c> if the entity was removed.</returns>
        private bool HandleEntity(DxfEntity entity)
        {
            InsertInfo info           = insertStack.Peek();
            DxfLayer   effectiveLayer = info.GetEffectiveLayer(entity);

            if (IsRemovedLayer(effectiveLayer))
            {
                // remove entity on incorrect index
                info.currentCollection.RemoveAt(info.currentIndex);
                return(true);
            }
            return(false);
        }
        /// <summary>
        /// Run over a collection of entities and remove all with different layers.
        /// </summary>
        /// <param name="entities">Entity collection.</param>
        /// <param name="effectiveLayer">The effective layer.</param>
        /// <returns><c>true</c> if zero layer entities were included in this collection.</returns>
        private bool HandleEntityCollection(DxfEntityCollection entities, DxfLayer effectiveLayer)
        {
            InsertInfo currentInfo = new InsertInfo(entities, effectiveLayer);

            try
            {
                insertStack.Push(currentInfo);
                while (currentInfo.currentIndex >= 0)
                {
                    DxfEntity entity = currentInfo.currentCollection[currentInfo.currentIndex];
                    entity.Accept(this);
                    --currentInfo.currentIndex;
                }
            }
            finally
            {
                insertStack.Pop();
            }
            return(currentInfo.HasZeroLayerEntities);
        }
Ejemplo n.º 4
0
        protected override SqlCommandDescription GenerateInsert(SqlCommandGenerateContext context)
        {
            SqlCommandDescription description = new SqlCommandDescription();

            InsertInfo info = (InsertInfo)context.CommandInfo;

            HashSet <string> lowerCaseWithoutFields = new HashSet <string>
                                                      (
                info.WithoutFields.Select(x => x.ToLower())
                                                      );

            IEnumerable <string> columnNames = GetColumnNames(context)
                                               .Where(x => !lowerCaseWithoutFields.Contains(x.ToLower()));
            string fields = columnNames.Join(",", x => $"[{x}]");
            string values = columnNames.Join(",", x => $"@{x}");

            foreach (var columnName in columnNames)
            {
                description.AddParameter(new SqlParameterInfo(columnName));
            }
            description.SqlCommand = $"INSERT INTO [{context.TableName}]({fields})VALUES({values});SELECT ISNULL(SCOPE_IDENTITY(),0) AS [Id]";
            return(description);
        }
Ejemplo n.º 5
0
    public static void SetRoundStartInfo(string infoR, bool current)
    {
        InsertInfo temp = JsonUtility.FromJson <InsertInfo>(infoR);;

        if (!current)
        {
            info = temp;
        }
        else
        {
            infoCurrent = temp;
        }

        // interpolation for internet erros
        currentRound = info.next_round - 1;

        timeLeft             = 0;
        currentRoundTimeLeft = 0;
        chosenWords          = new string[3];
        score = 0;

        if (temp.max_round_score == 0)
        {
            temp.max_round_score = 3 * temp.scoring[0];
        }

        // hacked stuff
        temp.collecting_results_duration_ms = 0;

        /*GameSettings.MyDebug(temp.player_id);
         * GameSettings.MyDebug(GameSettings.user);
         * if (temp.player_id != null)
         * {
         *  if (GameSettings.user == null)
         *      GameSettings.username = temp.player_id;
         * }*/
    }
Ejemplo n.º 6
0
 public static void SetRoundStartInfoForInsert(string info)
 {
     insert = JsonUtility.FromJson <InsertInfo>(info);
 }