public void Check_null_return(Tuple<string, TestAction> test)
 {
     var exception = Assert.Throws<ActionResultAssertionException>(() =>
         test.Item2(_controller.WithCallTo(c => c.Null()))
     );
     Assert.That(exception.Message, Is.EqualTo(string.Format("Received null action result when expecting {0}.", test.Item1)));
 }
 public void Check_return_type(Tuple<string, TestAction> test)
 {
     var exception = Assert.Throws<ActionResultAssertionException>(() =>
         test.Item2(_controller.WithCallTo(c => c.RandomResult()))
     );
     Assert.That(exception.Message, Is.EqualTo(string.Format("Expected action result to be a {0}, but instead received a RandomResult.", test.Item1)));
 }
コード例 #3
0
        internal bool Execute(
            bool skipIfNoChanges, bool changesExist, Action <EwfValidation, IEnumerable <string> > validationErrorHandler, bool performValidationOnly = false,
            Tuple <Action, Action> actionMethodAndPostModificationMethod = null)
        {
            var validationNeeded = validations.Any() && (!skipIfNoChanges || changesExist);

            if (validationNeeded)
            {
                var errorsOccurred = false;
                foreach (var validation in validations)
                {
                    var validator = new Validator();
                    validation.Method(validator);
                    if (validator.ErrorsOccurred)
                    {
                        errorsOccurred = true;
                        if (!validator.ErrorMessages.Any())
                        {
                            throw new ApplicationException("Validation errors occurred but there are no messages.");
                        }
                    }
                    validationErrorHandler(validation, validator.ErrorMessages);
                }
                if (errorsOccurred)
                {
                    throw new DataModificationException();
                }
            }

            var skipModification = !modificationMethods.Any() || (skipIfNoChanges && !changesExist);

            if (performValidationOnly || (skipModification && actionMethodAndPostModificationMethod == null))
            {
                return(validationNeeded);
            }

            DataAccessState.Current.DisableCache();
            try {
                if (!skipModification)
                {
                    foreach (var method in modificationMethods)
                    {
                        method();
                    }
                }
                actionMethodAndPostModificationMethod?.Item1();
                DataAccessState.Current.ResetCache();
                AppRequestState.Instance.PreExecuteCommitTimeValidationMethodsForAllOpenConnections();
                actionMethodAndPostModificationMethod?.Item2();
            }
            catch {
                AppRequestState.Instance.RollbackDatabaseTransactions();
                DataAccessState.Current.ResetCache();
                throw;
            }

            return(true);
        }
コード例 #4
0
        public void EndElement(object ctx, string elementName)
        {
            // Run the action that corresponds to the current element string found in xml file
            Tuple <Action, Action> elementParseActions = null;

            if (mapFileElementActions.TryGetValue(elementName, out elementParseActions))
            {
                // Item 2 of tuple corresponds to end element action
                elementParseActions.Item2();
            }
        }
コード例 #5
0
 protected override void Write(ITextOutput output)
 {
     output.Write(string.Format("{0}", index + 1), TextTokenType.Number);
     if (infoTuple != null)
     {
         output.WriteSpace();
         output.Write('-', TextTokenType.Operator);
         output.WriteSpace();
         infoTuple.Item2(output);
     }
 }
コード例 #6
0
 protected override void WriteCore(ITextColorWriter output, DocumentNodeWriteOptions options)
 {
     output.Write(BoxedTextColor.Number, string.Format("{0}", index + 1));
     if (infoTuple != null)
     {
         output.WriteSpace();
         output.Write(BoxedTextColor.Operator, "-");
         output.WriteSpace();
         infoTuple.Item2(output);
     }
 }
