Exemplo n.º 1
0
		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());
		}
Exemplo n.º 2
0
 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));
 }
Exemplo n.º 3
0
		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;
		}
Exemplo n.º 4
0
		public HitAttribute(AttackStateType height, ReadOnlyList<HitType> attackdata)
		{
			if (attackdata == null) throw new ArgumentNullException("attackdata");

			m_attackheight = height;
			m_attackdata = attackdata;
		}
Exemplo n.º 5
0
		public MissionObjectives(World world, MissionObjectivesInfo moInfo)
		{
			info = moInfo;
			Objectives = new ReadOnlyList<MissionObjective>(objectives);

			world.ObserveAfterWinOrLose = !info.EarlyGameOver;
		}
Exemplo n.º 6
0
 public TaskAreaCommandGroupViewModel(string displayName, params TaskAreaCommandViewModel[] commands)
     : base(displayName)
 {
     _commands = new ReadOnlyList<TaskAreaCommandViewModel>(commands);
     if (_commands.Count > 0)
         _selectedCommand = _commands[0];
 }
Exemplo n.º 7
0
        /// <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);
        }
Exemplo n.º 8
0
 public HGeneratorIterable(IEnvironment environment, ReadOnlyList<GeneratorStep> steps, ReadOnlyList<string> variableDeclarations, ILexicalEnvironment scope)
     : base(environment)
 {
     Steps = steps;
     VariableDeclarations = variableDeclarations;
     Scope = scope;
 }
Exemplo n.º 9
0
        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);
        }
Exemplo n.º 10
0
 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;
 }
Exemplo n.º 11
0
 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();
 }
Exemplo n.º 12
0
    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));
    }
Exemplo n.º 13
0
 public HGeneratorIterator(IEnvironment environment, Generator generator, ReadOnlyList<string> variableDeclarations, ILexicalEnvironment scope)
     : base(environment)
 {
     Generator = generator;
     VariableDeclarations = variableDeclarations;
     Scope = scope;
 }
Exemplo n.º 14
0
        public TextTable()
        {
            columns = new List<TextTableColumn>();
            rows = new List<TextTableRowBase>();

            Columns = new ReadOnlyList<TextTableColumn>(columns);
            Rows = new ReadOnlyList<TextTableRowBase>(rows);
        }
Exemplo n.º 15
0
 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;
 }
Exemplo n.º 16
0
        /// <summary>
        /// Public constructor.
        /// </summary>
        /// <param name="renderableTypes">The renderable types.</param>
        /// <param name="startsWithName">If not null, only collect renderables with a name that start with the given value.</param>
        /// <param name="depth">The depth.</param>
        public DefaultLayer(Type[] renderableTypes, string startsWithName, float depth)
        {
            this.RenderableTypes = renderableTypes;
            this.StartsWithName = startsWithName;
            this.Depth = depth;

            m_readOnlyRenderableList = new ReadOnlyList<IRenderable>(m_renderableList);
        }
Exemplo n.º 17
0
        /// <summary>
        /// Public constructor.
        /// </summary>
        /// <param name="depth">The depth.</param>
        public DefaultLayer(float depth)
        {
            this.RenderableTypes = new Type[0];
            this.StartsWithName = null;
            this.Depth = depth;

            m_readOnlyRenderableList = new ReadOnlyList<IRenderable>(m_renderableList);
        }
