public IEnumerable <KeyValuePair <string, string> > get_Baggage(object activityInstance)
            {
                // Activity API signature:
                // public IEnumerable<KeyValuePair<string, string>> Baggage { get; }

                // invoker = (activityInstance) => ((Activity) activityInstance).Baggage;

                ValidateType(activityInstance);

                Func <object, IEnumerable <KeyValuePair <string, string> > > invoker = _cashedDelegates.get_Baggage;

                if (invoker == null)
                {
                    ParameterExpression exprActivityInstance = Expression.Parameter(_activityType, "activityInstance");

                    var exprInvoker = Expression.Lambda <Func <object, IEnumerable <KeyValuePair <string, string> > > >(
                        Expression.Property(
                            Expression.Convert(exprActivityInstance, _activityType),
                            "Baggage"),
                        exprActivityInstance);

                    invoker = exprInvoker.Compile();
                    invoker = Concurrent.TrySetOrGetValue(ref _cashedDelegates.get_Baggage, invoker);
                }

                IEnumerable <KeyValuePair <string, string> > result = invoker(activityInstance);

                return(result);
            }
Esempio n. 2
0
 public override void Call(RpcServerContext ctx)
 {
     if (RatePerSecond != null)
     {
         try {
             if (RatePerSecond != null)
             {
                 RatePerSecond.Increment();
                 Concurrent.Increment();
             }
             Method.Invoke(Service, new object[] { new RpcBatchServerContext(ctx) });
         } catch (Exception ex) {
             ctx.ReturnError(RpcErrorCode.ServerError, ex);
         } finally {
             Concurrent.Decrement();
         }
     }
     else
     {
         try {
             Method.Invoke(Service, new object[] { new RpcBatchServerContext(ctx) });
         } catch (Exception ex) {
             ctx.ReturnError(RpcErrorCode.ServerError, ex);
         }
     }
 }
            public string get_Name(object diagnosticListenerInstance)
            {
                Func <object, string> invokerDelegate = _cashedDelegates.get_Name;

                if (invokerDelegate == null)
                {
                    try
                    {
                        // invokerDelegate = (diagnosticListenerInstance) => ((DiagnosticListener) diagnosticListenerInstance).Name;

                        ParameterExpression exprDiagnosticListenerInstanceParam = Expression.Parameter(typeof(object), "diagnosticListenerInstance");

                        PropertyInfo propertyInfo = _thisInvoker._diagnosticListenerType.GetProperty("Name", BindingFlags.Instance | BindingFlags.Public);

                        var exprInvoker = Expression.Lambda <Func <object, string> >(
                            Expression.Property(
                                Expression.Convert(exprDiagnosticListenerInstanceParam, _thisInvoker._diagnosticListenerType),
                                propertyInfo),
                            exprDiagnosticListenerInstanceParam);

                        invokerDelegate = exprInvoker.Compile();
                        invokerDelegate = Concurrent.TrySetOrGetValue(ref _cashedDelegates.get_Name, invokerDelegate);
                    }
                    catch (Exception ex)
                    {
                        throw new DynamicInvocationException(typeof(DynamicInvoker_DiagnosticListener),
                                                             $"Error while building the invocation delegate for the API \"{nameof(get_Name)}\".",
                                                             ex);
                    }
                }

                string result = invokerDelegate(diagnosticListenerInstance);

                return(result);
            }
            public IObservable <object> get_AllListeners()
            {
                Func <IObservable <object> > invokerDelegate = _cashedDelegates.get_AllListeners;

                if (invokerDelegate == null)
                {
                    try
                    {
                        // invokerDelegate = () => DiagnosticListener.AllListeners;

                        PropertyInfo propertyInfo = _thisInvoker._diagnosticListenerType.GetProperty("AllListeners", BindingFlags.Static | BindingFlags.Public);

                        var exprInvoker = Expression.Lambda <Func <IObservable <object> > >(
                            Expression.Property(
                                null,
                                propertyInfo));

                        invokerDelegate = exprInvoker.Compile();
                        invokerDelegate = Concurrent.TrySetOrGetValue(ref _cashedDelegates.get_AllListeners, invokerDelegate);
                    }
                    catch (Exception ex)
                    {
                        throw new DynamicInvocationException(typeof(DynamicInvoker_DiagnosticListener),
                                                             $"Error while building the invocation delegate for the API \"{nameof(get_AllListeners)}\".",
                                                             ex);
                    }
                }

                IObservable <object> result = invokerDelegate();

                return(result);
            }
            public object Ctor(string diagnosticSourceName)
            {
                Func <string, object> invokerDelegate = _cashedDelegates.Ctor;

                if (invokerDelegate == null)
                {
                    try
                    {
                        // invokerDelegate = (diagnosticSourceName) => new DiagnosticListener(diagnosticSourceName);

                        ParameterExpression exprDiagnosticSourceNameParam = Expression.Parameter(typeof(string), "diagnosticSourceName");

                        ConstructorInfo ctorInfo = _thisInvoker._diagnosticListenerType.GetConstructor(new Type[] { typeof(string) });

                        var exprInvoker = Expression.Lambda <Func <string, object> >(
                            Expression.New(
                                ctorInfo,
                                exprDiagnosticSourceNameParam),
                            exprDiagnosticSourceNameParam);

                        invokerDelegate = exprInvoker.Compile();
                        invokerDelegate = Concurrent.TrySetOrGetValue(ref _cashedDelegates.Ctor, invokerDelegate);
                    }
                    catch (Exception ex)
                    {
                        throw new DynamicInvocationException(typeof(DynamicInvoker_DiagnosticListener),
                                                             $"Error while building the invocation delegate for the API \"{nameof(Ctor)}\".",
                                                             ex);
                    }
                }

                object result = invokerDelegate(diagnosticSourceName);

                return(result);
            }
