当前位置: 首页>>代码示例>>C#>>正文


C# Tuple.First方法代码示例

本文整理汇总了C#中Tuple.First方法的典型用法代码示例。如果您正苦于以下问题:C# Tuple.First方法的具体用法?C# Tuple.First怎么用?C# Tuple.First使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tuple的用法示例。


在下文中一共展示了Tuple.First方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FirstOnThreeTuple

 public void FirstOnThreeTuple()
 {
     const int expected = 42;
       var t = new Tuple<int, int, int>(42, 1, 1);
       int actual = t.First();
       Assert.AreEqual(expected, actual);
 }
开发者ID:nicenemo,项目名称:Noaber,代码行数:7,代码来源:TupleFirstAndLastTests.cs

示例2: AsString

 public static string AsString(Tuple<string, object>[] keyValues)
 {
     return keyValues.Count() == 1
         ? keyValues.First().Item2 as string
         : keyValues.Select(k => string.Format("{0}='{1}'", k.Item1, k.Item2))
             .Aggregate((c, n) => c + "," + n);
 }
开发者ID:iambmelt,项目名称:Vipr,代码行数:7,代码来源:ODataKeyPredicate.cs

示例3: JumpToWindowViewModel

 public JumpToWindowViewModel(Tuple<int,int[]>[] threads)
 {
     CloseWindowCommand=new Command(CloseWindow,()=>SelectedThread!=null);
     this.threads=threads;
     SelectedThread=threads.First();
     SelectedResNumber=SelectedThread.Item2.First();
 }
开发者ID:go63,项目名称:BenzGorokuSearch,代码行数:7,代码来源:JumpToWindowViewModel.cs

示例4: IsStupidBrowser

        private static bool IsStupidBrowser(Tuple<string, decimal>[] current, NancyContext context)
        {
            // If there's one or less accept headers then we can't be a stupid
            // browser so just bail out early
            if (current.Length <= 1)
            {
                return false;
            }

            var maxScore = current.First().Item2;

            if (IsPotentiallyBrokenBrowser(context.Request.Headers.UserAgent)
                && !current.Any(h => h.Item2 == maxScore && string.Equals(HtmlContentType, h.Item1, StringComparison.OrdinalIgnoreCase)))
            {
                return true;
            }

            return false;
        }
开发者ID:RadifMasud,项目名称:Nancy,代码行数:19,代码来源:BuiltInAcceptHeaderCoercions.cs

