Exemplo n.º 1
0
        public override void VisitScalar <T> (string name, Column <T> column, int row)
        {
            int tlrow = column.Index[row];

            if (_source.Axis.Symbol != null)
            {
                if (_indicator[tlrow])
                {
                    _target.WriteCell(name, _source.SymbolAt(tlrow), column.Data[row], -1, true, true);
                }
            }
            else
            {
                if (_indicator[tlrow])
                {
                    _target.WriteCell(name, null, column.Data[row], -1, true, true);
                }
            }
        }
Exemplo n.º 2
0
 protected void DoChart <T> (RCCube result,
                             RCSymbolScalar name,
                             long row,
                             long col,
                             RCVector <T> right)
 {
     for (int i = 0; i < right.Count; ++i)
     {
         string         val = right[i].ToString();
         RCSymbolScalar s   = RCSymbolScalar.From(row, (long)col + i, 0L);
         RCSymbolScalar k   = new RCSymbolScalar(name, (long)i);
         result.WriteCell("r", s, row);
         result.WriteCell("c", s, (long)col + i);
         result.WriteCell("l", s, 0L);
         result.WriteCell("k", s, k);
         result.WriteCell("v", s, val);
         result.Write(s);
     }
 }
Exemplo n.º 3
0
        public void EvalDiff(RCRunner runner, RCClosure closure, RCString left, RCString right)
        {
            diff_match_patch dmp    = new diff_match_patch();
            List <Diff>      diffs  = dmp.diff_main(left[0], right[0], true);
            List <Patch>     patch  = dmp.patch_make(diffs);
            RCCube           result = new RCCube(new RCArray <string> ());

            for (int i = 0; i < patch.Count; ++i)
            {
                for (int j = 0; j < patch[i].diffs.Count; ++j)
                {
                    string operation = patch[i].diffs[j].operation.ToString();
                    string text      = patch[i].diffs[j].text;
                    result.WriteCell("op", null, operation);
                    result.WriteCell("text", null, text);
                    result.Axis.Write(null);
                }
            }
            runner.Yield(closure, result);
        }
Exemplo n.º 4
0
        public void Operators(RCRunner runner, RCClosure closure, RCBlock right)
        {
            RCCube result = new RCCube("S");

            result.ReserveColumn("module");
            result.ReserveColumn("name");
            result.ReserveColumn("method");
            result.ReserveColumn("left");
            result.ReserveColumn("right");
            foreach (KeyValuePair <RCActivator.OverloadKey,
                                   RCActivator.OverloadValue> kv in Activator._dispatch)
            {
                RCSymbolScalar sym;
                if (kv.Key.Left == null)
                {
                    sym = RCSymbolScalar.From("operator",
                                              kv.Value.Module.Name,
                                              kv.Key.Name,
                                              RCValue.TypeNameForType(kv.Key.Right));
                }
                else
                {
                    sym = RCSymbolScalar.From("operator",
                                              kv.Value.Module.Name,
                                              kv.Key.Name,
                                              RCValue.TypeNameForType(kv.Key.Left),
                                              RCValue.TypeNameForType(kv.Key.Right));
                }
                result.WriteCell("name", sym, kv.Key.Name);
                result.WriteCell("module", sym, kv.Value.Module.Name);
                result.WriteCell("method", sym, kv.Value.Implementation.Name);
                if (kv.Key.Left != null)
                {
                    result.WriteCell("left", sym, RCValue.TypeNameForType(kv.Key.Left));
                }
                result.WriteCell("right", sym, RCValue.TypeNameForType(kv.Key.Right));
                result.Axis.Write(sym);
            }
            runner.Yield(closure, result);
        }
