private void Initalize(IRValueInfo valueInfo) { Value = GetValue(valueInfo)?.Trim(); TypeName = valueInfo.TypeName; if (valueInfo.Classes != null) { var escaped = valueInfo.Classes.Select((x) => x.IndexOf(' ') >= 0 ? "'" + x + "'" : x); Class = string.Join(", ", escaped); // TODO: escape ',' in class names } HasChildren = valueInfo.HasChildren; if (valueInfo.Dim != null) { Dimensions = valueInfo.Dim; } else if (valueInfo.Length.HasValue) { Dimensions = new List <long>() { valueInfo.Length.Value, 1 }; } else { Dimensions = new List <long>(); } }
public override bool CanView(IRValueInfo value) { // We can only view collections that have elements. var length = value?.Length ?? 0; if (length == 0) { return(false); } // We can only view atomic vectors or lists. // Note that data.frame is always a list, and matrix and array can be either vector or list. if (!value.IsAtomic() && value.TypeName != "list") { return(false); } // We can only view dimensionless (treated as 1D), 1D, or 2D collections. // For 1D collections, only view if there's more than one element (for 2D, we still want // to enable grid in that case to expose row & column names). var dimCount = value.Dim?.Count ?? 1; if (dimCount > 2 || (dimCount == 1 && length == 1)) { return(false); } return(true); }
public override bool CanView(IRValueInfo evaluation) { if (evaluation != null && evaluation.Classes.Any(t => _tableClasses.Contains(t))) { return(evaluation.Dim != null && evaluation.Dim.Count == 2); } return(false); }
internal RActiveBindingInfo(IRSession session, string environmentExpression, string expression, string name, JObject json) : this(session, environmentExpression, expression, name, (IRValueInfo)null) { JObject bindingResultJson = json.Value<JObject>(FieldNames.ComputedValue); if (bindingResultJson != null) { ComputedValue = new RValueInfo(session, environmentExpression, expression, name, bindingResultJson); } }
public override bool CanView(IRValueInfo evaluation) { if (evaluation != null && evaluation.Classes.Any(t => _classes.Contains(t))) { return(evaluation.Length.HasValue && evaluation.Length > 1 && (evaluation.Dim == null || evaluation.Dim.Count == 1)); } return(false); }
public override bool CanView(IRValueInfo evaluation) { if (evaluation != null && !evaluation.Classes.Any(t => _excludedClasses.Contains(t))) { return(evaluation.Dim == null && evaluation.Length > 1); } return(false); }
internal RActiveBindingInfo(IRSession session, string environmentExpression, string expression, string name, JObject json) : this(session, environmentExpression, expression, name, (IRValueInfo)null) { JObject bindingResultJson = json.Value <JObject>(FieldNames.ComputedValue); if (bindingResultJson != null) { ComputedValue = new RValueInfo(session, environmentExpression, expression, name, bindingResultJson); } }
private string GetValue(IRValueInfo v) { var value = v.Representation; if (value != null) { var match = Regex.Match(value, DataFramePrefix); if (match.Success) { return(match.Groups[1].Value.Trim()); } } return(value?.ConvertCharacterCodes()); }
internal RActiveBindingInfo(IRSession session, string environmentExpression, string expression, string name, JObject json) : base(session, environmentExpression, expression, name) { JObject bindingResultJson = json.Value <JObject>("computed_value"); if (bindingResultJson == null) { ComputedValue = null; } else { ComputedValue = new RValueInfo(session, environmentExpression, expression, name, bindingResultJson); } }
private void SetViewButtonStatus(IRValueInfo result) { _detailsViewer = _aggregator.GetViewer(result); _title = result.Name; CanShowDetail = _detailsViewer != null; if (CanShowDetail) { ShowDetailCommand = new DelegateCommand(o => _detailsViewer.ViewAsync(result.Expression, _title).DoNotWait(), o => CanShowDetail); ShowDetailCommandTooltip = Resources.ShowDetailCommandTooltip; } CanShowOpenCsv = result.CanCoerceToDataFrame && (result.Length > 1 || result.TypeName == "S4"); if (CanShowOpenCsv) { OpenInCsvAppCommand = new DelegateCommand(OpenInCsvApp, o => CanShowOpenCsv); OpenInCsvAppCommandTooltip = Resources.OpenCsvAppCommandTooltip; } }
private void Initalize(IRValueInfo valueInfo) { Value = GetValue(valueInfo)?.Trim(); TypeName = valueInfo.TypeName; if (valueInfo.Classes != null) { var escaped = valueInfo.Classes.Select((x) => x.IndexOf(' ') >= 0 ? "'" + x + "'" : x); Class = string.Join(", ", escaped); // TODO: escape ',' in class names } HasChildren = valueInfo.HasChildren; if (valueInfo.Dim != null) { Dimensions = valueInfo.Dim; } else if (valueInfo.Length.HasValue) { Dimensions = new List<int>() { valueInfo.Length.Value, 1 }; } else { Dimensions = new List<int>(); } }
private void SetViewButtonStatus(IRValueInfo result) { _detailsViewer = _aggregator.GetViewer(result); _title = result.Name; CanShowDetail = _detailsViewer != null; if (CanShowDetail) { ShowDetailCommand = new DelegateCommand(o => _detailsViewer.ViewAsync(result.Expression, _title).DoNotWait(), o => CanShowDetail); ShowDetailCommandTooltip = Resources.ShowDetailCommandTooltip; } var tableCaps = (ViewerCapabilities.Table | ViewerCapabilities.List); CanShowOpenCsv = CanShowDetail && (_detailsViewer.Capabilities & tableCaps) != 0 && result.Length > 0; if (CanShowOpenCsv) { OpenInCsvAppCommand = new DelegateCommand(OpenInCsvApp, o => CanShowOpenCsv); OpenInCsvAppCommandTooltip = Resources.OpenCsvAppCommandTooltip; } }
public override bool CanView(IRValueInfo value) { // We can only view collections that have elements. var length = value?.Length ?? 0; if (length == 0) { return(false); } // We can only view atomic vectors or lists. // Note that data.frame is always a list, and matrix and array can be either vector or list. if (!value.IsAtomic() && value.TypeName != "list") { return(false); } // We can only view dimensionless (treated as 1D), 1D, or 2D collections. // For 1D collections, only view if there's more than one element (for 2D, we still want // to enable grid in that case to expose row & column names). var dimCount = value.Dim?.Count ?? 1; if (dimCount > 2 || (dimCount == 1 && length == 1)) { return(false); } // Grid viewer allocates arrays of doubles of the size of each dimension, to precompute cell coordinates. // If a given dimension is too large, the corresponding array can easily OOM on allocation. So, restrict // dimensions to reasonable sizes. foreach (var dim in value.Dim ?? new[] { length }) { if (dim > MaxDim) { return(false); } } return(true); }
public IObjectDetailsViewer GetViewer(IRValueInfo result) { Lazy <IObjectDetailsViewer> lazyViewer = Viewers.FirstOrDefault(x => x.Value.CanView(result)); return(lazyViewer?.Value); }
private string GetValue(IRValueInfo v) { var value = v.Representation; if (value != null) { Match match = Regex.Match(value, DataFramePrefix); if (match.Success) { return match.Groups[1].Value.Trim(); } } return value != null ? value.ConvertCharacterCodes() : value; }
public override bool CanView(IRValueInfo evaluation) { if (evaluation != null && !evaluation.Classes.Any(t => _excludedClasses.Contains(t))) { return evaluation.Dim == null && evaluation.Length > 1; } return false; }
abstract public bool CanView(IRValueInfo evaluation);
public override bool CanView(IRValueInfo evaluation) { if (evaluation != null && evaluation.Classes.Any(t => _tableClasses.Contains(t))) { return evaluation.Dim != null && evaluation.Dim.Count == 2; } return false; }
public override bool CanView(IRValueInfo evaluation) { return(evaluation != null && evaluation.Classes.Any(t => _classes.Contains(t))); }
internal RActiveBindingInfo(IRSession session, string environmentExpression, string expression, string name, IRValueInfo computedValue) : base(session, environmentExpression, expression, name) { ComputedValue = computedValue; }
public IObjectDetailsViewer GetViewer(IRValueInfo result) { Lazy<IObjectDetailsViewer> lazyViewer = Viewers.FirstOrDefault(x => x.Value.CanView(result)); return lazyViewer?.Value; }
public IObjectDetailsViewer GetViewer(IRValueInfo result) { return(Viewers.Select(viewer => viewer.Value).FirstOrDefault(viewer => viewer.CanView(result))); }
/// <seealso cref="RValueFlags.Atomic"/> public static bool IsAtomic(this IRValueInfo info) => info.Flags.HasFlag(RValueFlags.Atomic);
/// <summary> /// Whether this value has any attributes. /// </summary> public static bool HasAttributes(this IRValueInfo info) => info.AttributeCount != null && info.AttributeCount != 0;
public override bool CanView(IRValueInfo evaluation) { return evaluation != null && evaluation.Classes.Any(t => _classes.Contains(t)); }
internal RActiveBindingInfo(IRExpressionEvaluator evaluator, string environmentExpression, string expression, string name, IRValueInfo computedValue) : base(evaluator, environmentExpression, expression, name) { ComputedValue = computedValue; }
public abstract bool CanView(IRValueInfo evaluation);
public bool CanView(IRValueInfo evaluation) { return _types.Contains(evaluation?.TypeName); }
public override bool CanView(IRValueInfo evaluation) { if (evaluation != null && evaluation.Classes.Any(t => _classes.Contains(t))) { return evaluation.Length.HasValue && evaluation.Length > 1 && (evaluation.Dim == null || evaluation.Dim.Count == 1); } return false; }
/// <seealso cref="RValueFlags.Recursive"/> public static bool IsRecursive(this IRValueInfo info) => info.Flags.HasFlag(RValueFlags.Recursive);
/// <summary> /// Whether this value has any slots. /// </summary> public static bool HasSlots(this IRValueInfo info) => info.SlotCount != null && info.SlotCount != 0;