コード例 #7
0
 protected override void Write(ISyntaxHighlightOutput output)
 {
     output.Write(string.Format("{0}", index + 1), TextTokenKind.Number);
     if (infoTuple != null)
     {
         output.WriteSpace();
         output.Write("-", TextTokenKind.Operator);
         output.WriteSpace();
         infoTuple.Item2(output);
     }
 }
        /// <summary>
        /// Creates the <see cref="IHttpController"/> specified by <paramref name="controllerType"/> using the given <paramref name="controllerContext"/>
        /// </summary>
        /// <param name="controllerContext">The controller context.</param>
        /// <param name="controllerType">Type of the controller.</param>
        /// <returns>An instance of type <paramref name="controllerType"/>.</returns>
        public IHttpController Create(HttpControllerContext controllerContext, Type controllerType)
        {
            if (controllerContext == null)
            {
                throw Error.ArgumentNull("controllerContext");
            }

            if (controllerType == null)
            {
                throw Error.ArgumentNull("controllerType");
            }

            try
            {
                // First check in the local fast cache and if not a match then look in the broader
                // HttpControllerDescriptor.Properties cache
                if (_fastCache == null)
                {
                    // If service resolver returns controller object then keep asking it whenever we need a new instance
                    IHttpController instance = (IHttpController)_configuration.ServiceResolver.GetService(controllerType);
                    if (instance != null)
                    {
                        return(instance);
                    }

                    // Otherwise create a delegate for creating a new instance of the type
                    Func <IHttpController> activator = TypeActivator.Create <IHttpController>(controllerType);
                    Tuple <HttpControllerDescriptor, Func <IHttpController> > cacheItem = Tuple.Create(controllerContext.ControllerDescriptor, activator);
                    Interlocked.CompareExchange(ref _fastCache, cacheItem, null);

                    // Execute the delegate
                    return(activator());
                }
                else if (_fastCache.Item1 == controllerContext.ControllerDescriptor)
                {
                    // If the key matches and we already have the delegate for creating an instance then just execute it
                    return(_fastCache.Item2());
                }
                else
                {
                    // If the key doesn't match then lookup/create delegate in the HttpControllerDescriptor.Properties for
                    // that HttpControllerDescriptor instance
                    Func <IHttpController> activator = (Func <IHttpController>)controllerContext.ControllerDescriptor.Properties.GetOrAdd(
                        _cacheKey,
                        key => TypeActivator.Create <IHttpController>(controllerType));
                    return(activator());
                }
            }
            catch (Exception ex)
            {
                throw Error.InvalidOperation(ex, SRResources.DefaultControllerFactory_ErrorCreatingController, controllerType);
            }
        }
コード例 #9
0
ファイル: Timer.cs プロジェクト: LudumHub/LD36-Ancient-Rush
 public void Update(double delta)
 {
     time += (float)delta;
     if (nextSubscriber == null || time < nextSubscriber.Item1)
     {
         return;
     }
     nextSubscriber.Item2();
     subscribers.Remove(nextSubscriber);
     nextSubscriber = null;
     FindNextSubscriber();
 }
コード例 #10
0
        /// <summary>
        /// Creates the executor which can resolve a passed type and hand it
        /// to the closure
        /// </summary>
        /// <param name="stateValuePair">The state value pair.</param>
        /// <returns>a lambda lifted closure</returns>
        private static Func<Tuple<IResolveTypes, object>, object, object, object> CreateExecutor(Tuple<Type, Func<object, object, object, object>> stateValuePair)
        {
            return (resolver, name, value) =>
                       {
                           object item = null;

                           if (stateValuePair.Item1 != null)
                               item = resolver.Item1.Resolve(stateValuePair.Item1);

                           return stateValuePair.Item2(resolver.Item2, item, value);
                       };
        }
コード例 #11
0
ファイル: WaitForThenCall.cs プロジェクト: X606/CloneDroneVR
 void Update()
 {
     for (int i = 0; i < _scheduledActions.Count; i++)
     {
         Tuple <Action, Func <bool> > actions = _scheduledActions[i];
         if (actions.Item2())
         {
             actions.Item1();
             _scheduledActions.RemoveAt(i);
             i--;
         }
     }
 }
