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


C# ReadOnlyList类代码示例

本文整理汇总了C#中ReadOnlyList的典型用法代码示例。如果您正苦于以下问题:C# ReadOnlyList类的具体用法?C# ReadOnlyList怎么用?C# ReadOnlyList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: Test

		public void Test()
		{
			List<string> strings = new List<string>(new string[] { "a", "b", "c" });
			ReadOnlyList<String> read = new ReadOnlyList<string>(strings);
			strings.Add("d");
			Assert.AreEqual(3, read.Count);
			Assert.IsTrue(read.Contains("a"));
			Assert.AreEqual(0, read.IndexOf("a"));
			Assert.IsTrue(read.Contains("b"));
			Assert.AreEqual(1, read.IndexOf("b"));
			Assert.IsTrue(read.Contains("c"));
			Assert.AreEqual(2, read.IndexOf("c"));
			Assert.IsFalse(read.Contains("d"));
			Assert.AreEqual(-1, read.IndexOf("d"));
			Assert.AreEqual("a,b,c", String.Join(",", read.ToArray()));
			Assert.AreEqual("a,b,c", String.Join(",", new List<String>(read).ToArray()));
			
			string[] arcopy = new string[3];
			read.CopyTo(arcopy, 0);
			Assert.AreEqual("a,b,c", String.Join(",", arcopy));

			System.Collections.IEnumerator en = ((System.Collections.IEnumerable)read).GetEnumerator();
			Assert.IsTrue(en.MoveNext());
			Assert.AreEqual("a", en.Current);
			Assert.IsTrue(en.MoveNext());
			Assert.AreEqual("b", en.Current);
			Assert.IsTrue(en.MoveNext());
			Assert.AreEqual("c", en.Current);
			Assert.IsFalse(en.MoveNext());
		}
开发者ID:hivie7510,项目名称:csharptest-net,代码行数:30,代码来源:TestReadOnlyList.cs

示例2: Production

 public Production(INonTerminal leftHandSide, params ISymbol[] rightHandSide)
 {
     Assert.IsNotNull(leftHandSide, "leftHandSide");
     Assert.IsNotNull(rightHandSide, "rightHandSide");
     LeftHandSide = leftHandSide;
     _rightHandSide = new ReadOnlyList<ISymbol>(new List<ISymbol>(rightHandSide));
 }
开发者ID:whitten,项目名称:Pliant,代码行数:7,代码来源:Production.cs

示例3: GetCommands

		ReadOnlyList<Command> GetCommands(String filepath)
		{
			if (filepath == null) throw new ArgumentNullException("filepath");

			if (m_commandcache.ContainsKey(filepath) == true) return m_commandcache[filepath];

			List<Command> commands = new List<Command>();

			TextFile textfile = GetSubSystem<IO.FileSystem>().OpenTextFile(filepath);
			foreach (TextSection textsection in textfile)
			{
				if (String.Equals("Command", textsection.Title, StringComparison.OrdinalIgnoreCase) == true)
				{
					String name = textsection.GetAttribute<String>("name");
					String text = textsection.GetAttribute<String>("command");
					Int32 time = textsection.GetAttribute<Int32>("time", 15);
					Int32 buffertime = textsection.GetAttribute<Int32>("Buffer.time", 1);

					commands.Add(BuildCommand(name, text, time, buffertime));
				}
			}

			if (m_internalcommands != null)
			{
				commands.AddRange(m_internalcommands);
			}

			ReadOnlyList<Command> list = new ReadOnlyList<Command>(commands);
			m_commandcache.Add(filepath, list);

			return list;
		}
开发者ID:lodossDev,项目名称:xnamugen,代码行数:32,代码来源:CommandSystem.cs

示例4: HitAttribute

		public HitAttribute(AttackStateType height, ReadOnlyList<HitType> attackdata)
		{
			if (attackdata == null) throw new ArgumentNullException("attackdata");

			m_attackheight = height;
			m_attackdata = attackdata;
		}
开发者ID:lodossDev,项目名称:xnamugen,代码行数:7,代码来源:HitAttribute.cs

示例5: MissionObjectives

		public MissionObjectives(World world, MissionObjectivesInfo moInfo)
		{
			info = moInfo;
			Objectives = new ReadOnlyList<MissionObjective>(objectives);

			world.ObserveAfterWinOrLose = !info.EarlyGameOver;
		}
开发者ID:zombie-einstein,项目名称:OpenRA,代码行数:7,代码来源:MissionObjectives.cs

示例6: TaskAreaCommandGroupViewModel

 public TaskAreaCommandGroupViewModel(string displayName, params TaskAreaCommandViewModel[] commands)
     : base(displayName)
 {
     _commands = new ReadOnlyList<TaskAreaCommandViewModel>(commands);
     if (_commands.Count > 0)
         _selectedCommand = _commands[0];
 }
开发者ID:rmunn,项目名称:cog,代码行数:7,代码来源:TaskAreaCommandGroupViewModel.cs

示例7: DefaultLayer

        /// <summary>
        /// Public constructor.
        /// </summary>
        /// <param name="depth">The depth.</param>
        /// <param name="matcher">The matcher.</param>
        public DefaultLayer(float depth, Func<IRenderable, bool> matcher)
        {
            Depth = depth;
            Matcher = matcher;

            _readOnlyRenderableList = new ReadOnlyList<IRenderable>(_renderableList);
        }
开发者ID:jwvdiermen,项目名称:LD28,代码行数:12,代码来源:DefaultLayer.cs

