public override bool TryConvertFromRepresentation( IRepresentedType representedType, object [] representations, out object represented) { Color color; if (TryFindMatchingRepresentation <AG.Color, Color> ( representedType, representations, out color)) { represented = new AG.Color( (byte)(color.Red * 255), (byte)(color.Green * 255), (byte)(color.Blue * 255), (byte)(color.Alpha * 255)); return(true); } return(base.TryConvertFromRepresentation( representedType, representations, out represented)); }
public override bool TryConvertFromRepresentation( IRepresentedType representedType, object [] representations, out object represented) { represented = null; if (TryFindMatchingRepresentation <CGColor, Color> ( representedType, representations, out var color)) { represented = new CGColor( (nfloat)color.Red, (nfloat)color.Green, (nfloat)color.Blue, (nfloat)color.Alpha); return(true); } if (TryFindMatchingRepresentation <CGSize, Size> ( representedType, representations, out var size)) { represented = new CGPoint( size.Width, size.Height); return(true); } if (TryFindMatchingRepresentation <CGRect, Rectangle> ( representedType, representations, out var rect)) { represented = new CGRect( rect.X, rect.Y, rect.Width, rect.Height); return(true); } if (TryFindMatchingRepresentation <CGPoint, Point> ( representedType, representations, out var point)) { represented = new Point( point.X, point.Y); return(true); } return(base.TryConvertFromRepresentation( representedType, representations, out represented)); }
public override bool TryConvertFromRepresentation( IRepresentedType representedType, object [] representations, out object represented) { represented = null; if (TryFindMatchingRepresentation <UIColor, Color> ( representedType, representations, out var color)) { represented = new UIColor( (nfloat)color.Red, (nfloat)color.Green, (nfloat)color.Blue, (nfloat)color.Alpha); return(true); } if (TryFindMatchingRepresentation <MKPolyline, GeoPolyline> ( representedType, representations, out var polyline)) { represented = polyline.ToMKPolyline(); return(true); } return(base.TryConvertFromRepresentation( representedType, representations, out represented)); }
public override bool TryConvertFromRepresentation( IRepresentedType representedType, object[] representations, out object represented) { represented = null; if (representedType.ResolvedType == typeof(SWM.Color)) { var color = representations.OfType <XIR.Color> ().FirstOrDefault(); if (color != null) { represented = SWM.Color.FromArgb( (byte)(color.Alpha * 255), (byte)(color.Red * 255), (byte)(color.Green * 255), (byte)(color.Blue * 255) ); return(true); } } return(base.TryConvertFromRepresentation( representedType, representations, out represented)); }
public virtual bool TryConvertFromRepresentation( IRepresentedType representedType, object [] representations, out object represented) { represented = null; return(false); }
protected virtual bool TryFindMatchingRepresentation <TResolvedType, TRepresentationType> ( IRepresentedType representedType, object [] representations, out TRepresentationType matchedRepresentation) where TRepresentationType : class { matchedRepresentation = null; if (representedType.ResolvedType != typeof(TResolvedType)) { return(false); } matchedRepresentation = representations.OfType <TRepresentationType> ().FirstOrDefault(); return(matchedRepresentation != null); }
public override bool TryConvertFromRepresentation( IRepresentedType representedType, object [] representations, out object represented) { represented = null; XIR.Color color; if (TryFindMatchingRepresentation <XF.Color, XIR.Color> ( representedType, representations, out color)) { represented = new XF.Color(color.Red, color.Green, color.Blue, color.Alpha); return(true); } return(base.TryConvertFromRepresentation(representedType, representations, out represented)); }
/// <summary> /// Converts from a representation object such as a <see cref="Color"/> to a /// represented object such as a UIKit.UIColor via the first successful call /// to a registered <see cref="RepresentationProvider"/>'s version of this method. /// </summary> public bool TryConvertFromRepresentation( IRepresentedType representedType, object [] representations, out object represented) { foreach (var provider in providers) { try { if (provider.TryConvertFromRepresentation( representedType, representations, out represented)) { return(true); } } catch (Exception e) { Log.Error(TAG, $"provider {provider}.TryConvertFromRepresentation", e); } } represented = null; return(false); }
Evaluation( CodeCellId codeCellId, EvaluationStatus status, EvaluationResultHandling resultHandling, IRepresentedType resultType, IReadOnlyList <object> resultRepresentations, bool resultIsException, TimeSpan evaluationDuration, int cultureLCID, int uiCultureLCID, bool initializedIntegration, IReadOnlyList <AssemblyDefinition> loadedAssemblies) { CodeCellId = codeCellId; Status = status; ResultHandling = resultHandling; ResultType = resultType; ResultRepresentations = resultRepresentations; EvaluationDuration = evaluationDuration; CultureLCID = cultureLCID; UICultureLCID = uiCultureLCID; InitializedIntegration = initializedIntegration; LoadedAssemblies = loadedAssemblies; }
public virtual bool TryConvertFromRepresentation(IRepresentedType representedType, object[] representations, out object represented);
public override bool TryConvertFromRepresentation( IRepresentedType representedType, object[] representations, out object represented) { represented = null; if (TryFindMatchingRepresentation <SW.Size, XIR.Size> ( representedType, representations, out var size)) { represented = new SW.Size(size.Width, size.Height); return(true); } if (TryFindMatchingRepresentation <SW.Rect, XIR.Rectangle> ( representedType, representations, out var rectangle)) { represented = new SW.Rect( rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height); return(true); } if (TryFindMatchingRepresentation <SW.Point, XIR.Point> ( representedType, representations, out var point)) { represented = new SW.Point(point.X, point.Y); return(true); } if (TryFindMatchingRepresentation <SW.Thickness, XIR.Thickness> ( representedType, representations, out var thickness)) { represented = new SW.Thickness( thickness.Left, thickness.Top, thickness.Right, thickness.Bottom); return(true); } if (TryFindMatchingRepresentation <SWM.Color, XIR.Color> ( representedType, representations, out var color)) { represented = SWM.Color.FromArgb( (byte)(color.Alpha * 255), (byte)(color.Red * 255), (byte)(color.Green * 255), (byte)(color.Blue * 255)); return(true); } return(base.TryConvertFromRepresentation( representedType, representations, out represented)); }