コード例 #12
0
        private static SabotenCache Prefetch(this SabotenCache dataSample, int featureIndex, Tuple <Range, Converter <IEnumerable <double>, IEnumerable <double> > > dataTransformer)
        {
            if (dataSample.CacheHit(featureIndex))
            {
                return(dataSample);
            }
            else
            {
                IEnumerable <double> transformedData = dataTransformer.Item2(dataSample.Data);

                return(dataSample.LoadCache(dataTransformer.Item1, transformedData));
            }
        }
コード例 #13
0
 /// <remarks>Called when the connection with FLExBridge terminates (currently ~15 seconds after the user closes the FB window)</remarks>
 static void CleanupHost()
 {
     Console.WriteLine(@"FLExBridgeHelper.CleanupHost()");
     if (_noBlockerHostAndCallback != null)
     {
         KillTheHost(_noBlockerHostAndCallback.Item1);
         if (_noBlockerHostAndCallback.Item2 != null)
         {
             _noBlockerHostAndCallback.Item2();
         }
         _noBlockerHostAndCallback = null;
     }
 }
コード例 #14
0
        /// <summary>
        /// Invokes a method which may cause events to be raised.
        /// </summary>
        /// <param name="method">Method to be invoked, which may result in events being raised.</param>
        /// <param name="syncRoot">The object on which to acquire an exclusive lock while <paramref name="method" /> is being invoked.</param>
        /// <param name="args">Arguments to pass to <paramref name="method" />.</param>
        /// <returns>Value returned from <paramref name="method" />.</returns>
        /// <remarks>While <paramref name="method" /> is being invoked, any calls to the <see cref="EventQueueManager" /> <code>Raise</code>
        /// will result in the event handler being queued for invocation until the call to <paramref name="method" /> is finished.</remarks>
        public static object InvokeGet(Delegate method, object syncRoot, params object[] args)
        {
            Queue <Tuple <Delegate, Action <Exception, object[]>, object[]> > queuedEvents;

            Monitor.Enter(_syncRoot);
            try
            {
                if (_queuedEvents == null)
                {
                    queuedEvents  = new Queue <Tuple <Delegate, Action <Exception, object[]>, object[]> >();
                    _queuedEvents = queuedEvents;
                }
                else
                {
                    queuedEvents = null;
                }
            }
            finally { Monitor.Exit(_syncRoot); }

            object result;

            try
            {
                Monitor.Enter(syncRoot);
                try { result = method.DynamicInvoke((args == null) ? new object[0] : args); }
                finally { Monitor.Exit(syncRoot); }
            }
            finally
            {
                if (queuedEvents != null)
                {
                    Monitor.Enter(_syncRoot);
                    try { _queuedEvents = null; } finally { Monitor.Exit(_syncRoot); }

                    while (queuedEvents.Count > 0)
                    {
                        Tuple <Delegate, Action <Exception, object[]>, object[]> current = queuedEvents.Dequeue();
                        try { current.Item1.DynamicInvoke(current.Item3); }
                        catch (Exception e)
                        {
                            if (current.Item2 != null)
                            {
                                try { current.Item2(e, current.Item3); } catch { }
                            }
                        }
                    }
                }
            }
            return(result);
        }
コード例 #15
0
        protected override PageContent getContent()
        {
            var mod      = getMod();
            var password = new DataValue <string> {
                Value = ""
            };
            Tuple <IReadOnlyCollection <EtherealComponent>, Action <int> > logInHiddenFieldsAndMethod = null;

            return(FormState.ExecuteWithDataModificationsAndDefaultAction(
                       PostBack.CreateFull(
                           modificationMethod: () => {
                if (AppTools.User == null)
                {
                    mod.UserId = MainSequence.GetNextValue();
                }
                if (password.Value.Any())
                {
                    var passwordSalter = new Password(password.Value);
                    mod.Salt = passwordSalter.Salt;
                    mod.SaltedPassword = passwordSalter.ComputeSaltedHash();
                }
                mod.Execute();

                logInHiddenFieldsAndMethod?.Item2(mod.UserId);
            },
                           actionGetter: () => new PostBackAction(logInHiddenFieldsAndMethod != null ? (PageBase)Home.GetInfo() : Profile.GetInfo(AppTools.User.UserId)))
                       .ToCollection(),
                       () => {
                var content = new UiPageContent(contentFootActions: new ButtonSetup(AppTools.User != null ? "Update Settings" : "Sign up").ToCollection());

                if (AppTools.User == null)
                {
                    content.Add(
                        new EwfHyperlink(
                            EnterpriseWebLibrary.EnterpriseWebFramework.UserManagement.Pages.LogIn.GetInfo(Home.GetInfo().GetUrl()),
                            new StandardHyperlinkStyle("Have an account?")));
                }

                content.Add(getFormItemStack(mod, password));

                if (AppTools.User == null)
                {
                    logInHiddenFieldsAndMethod = FormsAuthStatics.GetLogInHiddenFieldsAndSpecifiedUserLogInMethod();
                    content.Add(logInHiddenFieldsAndMethod.Item1);
                }

                return content;
            }));
        }
