コード例 #1
0
        /// <summary> Creates a Modifier based on the given source and attaches it to the master. </summary>
        public static T Create <T>(TSelf master, T source, Action <T> initializer = null) where T : RootModifier
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }
            if (!source.isSource)
            {
                throw new ArgumentException($"{nameof(source)} must be a source", nameof(source));
            }

            var modifier = Instantiate(source);

            modifier.master = master;
            modifier.source = source;

            master.AttachModifier(modifier);
            Game.dataObjects.Add(modifier);
            Game.hooks.Hook(modifier);

            initializer?.Invoke(modifier);

            modifier.OnConfigureNonpersistent(true);
            modifier.OnCreate();
            modifier.Show();

            using (var scope = new Hooks.Scope()) Game.hooks.ForEach <IOnModifierCreate>(scope, v => v.OnModifierCreate(modifier));

            return(modifier);
        }
コード例 #2
0
ファイル: ModelBuilder.cs プロジェクト: Mecteral/Calculator
 void HandleMultiplicationOrDivisionBeforeAdditiveOperation <TSelf>() where TSelf : IArithmeticOperation, new()
 {
     if (mCurrentOperation?.Right is Variable)
     {
         if (mCurrentOperation.HasParent && !(mCurrentOperation.Parent is ParenthesedExpression))
         {
             var parent = (IArithmeticOperation)mCurrentOperation.Parent;
             var temp   = parent.Right;
             parent.Right = new TSelf()
             {
                 Left = temp
             };
             mCurrentOperation  = (IArithmeticOperation)parent.Right;
             mWasMultiplication = true;
         }
         else
         {
             var temp = mCurrentOperation;
             mCurrentOperation = new TSelf {
                 Left = temp
             };
         }
     }
     else if (mCurrentOperation != null && !(mCurrent is ParenthesedExpression))
     {
         var temp = mCurrentOperation.Right;
         var multiplicationOrDivision = new TSelf {
             Left = temp
         };
         mCurrentOperation.Right = multiplicationOrDivision;
         mCurrentOperation       = multiplicationOrDivision;
         mWasMultiplication      = true;
     }
     else
     {
         mCurrentOperation = new TSelf();
     }
 }
 public Restriction(TSelf options, Action <IAssertionContext <TMember> > action)
 {
     this.options = options;
     this.action  = action;
 }
コード例 #4
0
 internal abstract TOutput Call(TSelf genericFunc);