示例5: Setup

        public void Setup()
        {
            //TODO: this became an integration test - proper ProjectionCoreService and ProjectionManager testing is required as well
            _bus.Subscribe(_consumer);

            _processingQueues = GivenProcessingQueues();
            var queues = _processingQueues.ToDictionary(v => v.Item5, v => (IPublisher)v.Item1);
            _managerMessageDispatcher = new ProjectionManagerMessageDispatcher(queues);
            _manager = new ProjectionManager(
                GetInputQueue(),
                GetInputQueue(),
                queues,
                _timeProvider,
                ProjectionType.All,
                _ioDispatcher,
                _initializeSystemProjections);

            _coordinator = new ProjectionCoreCoordinator(
                ProjectionType.All,
                ProjectionCoreWorkersNode.CreateTimeoutSchedulers(queues.Count),
                queues.Values.ToArray(),
                _bus,
                Envelope);

            _bus.Subscribe<ProjectionManagementMessage.Internal.CleanupExpired>(_manager);
            _bus.Subscribe<ProjectionManagementMessage.Internal.Deleted>(_manager);
            _bus.Subscribe<CoreProjectionStatusMessage.Started>(_manager);
            _bus.Subscribe<CoreProjectionStatusMessage.Stopped>(_manager);
            _bus.Subscribe<CoreProjectionStatusMessage.Prepared>(_manager);
            _bus.Subscribe<CoreProjectionStatusMessage.Faulted>(_manager);
            _bus.Subscribe<CoreProjectionStatusMessage.StateReport>(_manager);
            _bus.Subscribe<CoreProjectionStatusMessage.ResultReport>(_manager);
            _bus.Subscribe<CoreProjectionStatusMessage.StatisticsReport>(_manager);
            _bus.Subscribe<CoreProjectionManagementMessage.SlaveProjectionReaderAssigned>(_manager);
            _bus.Subscribe<CoreProjectionStatusMessage.ProjectionWorkerStarted>(_manager);
            _bus.Subscribe<ProjectionManagementMessage.Command.Post>(_manager);
            _bus.Subscribe<ProjectionManagementMessage.Command.UpdateQuery>(_manager);
            _bus.Subscribe<ProjectionManagementMessage.Command.GetQuery>(_manager);
            _bus.Subscribe<ProjectionManagementMessage.Command.Delete>(_manager);
            _bus.Subscribe<ProjectionManagementMessage.Command.GetStatistics>(_manager);
            _bus.Subscribe<ProjectionManagementMessage.Command.GetState>(_manager);
            _bus.Subscribe<ProjectionManagementMessage.Command.GetResult>(_manager);
            _bus.Subscribe<ProjectionManagementMessage.Command.Disable>(_manager);
            _bus.Subscribe<ProjectionManagementMessage.Command.Enable>(_manager);
            _bus.Subscribe<ProjectionManagementMessage.Command.Abort>(_manager);
            _bus.Subscribe<ProjectionManagementMessage.Command.SetRunAs>(_manager);
            _bus.Subscribe<ProjectionManagementMessage.Command.Reset>(_manager);
            _bus.Subscribe<ProjectionManagementMessage.Command.StartSlaveProjections>(_manager);
            _bus.Subscribe<ClientMessage.WriteEventsCompleted>(_manager);
            _bus.Subscribe<ClientMessage.ReadStreamEventsBackwardCompleted>(_manager);
            _bus.Subscribe<ClientMessage.DeleteStreamCompleted>(_manager);
            _bus.Subscribe<SystemMessage.StateChangeMessage>(_manager);
            _bus.Subscribe<SystemMessage.SystemCoreReady>(_manager);
            _bus.Subscribe<ProjectionManagementMessage.ReaderReady>(_manager);
            _bus.Subscribe(
                CallbackSubscriber.Create<ProjectionManagementMessage.Starting>(
                    starting => _queue.Publish(new ProjectionManagementMessage.ReaderReady())));

            _bus.Subscribe<SystemMessage.StateChangeMessage>(_coordinator);
            _bus.Subscribe<SystemMessage.SystemCoreReady>(_coordinator);

            if (GetInputQueue() != _processingQueues.First().Item2)
            {
                _bus.Subscribe<PartitionProcessingResultBase>(_managerMessageDispatcher);
                _bus.Subscribe<CoreProjectionManagementControlMessage>(
                    _managerMessageDispatcher);
                _bus.Subscribe<PartitionProcessingResultOutputBase>(_managerMessageDispatcher);
                _bus.Subscribe<ReaderSubscriptionManagement.SpoolStreamReading>(_managerMessageDispatcher);
            }

            foreach(var q in _processingQueues)
                SetUpCoreServices(q.Item5, q.Item1, q.Item2, q.Item3, q.Item4);

            //Given();
            WhenLoop();
        }
开发者ID:SzymonPobiega,项目名称:EventStore,代码行数:76,代码来源:TestFixtureWithProjectionCoreAndManagementServices.cs

示例6: GenerateSyncCode

        private void GenerateSyncCode(
            Type type, CodeWriter.CodeWriter w, Type[] baseTypes,
            Tuple<Type, List<Tuple<MethodInfo, Tuple<string, string>>>>[] typeInfos)
        {
            // NoReply Interface

            var baseSynces = baseTypes.Select(t => Utility.GetActorSyncInterfaceName(t));
            var baseSyncesInherit = baseSynces.Any() ? string.Join(", ", baseSynces) : "IInterfacedActorSync";
            w._($"[AlternativeInterface(typeof({type.GetSymbolDisplay(typeless: true)}))]");
            using (w.B($"public interface {Utility.GetActorSyncInterfaceName(type)}{type.GetGenericParameters()} : {baseSyncesInherit}{type.GetGenericConstraintClause()}"))
            {
                foreach (var m in typeInfos.First().Item2)
                {
                    var method = m.Item1;
                    var parameters = method.GetParameters();
                    var paramStr = string.Join(", ", parameters.Select(p => p.GetParameterDeclaration(true)));
                    var returnType = method.ReturnType.GenericTypeArguments.FirstOrDefault();
                    var returnTypeLiteral = (returnType != null) ? returnType.GetSymbolDisplay(true) : "void";
                    w._($"{returnTypeLiteral} {method.Name}{method.GetGenericParameters()}({paramStr}){method.GetGenericConstraintClause()};");
                }
            }
        }