Esempio n. 6
0
        private bool GeneratePaths(List <Concurrent <int, int, int> .CommandResult> i)
        {
            var sut          = new Concurrent <int, int, int>(() => 1, 5);
            var correctState = new Concurrent <int, int, int> .CurrentState(true, 1);

            return(sut.HasValidPath(i, (r, s) => correctState, correctState).Valid);
        }
            public string GetBaggageItem(object activityInstance, string key)
            {
                // Activity API signature:
                // public string GetBaggageItem(string key)

                // invoker = (activityInstance, key) => ((Activity) activityInstance).GetBaggageItem(key);

                ValidateType(activityInstance);

                Func <object, string, string> invoker = _cashedDelegates.GetBaggageItem;

                if (invoker == null)
                {
                    ParameterExpression exprActivityInstance = Expression.Parameter(_activityType, "activityInstance");
                    ParameterExpression exprKey = Expression.Parameter(typeof(string), "key");

                    var exprInvoker = Expression.Lambda <Func <object, string, string> >(
                        Expression.Call(
                            Expression.Convert(exprActivityInstance, _activityType),
                            "GetBaggageItem", new[] { typeof(string) }, exprKey),
                        exprActivityInstance, exprKey);

                    invoker = exprInvoker.Compile();
                    invoker = Concurrent.TrySetOrGetValue(ref _cashedDelegates.GetBaggageItem, invoker);
                }

                string result = invoker(activityInstance, key);

                return(result);
            }
            //public object StartNewActivity(string operationName)
            //{
            //    invoker = (operationName) =>
            //    {
            //        Activity activity = new Activity(operationName);
            //        ActivityStub activityStub = ActivityStub.Wrap(activity);
            //        PreStartInitializationCallback(activityStub);
            //        autoInstrumentationDiagnosticSource.StartActivity(actvitiy, activity);
            //    }
            //}

            public void AddBaggage(object activityInstance, string key, string value)
            {
                // Activity API signature:
                // public Activity AddBaggage(string key, string value)

                // invoker = (activityInstance, key, value) => ((Activity) activityInstance).AddBaggage(key, value);

                ValidateType(activityInstance);

                Action <object, string, string> invoker = _cashedDelegates.AddBagage;

                if (invoker == null)
                {
                    ParameterExpression exprActivityInstance = Expression.Parameter(_activityType, "activityInstance");
                    ParameterExpression exprKey   = Expression.Parameter(typeof(string), "key");
                    ParameterExpression exprValue = Expression.Parameter(typeof(string), "value");

                    var exprInvoker = Expression.Lambda <Action <object, string, string> >(
                        Expression.Call(
                            Expression.Convert(exprActivityInstance, _activityType),
                            "AddBaggage", new[] { typeof(string), typeof(string) }, exprKey, exprValue),
                        exprActivityInstance, exprKey, exprValue);

                    invoker = exprInvoker.Compile();
                    invoker = Concurrent.TrySetOrGetValue(ref _cashedDelegates.AddBagage, invoker);
                }

                invoker(activityInstance, key, value);
            }
 public override void Dispose()
 {
     if (_ConcurrentNode != null)
     {
         _ConcurrentNode.Dispose();
         _ConcurrentNode = null;
     }
 }