Exemplo n.º 18
0
		public EvaluationResult Evaluate(EvaluationState state, ReadOnlyList<IEvaluate> args, ReadOnlyList<Object> data)
		{
			Combat.Character character = state.Character as Combat.Character;
			if (character == null) return new EvaluationResult();

			EvaluationResult result = args[1].Evaluate(state);
			if (result.ResultType == ResultType.None) return new EvaluationResult();

			FuncCaller varcaller = args[0] as FuncCaller;
			if (varcaller == null) return new EvaluationResult();

			if (varcaller.Function is Triggers.Var)
			{
				EvaluationResult varindex = varcaller.Args[0].Evaluate(state);
				if (varindex.ResultType == ResultType.None) return new EvaluationResult();

				if (character.Variables.SetInterger(varindex.IntValue, false, result.IntValue) == false)
				{
					return new EvaluationResult();
				}
			}
			else if (varcaller.Function is Triggers.FVar)
			{
				EvaluationResult varindex = varcaller.Args[0].Evaluate(state);
				if (varindex.ResultType == ResultType.None) return new EvaluationResult();

				if (character.Variables.SetFloat(varindex.IntValue, false, result.FloatValue) == false)
				{
					return new EvaluationResult();
				}
			}
			else if (varcaller.Function is Triggers.SysVar)
			{
				EvaluationResult varindex = varcaller.Args[0].Evaluate(state);
				if (varindex.ResultType == ResultType.None) return new EvaluationResult();

				if (character.Variables.SetInterger(varindex.IntValue, true, result.IntValue) == false)
				{
					return new EvaluationResult();
				}
			}
			else if (varcaller.Function is Triggers.SysFVar)
			{
				EvaluationResult varindex = varcaller.Args[0].Evaluate(state);
				if (varindex.ResultType == ResultType.None) return new EvaluationResult();

				if (character.Variables.SetFloat(varindex.IntValue, true, result.FloatValue) == false)
				{
					return new EvaluationResult();
				}
			}
			else
			{
				return new EvaluationResult();
			}

			return result;
		}
Exemplo n.º 19
0
    public void TestCopyToArray() {
      int[] inputIntegers = new int[] { 12, 34, 56, 78 };
      ReadOnlyList<int> testList = new ReadOnlyList<int>(inputIntegers);

      int[] outputIntegers = new int[testList.Count];
      testList.CopyTo(outputIntegers, 0);

      CollectionAssert.AreEqual(inputIntegers, outputIntegers);
    }
Exemplo n.º 20
0
 public OrderManager(string host, int port, string password, IConnection conn)
 {
     Host = host;
     Port = port;
     Password = password;
     Connection = conn;
     syncReport = new SyncReport(this);
     ChatCache = new ReadOnlyList<ChatLine>(chatCache);
     AddChatLine += CacheChatLine;
 }
Exemplo n.º 21
0
 public BFunction(IEnvironment environment, Code code, ReadOnlyList<string> formalParameters)
     : base(environment)
 {
     _code = code;
     _formalParameters = formalParameters;
     Class = "Function";
     Extensible = true;
     Prototype = Environment.FunctionPrototype;
     DefineOwnProperty("length", Environment.CreateDataDescriptor(Environment.CreateNumber(_formalParameters.Count), false, false, false), false);
 }
Exemplo n.º 22
0
        public SelectVarietiesViewModel(IEnumerable<Variety> varieties, ISet<Variety> selectedVarieties)
        {
            _varieties = new ReadOnlyList<SelectableVarietyViewModel>(varieties.Select(v => new SelectableVarietyViewModel(v) {IsSelected = selectedVarieties.Contains(v)}).ToArray());
            _selectAll = selectedVarieties.Count > 0;
            _monitor = new SimpleMonitor();
            if (selectedVarieties.Count > 0 && selectedVarieties.Count < _varieties.Count)
                _selectAll = null;

            foreach (SelectableVarietyViewModel variety in _varieties)
                variety.PropertyChanged += Varieties_PropertyChanged;
        }
Exemplo n.º 23
0
 public SimilarityMatrixVarietyViewModel(SimilarityMetric similarityMetric, IEnumerable<Variety> varieties, Variety variety)
     : base(variety)
 {
     var varietyPairs = new List<SimilarityMatrixVarietyPairViewModel>();
     foreach (Variety v in varieties)
     {
         VarietyPair vp;
         varietyPairs.Add(variety.VarietyPairs.TryGetValue(v, out vp) ? new SimilarityMatrixVarietyPairViewModel(similarityMetric, variety, vp) : new SimilarityMatrixVarietyPairViewModel(variety, v));
     }
     _varietyPairs = new ReadOnlyList<SimilarityMatrixVarietyPairViewModel>(varietyPairs);
 }
 public MultipleWordAlignmentWordViewModel(MultipleWordAlignmentViewModel parent, Word word, AlignmentCell<ShapeNode> prefix, IEnumerable<AlignmentCell<ShapeNode>> columns, AlignmentCell<ShapeNode> suffix, int cognateSetIndex)
 {
     _word = word;
     ReadOnlyCollection<Word> words = word.Variety.Words[word.Meaning];
     _variety = new MultipleWordAlignmentVarietyViewModel(word.Variety, words.Count == 1 ? 0 : IndexOf(words, word));
     _prefix = prefix.StrRep();
     _columns = new ReadOnlyList<string>(columns.Select(cell => cell.IsNull ? "-" : cell.StrRep()).ToArray());
     _suffix = suffix.StrRep();
     _cognateSetIndex = cognateSetIndex;
     _parent = parent;
 }