开发者ID:SaladLab,项目名称:Akka.Interfaced,代码行数:22,代码来源:InterfacedActorCodeGenerator.cs

示例7: GenerateRefCode

        private void GenerateRefCode(
            Type type, CodeWriter.CodeWriter w, Type[] baseTypes,
            Tuple<Type, List<Tuple<MethodInfo, Tuple<string, string>>>>[] typeInfos)
        {
            // NoReply Interface

            var baseNoReplys = baseTypes.Select(t => Utility.GetNoReplyInterfaceName(t));
            var baseNoReplysInherit = baseNoReplys.Any() ? " : " + string.Join(", ", baseNoReplys) : "";
            using (w.B($"public interface {Utility.GetNoReplyInterfaceName(type)}{type.GetGenericParameters()}{baseNoReplysInherit}{type.GetGenericConstraintClause()}"))
            {
                foreach (var m in typeInfos.First().Item2)
                {
                    var method = m.Item1;
                    var parameters = method.GetParameters();
                    var paramStr = string.Join(", ", parameters.Select(p => p.GetParameterDeclaration(true)));
                    w._($"void {method.Name}{method.GetGenericParameters()}({paramStr}){method.GetGenericConstraintClause()};");
                }
            }

            // ActorRef

            var refClassName = Utility.GetActorRefClassName(type);
            var refClassGenericName = refClassName + type.GetGenericParameters();
            var noReplyInterfaceName = Utility.GetNoReplyInterfaceName(type);
            var noReplyInterfaceGenericName = noReplyInterfaceName + type.GetGenericParameters();

            using (w.B($"public class {refClassName}{type.GetGenericParameters()} : InterfacedActorRef, {type.GetSymbolDisplay()}, {noReplyInterfaceName}{type.GetGenericParameters()}{type.GetGenericConstraintClause()}"))
            {
                // InterfaceType property

                w._($"public override Type InterfaceType => typeof({type.GetSymbolDisplay()});");
                w._();

                // Constructors

                using (w.B($"public {refClassName}() : base(null)"))
                {
                }

                using (w.B($"public {refClassName}(IRequestTarget target) : base(target)"))
                {
                }

                using (w.B($"public {refClassName}(IRequestTarget target, IRequestWaiter requestWaiter, TimeSpan? timeout = null) : base(target, requestWaiter, timeout)"))
                {
                }

                // With Helpers

                using (w.B($"public {noReplyInterfaceGenericName} WithNoReply()"))
                {
                    w._("return this;");
                }

                using (w.B($"public {refClassGenericName} WithRequestWaiter(IRequestWaiter requestWaiter)"))
                {
                    w._($"return new {refClassGenericName}(Target, requestWaiter, Timeout);");
                }

                using (w.B($"public {refClassGenericName} WithTimeout(TimeSpan? timeout)"))
                {
                    w._($"return new {refClassGenericName}(Target, RequestWaiter, timeout);");
                }

                // IInterface message methods

                foreach (var t in typeInfos)
                {
                    var payloadTableClassName = Utility.GetPayloadTableClassName(t.Item1) + type.GetGenericParameters();

                    foreach (var m in t.Item2)
                    {
                        var method = m.Item1;
                        var payloadTypes = m.Item2;
                        var parameters = method.GetParameters();

                        var parameterTypeNames = string.Join(", ", parameters.Select(p => p.GetParameterDeclaration(true)));
                        var parameterInits = string.Join(", ", parameters.Select(Utility.GetParameterAssignment));
                        var returnType = method.ReturnType.GenericTypeArguments.FirstOrDefault();

                        // Request Methods

                        var returnTaskType = (returnType != null) ? $"Task<{returnType.GetSymbolDisplay(true)}>" : "Task";
                        var prototype = $"public {returnTaskType} {method.Name}{method.GetGenericParameters()}({parameterTypeNames}){method.GetGenericConstraintClause()}";
                        using (w.B(prototype))
                        {
                            using (w.i("var requestMessage = new RequestMessage {", "};"))
                            {
                                w._($"InvokePayload = new {payloadTableClassName}.{payloadTypes.Item1}{method.GetGenericParameters()} {{ {parameterInits} }}");
                            }

                            if (returnType != null)
                                w._($"return SendRequestAndReceive<{returnType.GetSymbolDisplay(true)}>(requestMessage);");
                            else
                                w._($"return SendRequestAndWait(requestMessage);");
                        }
                    }
                }

                // IInterface_NoReply message methods
//.........这里部分代码省略.........
开发者ID:SaladLab,项目名称:Akka.Interfaced,代码行数:101,代码来源:InterfacedActorCodeGenerator.cs

示例8: IntersectDates

        public static Tuple<Tuple<DateTime, RollResultItem>[], Tuple<DateTime, RollResultItem>[]> IntersectDates(Tuple<DateTime, RollResultItem>[] series1, Tuple<DateTime, RollResultItem>[] series2)
        {
            var commonDates = series1.Select(s => s.Item1).Concat(series2.Select(s => s.Item1)).Distinct();
            var list1 = new List<Tuple<DateTime, RollResultItem>>();
            var list2 = new List<Tuple<DateTime, RollResultItem>>();
            foreach (var date in commonDates)
            {
                if (series1.Any(s => s.Item1 == date)) 
                    list1.Add(series1.First(s => s.Item1 == date));
                else
                    list1.Add(new Tuple<DateTime, RollResultItem>(date, new RollResultItem(){Value = double.NaN}));

                if (series2.Any(s => s.Item1 == date))
                    list2.Add(series2.First(s => s.Item1 == date));
                else
                    list2.Add(new Tuple<DateTime, RollResultItem>(date, new RollResultItem() { Value = double.NaN }));
            }

            return new Tuple<Tuple<DateTime, RollResultItem>[], Tuple<DateTime, RollResultItem>[]>(list1.ToArray(), list2.ToArray());
        }
开发者ID:heimanhon,项目名称:researchwork,代码行数:20,代码来源:RollResultCalculator.cs

示例9: GetAmmoGroupings_Assign

        private static GunAmmoGroup[] GetAmmoGroupings_Assign(IEnumerable<GunGroup> guns, AmmoBox[] boxesDescending, Tuple<long, long, double>[] ammo_gun_distance)
        {
            // Build a structure that can be added to
            var retVal = guns.
                Select(o => new { Gun = o, Boxes = new List<AmmoBox>() }).
                ToArray();

            for (int cntr = 0; cntr < boxesDescending.Length; cntr++)
            {
                double boxVolume = boxesDescending[cntr].QuantityMax;
                double boxMinDimension = Math1D.Min(boxesDescending[cntr].ScaleActual.X, boxesDescending[cntr].ScaleActual.Y, boxesDescending[cntr].ScaleActual.Z);
                long boxToken = boxesDescending[cntr].Token;

                // Find the gun that most needs this box
                var bestMatch = retVal.
                    Where(o => o.Gun.DemandPerGun <= boxVolume && o.Gun.Caliber <= boxMinDimension).       // only look at guns that could use this box
                    Select(o =>
                    {
                        var capacityFirings = Get_Capacity_Firings(o.Boxes, o.Gun);

                        // Add up the distance between the box and all the guns in this group
                        double distance = o.Gun.Guns.Sum(p => ammo_gun_distance.First(q => q.Item1 == boxToken && q.Item2 == p.Token).Item3);

                        return new
                        {
                            Item = o,
                            Capacity = capacityFirings.Item1,       // the current amount of capacity this gun has
                            Firings = capacityFirings.Item2,     // how many shots can be fired based on this capacity
                            Distance = distance,
                        };
                    }).
                    //TODO: Figure out how to come up with a scoring system that takes distance into account
                    OrderBy(o => o.Firings).       // order by guns with the smallest amount of available shots
                    ThenByDescending(o => o.Item.Gun.DemandTotal).       // if there's a tie, choose the greediest gun
                    First();

                // Give this box to the chosen set of guns
                bestMatch.Item.Boxes.Add(boxesDescending[cntr]);
            }

            return retVal.
                Select(o => new GunAmmoGroup(o.Gun, o.Boxes.ToArray(), Convert.ToInt32(Math.Floor(Get_Capacity_Firings(o.Boxes, o.Gun).Item2)))).
                ToArray();
        }
开发者ID:charlierix,项目名称:AsteroidMiner,代码行数:44,代码来源:ProjectileGun.cs


注:本文中的Tuple.First方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。