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


C# ImmutableList.Add方法代码示例

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


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

示例1: RecoursiveCheckGraph

        private static bool RecoursiveCheckGraph(Task root, ImmutableList<Guid> previousTasks)
        {
            Contract.Requires(root != null);
            Contract.Requires(root.Inputs != null);
            Contract.Requires(previousTasks != null);

            if (previousTasks.Contains(root.Id))
            {
                Logger.Write(
                    LogCategories.Error(string.Format(
                    "{0} is cycled.", root),
                    LogCategories.TaskServices));
                return false;
            }

            foreach (var task in root.Inputs)
            {
                if (previousTasks.Contains(task.Id))
                {
                    Logger.Write(
                        LogCategories.Error(string.Format(
                        "{0} is cycled.", task),
                        LogCategories.TaskServices));
                    return false;
                }

                if (!RecoursiveCheckGraph(task, previousTasks.Add(root.Id)))
                    return false;
            }
            return true;
        }
开发者ID:kapitanov,项目名称:diploma,代码行数:31,代码来源:JobGraphCyclesValidationStrategy.cs

示例2: ImmutableListAndObject

 public void ImmutableListAndObject()
 {
     var list = new ImmutableList<ImmutableObject>();
     list.Add(new ImmutableObject(1)).Add(new ImmutableObject(2));
     Assert.Equal(2, list.Count);
     list[0].CalculateDummyValue();
     Assert.Equal(1, list[0].CallCount);
 }
开发者ID:ramik,项目名称:Demo,代码行数:8,代码来源:ImmutabilityTest.cs

示例3: Add_ReturnsNewListWithNewItemAppended

        public void Add_ReturnsNewListWithNewItemAppended()
        {
            var subject = new ImmutableList<int>();
            var result = subject.Add(12);

            Assert.AreEqual(0, subject.Count);
            Assert.AreEqual(1, result.Count);
        }
开发者ID:gmf520,项目名称:Smocks,代码行数:8,代码来源:ImmutableListTests.cs

示例4: RecoursiveCheckGraph

        private static bool RecoursiveCheckGraph(TaskRequest root, ImmutableList<Guid> previousTasks)
        {
            if (previousTasks.Contains(root.Id))

                return false;

            foreach (var task in root.Dependencies)
            {
                if (previousTasks.Contains(task.Id))
                    return false;

                if (!RecoursiveCheckGraph(task, previousTasks.Add(root.Id)))
                    return false;
            }
            return true;
        }
开发者ID:kapitanov,项目名称:diploma,代码行数:16,代码来源:ValidateGraph.cs

示例5: RecoursiveCheckGraph

        private static bool RecoursiveCheckGraph(Japi.Task root, ImmutableList<Japi.Task> previousTasks)
        {
            if(previousTasks.Contains(root))
            {
                Console.WriteLine("1: {0}", root);
                return false;
            }

            foreach(var task in root.Dependencies)
            {
                if(previousTasks.Contains(task))
                {
                    Console.WriteLine("2: {0}", root);
                    return false;
                }

                if(!RecoursiveCheckGraph(task, previousTasks.Add(root)))
                    return false;
            }
            return true;
        }
开发者ID:kapitanov,项目名称:diploma,代码行数:21,代码来源:ValidateGraph.cs

示例6: ReferenceFinders

 static ReferenceFinders()
 {
     DefaultRenameReferenceFinders = ImmutableList.Create(
         Constructor,
         Destructor,
         Event,
         ExplicitInterfaceMethod,
         Field,
         Label,
         Local,
         MethodTypeParameter,
         NamedType,
         Namespace,
         Operator,
         OrdinaryMethod,
         Parameter,
         Property,
         PropertyAccessor,
         RangeVariable,
         TypeParameter);
     DefaultReferenceFinders = DefaultRenameReferenceFinders.Add(ConstructorInitializer);
 }
开发者ID:riversky,项目名称:roslyn,代码行数:22,代码来源:ReferenceFinders.cs

