コード例 #1
0
        /// <summary>
        /// Throws an exception if the given selector either is null or selects more than one entity
        /// </summary>
        /// <param name="selector">The selector to check</param>
        /// <param name="selectorName">The name of the selector variable</param>
        /// <param name="classHolderName">The name of the class holding the selector variable</param>
        /// <exception cref="ArgumentNullException">If the selector is null</exception>
        /// <exception cref="ArgumentException">If the selector selects too many entities</exception>
        /// <returns>The checked selector</returns>
        public static BaseSelector ValidateSingleSelectSelector(BaseSelector selector, string selectorName, string classHolderName)
        {
            if (!(selector ?? throw new ArgumentNullException(selectorName, selectorName + " may not be null.")).IsLimited())
            {
                throw new ArgumentException(classHolderName + " doesn't allow " + selectorName + " to select multiple entities", selectorName);
            }

            return(selector);
        }
コード例 #2
0
ファイル: ScoreValue.cs プロジェクト: Vilder50/SharpCraft
 /// <summary>
 /// Intializes a new <see cref="ScoreValue"/>
 /// </summary>
 /// <param name="selector">Selector for selecting the score</param>
 /// <param name="scoreObject">The objective the score is in</param>
 public ScoreValue(BaseSelector selector, Objective scoreObject)
 {
     Selector    = selector;
     ScoreObject = scoreObject;
 }