Exemplo n.º 5
0
        public static void ListExec(RCRunner runner, RCClosure closure)
        {
            RCArray <Exec> modules = new RCArray <Exec> ();
            RCArray <long> keys    = new RCArray <long> ();

            lock (runner._botLock)
            {
                foreach (KeyValuePair <long, RCBot> kv in runner._bots)
                {
                    keys.Write(kv.Key);
                    modules.Write((Exec)runner._bots[kv.Key].GetModule(typeof(Exec)));
                }
            }
            RCCube result = new RCCube("S");

            for (int i = 0; i < modules.Count; ++i)
            {
                lock (modules[i]._lock)
                {
                    foreach (KeyValuePair <long, Exec.ChildProcess> kv in modules[i]._process)
                    {
                        RCSymbolScalar sym = RCSymbolScalar.From("exec", keys[i], kv.Key);
                        result.WriteCell("bot", sym, keys[i]);
                        result.WriteCell("handle", sym, (long)kv.Key);
                        result.WriteCell("pid", sym, (long)kv.Value._pid);
                        result.WriteCell("program", sym, kv.Value._program);
                        result.WriteCell("arguments", sym, kv.Value._arguments);
                        result.WriteCell("exit", sym, kv.Value._exitCode);
                        result.Write(sym);
                    }
                }
            }
            runner.Yield(closure, result);
        }
Exemplo n.º 6
0
        public static void ListVars(RCRunner runner, RCClosure closure)
        {
            RCArray <Variable> modules = new RCArray <Variable> ();
            RCArray <long>     keys    = new RCArray <long> ();

            lock (runner._botLock)
            {
                foreach (KeyValuePair <long, RCBot> kv in runner._bots)
                {
                    keys.Write(kv.Key);
                    modules.Write((Variable)runner._bots[kv.Key].GetModule(typeof(Variable)));
                }
            }
            RCCube result = new RCCube("S");

            for (int i = 0; i < modules.Count; ++i)
            {
                lock (modules[i]._lock)
                {
                    foreach (KeyValuePair <object, Dictionary <RCSymbolScalar,
                                                               RCValue> > section in modules[i]._sections)
                    {
                        RCSymbolScalar botsym = RCSymbolScalar.From("var", keys[i]);
                        foreach (KeyValuePair <RCSymbolScalar, RCValue> kv in section.Value)
                        {
                            RCSymbolScalar varsym = RCSymbolScalar.From(botsym, kv.Key);
                            result.WriteCell("bot", varsym, keys[i]);
                            result.WriteCell("section", varsym, section.Key);
                            result.WriteCell("name", varsym, kv.Key);
                            result.WriteCell("value", varsym, kv.Value.ToString());
                            result.Write(varsym);
                        }
                    }
                }
            }
            runner.Yield(closure, result);
        }
Exemplo n.º 7
0
        public override void Cubify(RCCube target, Stack <object> names)
        {
            object[] array = names.ToArray();
            System.Array.Reverse(array);
            RCSymbolScalar symbol = RCSymbolScalar.From(array);

            for (int i = 0; i < Count; ++i)
            {
                T val = this[i];
                RCSymbolScalar symboli = new RCSymbolScalar(symbol, (long)i);
                // Do not try to evaluate incrs during cubification
                target.WriteCell(this.TypeCode.ToString(), symboli, val, -1, true, false);
                target.Write(symboli);
            }
        }
Exemplo n.º 8
0
        public override void Cubify(RCCube target, Stack <object> names)
        {
            if (this.Left != null)
            {
                names.Push("L");
                this.Left.Cubify(target, names);
                names.Pop();
            }
            names.Push("R");
            this.Right.Cubify(target, names);
            names.Pop();
            object[] array = names.ToArray();
            System.Array.Reverse(array);
            RCSymbolScalar symbol = RCSymbolScalar.From(array);

            target.WriteCell("o", symbol, Name);
            target.Write(symbol);
        }
Exemplo n.º 9
0
        public override void VisitScalar <T> (string name, Column <T> column, int i)
        {
            // Can I turn this into WriteCell<T> and get rid of the boxing?
            bool           delete;
            RCSymbolScalar result = _target.WriteCell(name,
                                                      _source.Axis.SymbolAt(column.Index[i]),
                                                      column.Data[i],
                                                      -1,
                                                      _keepIncrs,
                                                      _force,
                                                      out delete);

            _delete = _delete || delete;
            if (result != null || _target.Axis.ColCount == 0)
            {
                _result.Add(result);
                _writeAxis = true;
            }
        }