コード例 #16
0
        public void QueryString_Has_WarningsAsErrors_When_ErrorLevel_Is_Supplied([ValueSource("_errorLevelActions")] Tuple <string, Func <TestMutableService, CompanyFile, string> > action)
        {
            // arrange
            var cf = new CompanyFile()
            {
                Uri = new Uri("https://dc1.api.myob.com/accountright/7D5F5516-AF68-4C5B-844A-3F054E00DF10")
            };

            // act
            var received = action.Item2(_service, cf);

            // assert
            Assert.IsNotNull(_webFactory.UnhandledUris.First(u => u.Query.ToLower().Contains("warningsaserrors=true")));
            Assert.IsNull(_webFactory.UnhandledUris.FirstOrDefault(u => u.Query.ToLower().Contains("generateuris=false")));
        }
コード例 #17
0
        private static BenchmarkCase RunBenchmarkCase <TViewModel>(Tuple <TViewModel, Func <TViewModel, string> > values, string name, int runs, long renderCountPerRun)
        {
            Console.WriteLine($"Started case '{name}'");
            var result = new BenchmarkCase();

            result.Name = name;
            Console.WriteLine(values.Item2(values.Item1));
            //One dryrun
            Measure(values.Item2, values.Item1, renderCountPerRun, name);
            for (int i = 0; i < runs; i++)
            {
                result.Items.Add(Measure(values.Item2, values.Item1, renderCountPerRun, name));
            }
            return(result);
        }
コード例 #18
0
ファイル: Button.cs プロジェクト: HJfod/proton-sharp
 public CheckBox(Tuple <Func <bool>, Func <bool, bool> > _Var, string _text = "", bool _checked = false, Color?_fg = null)
 {
     this.AutoSize  = true;
     this.Padding   = new Padding(Style.PaddingSize / 2);
     this.ForeColor = _fg is Color ? (Color)_fg : Style.Colors.Text;
     this.Text      = _text + "     ";
     this.Checked   = _checked;
     this.Cursor    = Cursors.Hand;
     this.Checked   = _Var.Item1();
     this.Click    += (s, e) => {
         this.Checked = this.Checked ? false : true;
         _Var.Item2(this.Checked);
         this.Invalidate();
     };
 }
コード例 #19
0
        public void ShiftTest()
        {
            Tuple <int, int> tuple1 = ChurchTuple <int, int> .Create(1)(2).Shift(_ => _);

            Assert.AreEqual(2, tuple1.Item1());
            Assert.AreEqual(2, tuple1.Item2());
            Tuple <int, int> tuple2 = ChurchTuple <int, int> .Create(2)(3).Shift(value => value * 2);

            Assert.AreEqual(3, tuple2.Item1());
            Assert.AreEqual(6, tuple2.Item2());
            Tuple <string, string> tuple3 = ChurchTuple <string, string> .Create("a")("b").Shift(value => value + "c");

            Assert.AreEqual("b", tuple3.Item1());
            Assert.AreEqual("bc", tuple3.Item2());
        }