Esempio n. 10
0
        static int Main(string[] args)
        {
            if (args.Length == 0)
            {
                Console.WriteLine("[FATAL] Missing required command-line argument: 'limit'");
                return(1);
            }

            if (!int.TryParse(args[0], out int limit))
            {
                Console.WriteLine("[FATAL] Cannot parse '{0}' as integer", args[0]);
                return(2);
            }

            if (limit < 0)
            {
                Console.WriteLine("[FATAL] Expected positive value for argument '{0}', got: {1}", nameof(limit), limit);
                return(3);
            }

            var log = Concurrent <string> .List();

            var runners = (
                new SieveRunner <EulerSieve>("Euler"),
                new SieveRunner <EratosthenesSieve>("Eratosthenes")
                );

            var current = new ConcurrentScalar <string, DateTime>();

            current.updated += (prev, current) => {
                if (prev.data != default)
                {
                    log.Add($"Iesire temporara fir: {prev.data}@{asTimestamp(current.extra)}");
                }
            };

            foreach (var runner in runners.iterate <AbstractSieveRunner>())
            {
                runner.begun += (DateTime time, int limit) => {
                    log.Add($"Startfir: {runner.name}@{asTimestamp(time)} Numar natural dat = {limit}");
                };
                runner.waiting += (DateTime time) => {
                    current[runner.name] = time;
                };
                runner.done += (DateTime time, int result) => {
                    log.Add($"End fir: {runner.name}@{asTimestamp(time)} Numar prim = {result}");
                };

                runner.execute(limit);
            }

            runners.complete <AbstractSieveRunner>();

            log.ForEach(Console.WriteLine);

            return(0);
        }
Esempio n. 11
0
        public void TestParrel_concurrent_locked()
        {
            var concurrentTape = new Concurrent <ITape, int, int>(() => new TapeConcurrentLocking(), 2);

            concurrentTape
            .ToProperty(Validate, new Collection <ConcurrentCommand.Command <ITape, int> > {
                new GetTicketCommand(), new ReadCommand()
            }, 0)
            .VerboseCheckThrowOnFailure();
        }
Esempio n. 12
0
        /// <summary>
        /// Get a version of this object suitable for use in a ParallelFor job
        /// </summary>
        ///
        /// <returns>
        /// A version of this object suitable for use in a ParallelFor job
        /// </returns>
        public Concurrent ToConcurrent()
        {
#if ENABLE_UNITY_COLLECTIONS_CHECKS
            Concurrent concurrent = new Concurrent(m_Buffer, m_Safety);
            AtomicSafetyHandle.UseSecondaryVersion(ref concurrent.m_Safety);
#else
            Concurrent concurrent = new Concurrent(m_Buffer);
#endif
            return(concurrent);
        }
