AddCell() public method

public AddCell ( Cell cell ) : void
cell Cell
return void
Exemplo n.º 1
0
        public override GrammarModel ApplyOverrides(GrammarModel grammar)
        {
            var sentence = new Sentence {key = key};

            var over = grammar as Sentence;
            if (over == null)
            {
                sentence.format = format;
                sentence.cells = cells.Select(c => c.ApplyOverrides(null)).ToArray();
                return sentence;
            }

            sentence.format = over.format.IsNotEmpty() ? over.format : format;
            sentence.cells = cells?.Select(c =>
            {
                var match = sentence.cells.FirstOrDefault(x => x.Key == c.Key);
                return c.ApplyOverrides(match);
            }).ToArray();

            var keys = sentence.cells.Select(x => x.Key).ToList();
            var missing = over.cells.Where(x => !keys.Contains(x.Key));
            missing.Each(c =>
            {
                sentence.AddCell(c.ApplyOverrides(null));
            });

            return sentence;
        }
Exemplo n.º 2
0
        public override GrammarModel ApplyOverrides(GrammarModel grammar)
        {
            var sentence = new Sentence();

            sentence.key = key;

            var over = grammar as Sentence;

            if (over == null)
            {
                sentence.format = format;
                sentence.cells  = cells.Select(c => c.ApplyOverrides(null)).ToArray();
                return(sentence);
            }

            sentence.format = over.format.IsNotEmpty() ? over.format : format;
            sentence.cells  = cells?.Select(c =>
            {
                var match = sentence.cells.FirstOrDefault(x => x.Key == c.Key);
                return(c.ApplyOverrides(match));
            }).ToArray();

            var keys    = sentence.cells.Select(x => x.Key).ToList();
            var missing = over.cells.Where(x => !keys.Contains(x.Key));

            missing.Each(c =>
            {
                sentence.AddCell(c.ApplyOverrides(null));
            });

            return(sentence);
        }