Exemplo n.º 1
0
        protected void DeleteRow(DataRow row)
        {
            var instance       = row.ItemArray[0];
            var backingPropVal = BackingProprty.GetValue(Owner);

            backingPropVal.GetType().GetMethod("Remove", new[] { instance.GetType() }).Invoke(backingPropVal, new[] { instance });

            // Save json
            var cmd = new RepositoryAsJsonCommand(Repository, $"SIM.Aibel.{Mediator.Context}");

            cmd.Execute();
        }
Exemplo n.º 2
0
        private void PopulateTable()
        {
            var backinPropValue = (BackingProprty.GetValue(Owner) as IEnumerable)?.GetEnumerator();

            if (backinPropValue == null)
            {
                return;
            }

            while (backinPropValue.MoveNext())
            {
                var current = backinPropValue.Current;
                var row     = Table.NewRow();
                row[Table.Columns[0]] = current;

                for (int i = 1; i < Table.Columns.Count; i++)
                {
                    var    value    = current.GetType().GetProperty(Table.Columns[i].ColumnName).GetValue(current);
                    string valueStr = string.Empty;
                    if (value != null && value.GetType().GetInterface("IEnumerable") != null && !value.GetType().Equals(typeof(string)))
                    {
                        var enumerator = (value as IEnumerable).GetEnumerator();
                        while (enumerator.MoveNext())
                        {
                            var c = enumerator.Current;
                            valueStr = string.Format("{0}{1} ", valueStr, c.ToString());
                        }
                    }
                    else
                    {
                        valueStr = value?.ToString();
                    }
                    row[Table.Columns[i]] = valueStr;
                }

                Table.Rows.Add(row);
            }
        }