Esempio n. 13
0
        public static Concurrent ToConcurrent(this RaceEntity entity)
        {
            Concurrent concurrent = new Concurrent();

            concurrent.Nom          = entity.Concurrent;
            concurrent.ConcurrentId = Convert.ToInt32(entity.PartitionKey);
            concurrent.SC           = entity.SC;

            return(concurrent);
        }
        public GameScene()
        {
            Concurrent cameraPan;
            Sequence   panZoomSequence = new Sequence();


            //m_backpackers[2].Transform.PosX += 100;

            Party.Initialise();

            m_introSequence = new Sequence();
            m_introSequence.AddAction(Party.GetMovingOutAnimation());

            #region Camera Intro Pan Forward T = 5s

            m_cameraIntroForwardPan = new MoveToStaticAction(Globals.TheGame, World.cam_Main.Transform, Vector2.Zero, 1);
            m_cameraIntroForwardPan.Timer.Interval = 5.0f;
            m_cameraIntroForwardPan.Interpolator   = new PSmoothstepInterpolation();

            ScaleToAction zoom1 = new ScaleToAction(Globals.TheGame, World.cam_Main.Transform, new Vector2(IntroZoom, IntroZoom), 1);
            zoom1.Timer.Interval = 3.0f;
            zoom1.StartScale     = new Vector2(WaveZoom, WaveZoom);
            zoom1.Interpolator   = new PSmoothstepInterpolation();
            panZoomSequence.AddAction(zoom1);

            panZoomSequence.AddAction(new DelayAction(Globals.TheGame, 1.0f));

            ScaleToAction zoom2 = new ScaleToAction(Globals.TheGame, World.cam_Main.Transform, new Vector2(IntroOnExitZoom, IntroOnExitZoom), 1);
            zoom2.Timer.Interval = 1.0f;
            zoom2.StartScale     = zoom1.Target;
            zoom2.Interpolator   = new PSmoothstepInterpolation();
            panZoomSequence.AddAction(zoom2);

            cameraPan = new Concurrent(new PastaGameLibrary.Action[] { m_cameraIntroForwardPan, panZoomSequence });
            m_introSequence.AddAction(cameraPan);

            m_introSequence.AddAction(new DelayAction(Globals.TheGame, 0.5f));

            #endregion

            #region Camera pan backwards T = 3s

            m_cameraIntroBackwardsPan = new MoveToStaticAction(Globals.TheGame, World.cam_Main.Transform, Vector2.Zero, 1);
            m_cameraIntroBackwardsPan.Timer.Interval = 3.0f;
            m_cameraIntroBackwardsPan.Interpolator   = new PSmoothstepInterpolation();
            zoom1 = new ScaleToAction(Globals.TheGame, World.cam_Main.Transform, new Vector2(1.0f, 1.0f), 1);
            zoom1.Timer.Interval = 1.0f;
            zoom1.StartScale     = zoom2.Target;
            zoom1.Interpolator   = new PSmoothstepInterpolation();
            cameraPan            = new Concurrent(new PastaGameLibrary.Action[] { m_cameraIntroBackwardsPan, zoom1 });

            m_introSequence.AddAction(cameraPan);

            #endregion
        }
Esempio n. 15
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = Server.GetHashCode();
         hashCode = (hashCode * 397) ^ Concurrent.GetHashCode();
         hashCode = (hashCode * 397) ^ CpuGroups.GetHashCode();
         hashCode = (hashCode * 397) ^ Force.GetHashCode();
         hashCode = (hashCode * 397) ^ AllowVeryLargeObjects.GetHashCode();
         return(hashCode);
     }
 }
Esempio n. 16
0
        private static PackagedAssemblyLookup GetPackagedAssemblies()
        {
            PackagedAssemblyLookup packagedAssemblies = s_packagedAssemblies;

            if (packagedAssemblies == null)
            {
                packagedAssemblies = ReadPackagedAssembliesFromDisk();
                packagedAssemblies = Concurrent.TrySetOrGetValue(ref s_packagedAssemblies, packagedAssemblies);
            }

            return(packagedAssemblies);
        }