示例8: HGeneratorIterable

 public HGeneratorIterable(IEnvironment environment, ReadOnlyList<GeneratorStep> steps, ReadOnlyList<string> variableDeclarations, ILexicalEnvironment scope)
     : base(environment)
 {
     Steps = steps;
     VariableDeclarations = variableDeclarations;
     Scope = scope;
 }
开发者ID:ChaosPandion,项目名称:Machete,代码行数:7,代码来源:HGeneratorIterable.cs

示例9: VisitSelect

        protected override Expression VisitSelect(SqlSelectExpression selectExpression)
        {
            if (selectExpression.Skip != null)
            {
                var rowNumber = new SqlFunctionCallExpression(typeof(int), "ROW_NUMBER");
                var over = new SqlOverExpression(rowNumber, selectExpression.OrderBy ?? new ReadOnlyList<Expression>(new [] { new SqlOrderByExpression(OrderType.Ascending, selectExpression.Columns[0].Expression) }));
                var additionalColumn = new SqlColumnDeclaration(RowColumnName, over);

                var newAlias = selectExpression.Alias + "INNER";
                var innerColumns = new ReadOnlyList<SqlColumnDeclaration>(selectExpression.Columns.Select(c => c).Concat(new[] { additionalColumn }));

                var innerSelect = new SqlSelectExpression(selectExpression.Type, newAlias, innerColumns, selectExpression.From, selectExpression.Where, null, selectExpression.GroupBy, selectExpression.Distinct, null, null, selectExpression.ForUpdate);

                var outerColumns = selectExpression.Columns.Select(c => new SqlColumnDeclaration(c.Name, new SqlColumnExpression(c.Expression.Type, newAlias, c.Name)));

                Expression rowPredicate = Expression.GreaterThan(new SqlColumnExpression(typeof(int), newAlias, additionalColumn.Name), selectExpression.Skip);

                if (selectExpression.Take != null && !(selectExpression.Take is SqlTakeAllValueExpression))
                {
                    rowPredicate = Expression.And
                    (
                        rowPredicate,
                        Expression.LessThanOrEqual(new SqlColumnExpression(typeof(int), newAlias, additionalColumn.Name), Expression.Add(selectExpression.Skip, selectExpression.Take))
                    );
                }

                return new SqlSelectExpression(selectExpression.Type, selectExpression.Alias, outerColumns, innerSelect, rowPredicate, null, selectExpression.ForUpdate);
            }

            return base.VisitSelect(selectExpression);
        }
开发者ID:smadep,项目名称:Shaolinq,代码行数:31,代码来源:SqlServerLimitAmmender.cs

示例10: EditRegionViewModel

 public EditRegionViewModel(IEnumerable<Variety> varieties, Variety variety, GeographicRegion region)
 {
     _title = "Edit Region";
     _varieties = new ReadOnlyList<VarietyViewModel>(varieties.Select(v => new VarietyViewModel(v)).OrderBy(vm => vm.Name).ToArray());
     _selectedVariety = _varieties.First(vm => vm.DomainVariety == variety);
     _description = region.Description;
 }
开发者ID:rmunn,项目名称:cog,代码行数:7,代码来源:EditRegionViewModel.cs

示例11: MultipleWordAlignerResult

 public MultipleWordAlignerResult(IWordAligner wordAligner, IPairwiseAlignmentScorer<Word, ShapeNode> scorer, IEnumerable<Word> words)
     : base(wordAligner)
 {
     _words = new ReadOnlyList<Word>(words.ToArray());
     _algorithm = new MultipleAlignmentAlgorithm<Word, ShapeNode>(scorer, _words, GetNodes);
     _algorithm.Compute();
 }
开发者ID:rmunn,项目名称:cog,代码行数:7,代码来源:MultipleWordAlignerResult.cs

示例12: TestContains

    public void TestContains() {
      int[] integers = new int[] { 1234, 6789 };
      ReadOnlyList<int> testList = new ReadOnlyList<int>(integers);

      Assert.IsTrue(testList.Contains(1234));
      Assert.IsFalse(testList.Contains(4321));
    }
开发者ID:pr0gramm3r1,项目名称:AngryTanks,代码行数:7,代码来源:ReadOnlyList.Test.cs

示例13: HGeneratorIterator

 public HGeneratorIterator(IEnvironment environment, Generator generator, ReadOnlyList<string> variableDeclarations, ILexicalEnvironment scope)
     : base(environment)
 {
     Generator = generator;
     VariableDeclarations = variableDeclarations;
     Scope = scope;
 }
开发者ID:ChaosPandion,项目名称:Machete,代码行数:7,代码来源:HGeneratorIterator.cs

示例14: TextTable

        public TextTable()
        {
            columns = new List<TextTableColumn>();
            rows = new List<TextTableRowBase>();

            Columns = new ReadOnlyList<TextTableColumn>(columns);
            Rows = new ReadOnlyList<TextTableRowBase>(rows);
        }
开发者ID:cdhowie,项目名称:Cdh.Toolkit,代码行数:8,代码来源:TextTable.cs

示例15: ComponentOptionsViewModel

 protected ComponentOptionsViewModel(string displayName, string optionDisplayName, params ComponentSettingsViewModelBase[] options)
     : base(displayName)
 {
     _optionDisplayName = optionDisplayName;
     _options = new ReadOnlyList<ComponentSettingsViewModelBase>(options);
     foreach (ComponentSettingsViewModelBase option in _options)
         option.PropertyChanged += ChildPropertyChanged;
 }
开发者ID:rmunn,项目名称:cog,代码行数:8,代码来源:ComponentOptionsViewModel.cs


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