示例7: VerifyRootPrincipal

        private IProperty VerifyRootPrincipal(
            IProperty principalProperty,
            Dictionary<IProperty, IProperty> verifiedProperties,
            ImmutableList<IForeignKey> visitedForeignKeys,
            out string errorMessage)
        {
            errorMessage = null;
            IProperty rootPrincipal;
            if (verifiedProperties.TryGetValue(principalProperty, out rootPrincipal))
            {
                return rootPrincipal;
            }

            var rootPrincipals = new Dictionary<IProperty, IForeignKey>();
            foreach (var foreignKey in principalProperty.DeclaringEntityType.GetForeignKeys())
            {
                for (var index = 0; index < foreignKey.Properties.Count; index++)
                {
                    if (principalProperty == foreignKey.Properties[index])
                    {
                        var nextPrincipalProperty = foreignKey.PrincipalKey.Properties[index];
                        if (visitedForeignKeys.Contains(foreignKey))
                        {
                            var cycleStart = visitedForeignKeys.IndexOf(foreignKey);
                            var cycle = visitedForeignKeys.GetRange(cycleStart, visitedForeignKeys.Count - cycleStart);
                            errorMessage = Strings.CircularDependency(cycle.Select(fk => fk.ToString()).Join());
                            continue;
                        }
                        rootPrincipal = VerifyRootPrincipal(nextPrincipalProperty, verifiedProperties, visitedForeignKeys.Add(foreignKey), out errorMessage);
                        if (rootPrincipal == null)
                        {
                            if (principalProperty.RequiresValueGenerator)
                            {
                                rootPrincipals[principalProperty] = foreignKey;
                            }
                            continue;
                        }

                        if (principalProperty.RequiresValueGenerator)
                        {
                            ShowError(Strings.ForeignKeyValueGenerationOnAdd(
                                principalProperty.Name,
                                principalProperty.DeclaringEntityType.DisplayName(),
                                Property.Format(foreignKey.Properties)));
                            return principalProperty;
                        }

                        rootPrincipals[rootPrincipal] = foreignKey;
                    }
                }
            }

            if (rootPrincipals.Count == 0)
            {
                if (errorMessage != null)
                {
                    return null;
                }

                if (!principalProperty.RequiresValueGenerator)
                {
                    ShowError(Strings.PrincipalKeyNoValueGenerationOnAdd(principalProperty.Name, principalProperty.DeclaringEntityType.DisplayName()));
                    return null;
                }

                return principalProperty;
            }

            if (rootPrincipals.Count > 1)
            {
                var firstRoot = rootPrincipals.Keys.ElementAt(0);
                var secondRoot = rootPrincipals.Keys.ElementAt(1);
                ShowWarning(Strings.MultipleRootPrincipals(
                    rootPrincipals[firstRoot].DeclaringEntityType.DisplayName(),
                    Property.Format(rootPrincipals[firstRoot].Properties),
                    firstRoot.DeclaringEntityType.DisplayName(),
                    firstRoot.Name,
                    Property.Format(rootPrincipals[secondRoot].Properties),
                    secondRoot.DeclaringEntityType.DisplayName(),
                    secondRoot.Name));

                return firstRoot;
            }

            errorMessage = null;
            rootPrincipal = rootPrincipals.Keys.Single();
            verifiedProperties[principalProperty] = rootPrincipal;
            return rootPrincipal;
        }
开发者ID:JamesWang007,项目名称:EntityFramework,代码行数:89,代码来源:ModelValidator.cs

示例8: GuildBank

		public GuildBank(Guild guild, bool isNew)
		{
			Guild = guild;
			BankTabs = new ImmutableList<GuildBankTab>(5);
			if (isNew)
			{
				var tab = new GuildBankTab(this)
				          	{
				          		BankSlot = 0,
				          		Icon = "",
				          		Name = "Slot 0",
				          		Text = ""
				          	};
				BankTabs.Add(tab);
			}
			else
			{
				var tabs = GuildBankTab.FindAllByProperty("_guildId", (int) guild.Id);
				foreach (var tab in tabs)
				{
					BankTabs.Add(tab);
				}
			}
		}
开发者ID:ray2006,项目名称:WCell,代码行数:24,代码来源:GuildBank.cs

示例9: FreeVariableNames

 public override ImmutableList<char> FreeVariableNames(ImmutableList<Symbol> boundVariables)
 {
     return _body.FreeVariableNames(boundVariables.Add(_variable));
 }
开发者ID:michaellperry,项目名称:ClipboardCalculator,代码行数:4,代码来源:Lambda.cs

示例10: RollbackUtxo

        //TODO with the rollback information that's now being stored, rollback could be down without needing the block
        public void RollbackUtxo(IChainStateCursor chainStateCursor, Chain chain, ChainedHeader chainedHeader, IEnumerable<BlockTx> blockTxes, ImmutableList<UnmintedTx>.Builder unmintedTxes)
        {
            //TODO don't reverse here, storage should be read in reverse
            foreach (var blockTx in blockTxes.Reverse())
            {
                var tx = blockTx.Decode().Transaction;
                var txIndex = blockTx.Index;

                // remove transaction's outputs from utxo, except for the genesis block and the duplicate coinbases
                var isDupeCoinbase = IsDupeCoinbase(chainedHeader, tx);
                if (chainedHeader.Height > 0 && !isDupeCoinbase)
                {
                    this.Unmint(chainStateCursor, tx, chainedHeader);

                    // decrease unspent output count
                    chainStateCursor.UnspentOutputCount -= tx.Outputs.Length;

                    // decrement unspent tx count
                    chainStateCursor.UnspentTxCount--;

                    chainStateCursor.TotalTxCount--;
                    chainStateCursor.TotalInputCount -= tx.Inputs.Length;
                    chainStateCursor.TotalOutputCount -= tx.Outputs.Length;
                }

                var prevTxOutputs = ImmutableArray.CreateBuilder<PrevTxOutput>(!tx.IsCoinbase ? tx.Inputs.Length : 0);

                if (!tx.IsCoinbase)
                {
                    // remove inputs in reverse order
                    for (var inputIndex = tx.Inputs.Length - 1; inputIndex >= 0; inputIndex--)
                    {
                        var input = tx.Inputs[inputIndex];
                        var prevTxOutput = this.Unspend(chainStateCursor, input, chainedHeader);

                        // store rollback replay information
                        prevTxOutputs.Add(prevTxOutput);
                    }
                }

                // reverse output keys to match original input order, as the inputs were read in reverse here
                prevTxOutputs.Reverse();

                // store rollback replay information
                unmintedTxes.Add(new UnmintedTx(tx.Hash, prevTxOutputs.MoveToImmutable()));
            }
        }
开发者ID:cole2295,项目名称:BitSharp,代码行数:48,代码来源:UtxoBuilder.cs


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