Exemplo n.º 10
0
 protected void WriteTree(RCCube result, TreeNode node)
 {
     result.WriteCell("x", node.s, node.x);
     result.WriteCell("y", node.s, node.y);
     result.WriteCell("k", node.s, node.k);
     result.WriteCell("v", node.s, node.v);
     result.WriteCell("m", node.s, node.m);
     result.WriteCell("n", node.s, node.n);
     result.WriteCell("g", node.s, node.g);
     result.Axis.Write(node.s);
     if (node.children != null)
     {
         for (int i = 0; i < node.children.Count; ++i)
         {
             TreeNode child = node.children[i];
             WriteTree(result, child);
         }
     }
 }
Exemplo n.º 11
0
        public void Timezones(RCRunner runner, RCClosure closure, RCBlock right)
        {
            RCCube   result = new RCCube("S");
            DateTime now    = DateTime.UtcNow;
            ReadOnlyCollection <TimeZoneInfo> timezones = TimeZoneInfo.GetSystemTimeZones();

            foreach (TimeZoneInfo timezone in timezones)
            {
                RCSymbolScalar sym = RCSymbolScalar.From("timezones", timezone.Id);
                result.WriteCell("displayName", sym, timezone.DisplayName);
                result.WriteCell("standardName", sym, timezone.StandardName);
                result.WriteCell("daylightName", sym, timezone.DaylightName);
                result.WriteCell("utcOffset", sym, new RCTimeScalar(timezone.GetUtcOffset(now)));
                result.WriteCell("isDaylightSavingTime", sym, timezone.IsDaylightSavingTime(now));
                result.WriteCell("supportsDaylightSavingTime", sym, timezone.SupportsDaylightSavingTime);
                result.Axis.Write(sym);
            }
            runner.Yield(closure, result);
        }
Exemplo n.º 12
0
        protected void AppendEntry()
        {
            if (_time != null)
            {
                _result.WriteCell("time", null, _time.ParseTime(_lexer));
            }
            if (_bot != null)
            {
                _result.WriteCell("bot", null, _bot.ParseLong(_lexer));
            }
            else
            {
                _result.WriteCell("bot", null, (long)-1);
            }
            if (_fiber != null)
            {
                _result.WriteCell("fiber", null, _fiber.ParseLong(_lexer));
            }
            else
            {
                _result.WriteCell("fiber", null, (long)-1);
            }
            if (_module != null)
            {
                _result.WriteCell("module", null, _module.Text);
            }
            else
            {
                _result.WriteCell("module", null, "");
            }
            if (_instance != null)
            {
                _result.WriteCell("instance", null, _instance.ParseLong(_lexer));
            }
            else
            {
                _result.WriteCell("instance", null, (long)-1);
            }
            if (_event != null)
            {
                _result.WriteCell("event", null, _event.Text);
            }
            else
            {
                _result.WriteCell("event", null, "");
            }
            if (_message != null)
            {
                _result.WriteCell("message", null, _message);
            }
            if (_document != null)
            {
                _result.WriteCell("document", null, _document);
            }
            _result.Axis.Write();

            // Reset everything for the next log entry.
            _time     = null;
            _bot      = null;
            _fiber    = null;
            _module   = null;
            _instance = null;
            _event    = null;
            _message  = null;
            _document = null;
        }
