コード例 #1
0
 internal bool TryClearLeader(ConnectorEx oldLeader, AsyncSocket oldSocket)
 {
     lock (this)
     {
         if (_Leader == oldLeader)
         {
             CollectPendingRpc(_Leader, oldSocket);
             _Leader = null;
             return(true);
         }
         return(false);
     }
 }
コード例 #2
0
 private void CollectPendingRpc(ConnectorEx oldLeader, AsyncSocket oldSocket)
 {
     if (null != oldLeader)
     {
         // 再 Rpc.UserState 里面记录发送目的的ConnectorEx,然后这里严格判断?
         // 由于一个时候只有Leader,所以直接使用Sender也足够了吧。
         var ctxSends   = Client.GetRpcContextsToSender(oldSocket);
         var ctxPending = Client.RemoveRpcContets(ctxSends.Keys);
         foreach (var rpc in ctxPending)
         {
             Pending.TryAdd(rpc, rpc);
         }
     }
 }
コード例 #3
0
 internal bool TrySetLeader(LeaderIs r, ConnectorEx newLeader)
 {
     lock (this)
     {
         if (r.Argument.Term < newLeader.Term)
         {
             logger.Warn("{0} Skip LeaderIs {1}", Name, r);
             return(false);
         }
         if (_Leader != newLeader)
         {
             // 把旧的_Leader的没有返回结果的请求收集起来,准备重新发送。
             CollectPendingRpc(_Leader, _Leader?.Socket);
         }
         newLeader.Term = r.Argument.Term;
         _Leader        = newLeader;
         return(true);
     }
 }
コード例 #4
0
        static void RemovingProtection()
        {
            string MyDir = @"Files\";
            //Open the desired presentation
            PresentationEx pTemplate = new PresentationEx(MyDir + "ProtectedSample.pptx");

            //ISlide object for accessing the slides in the presentation
            SlideEx slide = pTemplate.Slides[0];

            //IShape object for holding temporary shapes
            ShapeEx shape;

            //Traversing through all the slides in presentation
            for (int slideCount = 0; slideCount < pTemplate.Slides.Count; slideCount++)
            {
                slide = pTemplate.Slides[slideCount];

                //Travesing through all the shapes in the slides
                for (int count = 0; count < slide.Shapes.Count; count++)
                {
                    shape = slide.Shapes[count];

                    //if shape is autoshape
                    if (shape is AutoShapeEx)
                    {
                        //Type casting to Auto shape and  getting auto shape lock
                        AutoShapeEx     Ashp          = shape as AutoShapeEx;
                        AutoShapeLockEx AutoShapeLock = Ashp.ShapeLock;

                        //Applying shapes locks
                        AutoShapeLock.PositionLocked = false;
                        AutoShapeLock.SelectLocked   = false;
                        AutoShapeLock.SizeLocked     = false;
                    }

                    //if shape is group shape
                    else if (shape is GroupShapeEx)
                    {
                        //Type casting to group shape and  getting group shape lock
                        GroupShapeEx     Group          = shape as GroupShapeEx;
                        GroupShapeLockEx groupShapeLock = Group.ShapeLock;

                        //Applying shapes locks
                        groupShapeLock.GroupingLocked = false;
                        groupShapeLock.PositionLocked = false;
                        groupShapeLock.SelectLocked   = false;
                        groupShapeLock.SizeLocked     = false;
                    }

                    //if shape is Connector shape
                    else if (shape is ConnectorEx)
                    {
                        //Type casting to connector shape and  getting connector shape lock
                        ConnectorEx     Conn     = shape as ConnectorEx;
                        ConnectorLockEx ConnLock = Conn.ShapeLock;

                        //Applying shapes locks
                        ConnLock.PositionMove = false;
                        ConnLock.SelectLocked = false;
                        ConnLock.SizeLocked   = false;
                    }

                    //if shape is picture frame
                    else if (shape is PictureFrameEx)
                    {
                        //Type casting to pitcture frame shape and  getting picture frame shape lock
                        PictureFrameEx     Pic     = shape as PictureFrameEx;
                        PictureFrameLockEx PicLock = Pic.ShapeLock;

                        //Applying shapes locks
                        PicLock.PositionLocked = false;
                        PicLock.SelectLocked   = false;
                        PicLock.SizeLocked     = false;
                    }
                }
            }
            //Saving the presentation file
            pTemplate.Save(MyDir + "RemoveProtectionSample.pptx", Aspose.Slides.Export.SaveFormat.Pptx);
        }