Exemplo n.º 25
0
 public ExecutableCode(
     Code code, 
     ReadOnlyList<string> variableDeclarations,
     ReadOnlyList<FunctionDeclaration> functionDeclarations,
     bool strict)
 {
     Code = code;
     VariableDeclarations = variableDeclarations;
     FunctionDeclarations = functionDeclarations;
     Strict = strict;
 }
Exemplo n.º 26
0
 public PairwiseWordAlignerResult(IWordAligner wordAligner, IPairwiseAlignmentScorer<Word, ShapeNode> scorer, WordPairAlignerSettings settings, Word word1, Word word2)
     : base(wordAligner)
 {
     _words = new ReadOnlyList<Word>(new [] {word1, word2});
     _algorithm = new PairwiseAlignmentAlgorithm<Word, ShapeNode>(scorer, word1, word2, GetNodes)
         {
             ExpansionCompressionEnabled = settings.ExpansionCompressionEnabled,
             Mode = settings.Mode
         };
     _algorithm.Compute();
 }
Exemplo n.º 27
0
 public Grammar(INonTerminal start, IProduction[] productions, ILexerRule[] lexerRules, ILexerRule[] ignore)
 {
     Assert.IsNotNullOrEmpty(productions, "productions");
     Assert.IsNotNull(start, "start");
     _productionIndex = CreateProductionIndex(productions);
     _lexerRuleIndex = CreateLexerRuleIndex(lexerRules);
     Productions = new ReadOnlyList<IProduction>(productions ?? EmptyProductionArray);
     LexerRules = new ReadOnlyList<ILexerRule>(lexerRules ?? EmptyLexerRuleArray);
     Ignores = new ReadOnlyList<ILexerRule>(ignore ?? EmptyLexerRuleArray);
     Start = start;
 }
Exemplo n.º 28
0
		public EvaluationResult Evaluate(EvaluationState state, ReadOnlyList<IEvaluate> args, ReadOnlyList<Object> data)
		{
			EvaluationResult checkagainst = args[0].Evaluate(state);
			EvaluationResult first = args[1].Evaluate(state);
			EvaluationResult second = args[2].Evaluate(state);

			Operator compare = (Operator)data[0];
			Symbol pre_op = (Symbol)data[1];
			Symbol post_op = (Symbol)data[2];

			return BaseOperations.Range(checkagainst, first, second, compare, pre_op, post_op);
		}
Exemplo n.º 29
0
        public void TestModifyMaster()
        {
            List<string> strings = new List<string>(new string[] { "a", "b", "c" });
            ReadOnlyList<String> read = new ReadOnlyList<string>(strings, false);

            Assert.AreEqual(3, read.Count);
            strings.RemoveAt(2);
            Assert.AreEqual(2, read.Count);
            Assert.AreEqual("a", read[0]);
            Assert.AreEqual("b", read[1]);

            Assert.AreEqual("a,b", String.Join(",", read.Clone().ToArray()));
        }
Exemplo n.º 30
0
        internal QiMethodInfo(QiValue mInfo)
        {
            UID = mInfo[0].ToInt64();
            ReturnValueSignature = mInfo[1].ToString();
            Name = mInfo[2].ToString();
            ArgumentSignature = mInfo[3].ToString();
            Description = mInfo[4].ToString();

            ArgumentsInfo = new ReadOnlyList<QiMethodArgumentInfo>(
                Enumerable.Range(0, mInfo[5].Count)
                .Select(i => new QiMethodArgumentInfo(mInfo[5][i]))
                .ToList());

            ReturnValueDescription = mInfo[6].ToString();
        }