Esempio n. 17
0
        protected R AddInDatabases <R, T>(Func <DBItemContext, IEnumerable <Row> > AddRow)
            where T : DBItemWorkerBaseResultItem, new()
            where R : DBItemWorkerBaseResult, new()
        {
            var result = new R {
                Session = DBItems[0].Session
            };
            int c          = 0;
            int l          = DBItems.Length;
            var progress   = new Log();
            var concurrent = new Concurrent();

            concurrent.ForEach(DBItems, dbitem =>
            {
                var dbic = new DBItemContext(dbitem);
                try
                {
                    dbic.Init(loginLock);
                    var rows = AddRow(dbic);
                    dbic.Session.Save();
                    lock (result.SyncRoot)
                    {
                        foreach (var row in rows)
                        {
                            result.Items.Add(new T()
                            {
                                Session = dbic.DBItem.Session,
                                DBItem  = dbic.DBItem,
                                Row     = row
                            });
                        }
                    }
                }
                catch (Exception ex)
                {
                    lock (result.SyncRoot)
                    {
                        result.Items.Add(new T()
                        {
                            Session   = dbic.DBItem.Session,
                            DBItem    = dbic.DBItem,
                            Exception = ex
                        });
                    }
                }
                finally
                {
                    dbic.Dispose();
                }
                progress.Write(new Percent(c++, l));
            });
            return(result);
        }
Esempio n. 18
0
        public static CompetitorEntity ToCompetitorEntity(this Concurrent concurrent)
        {
            CompetitorEntity competitorEntity = new CompetitorEntity();

            competitorEntity.Victoires  = concurrent.Victoires;
            competitorEntity.SC         = concurrent.SC;
            competitorEntity.Nom        = concurrent.Nom;
            competitorEntity.Entraineur = concurrent.Entraineur.Nom;
            competitorEntity.Defaites   = concurrent.Defaites;

            return(competitorEntity);
        }
Esempio n. 19
0
        public void DegenerateCaseComplates()
        {
            const int generationSize = 17;
            var       gen            = AlwaysTrueCommandResult(generationSize).Sample(1, 1).First();

            gen.Add(new Concurrent <bool, bool, bool> .CommandResult(new Concurrent <bool, bool, bool> .ClientCommand(2, new BoolIdentity()), false));

            var sut    = new Concurrent <bool, bool, bool>(() => true, 2);
            var result = sut.HasValidPath(gen, MatchTheResult, new Concurrent <bool, bool, bool> .CurrentState(true, true));

            Assert.False(result.Valid);
        }
Esempio n. 20
0
        private Concurrent <ITape, int, int> .CurrentState Validate(Concurrent <ITape, int, int> .CommandResult cmdResult, Concurrent <ITape, int, int> .CurrentState state)
        {
            var model    = state.Model;
            var newModel = cmdResult.ClientCommand.Command switch
            {
                GetTicketCommand _ => model + 1,
                ReadCommand _ => model,
                _ => throw new Exception("Bad command processed")
            };

            return(new Concurrent <ITape, int, int> .CurrentState(cmdResult.Result == newModel, newModel));
        }