コード例 #20
0
        public void QueryString_Has_GenerateUris_When_ConfigurationSettingIsSet([ValueSource("_errorLevelActions")] Tuple <string, Func <TestMutableService, CompanyFile, string> > action)
        {
            // arrange
            _configuration.GenerateUris.Returns(false);
            var cf = new CompanyFile()
            {
                Uri = new Uri("https://dc1.api.myob.com/accountright/7D5F5516-AF68-4C5B-844A-3F054E00DF10")
            };

            // act
            var received = action.Item2(_service, cf);

            // assert
            Assert.IsNotNull(_webFactory.UnhandledUris.First(u => u.Query.ToLower().Contains("generateuris=false")));
        }
コード例 #21
0
        /// <summary>
        /// Calculates integral image. The dimensions of integral image are (width + 1, height + 1).
        /// Use extension functions to access integral data with ease.
        /// </summary>
        /// <returns>Integral image.</returns>
        internal static IImage MakeIntegral(IImage img)
        {
            Tuple <Type, MakeIntegralFunc> makeIntegral = null;

            if (makeIntegralFuncs.TryGetValue(img.ColorInfo.ChannelType, out makeIntegral) == false)
            {
                throw new Exception(string.Format("MakeIntegral function can not process image of color depth type {0}", img.ColorInfo.ChannelType));
            }

            var    destColor = ColorInfo.GetInfo(img.ColorInfo.ColorType, makeIntegral.Item1);
            IImage dest      = Image.Create(destColor, img.Width + 1, img.Height + 1);

            makeIntegral.Item2(img, dest);
            return(dest);
        }
コード例 #22
0
        public void WeGetByInvalidUriUsingCompanyFileBaseUrlThrowsException([ValueSource("_getByInvalidUriActions")] Tuple <string, Func <TestReadOnlyService, CompanyFile, UserContract> > action)
        {
            // arrange
            var cf = new CompanyFile()
            {
                Uri = new Uri("https://dc1.api.myob.com/accountright/7D5F5516-AF68-4C5B-844A-3F054E00DF10")
            };

            _webFactory.RegisterResultForUri(cf.Uri.AbsoluteUri + "/Test/User/Contract/" + _uid, new UserContract()
            {
                UID = _uid
            }.ToJson());

            // act
            var ex = Assert.Throws <ArgumentException>(() => action.Item2(_service, cf), "The test {0} should have thrown an exception", action.Item1);
        }
コード例 #23
0
        /// <summary>
        /// Run the remaining task in the waiting queue
        /// </summary>
        private void RunRemainingTask()
        {
            if (cancellationToken.IsCancellationRequested)
            {
                return;
            }

            Tuple <long, Func <long, Task> > remainingTask = null;

            taskQueue.TryDequeue(out remainingTask);
            if (remainingTask != null)
            {
                Task task = remainingTask.Item2(remainingTask.Item1);
                RunConcurrentTask(remainingTask.Item1, task);
            }
        }
コード例 #24
0
        public void WeDeleteContactUsingCompanyFileBaseUrl([ValueSource("_deleteActions")] Tuple <string, Func <TestMutableService, CompanyFile, bool> > action)
        {
            // arrange
            var cf = new CompanyFile()
            {
                Uri = new Uri("https://dc1.api.myob.com/accountright/7D5F5516-AF68-4C5B-844A-3F054E00DF10")
            };

            _webFactory.RegisterResultForUri(cf.Uri.AbsoluteUri + "/Test/User/Contract/" + _uid, (string)null);

            // act
            var ret = action.Item2(_service, cf);

            // assert
            Assert.IsTrue(ret, "Incorrect data received during {0} operation", action.Item1);
        }
        public void WeGetRangeUsingCompanyFileBaseUrlAndQuery([ValueSource("_getRangeQueryActions")] Tuple <string, Func <CompanyFileService, CompanyFile[]> > action)
        {
            // arrange
            var id = new Guid("2BB63466-1A6C-4757-B3B8-D8B799D641E9");

            _webFactory.RegisterResultForUri(ApiRequestHandler.ApiRequestUri.AbsoluteUri + "/?$filter=Id eq guid'2BB63466-1A6C-4757-B3B8-D8B799D641E9'", new[] { new CompanyFile()
                                                                                                                                                                 {
                                                                                                                                                                     Id = id
                                                                                                                                                                 } }.ToJson());

            // act
            var received = action.Item2(_service);

            // assert
            Assert.AreEqual(id, received[0].Id, "Incorrect data received during {0} operation", action.Item1);
        }
        public void WeGetCompanyFilesUsingTheConfigurationSuppliedBaseUrl([ValueSource("_companyFileActions")] Tuple <string, Func <CompanyFileService, CompanyFile[]> > action)
        {
            // arrange
            var id = Guid.NewGuid();

            _webFactory.RegisterResultForUri(ApiRequestHandler.ApiRequestUri.AbsoluteUri, new[] { new CompanyFile {
                                                                                                      Id = id
                                                                                                  } }.ToJson());

            // act
            var received = action.Item2(_service);

            // assert
            Assert.AreEqual(1, received.Count());
            Assert.AreEqual(id, received[0].Id);
        }