Exemplo n.º 13
0
        protected void DoChart(RCCube result,
                               RCSymbolScalar parent,
                               ref long row,
                               long col,
                               RCBlock
                               right)
        {
            for (int i = 0; i < right.Count; ++i)
            {
                RCBlock current   = right.GetName(i);
                object  shortName = current.Name;
                if (shortName.Equals(""))
                {
                    shortName = (long)i;
                }
                RCSymbolScalar name = new RCSymbolScalar(parent, shortName);
                RCSymbolScalar cell = RCSymbolScalar.From(row, col, 0L);
                result.WriteCell("r", cell, row);
                result.WriteCell("c", cell, col);
                result.WriteCell("l", cell, 0L);
                result.WriteCell("k", cell, name);
                result.WriteCell("v", cell, shortName is long?shortName.ToString() : shortName);
                result.Axis.Write(cell);
                RCVectorBase vector = current.Value as RCVectorBase;
                if (vector != null)
                {
                    ++col;
                    switch (vector.TypeCode)
                    {
                    case 'l': DoChart <long> (result, name, row, col, (RCVector <long>)vector); break;

                    case 'd': DoChart <double> (result, name, row, col, (RCVector <double>)vector); break;

                    case 'm': DoChart <decimal> (result, name, row, col, (RCVector <decimal>)vector); break;

                    case 's': DoChart <string> (result, name, row, col, (RCVector <string>)vector); break;

                    case 'x': DoChart <byte> (result, name, row, col, (RCVector <byte>)vector); break;

                    case 'y': DoChart <RCSymbolScalar> (result,
                                                        name,
                                                        row,
                                                        col,
                                                        (RCVector <RCSymbolScalar>)vector); break;

                    case 'b': DoChart <bool> (result, name, row, col, (RCVector <bool>)vector); break;

                    default: throw new Exception("Unknown typecode: " + vector.TypeCode);
                    }
                    --col;
                    ++row;
                    continue;
                }
                RCBlock block = current.Value as RCBlock;
                if (block != null)
                {
                    ++col;
                    ++row;
                    DoChart(result, name, ref row, col, block);
                    --col;
                    continue;
                }
                RCOperator oper = current.Value as RCOperator;
                if (oper != null)
                {
                    ++col;
                    string val = oper.ToString();
                    cell = RCSymbolScalar.From(row, col, 0L);
                    result.WriteCell("r", cell, (long)row);
                    result.WriteCell("c", cell, (long)col);
                    result.WriteCell("l", cell, 0L);
                    result.WriteCell("k", cell, new RCSymbolScalar(name, 0L));
                    result.WriteCell("v", cell, val);
                    result.Write(cell);
                    ++row;
                    --col;
                    continue;
                }
                RCReference reference = current.Value as RCReference;
                if (reference != null)
                {
                    ++col;
                    string val = reference.ToString();
                    cell = RCSymbolScalar.From(row, col, 0L);
                    result.WriteCell("r", cell, (long)row);
                    result.WriteCell("c", cell, (long)col);
                    result.WriteCell("l", cell, 0L);
                    result.WriteCell("k", cell, new RCSymbolScalar(name, 0L));
                    result.WriteCell("v", cell, val);
                    result.Write(cell);
                    ++row;
                    --col;
                    continue;
                }
                RCCube cube = current.Value as RCCube;
                if (cube != null)
                {
                    ++col;
                    ++row;
                    DoChart(result, name, ref row, col, cube);
                    ++row;
                    --col;
                    continue;
                }
            }
        }