Esempio n. 21
0
        public void TestParrel_concurrent_buggy_std()
        {
            var t = Configuration.QuickThrowOnFailure;

            t.Replay = FsCheck.Random.StdGen.NewStdGen(1867961639, 296867728);
            var concurrentTape = new Concurrent <ITape, int, int>(() => new TapeConcurrentBug(), 2);

            concurrentTape
            .ToProperty(Validate, new Collection <ConcurrentCommand.Command <ITape, int> > {
                new GetTicketCommand(), new ReadCommand()
            }, 0)
            .Check(t);
        }
            public bool IsEnabled(object diagnosticSourceInstance, string eventName, object arg1, object arg2)
            {
                Func <object, string, object, object, bool> invokerDelegate = _cashedDelegates.IsEnabled;

                if (invokerDelegate == null)
                {
                    try
                    {
                        // invokerDelegate = (diagnosticSourceInstance, eventName, arg1, arg2) =>
                        //                              ((Diagnosticource) diagnosticSourceInstance).Subscribe(eventName, arg1, arg2);

                        ParameterExpression exprDiagnosticSourceInstanceParam = Expression.Parameter(typeof(object), "diagnosticSourceInstance");
                        ParameterExpression exprEventNameParam = Expression.Parameter(typeof(string), "eventName");
                        ParameterExpression exprArg1Param      = Expression.Parameter(typeof(object), "arg1");
                        ParameterExpression exprArg2Param      = Expression.Parameter(typeof(object), "arg2");

                        MethodInfo methodInfo = _thisInvoker._diagnosticSourceType.GetMethod("IsEnabled",
                                                                                             BindingFlags.Instance | BindingFlags.Public,
                                                                                             binder: null,
                                                                                             new Type[] { typeof(string), typeof(object), typeof(object) },
                                                                                             modifiers: null);

                        var exprInvoker = Expression.Lambda <Func <object, string, object, object, bool> >(
                            Expression.Call(
                                Expression.Convert(exprDiagnosticSourceInstanceParam, _thisInvoker._diagnosticSourceType),
                                methodInfo,
                                exprEventNameParam,
                                exprArg1Param,
                                exprArg2Param),
                            exprDiagnosticSourceInstanceParam,
                            exprEventNameParam,
                            exprArg1Param,
                            exprArg2Param);

                        invokerDelegate = exprInvoker.Compile();
                        invokerDelegate = Concurrent.TrySetOrGetValue(ref _cashedDelegates.IsEnabled, invokerDelegate);
                    }
                    catch (Exception ex)
                    {
                        throw new DynamicInvocationException(typeof(DynamicInvoker_DiagnosticSource),
                                                             $"Error while building the invocation delegate for the API \"{nameof(IsEnabled)}\".",
                                                             ex);
                    }
                }

                bool result = invokerDelegate(diagnosticSourceInstance, eventName, arg1, arg2);

                return(result);
            }
            public IDisposable Subscribe(object diagnosticListenerInstance,
                                         IObserver <KeyValuePair <string, object> > eventObserver,
                                         Func <string, object, object, bool> isEventEnabledFilter)
            {
                Func <object, IObserver <KeyValuePair <string, object> >, Func <string, object, object, bool>, IDisposable> invokerDelegate = _cashedDelegates.Subscribe;

                if (invokerDelegate == null)
                {
                    try
                    {
                        // invokerDelegate = (diagnosticListenerInstance, eventObserver, isEventEnabledFilter) =>
                        //                              ((DiagnosticListener) diagnosticListenerInstance).Subscribe(eventObserver, isEventEnabledFilter);

                        ParameterExpression exprDiagnosticListenerInstanceParam = Expression.Parameter(typeof(object), "diagnosticListenerInstance");
                        ParameterExpression exprEventObserverParam        = Expression.Parameter(typeof(IObserver <KeyValuePair <string, object> >), "eventObserver");
                        ParameterExpression exprIsEventEnabledFilterParam = Expression.Parameter(typeof(Func <string, object, object, bool>), "isEventEnabledFilter");

                        MethodInfo methodInfo = _thisInvoker._diagnosticListenerType.GetMethod("Subscribe",
                                                                                               BindingFlags.Instance | BindingFlags.Public,
                                                                                               binder: null,
                                                                                               new Type[] { typeof(IObserver <KeyValuePair <string, object> >),
                                                                                                            typeof(Func <string, object, object, bool>) },
                                                                                               modifiers: null);

                        var exprInvoker = Expression.Lambda <Func <object, IObserver <KeyValuePair <string, object> >, Func <string, object, object, bool>, IDisposable> >(
                            Expression.Call(
                                Expression.Convert(exprDiagnosticListenerInstanceParam, _thisInvoker._diagnosticListenerType),
                                methodInfo,
                                exprEventObserverParam,
                                exprIsEventEnabledFilterParam),
                            exprDiagnosticListenerInstanceParam,
                            exprEventObserverParam,
                            exprIsEventEnabledFilterParam);

                        invokerDelegate = exprInvoker.Compile();
                        invokerDelegate = Concurrent.TrySetOrGetValue(ref _cashedDelegates.Subscribe, invokerDelegate);
                    }
                    catch (Exception ex)
                    {
                        throw new DynamicInvocationException(typeof(DynamicInvoker_DiagnosticListener),
                                                             $"Error while building the invocation delegate for the API \"{nameof(Subscribe)}\".",
                                                             ex);
                    }
                }

                IDisposable result = invokerDelegate(diagnosticListenerInstance, eventObserver, isEventEnabledFilter);

                return(result);
            }
