Beispiel #1
0
        void AddRow(XmlNode src, RowKind kind, Int32 rowNo)
        {
            ExRow row       = _sheet.GetRow(rowNo, kind);
            var   classAttr = src.Attributes["class"];

            if (classAttr != null)
            {
                row.SetRoleAndStyle(classAttr.Value);
            }
            var heightAttr = src.Attributes["data-row-height"];

            if (heightAttr != null)
            {
                if (UInt32.TryParse(heightAttr.Value, out UInt32 height))
                {
                    row.Height = height;
                }
            }
            foreach (var cn in src.ChildNodes.OfType <XmlNode>().Where(node => node.Name == "td"))
            {
                var colSpanAttr = cn.Attributes["colspan"];
                var rowSpanAttr = cn.Attributes["rowspan"];
                var span        = new CellSpan();
                if (colSpanAttr != null)
                {
                    span.Col = Int32.Parse(colSpanAttr.Value);
                }
                if (rowSpanAttr != null)
                {
                    span.Row = Int32.Parse(rowSpanAttr.Value);
                }

                var    dataTypeAttr = cn.Attributes["data-type"];
                String dataType     = null;
                if (dataTypeAttr != null)
                {
                    dataType = dataTypeAttr.Value;
                }
                var    cellClassAttr = cn.Attributes["class"];
                String cellClass     = null;
                if (cellClassAttr != null)
                {
                    cellClass = cellClassAttr.Value;
                }

                String cellText = GetNodeText(cn);
                _sheet.AddCell(rowNo, row, span, cellText, dataType, cellClass);
            }
        }
Beispiel #2
0
        private MethodInfo[] FindRowHandler(PageRequest request, RowKind kind)
        {
            List <MethodInfo> list = new List <MethodInfo>();

            foreach (MethodInfo method in GetType().GetMethods((BindingFlags.Public | (BindingFlags.NonPublic | BindingFlags.Instance))))
            {
                foreach (RowBuilderAttribute filter in method.GetCustomAttributes(typeof(RowBuilderAttribute), true))
                {
                    if (filter.Kind == kind)
                    {
                        if ((request.Controller == filter.Controller) && (String.IsNullOrEmpty(filter.View) || (request.View == filter.View)))
                        {
                            list.Add(method);
                        }
                    }
                }
            }
            return(list.ToArray());
        }
Beispiel #3
0
        public ExRow GetRow(Int32 rowNo, RowKind kind)
        {
            IList <ExRow> _rows = null;

            switch (kind)
            {
            case RowKind.Header:
                _rows = _header; break;

            case RowKind.Footer:
                _rows = _footer; break;

            case RowKind.Body:
                _rows = _body; break;
            }
            while (_rows.Count <= rowNo)
            {
                _rows.Add(new ExRow()
                {
                    Kind = kind
                });
            }
            return(_rows[rowNo]);
        }
Beispiel #4
0
        ExCell AddSpanCell(RowKind kind, Int32 row, Int32 col)
        {
            var r = GetRow(row, kind);

            return(r.SetSpanCell(col));
        }
Beispiel #5
0
 public RowBuilderAttribute(string controller, string view, RowKind kind)
 {
     this._controller = controller;
     this._view       = view;
     this._kind       = kind;
 }
Beispiel #6
0
 public RowBuilderAttribute(string controller, RowKind kind) :
     this(controller, null, kind)
 {
 }
        public static EventStreamRow FromRaw(string rawDataString)
        {
            var parsed = JsonConvert.DeserializeObject <List <dynamic> >(rawDataString);

            // Synapse 0.99.4+ sends ["ev", [...]] - the 'ev' represents the kind of event.
            RowKind kind = RowKind.Unknown;

            if (parsed[0] == "ev")
            {
                kind = RowKind.Event;
            }
            if (parsed[0] == "state")
            {
                kind = RowKind.State;
            }

            var        secondArgType = (parsed[1] as object).GetType().FullName;
            RowVersion version       = secondArgType == typeof(JArray).FullName ? RowVersion.Post0994 : RowVersion.Pre0994;

            // We have to convert the JArray to something useful
            var rowData = version == RowVersion.Post0994 ? ((JArray)parsed[1]).ToObject <List <dynamic> >() : new List <dynamic>();

            string relatesToEventId = null;

            if (rowData.Count >= 6)
            {
                version          = RowVersion.Post0995;
                relatesToEventId = rowData[5];
            }

            switch (kind)
            {
            case RowKind.Event:
                return(new EventStreamRow
                {
                    Kind = kind,
                    SynapseVersion = version,
                    EventId = rowData[0],
                    RoomId = rowData[1],
                    EventType = rowData[2],
                    StateKey = rowData[3],
                    RedactsEventId = rowData[4],
                    RelatesToEventId = relatesToEventId,
                });

            case RowKind.State:
                return(new EventStreamRow
                {
                    Kind = kind,
                    SynapseVersion = version,
                    RoomId = rowData[0],
                    EventType = rowData[1],
                    StateKey = rowData[2],
                    EventId = rowData[3],
                });

            default:
                if (version == RowVersion.Pre0994)
                {
                    return(new EventStreamRow
                    {
                        Kind = kind,
                        SynapseVersion = version,
                        EventId = parsed[0],
                        RoomId = parsed[1],
                        EventType = parsed[2],
                        StateKey = parsed[3],
                        RedactsEventId = parsed[4],
                        RelatesToEventId = relatesToEventId,
                    });
                }
                else
                {
                    return(new EventStreamRow {
                        Kind = kind, SynapseVersion = version
                    });
                }
            }
        }