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


C# List.Insert方法代码示例

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


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

示例1: AddCommands

 public override void AddCommands(List<ToolBarCommand> commands)
 {
     base.AddCommands(commands);
     commands.Insert(0, tbcAdd);
     commands.Insert(1, tbcModify);
     commands.Insert(2, tbcView);
 }
开发者ID:hkiaipc,项目名称:jsb,代码行数:7,代码来源:trade_list.cs

示例2: AddIgnoredExtension

        private void AddIgnoredExtension(object _params)
        {
            string extension = _params as string;
            Debug.Assert(extension != null);

            extension = extension.ToLowerInvariant();

            var ignoredExtensions = new List<string>(Settings.Default.IgnoredExtensions);
            if (!ignoredExtensions.Contains(extension))
            {
                ignoredExtensions.Insert(0, extension);
                ClearInput(null);
            }

            Settings.Default.IgnoredExtensions = ignoredExtensions;
            Settings.Default.Save();
        }
开发者ID:mkramers,项目名称:Projects,代码行数:17,代码来源:SettingsViewModel.cs

示例3: AddMostRecentEvent

        public async Task AddMostRecentEvent()
        {
            ServiceCancellation cancelSource = new ServiceCancellation(CancellationToken.None);
            MockReliableStateManager stateManager = new MockReliableStateManager();

            IReliableDictionary<string, DeviceEvent> store =
                await stateManager.GetOrAddAsync<IReliableDictionary<string, DeviceEvent>>(DataService.EventDictionaryName);

            IReliableQueue<DeviceEventSeries> queue =
                await stateManager.GetOrAddAsync<IReliableQueue<DeviceEventSeries>>(DataService.EventQueueName);

            string expectedDeviceId = "some-device";

            List<DeviceEvent> expectedDeviceList = new List<DeviceEvent>();
            DeviceEvent expectedDeviceEvent = new DeviceEvent(new DateTimeOffset(100, TimeSpan.Zero));
            for (int i = 0; i < 10; ++i)
            {
                expectedDeviceList.Add(new DeviceEvent(new DateTimeOffset(i, TimeSpan.Zero)));
            }
            expectedDeviceList.Insert(4, expectedDeviceEvent);

            EventsController target = new EventsController(stateManager, statefulServiceContext, cancelSource);

            IActionResult result = await target.Post(expectedDeviceId, expectedDeviceList);

            Assert.True(result is OkResult);

            using (ITransaction tx = stateManager.CreateTransaction())
            {
                ConditionalValue<DeviceEvent> actualStoredEvent = await store.TryGetValueAsync(tx, expectedDeviceId);
                ConditionalValue<DeviceEventSeries> actualQueuedEvent = await queue.TryDequeueAsync(tx);

                Assert.True(actualStoredEvent.HasValue);
                Assert.Equal(expectedDeviceEvent.Timestamp, actualStoredEvent.Value.Timestamp);

                Assert.True(actualQueuedEvent.HasValue);
                Assert.True(actualQueuedEvent.Value.Events.Select(x => x.Timestamp).SequenceEqual(expectedDeviceList.Select(x => x.Timestamp)));

                await tx.CommitAsync();
            }
        }
开发者ID:Azure-Samples,项目名称:service-fabric-dotnet-iot,代码行数:41,代码来源:EventControllerTests.cs

示例4: AddCommands

 public override void AddCommands(List<ToolBarCommand> commands)
 {
     base.AddCommands(commands);
     commands.Insert(0, tbcCancel);
     commands.Insert(1, tbcUpdate);
 }
开发者ID:hkiaipc,项目名称:jsb,代码行数:6,代码来源:makeoverclass_update.cs

示例5: GetParents

		private List<OrganisationBaseObjectInfo<Department>> GetParents(DataProvider dataProvider, OrganisationBaseObjectInfo<Department> department)
		{
			var parents = new List<OrganisationBaseObjectInfo<Department>>();
			for (OrganisationBaseObjectInfo<Department> current = department; current.Item.ParentDepartmentUID != Guid.Empty;)
			{
				current = dataProvider.Departments[current.Item.ParentDepartmentUID];
				parents.Insert(0, current);
			}
			parents.Add(department);
			return parents;
		}
开发者ID:xbadcode,项目名称:Rubezh,代码行数:11,代码来源:DepartmentsReport.cs