コード例 #27
0
        public void SwapTest()
        {
            Tuple <int, string> tuple1 = ChurchTuple <string, int> .Create("a")(1).Swap();

            Assert.AreEqual(1, tuple1.Item1());
            Assert.AreEqual("a", tuple1.Item2());
            Tuple <string, int> tuple2 = ChurchTuple <int, string> .Create(1)("a").Swap();

            Assert.AreEqual("a", tuple2.Item1());
            Assert.AreEqual(1, tuple2.Item2());
            object @object             = new object();
            Tuple <object, int> tuple3 = ChurchTuple <int, object> .Create(1)(@object).Swap();

            Assert.AreEqual(@object, tuple3.Item1());
            Assert.AreEqual(1, tuple3.Item2());
        }
コード例 #28
0
        /// <summary>
        /// Projects each element of a sequence into a new form allowing for callback that be called on completion (by well behaved consumers).
        /// </summary>
        /// <typeparam name="TSource"></typeparam>
        /// <typeparam name="TResult"></typeparam>
        /// <param name="collection"></param>
        /// <param name="selector"></param>
        /// <returns></returns>
        public static IEnumerable <TResult> Select <TSource, TResult>(this IEnumerable <TSource> collection, Func <TSource, Tuple <TResult, Action> > selector)
        {
            foreach (TSource element in collection)
            {
                Tuple <TResult, Action> result = selector(element);

                try
                {
                    yield return(result.Item1);
                }
                finally
                {
                    result.Item2();
                }
            }
        }
コード例 #29
0
        private void DoPostWrite(Tuple <long, Func <long> > postWrite, EndianBinaryWriter writer)
        {
            long offsetOffset = postWrite.Item1;

            // Do actual write
            long offset = postWrite.Item2();

            // Write offset
            long returnPos = writer.BaseStream.Position;

            writer.BaseStream.Seek(offsetOffset, SeekOrigin.Begin);
            writer.Write(( int )offset);

            // Seek back for next one
            writer.BaseStream.Seek(returnPos, SeekOrigin.Begin);
        }
