Exemple #1
0
 protected KOSDelegate(KOSDelegate oldCopy)
 {
     Cpu = oldCopy.Cpu;
     PreBoundArgs = new List<Structure>();
     InitializeSuffixes();
     foreach (Structure ca in oldCopy.PreBoundArgs)
         PreBoundArgs.Add(ca);
 }
Exemple #2
0
 protected KOSDelegate(KOSDelegate oldCopy)
 {
     Cpu = oldCopy.Cpu;
     PreBoundArgs = new List<Structure>();
     InitializeSuffixes();
     foreach (Structure ca in oldCopy.PreBoundArgs)
         PreBoundArgs.Add(ca);
 }
Exemple #3
0
        /// <summary>
        /// This returns a new variant of the delegate that has the first
        /// parameters hardcoded.  If you call :bind(1,2,3) on a delegate that takes 5 arguments, you get
        /// a variant of the delegate that now only takes the lastmost 2 arguments, with the first two
        /// having been hardcoded to 1,2,3.
        /// This is actually the technique known as "partial function application" in C#'s terms.
        /// </summary>
        /// <param name="args">the arguments to be hardcoded at the front of the list of arguments, going left to right</param>
        /// <returns>a delegate that now takes fewer arguments, just the leftover ones that weren't hardcoded</returns>
        public KOSDelegate Bind(params Structure[] args)
        {
            KOSDelegate preBoundDel = Clone();

            foreach (Structure arg in args)
            {
                preBoundDel.AddPreBoundArg(arg);
            }

            return(preBoundDel);
        }