Exemplo n.º 14
0
        protected RCCube Compare(string left, string right, bool breakLines)
        {
            diff_match_patch dmp    = new diff_match_patch();
            List <Diff>      diffs  = dmp.diff_main(left, right, true);
            List <Patch>     patch  = dmp.patch_make(diffs);
            RCCube           result = new RCCube(new RCArray <string> ());
            int start = 0;
            int end   = 0;

            for (int i = 0; i < patch.Count; ++i)
            {
                // int hunkStart = start;
                for (int j = 0; j < patch[i].diffs.Count; ++j)
                {
                    Operation op   = patch[i].diffs[j].operation;
                    string    text = patch[i].diffs[j].text;
                    if (op == Operation.EQUAL)
                    {
                        end = left.IndexOf(text, start);
                        if (end < 0)
                        {
                            throw new Exception(
                                      "cannot find string \"" + text + "\" after position " + start + " in \"" +
                                      left + "\"");
                        }
                        end += text.Length;
                        string section = left.Substring(start, (end - start));
                        start = end; // + text.Length;
                        string[] lines = section.Split('\n');
                        if (breakLines && lines.Length > 1)
                        {
                            for (int k = 0; k < lines.Length; ++k)
                            {
                                if (!(k == lines.Length - 1 && lines[k] == ""))
                                {
                                    result.WriteCell("op", null, op.ToString());
                                    result.WriteCell("old", null, lines[k] + "\n");
                                    result.WriteCell("new", null, lines[k] + "\n");
                                    result.Axis.Write(null);
                                }
                            }
                        }
                        else
                        {
                            result.WriteCell("op", null, op.ToString());
                            result.WriteCell("old", null, section);
                            result.WriteCell("new", null, section);
                            result.Axis.Write(null);
                        }
                    }
                    else if (op == Operation.INSERT)
                    {
                        // start = Math.Max (0, start - text.Length);
                        // end = start;
                        // end = start;
                        if (breakLines)
                        {
                            string[] lines = text.Split('\n');
                            if (lines.Length > 1)
                            {
                                for (int k = 0; k < lines.Length; ++k)
                                {
                                    if (!(k == lines.Length - 1 && lines[k] == ""))
                                    {
                                        result.WriteCell("op", null, op.ToString());
                                        result.WriteCell("new", null, lines[k] + "\n");
                                        result.Axis.Write(null);
                                    }
                                }
                            }
                            else
                            {
                                result.WriteCell("op", null, op.ToString());
                                result.WriteCell("new", null, text);
                                result.Axis.Write(null);
                            }
                        }
                        else
                        {
                            result.WriteCell("op", null, op.ToString());
                            result.WriteCell("new", null, text);
                            result.Axis.Write(null);
                        }
                    }
                    else // DELETE
                    {
                        end  += patch[i].diffs[j].text.Length;
                        start = end;
                        if (breakLines)
                        {
                            string[] lines = text.Split('\n');
                            if (lines.Length > 1)
                            {
                                for (int k = 0; k < lines.Length; ++k)
                                {
                                    if (!(k == lines.Length - 1 && lines[k] == ""))
                                    {
                                        result.WriteCell("op", null, op.ToString());
                                        result.WriteCell("old", null, lines[k] + "\n");
                                        result.Axis.Write(null);
                                    }
                                }
                            }
                            else
                            {
                                result.WriteCell("op", null, op.ToString());
                                result.WriteCell("old", null, text);
                                result.Axis.Write(null);
                            }
                        }
                        else
                        {
                            result.WriteCell("op", null, op.ToString());
                            result.WriteCell("old", null, text);
                            result.Axis.Write(null);
                        }
                    }
                }
            }
            return(result);
        }
