コード例 #1
0
ファイル: ActionBase.cs プロジェクト: prime167/Stylet
        /// <summary>
        /// Assert that the target is not View.InitialActionTarget
        /// </summary>
        protected internal void AssertTargetSet()
        {
            // If we've made it this far and the target is still the default, then something's wrong
            // Make sure they know
            if (this.Target == View.InitialActionTarget)
            {
                var ex = new ActionNotSetException(String.Format("View.ActionTarget not set on control {0} (method {1}). " +
                                                                 "This probably means the control hasn't inherited it from a parent, e.g. because a ContextMenu or Popup sits in the visual tree. " +
                                                                 "You will need so set 's:View.ActionTarget' explicitly. See the wiki section \"Actions\" for more details.", this.Subject, this.MethodName));
                this.logger.Error(ex);
                throw ex;
            }

            if (this.TargetMethodInfo == null && this.ActionNonExistentBehaviour == ActionUnavailableBehaviour.Throw)
            {
                var ex = new ActionNotFoundException(String.Format("Unable to find method {0} on target {1}", this.MethodName, this.Target.GetType().Name));
                this.logger.Error(ex);
                throw ex;
            }
        }
コード例 #2
0
ファイル: ActionBase.cs プロジェクト: modulexcite/Stylet
        /// <summary>
        /// Assert that the target is not View.InitialActionTarget
        /// </summary>
        protected internal void AssertTargetSet()
        {
            // If we've made it this far and the target is still the default, then something's wrong
            // Make sure they know
            if (this.Target == View.InitialActionTarget)
            {
                var ex = new ActionNotSetException(String.Format("View.ActionTarget not set on control {0} (method {1}). " +
                    "This probably means the control hasn't inherited it from a parent, e.g. because a ContextMenu or Popup sits in the visual tree. " +
                    "You will need so set 's:View.ActionTarget' explicitly. See the wiki section \"Actions\" for more details.", this.Subject, this.MethodName));
                this.logger.Error(ex);
                throw ex;
            }

            if (this.TargetMethodInfo == null && this.ActionNonExistentBehaviour == ActionUnavailableBehaviour.Throw)
            {
                var ex = new ActionNotFoundException(String.Format("Unable to find method {0} on target {1}", this.MethodName, this.Target.GetType().Name));
                this.logger.Error(ex);
                throw ex;
            }
        }