示例6: ProcessEquation

        //Shunting yard algorithm
        public static double ProcessEquation(string equation, AttributeProperty property, int level, int previousLevel, float previousAnswer)
        {
            if (equation.Equals("")) {
                throw new ArgumentException("Equation is empty.");
            }
            List<string> result = new List<string>(Regex.Split(equation.ToLower().Trim()));
            for (int i = result.Count - 1; i >= 0; i--) {
                if (result[i].Equals("") || result[i].Equals(" ")) {
                    result.RemoveAt(i);
                }
            }
            Queue<string> queue = new Queue<string>();
            Stack<string> stack = new Stack<string>();

            for (int i = 0; i < result.Count; i++) {
                if (result[i].Equals("x") || result[i].Equals("X")) {
                    result[i] = level.ToString();
                }
                else if (result[i].Equals("k") || result[i].Equals("K")) {
                    if (previousLevel > 0) {
                        result[i] = previousLevel.ToString();
                    }
                    else {
                        result[i] = "0";
                    }
                }
                else if (result[i].Equals("p") || result[i].Equals("P")) {
                    result[i] = previousAnswer.ToString();
                }
                else if (result[i].Equals("r") || result[i].Equals("R")) {
                    float value = UnityEngine.Random.Range(1f, 1000f);
                    value /= 1000f;
                    result[i] = value.ToString();
                }
            }

            TokenClass previousTokenClass = TokenClass.Value;
            for (int i = 0; i < result.Count; i++) {
                string element = result[i];

                if (element.Equals("y") || element.Equals("=")) {
                    continue;
                }

                TokenClass tokenClass = GetTokenClass(element);
                switch (tokenClass) {
                    case TokenClass.Value:
                        queue.Enqueue(element);
                        break;
                    case TokenClass.LeftParentheses:
                        stack.Push(element);
                        break;
                    case TokenClass.RightParentheses:
                        while (!stack.Peek().Equals("(")) {
                            queue.Enqueue(stack.Pop());
                        }
                        stack.Pop();
                        break;
                    case TokenClass.Operator:
                        if (element.Equals("-") && (previousTokenClass == TokenClass.Operator || previousTokenClass == TokenClass.LeftParentheses) && (stack.Count == 0 || result[i - 1].Equals("("))) {
                            //Push unary operator "Negative" to stack.
                            stack.Push("NEG");
                            break;
                        }
                        if (element.Equals("-") && (i + 1 < result.Count) && GetTokenClass(result[i + 1]) == TokenClass.Value) {
                            if (previousTokenClass == TokenClass.Value) {
                                stack.Push(element);
                            }
                            else {
                                stack.Push("NEG");
                            }
                            break;
                        }
                        if (stack.Count > 0) {
                            string stackTopToken = stack.Peek();
                            if (GetTokenClass(stackTopToken) == TokenClass.Operator) {
                                Associativity tokenAssociativity = GetAssociativity(stackTopToken);
                                int tokenPrecedence = GetPrecedence(element);
                                int stackTopPrecedence = GetPrecedence(stackTopToken);
                                if ((tokenAssociativity == Associativity.Left && tokenPrecedence <= stackTopPrecedence) || (tokenAssociativity == Associativity.Right && tokenPrecedence < stackTopPrecedence)) {
                                    queue.Enqueue(stack.Pop());
                                }
                            }
                        }
                        stack.Push(element);
                        break;
                }

                if (tokenClass == TokenClass.Value || tokenClass == TokenClass.RightParentheses) {
                    if (i < result.Count - 1) {
                        string nextToken = result[i + 1];
                        TokenClass nextTokenClass = GetTokenClass(nextToken);
                        if (nextTokenClass != TokenClass.Operator && nextTokenClass != TokenClass.RightParentheses) {
                            result.Insert(i + 1, "*");
                        }
                    }
                }

                previousTokenClass = tokenClass;
//.........这里部分代码省略.........
开发者ID:tommai78101,项目名称:Multiplier,代码行数:101,代码来源:MathParser.cs

示例7: RetrievePersonList

        public ActionResult RetrievePersonList(string value)
        {
            var personType = (Persontype)Enum.Parse(typeof(Persontype), value);
            if (personType == Persontype.StakeHolder)
            {
                var list = this.projectStakeHolderService.RetrieveStackHolderList(SessionData.Instance.UserInfo.Developer.DeveloperID);
                var stakeHolderList = new List<StackHolderInfo>();
                foreach (var item in list)
                {
                    var stakeHolder = new StackHolderInfo();
                    stakeHolder.DeveloperID = item.StakeHolderID;
                    stakeHolder.DeveloperName = item.FirstName;
                    stakeHolderList.Add(stakeHolder);
                }

                ////StackHolderInfo defaultValue = AddDefaultStackHolder();
                stakeHolderList.Insert(0, AddDefaultStackHolder());

                return new JsonResult { Data = stakeHolderList, MaxJsonLength = int.MaxValue };
            }
            else if (personType == Persontype.OnSiteTeam)
            {
                var list = this.developerService.RetrieveList(null, null, SessionData.Instance.UserInfo.Developer.DeveloperID);
                ////DeveloperListItem defaultValue = AddDefaultDeveloper();
                list.Insert(0, AddDefaultDeveloper());
                return new JsonResult { Data = list, MaxJsonLength = int.MaxValue };
            }

            return this.Json(string.Empty);
        }
开发者ID:JaipurAnkita,项目名称:mastercode,代码行数:30,代码来源:ProjectsController.cs

示例8: MF1

        public Vector MF1(double t, Vector v, TaskParameters p)
        {
            var res = new Vector(1);
            if (p.Gamma is List<double>)
            {
                var pp = new List<double>();
                (p.Gamma as List<double>).ForEach(x => pp.Add(x));

                pp.Insert(0, double.MinValue);
                pp.Add(double.MaxValue);

                //double a = double.MinValue;
                double b = pp[0];

                for (int i = 0; i < pp.Count - 1; i++)
                {
                    if (v[0] > pp[i] && v[0] <= pp[i + 1])
                    {
                        res[0] = CallSecFunc(SecFuncName, t, v, p[i]);
                    }
                    else
                        continue;
                }
            }
            else if (p.Gamma is Dictionary<double, int>)
            {
                try
                {
                    var tt = p.Gamma as Dictionary<double, int>;
                    //int i = -1;
                    double index = tt.Keys.ToList().Find(x => Math.Abs(x - t) < 0.01);
                    res[0] = CallSecFunc(SecFuncName, t, v, p[tt[index]]);
                }
                catch (Exception)
                {
                    res[0] = 1;
                }
            }
            else
                throw new NotImplementedException("not impl yet");
            return res;
        }
开发者ID:apravdivy,项目名称:MagistrSolution,代码行数:42,代码来源:Functions_2_2.cs

示例9: GetCandidates

        public static IEnumerable<Candidate> GetCandidates(
            ExplorationSpace space,
            ExplorationNode start,
            ExplorationNode lastGoal,
            HashSet<uint> busyObjects,
            Scorer scorer,
            int numRecommendations,
            bool descending)
        {
            if (busyObjects == null)
                busyObjects = new HashSet<uint>();

            List<Candidate> candidates = new List<Candidate>();
            foreach (ExplorationNode node in space.Nodes)
            {
                if (start == node)
                    continue;

                // Make sure it's reachable
                ExplorationEdge[] path = start.GetPathOut(node.Id);
                if (path != null)
                {
                    // Add it as a candidate if the score is high enough
                    double score = scorer(start, node);
                    ExplorationEdge edge = path[0];
                    ExplorationNode goal = path.Last().Target;
                    double sentimentScore = SentimentScore(score, path);
                    candidates.Add(new Candidate(path, goal, sentimentScore));
                }
            }

            // Sort the candidates by score
            candidates.Sort((c1, c2) => c1.Score.CompareTo(c2.Score));
            if (descending == true)
                candidates.Reverse();

            // Add the previous goal to the front if we still have a path to it
            if (lastGoal != null)
            {
                ExplorationEdge[] oldPath = start.GetPathOut(lastGoal.Id);
                if (oldPath != null)
                    candidates.Insert(0, new Candidate(oldPath, lastGoal, 0.0));
            }

            HashSet<ExplorationNode> seenGoals = new HashSet<ExplorationNode>();
            HashSet<ExplorationEdge> seenEdges = new HashSet<ExplorationEdge>();

            // Pick the top N
            int count = 0;
            foreach (Candidate candidate in candidates)
            {
                ExplorationNode goal = candidate.Goal;
                if (candidate.Path.Length == 0)
                    continue;
                ExplorationEdge edge = candidate.Path[0];

                // Nix this event if it uses an object that's currently in use
                // TODO: Assumes only one event per edge
                TransitionEvent evt = edge.Events[0];
                foreach (uint id in evt.Participants)
                    if (busyObjects.Contains(id) == true)
                        goto skipCandidate;

                // If this is a novel direction to go, add it
                bool seenGoal = seenGoals.Contains(goal);
                bool seenEdge = seenEdges.Contains(edge);

                if (seenGoal == false && seenEdge == false)
                {
                    seenGoals.Add(goal);
                    seenEdges.Add(edge);
                    count++;
                    yield return candidate;
                }

                if (count >= numRecommendations)
                    break;

                skipCandidate : continue;
            }
        }
开发者ID:fgeraci,项目名称:CS195-Core,代码行数:81,代码来源:GoalSelector.cs

示例10: ToSelectList

        public static IEnumerable<SelectListItem> ToSelectList(this IDictionary<string, string> items, bool blank = false, params string[] selected)
        {
            var list = new List<SelectListItem>();

            if (items == null)
                return list;

            list.AddRange(items.Select(item => new SelectListItem
                {
                    Value = item.Key,
                    Text = item.Value,
                    Selected = selected.Contains(item.Key),
                }));

            if (blank)
                list.Insert(0, new SelectListItem());

            return list;
        }
开发者ID:duggiemitchell,项目名称:Mentor,代码行数:19,代码来源:HtmlHelper.cs


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