コード例 #30
0
        internal bool Execute(
            bool skipIfNoChanges, bool formValuesChanged, Action<EwfValidation, IEnumerable<string>> validationErrorHandler, bool performValidationOnly = false,
            Tuple<Action, Action> actionMethodAndPostModificationMethod = null)
        {
            var validationNeeded = validations.Any() && ( !skipIfNoChanges || formValuesChanged );
            if( validationNeeded ) {
                var topValidator = new Validator();
                foreach( var validation in validations ) {
                    if( topValidations.Contains( validation ) )
                        validation.Method( AppRequestState.Instance.EwfPageRequestState.PostBackValues, topValidator );
                    else {
                        var validator = new Validator();
                        validation.Method( AppRequestState.Instance.EwfPageRequestState.PostBackValues, validator );
                        if( validator.ErrorsOccurred )
                            topValidator.NoteError();
                        validationErrorHandler( validation, validator.ErrorMessages );
                    }
                }
                if( topValidator.ErrorsOccurred )
                    throw new DataModificationException( Translation.PleaseCorrectTheErrorsShownBelow.ToSingleElementArray().Concat( topValidator.ErrorMessages ).ToArray() );
            }

            var skipModification = !modificationMethods.Any() || ( skipIfNoChanges && !formValuesChanged );
            if( performValidationOnly || ( skipModification && actionMethodAndPostModificationMethod == null ) )
                return validationNeeded;

            DataAccessState.Current.DisableCache();
            try {
                if( !skipModification ) {
                    foreach( var method in modificationMethods )
                        method();
                }
                if( actionMethodAndPostModificationMethod != null )
                    actionMethodAndPostModificationMethod.Item1();
                DataAccessState.Current.ResetCache();
                AppRequestState.Instance.PreExecuteCommitTimeValidationMethodsForAllOpenConnections();
                if( actionMethodAndPostModificationMethod != null )
                    actionMethodAndPostModificationMethod.Item2();
            }
            catch {
                AppRequestState.Instance.RollbackDatabaseTransactions();
                DataAccessState.Current.ResetCache();
                throw;
            }

            return true;
        }
コード例 #31
0
        /// <summary> Returns whether the given skin name is used in the given beatmapset (including animations). </summary>
        public static bool IsUsed(string anElementName, BeatmapSet aBeatmapSet)
        {
            if (!isInitialized)
            {
                Initialize();
            }

            // find the tuple that contains the element name
            Tuple <string[], Func <BeatmapSet, bool> > skinCondition = null;

            foreach (Tuple <string[], Func <BeatmapSet, bool> > conditionalTuple in conditionalTuples.ToList())
            {
                foreach (string elementName in conditionalTuple.Item1)
                {
                    if (elementName.ToLower() == anElementName.ToLower())
                    {
                        skinCondition = conditionalTuple;
                    }

                    // animation frames, i.e. "followpoint-{n}.png"
                    if (elementName.Contains("{n}"))
                    {
                        int startIndex = elementName.IndexOf("{n}");
                        if (startIndex != -1 &&
                            anElementName.Length > startIndex &&
                            anElementName.IndexOf('.', startIndex) != -1)
                        {
                            int    endIndex = anElementName.IndexOf('.', startIndex);
                            string frame    = anElementName.Substring(startIndex, endIndex - startIndex);

                            if (elementName.Replace("{n}", frame).ToLower() == anElementName)
                            {
                                skinCondition = conditionalTuple;
                            }
                        }
                    }
                }
            }

            // if it's use condition matches, it's used
            if (skinCondition != null && (skinCondition.Item2 == null || skinCondition.Item2(aBeatmapSet)))
            {
                return(true);
            }

            return(false);
        }
コード例 #32
0
        public void WePostCalculateDiscountsUsingCompanyFileBaseUrl([ValueSource("_executeActions")] Tuple <string, Func <CalculateDiscountsFeesService, CompanyFile, CalculateDiscountsFeesResponse> > action)
        {
            // arrange
            var cf = new CompanyFile {
                Uri = new Uri("https://dc1.api.myob.com/accountright/7D5F5516-AF68-4C5B-844A-3F054E00DF10")
            };

            var location = cf.Uri.AbsoluteUri + "/" + _service.Route;

            _webFactory.RegisterResultForUri(cf.Uri.AbsoluteUri + "/" + _service.Route, new CalculateDiscountsFees().ToJson(), HttpStatusCode.OK, location);

            // act
            var received = action.Item2(_service, cf);

            // assert
            Assert.IsNotNull(received);
        }