Exemplo n.º 15
0
        protected RCCube CompareNew(string left, string right, bool breakLines)
        {
            diff_match_patch dmp    = new diff_match_patch();
            List <Diff>      diffs  = dmp.diff_main(left, right, true);
            RCCube           result = new RCCube(new RCArray <string> ());
            int start = 0;
            int end   = 0;

            for (int i = 0; i < diffs.Count; ++i)
            {
                Operation op   = diffs[i].operation;
                string    text = diffs[i].text;
                if (op == Operation.EQUAL)
                {
                    int match = left.IndexOf(text, start);
                    if (match < 0)
                    {
                        throw new Exception(
                                  "cannot find string \"" + text + "\" after position " + start + " in \"" +
                                  left + "\"");
                    }
                    end = match + text.Length;
                    string section = left.Substring(start, end - start);
                    start = end;

                    if (breakLines)
                    {
                        int lineStart = 0;
                        while (true)
                        {
                            int lineEnd = section.IndexOf('\n', lineStart);
                            if (lineEnd >= 0)
                            {
                                result.WriteCell("op", null, op.ToString());
                                string line = section.Substring(lineStart, 1 + (lineEnd - lineStart));
                                result.WriteCell("old", null, line);
                                result.WriteCell("new", null, line);
                                result.Axis.Write(null);
                                lineStart = lineEnd + 1;
                            }
                            else if (lineStart < section.Length)
                            {
                                result.WriteCell("op", null, op.ToString());
                                string rest = section.Substring(lineStart, section.Length - lineStart);
                                result.WriteCell("old", null, rest);
                                result.WriteCell("new", null, rest);
                                result.Axis.Write(null);
                                break;
                            }
                            else
                            {
                                break;
                            }
                        }
                    }
                    else
                    {
                        result.WriteCell("op", null, op.ToString());
                        result.WriteCell("old", null, section);
                        result.WriteCell("new", null, section);
                        result.Axis.Write(null);
                    }

                    // string[] lines = section.Split ('\n');
                    // if (lines.Length > 1 && section.Length == 1) continue;

                    /*
                     * if (breakLines && lines.Length > 1)
                     * {
                     * for (int k = 0; k < lines.Length; ++k)
                     * {
                     *  if (k < lines.Length - 1)
                     *  {
                     *    result.WriteCell ("op", null, op.ToString ());
                     *    result.WriteCell ("old", null, lines[k] + "\n");
                     *    result.WriteCell ("new", null, lines[k] + "\n");
                     *    result.Axis.Write (null);
                     *  }
                     *  else if (lines[k] != "")
                     *  {
                     *    result.WriteCell ("op", null, op.ToString ());
                     *    result.WriteCell ("old", null, lines[k]);
                     *    result.WriteCell ("new", null, lines[k]);
                     *    result.Axis.Write (null);
                     *  }
                     *  else
                     *  {
                     *    result.WriteCell ("op", null, op.ToString ());
                     *    result.WriteCell ("old", null, "\n");
                     *    result.WriteCell ("new", null, "\n");
                     *    result.Axis.Write (null);
                     *  }
                     *  if (lines[k] == "")
                     *  {
                     *    result.WriteCell ("op", null, op.ToString ());
                     *    result.WriteCell ("old", null, "\n");
                     *    result.WriteCell ("new", null, "\n");
                     *    result.Axis.Write (null);
                     *  }
                     *  if (!(k == lines.Length - 1 && lines[k] == ""))
                     *  {
                     *    result.WriteCell ("op", null, op.ToString ());
                     *    result.WriteCell ("old", null, lines[k] + "\n");
                     *    result.WriteCell ("new", null, lines[k] + "\n");
                     *    result.Axis.Write (null);
                     *  }
                     * }
                     * }
                     * else
                     * {
                     * result.WriteCell ("op", null, op.ToString ());
                     * result.WriteCell ("old", null, section);
                     * result.WriteCell ("new", null, section);
                     * result.Axis.Write (null);
                     * }
                     */
                }
                else if (op == Operation.INSERT)
                {
                    string   section = text;
                    string[] lines   = section.Split('\n');
                    if (breakLines && lines.Length > 1)
                    {
                        for (int k = 0; k < lines.Length; ++k)
                        {
                            if (!(k == lines.Length - 1 && lines[k] == ""))
                            {
                                result.WriteCell("op", null, op.ToString());
                                result.WriteCell("new", null, lines[k] + "\n");
                                result.Axis.Write(null);
                            }
                        }
                    }
                    else
                    {
                        result.WriteCell("op", null, op.ToString());
                        result.WriteCell("new", null, section);
                        result.Axis.Write(null);
                    }
                }
                else if (op == Operation.DELETE)
                {
                    start += text.Length;
                    string   section = text;
                    string[] lines   = section.Split('\n');
                    if (breakLines && lines.Length > 1)
                    {
                        for (int k = 0; k < lines.Length; ++k)
                        {
                            if (!(k == lines.Length - 1 && lines[k] == ""))
                            {
                                result.WriteCell("op", null, op.ToString());
                                result.WriteCell("old", null, lines[k] + "\n");
                                result.Axis.Write(null);
                            }
                        }
                    }
                    else
                    {
                        result.WriteCell("op", null, op.ToString());
                        result.WriteCell("old", null, section);
                        result.Axis.Write(null);
                    }
                }
            }
            return(result);
        }