Esempio n. 24
0
        public TestingSession(string assemblyName, string assemblyPath, string methodDeclaringClass, string methodName, int schedulingSeed, int timeoutMs = Constants.SessionTimeoutMs, int maxDecisions = Constants.SessionMaxDecisions)
        {
            this.Meta = new SessionInfo(IdGen.Generate().ToString(), assemblyName, assemblyPath, methodDeclaringClass, methodName, schedulingSeed, timeoutMs, maxDecisions);

            this.records = new List <SessionRecord>();

            // initialize run-time objects
            // this._onComplete = record => { };     // empty onComplete handler
            this.stateLock  = new object();
            this.traceFile  = File.AppendText(this.traceFilePath);
            this.logFile    = File.AppendText(this.logFilePath);
            this.IsFinished = new Concurrent <bool>();

            this.Reset();
        }
Esempio n. 25
0
        public DetailCourseViewModel GetDetailCourseViewModel(int idCourse)
        {
            DetailCourseViewModel vm = new DetailCourseViewModel();

            List <RaceEntity> entities = _unitOfWork.RaceRepository.GetRaceDetail(idCourse);

            vm.Course = entities.First().ToCourse();
            foreach (RaceEntity entity in entities)
            {
                Concurrent concurrent = entity.ToConcurrent();
                vm.Concurrents.Add(concurrent);
            }

            return(vm);
        }
Esempio n. 26
0
        /// <summary>Adds an item to the collection.</summary>
        /// <param name="item">Item to be added.</param>
        public void Add(T item)
        {
            GrowingCollectionSegment <T> currHead = Volatile.Read(ref _dataHead);

            bool added = currHead.TryAdd(item);

            while (!added)
            {
                var newHead = new GrowingCollectionSegment <T>(currHead);
                Concurrent.CompareExchangeResult(ref _dataHead, newHead, currHead);

                GrowingCollectionSegment <T> updatedHead = Interlocked.CompareExchange(ref _dataHead, newHead, currHead);
                added = updatedHead.TryAdd(item);
            }
        }
Esempio n. 27
0
        [Obsolete] public Concurrent ToConcurrent()
        {
            var concurrent = new Concurrent
            {
                m_StageCollection           = m_StageCollection,
                m_Pipelines                 = m_Pipelines,
                m_StageList                 = m_StageList,
                m_SendStageNeedsUpdateWrite = m_SendStageNeedsUpdateRead.ToConcurrent(),
                sizePerConnection           = sizePerConnection,
                sendBuffer   = m_SendBuffer,
                sharedBuffer = m_SharedBuffer,
                m_timestamp  = m_timestamp
            };

            return(concurrent);
        }
Esempio n. 28
0
        public static Concurrent ToConcurrent(this CompetitorEntity entity)
        {
            Concurrent concurrent = new Concurrent();

            concurrent.Nom          = entity.Nom;
            concurrent.ConcurrentId = Convert.ToInt32(entity.PartitionKey);
            concurrent.Defaites     = entity.Defaites;
            concurrent.Entraineur   = new Entraineur()
            {
                Nom = entity.Entraineur
            };
            concurrent.SC        = entity.SC;
            concurrent.Victoires = entity.Victoires;

            return(concurrent);
        }