コード例 #33
0
 /// <summary>
 /// General function for basic object interaction
 /// </summary>
 /// <param name="staticObj">Object "player" will interact with</param>
 /// <param name="movingObj">Player object</param>
 /// <param name="range">Within which range should the interaction take place</param>
 /// <param name="Actions">In/Out of range functions to execute</param>
 public static void InteractGeneral(GameObject staticObj, GameObject movingObj, float range, Tuple <Action, Action> Actions)
 {
     if (Vector3.Distance(staticObj.transform.position, movingObj.transform.position) <= range)
     {
         RaycastHit hit;
         if (Physics.Raycast(movingObj.transform.position, movingObj.transform.forward, out hit, Mathf.Infinity))
         {
             Debug.DrawRay(movingObj.transform.position, movingObj.transform.forward * hit.distance, Color.yellow);
             Actions.Item1();
         }
         else
         {
             Debug.DrawRay(movingObj.transform.position, movingObj.transform.forward * 1000, Color.white);
             Actions.Item2();
         }
     }
 }
コード例 #34
0
        public void WePutContactUsingCompanyFileBaseUrl([ValueSource("_putActions")] Tuple <string, Func <TestMutableService, CompanyFile, string> > action)
        {
            // arrange
            var cf = new CompanyFile()
            {
                Uri = new Uri("https://dc1.api.myob.com/accountright/7D5F5516-AF68-4C5B-844A-3F054E00DF10")
            };
            var location = cf.Uri.AbsoluteUri + "/Test/User/Contract/" + UID;

            _webFactory.RegisterResultForUri(cf.Uri.AbsoluteUri + "/Test/User/Contract/" + UID, (string)null, HttpStatusCode.OK, location);

            // act
            var received = action.Item2(_service, cf);

            // assert
            Assert.AreEqual(location, received, "Incorrect data received during {0} operation", action.Item1);
        }
コード例 #35
0
		private Button CreateButton(Tuple<string, Func<bool>> buttonInfo)
		{
			TextImageButtonFactory buttonFactory = new TextImageButtonFactory();

			buttonFactory.FixedHeight = this.FixedHeight;
			buttonFactory.normalFillColor = this.normalFillColor;
			buttonFactory.normalTextColor = this.normalTextColor;
			buttonFactory.hoverTextColor = this.hoverTextColor;
			buttonFactory.hoverFillColor = this.hoverFillColor;
			buttonFactory.borderWidth = 1;
			buttonFactory.normalBorderColor = this.normalBorderColor;
			buttonFactory.hoverBorderColor = this.hoverBorderColor;

			Button button = buttonFactory.Generate(buttonInfo.Item1, normalImageName: imageName, centerText: true);

			button.Click += (object sender, EventArgs e) =>
			{
				buttonInfo.Item2();
			};

			return button;
		}
コード例 #36
0
ファイル: R6502.cs プロジェクト: Jegqamas/Beanulator
 private Action ap_cmb(Tuple<Action, Action> code)
 {
     return delegate() { code.Item1(); code.Item2(); };
 }
コード例 #37
0
		private void EmitExceptionBlockCore( Action<TracingILGenerator, Label> tryBlockEmitter, Tuple<Type, Action<TracingILGenerator, Label, Type>> firstCatchBlockEmitter, Tuple<Type, Action<TracingILGenerator, Label, Type>>[] remainingCatchBlockEmitters, Action<TracingILGenerator, Label> finallyBlockEmitter )
		{
			var endOfExceptionBlock = this.BeginExceptionBlock();
			tryBlockEmitter( this, endOfExceptionBlock );
			if ( firstCatchBlockEmitter != null )
			{
				this.BeginCatchBlock( firstCatchBlockEmitter.Item1 );
				firstCatchBlockEmitter.Item2( this, endOfExceptionBlock, firstCatchBlockEmitter.Item1 );
			}

			foreach ( var catchBlockEmitter in remainingCatchBlockEmitters )
			{
				this.BeginCatchBlock( catchBlockEmitter.Item1 );
				firstCatchBlockEmitter.Item2( this, endOfExceptionBlock, catchBlockEmitter.Item1 );
			}

			if ( finallyBlockEmitter != null )
			{
				this.BeginFinallyBlock();
				finallyBlockEmitter( this, endOfExceptionBlock );
			}

			this.EndExceptionBlock();
		}