Exemplo n.º 16
0
        protected void DoChart(RCCube result,
                               RCSymbolScalar name,
                               ref long row,
                               long col,
                               RCCube cube)
        {
            for (int i = 0; i < cube.Cols; ++i)
            {
                string         colname = cube.NameAt(i);
                ColumnBase     data    = cube.GetColumn(i);
                RCSymbolScalar cell    = RCSymbolScalar.From(row, (long)col, 0L);
                RCSymbolScalar parent  = new RCSymbolScalar(name, colname);
                result.WriteCell("r", cell, (long)row);
                result.WriteCell("c", cell, (long)col);
                result.WriteCell("l", cell, 0L);
                result.WriteCell("k", cell, parent);
                result.WriteCell("v", cell, colname);
                result.Write(cell);

                for (int j = 0; j < data.Count; ++j)
                {
                    string val = data.BoxCell(j).ToString();
                    cell = RCSymbolScalar.From(row, (long)col + data.Index[j] + 1, 0L);
                    RCSymbolScalar child = new RCSymbolScalar(parent, (long)j);
                    result.WriteCell("r", cell, (long)row);
                    result.WriteCell("c", cell, (long)col + data.Index[j] + 1);
                    result.WriteCell("l", cell, 0L);
                    result.WriteCell("k", cell, child);
                    result.WriteCell("v", cell, val);
                    result.Write(cell);
                }
                ++row;
            }
            if (cube.Axis.Global != null)
            {
                RCSymbolScalar cell   = RCSymbolScalar.From(row, col, 0L);
                RCSymbolScalar parent = new RCSymbolScalar(name, "G");
                result.WriteCell("r", cell, (long)row);
                result.WriteCell("c", cell, (long)col);
                result.WriteCell("l", cell, 0L);
                result.WriteCell("k", cell, parent);
                result.WriteCell("v", cell, "G");
                result.Write(cell);
                for (int i = 0; i < cube.Axis.Global.Count; ++i)
                {
                    string val = cube.Axis.Global[i].ToString();
                    cell = RCSymbolScalar.From(row, col + i + 1, 0L);
                    RCSymbolScalar child = new RCSymbolScalar(parent, (long)i);
                    result.WriteCell("r", cell, (long)row);
                    result.WriteCell("c", cell, (long)col + i + 1);
                    result.WriteCell("l", cell, 0L);
                    result.WriteCell("k", cell, child);
                    result.WriteCell("v", cell, val);
                    result.Write(cell);
                }
                ++row;
            }
            if (cube.Axis.Event != null)
            {
                RCSymbolScalar cell   = RCSymbolScalar.From(row, col, 0L);
                RCSymbolScalar parent = new RCSymbolScalar(name, "E");
                result.WriteCell("r", cell, (long)row);
                result.WriteCell("c", cell, (long)col);
                result.WriteCell("l", cell, 0L);
                result.WriteCell("k", cell, parent);
                result.WriteCell("v", cell, "E");
                result.Write(cell);
                for (int i = 0; i < cube.Axis.Event.Count; ++i)
                {
                    string val = cube.Axis.Event[i].ToString();
                    cell = RCSymbolScalar.From(row, col + i + 1, 0L);
                    RCSymbolScalar child = new RCSymbolScalar(parent, (long)i);
                    result.WriteCell("r", cell, (long)row);
                    result.WriteCell("c", cell, (long)col + i + 1);
                    result.WriteCell("l", cell, 0L);
                    result.WriteCell("k", cell, child);
                    result.WriteCell("v", cell, val);
                    result.Write(cell);
                }
                ++row;
            }
            if (cube.Axis.Time != null)
            {
                RCSymbolScalar cell   = RCSymbolScalar.From(row, col, 0L);
                RCSymbolScalar parent = new RCSymbolScalar(name, "T");
                result.WriteCell("r", cell, (long)row);
                result.WriteCell("c", cell, (long)col);
                result.WriteCell("l", cell, 0L);
                result.WriteCell("k", cell, parent);
                result.WriteCell("v", cell, "T");
                result.Write(cell);
                for (int i = 0; i < cube.Axis.Time.Count; ++i)
                {
                    string val = cube.Axis.Time[i].ToString();
                    cell = RCSymbolScalar.From(row, col + i + 1, 0L);
                    RCSymbolScalar child = new RCSymbolScalar(parent, (long)i);
                    result.WriteCell("r", cell, (long)row);
                    result.WriteCell("c", cell, (long)col + i + 1);
                    result.WriteCell("l", cell, 0L);
                    result.WriteCell("k", cell, child);
                    result.WriteCell("v", cell, val);
                    result.Write(cell);
                }
                ++row;
            }
            if (cube.Axis.Symbol != null)
            {
                RCSymbolScalar cell   = RCSymbolScalar.From(row, col, 0L);
                RCSymbolScalar parent = new RCSymbolScalar(name, "S");
                result.WriteCell("r", cell, (long)row);
                result.WriteCell("c", cell, (long)col);
                result.WriteCell("l", cell, 0L);
                result.WriteCell("k", cell, parent);
                result.WriteCell("v", cell, "S");
                result.Write(cell);
                for (int i = 0; i < cube.Axis.Symbol.Count; ++i)
                {
                    string val = cube.Axis.Symbol[i].ToString();
                    cell = RCSymbolScalar.From(row, col + i + 1, 0L);
                    RCSymbolScalar child = new RCSymbolScalar(parent, (long)i);
                    result.WriteCell("r", cell, (long)row);
                    result.WriteCell("c", cell, (long)col + i + 1);
                    result.WriteCell("l", cell, 0L);
                    result.WriteCell("k", cell, child);
                    result.WriteCell("v", cell, val);
                    result.Write(cell);
                }
                ++row;
            }
        }
