Example #1
0
        /// <summary>
        /// Trys to lock <paramref name="lockObject"/>, if successful it will call <paramref name="successAction"/>
        /// </summary>
        /// <param name="lockObject">Object to lock</param>
        /// <param name="successAction">Action to call if locked</param>
        /// <returns>True if locked, otherwise false</returns>
        public static bool Lock( object lockObject, LockAction successAction )
        {
            if( successAction == null )
                throw new ArgumentNullException( "successAction" );

            return Lock( lockObject, successAction, null );
        }
Example #2
0
        /// <summary>
        /// Locks or unlocks (aka. close or reopen) the topic with the specified action.
        /// </summary>
        /// <param name="action">The action to perform.</param>
        /// <param name="reason">The reason for operation.</param>
        /// <param name="cancellationToken">A token used to cancel the operation.</param>
        /// <remarks>This method will not update <see cref="TopicTitleRevision"/> content, you need to call <see cref="RefreshAsync()"/> if you need the latest revision information.</remarks>
        public async Task LockAsync(LockAction action, string reason, CancellationToken cancellationToken)
        {
            if (reason == null)
            {
                throw new ArgumentNullException(nameof(reason));
            }
            if (reason.Length == 0)
            {
                throw new ArgumentException("Reason cannot be empty.", nameof(reason));
            }
            JToken jresult;

            using (await Site.ModificationThrottler.QueueWorkAsync("Moderate: " + WorkflowId, cancellationToken))
            {
                jresult = await Site.InvokeMediaWikiApiAsync(new MediaWikiFormRequestMessage(new
                {
                    action = "flow",
                    submodule = "lock-topic",
                    token = WikiSiteToken.Edit,
                    page = Title,
                    cotmoderationState = EnumParser.ToString(action),
                    cotreason = reason,
                }), cancellationToken);
            }
        }
Example #3
0
        /// <summary>
        /// Trys to lock <paramref name="lockObject"/>, if successful it will call <paramref name="successAction"/>
        /// otherwise it will call it will call <paramref name="failureAction"/>
        /// </summary>
        /// <param name="lockObject">Object to lock</param>
        /// <param name="successAction">Action to call if locked</param>
        /// <param name="failureAction">Action to call if lock failed</param>
        /// <returns>True if locked, otherwise false</returns>
        public static bool Lock( object lockObject, LockAction successAction, LockAction failureAction )
        {
            if( lockObject == null )
                throw new ArgumentNullException( "lockObject" );

            if( Monitor.TryEnter( lockObject ) )
            {
                try
                {
                    if( successAction != null )
                    {
                        successAction();
                    }
                    return true;
                }
                finally
                {
                    Monitor.Exit( lockObject );
                }
            }
            else
            {
                if( failureAction != null )
                {
                    failureAction();
                }
            }
            return false;
        }
 /// <summary>
 /// 通道锁动作。
 /// </summary>
 /// <remarks>通道锁动作。</remarks>
 /// <param name="action">设置锁动作。</param>
 internal void OnLockActionChange(LockAction action)
 {
     /*
      * //验证锁动作类型。
      * if (action == LockAction.Destruction || action == LockAction.Timeout || action == LockAction.UnLock)
      * {
      *  //通知等待继续。
      *  this.Event.Set();
      * }
      */
 }
Example #5
0
 public void SetLock(LockAction action)
 {
     if (jtCradle.ControlLock(action))
     {
         Toast.MakeText(this, action.ToString(), ToastLength.Short).Show();
     }
     else
     {
         Toast.MakeText(this, "Failed to control the lock. Check if the device is inserted in the Cradle",
                        ToastLength.Long).Show();
     }
 }
 /**
  * Creates a signature lock for specific fields in the document.
  */
 public PdfSigLockDictionary(LockAction action, LockPermissions p, params String[] fields)
     : base(PdfName.SIGFIELDLOCK)
 {
     this.Put(PdfName.ACTION, action.Value);
     if (p != null)
         this.Put(PdfName.P, p.Value);
     PdfArray fieldsArray = new PdfArray();
     foreach (String field in fields) {
         fieldsArray.Add(new PdfString(field));
     }
     this.Put(PdfName.FIELDS, fieldsArray);
 }
Example #7
0
        public static string ToString(LockAction value)
        {
            switch (value)
            {
            case LockAction.Lock: return("lock");

            case LockAction.Unlock: return("unlock");

            default:
                throw new ArgumentOutOfRangeException(nameof(value), value, null);
            }
        }
Example #8
0
 private void ExecuteLockAction(LockAction action, Control.ControlCollection controls)
 {
     foreach (Control c in controls)
     {
         if (c.HasChildren)
         {
             ExecuteLockAction(action, c.Controls);
         }
         if (m_lockableControls.Contains(c))
         {
             c.Enabled = action == LockAction.Unlock ? true : false;
         }
     }
 }
        /**
         * Creates a signature lock for specific fields in the document.
         */
        public PdfSigLockDictionary(LockAction action, LockPermissions p, params String[] fields) : base(PdfName.SIGFIELDLOCK)
        {
            this.Put(PdfName.ACTION, action.Value);
            if (p != null)
            {
                this.Put(PdfName.P, p.Value);
            }
            PdfArray fieldsArray = new PdfArray();

            foreach (String field in fields)
            {
                fieldsArray.Add(new PdfString(field));
            }
            this.Put(PdfName.FIELDS, fieldsArray);
        }
 /// <summary>
 /// Allows for exclusive access to a channel.
 /// </summary>
 /// <param name="lockAction"></param>
 /// <param name="lockPhrase"></param>
 /// <returns></returns>
 public virtual bool Lock(LockAction lockAction, string lockPhrase)
 {
     return(_amcpTcpParser.SendCommand($"{AMCPCommand.LOCK.ToAmcpValue()} {ID} {lockAction} {lockPhrase}"));
 }
 /**
  * Creates a signature lock for specific fields in the document.
  */
 public PdfSigLockDictionary(LockAction action, params String[] fields) : this(action, null, fields) {
 }
 /**
  * Creates a signature lock for specific fields in the document.
  */
 public PdfSigLockDictionary(LockAction action, params String[] fields) : this(action, null, fields)
 {
 }
Example #13
0
 /// <inheritdoc cref="LockAsync(LockAction,string,CancellationToken)"/>
 public Task LockAsync(LockAction action, string reason)
 {
     return(LockAsync(action, reason, CancellationToken.None));
 }
Example #14
0
 /// <summary>
 /// Constructor to initialize the parameters of Lock
 /// </summary>
 /// <param name="accessPassword">The access password</param>
 /// <param name="lockAction">The Gen2 Lock Action</param>
 
 public Lock(UInt32 accessPassword, LockAction lockAction)
 {
     this.AccessPassword = accessPassword;
     this.LockAction = lockAction;
 }
Example #15
0
 public ActionMouseLock(LockAction lockAction) : base(0)
 {
     Type            = ActionType.MouseLock;
     this.lockAction = lockAction;
 }
Example #16
0
 private void ExecuteLockAction(LockAction action)
 {
     ExecuteLockAction(action, Controls);
 }