Esempio n. 29
0
        static void InitialiseMovingOutAnimation()
        {
            #region Backpacker 0

            Sequence waveAnimation_0 = new Sequence();

            MoveToStaticAction walkMove_0 = new MoveToStaticAction(Globals.TheGame, Backpackers[0].Transform, new Vector2(MeetingPoint, 0), 1);
            walkMove_0.Timer.Interval = 0.5f;
            SpriteSheetAnimation walkAnim_0 = new SpriteSheetAnimation(Backpackers[0].Sprite, 0, 1, 0.1f, 5);
            waveAnimation_0.AddAction(new Concurrent(new PastaGameLibrary.Action[] { walkMove_0, walkAnim_0 }));
            waveAnimation_0.AddAction(new SpriteSheetAnimation(Backpackers[0].Sprite, 0, 0, 0.5f, 1));
            waveAnimation_0.AddAction(new SpriteSheetAnimation(Backpackers[0].Sprite, 2, 3, 0.2f, 4));
            waveAnimation_0.AddAction(new SpriteSheetAnimation(Backpackers[0].Sprite, 0, 0, 0.1f, 1));

            #endregion

            #region Backpacker 1

            Sequence waveAnimation_1 = new Sequence();

            MoveToStaticAction walkMove_1 = new MoveToStaticAction(Globals.TheGame, Backpackers[1].Transform, new Vector2(MeetingPoint - 40, 0), 1);
            walkMove_1.Timer.Interval = 0.5f;
            SpriteSheetAnimation walkAnim_1 = new SpriteSheetAnimation(Backpackers[1].Sprite, 0, 1, 0.1f, 5);
            waveAnimation_1.AddAction(new DelayAction(Globals.TheGame, 0.2f));
            waveAnimation_1.AddAction(new Concurrent(new PastaGameLibrary.Action[] { walkMove_1, walkAnim_1 }));
            waveAnimation_1.AddAction(new SpriteSheetAnimation(Backpackers[1].Sprite, 0, 0, 0.5f, 1));
            waveAnimation_1.AddAction(new SpriteSheetAnimation(Backpackers[1].Sprite, 2, 3, 0.1f, 5));
            waveAnimation_1.AddAction(new SpriteSheetAnimation(Backpackers[1].Sprite, 0, 0, 0.1f, 1));

            #endregion

            #region Backpacker 2

            Sequence waveAnimation_2 = new Sequence();

            MoveToStaticAction walkMove_2 = new MoveToStaticAction(Globals.TheGame, Backpackers[2].Transform, new Vector2(MeetingPoint - 80, 0), 1);
            walkMove_2.Timer.Interval = 0.5f;
            SpriteSheetAnimation walkAnim_2 = new SpriteSheetAnimation(Backpackers[2].Sprite, 0, 1, 0.1f, 5);
            waveAnimation_2.AddAction(new DelayAction(Globals.TheGame, 0.4f));
            waveAnimation_2.AddAction(new Concurrent(new PastaGameLibrary.Action[] { walkMove_2, walkAnim_2 }));
            waveAnimation_2.AddAction(new SpriteSheetAnimation(Backpackers[2].Sprite, 2, 3, 0.2f, 3));
            waveAnimation_2.AddAction(new SpriteSheetAnimation(Backpackers[2].Sprite, 0, 0, 0.1f, 1));

            #endregion

            s_movingOutAnimation = new Concurrent(new PastaGameLibrary.Action[] { waveAnimation_0, waveAnimation_1, waveAnimation_2 });
        }
Esempio n. 30
0
        public void ShinkerProperties()
        {
            var config    = Configuration.QuickThrowOnFailure;
            var sut       = new Concurrent <int, int, int>(() => 1, 3);
            var generator = Arb.From(sut.Generator(new Collection <ConcurrentCommand.Command <int, int> > {
                new IntSutIdentity()
            }), sut.Shrinker);

            Prop.ForAll(generator, testCase =>
            {
                var uniqeClients = MakeClientsUniqe(testCase);
                var shrunken     = sut.Shrinker(uniqeClients).ToList();
                var flatClients  = Flatten(uniqeClients);
                return(AllShunkenClientsElementOfOriginal(shrunken, flatClients)
                       .And(OnlyOneElementOfOriginalNotInShrunken(shrunken, flatClients)));
            }).Check(config);
        }