Exemplo n.º 17
0
        protected static void ListFilesCube(object obj)
        {
            RCAsyncState state = (RCAsyncState)obj;
            ListArgs     args  = (ListArgs)state.Other;

            try
            {
                RCCube         result   = new RCCube(new RCArray <string> ("S"));
                Queue <string> todo     = new Queue <string> ();
                string         top      = args.Path;
                string[]       topParts = top.Split(Path.DirectorySeparatorChar);
                int            startPart;
                RCSymbolScalar prefix;
                if (args.Spec != null)
                {
                    startPart = (int)(topParts.Length - args.Spec.Length) + 1;
                    prefix    = RCSymbolScalar.From(args.Spec.Part(0));
                }
                else
                {
                    startPart = 1;
                    prefix    = RCSymbolScalar.From(topParts[0]);
                }
                todo.Enqueue(top);
                while (todo.Count > 0)
                {
                    string   path  = todo.Dequeue();
                    string[] files = Directory.GetFiles(path);
                    for (int i = 0; i < files.Length; ++i)
                    {
                        FileInfo file = new FileInfo(files[i]);
                        if (args.All || file.Name[0] != '.')
                        {
                            string []      parts  = files[i].Split(Path.DirectorySeparatorChar);
                            RCSymbolScalar symbol = RCSymbolScalar.From(startPart, prefix, parts);
                            result.WriteCell("name", symbol, file.Name);
                            result.WriteCell("size", symbol, file.Length);
                            result.WriteCell("type", symbol, "f");
                            result.WriteCell("ext", symbol, file.Extension);
                            result.WriteCell("access",
                                             symbol,
                                             new RCTimeScalar(file.LastAccessTime,
                                                              RCTimeType.Datetime));
                            result.WriteCell("write",
                                             symbol,
                                             new RCTimeScalar(file.LastWriteTime,
                                                              RCTimeType.Datetime));
                            result.Axis.Write(symbol);
                        }
                    }
                    RCArray <string> dirs = new RCArray <string> (Directory.GetDirectories(path));
                    for (int i = 0; i < dirs.Count; ++i)
                    {
                        DirectoryInfo dir = new DirectoryInfo(dirs[i]);
                        if (args.All || dir.Name[0] != '.')
                        {
                            string []      parts  = dirs[i].Split(Path.DirectorySeparatorChar);
                            RCSymbolScalar symbol = RCSymbolScalar.From(startPart, prefix, parts);
                            result.WriteCell("name", symbol, dir.Name);
                            result.WriteCell("type", symbol, "d");
                            result.WriteCell("access",
                                             symbol,
                                             new RCTimeScalar(dir.LastAccessTime,
                                                              RCTimeType.Datetime));
                            result.WriteCell("write",
                                             symbol,
                                             new RCTimeScalar(dir.LastWriteTime,
                                                              RCTimeType.Datetime));
                            result.Axis.Write(symbol);
                            if (args.Deep)
                            {
                                todo.Enqueue(dirs[i]);
                            }
                        }
                    }
                }
                state.Runner.Yield(state.Closure, result);
            }
            catch (DirectoryNotFoundException ex)
            {
                state.Runner.Finish(state.Closure,
                                    new RCException(state.Closure, RCErrors.File, ex.Message),
                                    1);
            }
            catch (Exception ex)
            {
                state.Runner.Report(state.Closure, ex);
            }
        }