static ITT() { var initializator = CreateInitializator(); initializator.Init(); Native = initializator.CreateNative(); }
private static void GenerateHandleInvokeCode(ILGenerator ilGenerator, INative native, NativeIlGenContext context, LocalBuilder argsLocal) { // NativeHandleInvokers.InvokeHandle(handle, args) ilGenerator.Emit(OpCodes.Ldc_I4, native.Handle); ilGenerator.Emit(OpCodes.Ldloc, argsLocal); ilGenerator.EmitCall(GetHandleInvokerMethod(context)); }
public void Render(INative context) { if (Native != null) { (Native as CanvasView).Render(); } }
/// <summary> /// Initializes a new instance of the <see cref="NativeObjectILGenerator" /> class. /// </summary> /// <param name="native">The native.</param> /// <param name="nativeObjectType">Type of the native object.</param> /// <param name="identifiers">The identifiers.</param> /// <param name="parameterTypes">The parameter types.</param> /// <param name="returnType">Type of the return.</param> /// <exception cref="ArgumentNullException">Thrown if nativeObjectType or idnetifiers is null.</exception> public NativeObjectILGenerator(INative native, Type nativeObjectType, string[] identifiers, Type[] parameterTypes, Type returnType) : base(native, AddIdentifiersToParameterTypes(identifiers, parameterTypes), returnType) { _nativeObjectType = nativeObjectType ?? throw new ArgumentNullException(nameof(nativeObjectType)); _identifiers = identifiers ?? throw new ArgumentNullException(nameof(identifiers)); }
internal Task(INative native, IntPtr domain, string name, ulong id, Task parent) { _native = native; _domain = domain; Id = id; _native.BeginTask(domain, id, parent?.Id ?? 0, name, 0); }
public bool Greater(INative b) { return(b switch { Array array => _natives.Count > array._natives.Count, Number number => _natives.Count > number, _ => false });
public bool Lesser(INative a) { if (a is Bool bol) { return(bol._value && !_value); } return(false); }
public bool Greater(INative b) { if (b is Bool bol) { return(!bol._value && _value); } return(false); }
public bool Greater(INative b) { return(b switch { Number number => this > number, Text text => this > text.Length, Date date => new Date(_value) > date, _ => false });
public void Remove(INative value) { if (value.Native != null) { _ncanvas.Children.Remove(value.Native as UIElement); } Children.Remove(value); }
internal static object Create(Type type, INative parent, Locator locator) { var listType = typeof(WebElementsCollection <>); var genericArgs = type.GetGenericArguments(); var concreteType = listType.MakeGenericType(genericArgs); var newList = Activator.CreateInstance(concreteType, parent, locator); return(newList); }
public void Add(INative value) { if (value.Native != null) { _ncanvas.Children.Add(value.Native as UIElement); } Children.Add(value); }
private static IHtmlElement Create(Type elementType, INative parent, Locator locator, int index = 0) { var htmlElement = (IHtmlElement)Activator.CreateInstance(elementType); htmlElement.Parent = parent; htmlElement.SearchStrategy = new SearchStrategy(locator, index); InitProperties(htmlElement); return(htmlElement); }
private void Generate(ILGenerator ilGenerator, NativeIlGenContext context, INative native) { var argsLocal = GenerateArgsArray(ilGenerator, context); GenerateInvokeInputCode(ilGenerator, context, argsLocal); GenerateHandleInvokeCode(ilGenerator, native, context, argsLocal); GenerateInvokeOutputCode(ilGenerator, context, argsLocal); // return $0 ilGenerator.Emit(OpCodes.Ret); }
/// <summary> /// 销毁INative, 也可以调用 Native的Dispose方法 /// </summary> /// <param name="p_native"></param> public static void Free(INative p_native) { var native = p_native; if (native == null) { return; } native.Dispose(); }
static Native() { Current = null; if (Environment.OSVersion.Platform == PlatformID.Win32NT) { Current = new Win32Native(); } else { Current = new PlatformIndependentNative(); } }
public DynamicNative(INative p_native) { _native = p_native; if (_native == null) { throw new ArgumentNullException(nameof(p_native)); } if (_native.HasDisposed) { throw new ArgumentException("INative can not be null or disposed."); } }
/// <summary> /// Initializes a new instance of the <see cref="NativeHandleBasedProxyGenerator" /> class. /// </summary> /// <param name="native">The native.</param> /// <param name="nativeObjectType">Type of the native object.</param> /// <param name="identifiers">The identifiers.</param> /// <param name="identifierIndex">The start index of the identifiers.</param> /// <param name="parameterTypes">The parameter types.</param> /// <param name="returnType">Type of the return.</param> /// <exception cref="ArgumentNullException">Thrown if nativeObjectType or identifiers is null.</exception> public NativeHandleBasedProxyGenerator(INative native, Type nativeObjectType, string[] identifiers, int identifierIndex, Type[] parameterTypes, Type returnType) { if (parameterTypes == null) { throw new ArgumentNullException(nameof(parameterTypes)); } parameterTypes = AddIdentifiersToParameterTypes(identifiers, identifierIndex, parameterTypes); ParameterTypes = parameterTypes; Native = native ?? throw new ArgumentNullException(nameof(native)); ReturnType = returnType ?? throw new ArgumentNullException(nameof(returnType)); _nativeObjectType = nativeObjectType ?? throw new ArgumentNullException(nameof(nativeObjectType)); _identifiers = identifiers ?? throw new ArgumentNullException(nameof(identifiers)); _identifierIndex = identifierIndex; }
public Task <INative> Deserialize(Scope scope, params INative[] args) { var value = args.ElementAtOrDefault(0); if (value == null || !value.Is <Text>(out var text)) { throw new NativeException("Se requiere un texto para deserializar"); } var token = JToken.Parse(text); INative result = token switch { JArray array => array.ToObject <Objects.Array>() !, JObject jObject => jObject.ToObject <Objects.Object>() !, _ => new Undefined() }; return(Task.FromResult(result)); }
public NativeILGenerator(INative native, Type[] parameterTypes, Type returnType) { if (native == null) { throw new ArgumentNullException(nameof(native)); } if (parameterTypes == null) { throw new ArgumentNullException(nameof(parameterTypes)); } if (returnType == null) { throw new ArgumentNullException(nameof(returnType)); } ParameterTypes = parameterTypes; Native = native; ReturnType = returnType; }
public INative Convert(INative native) { if (native is IPin) { return(Convert(native as IPin)); } else if (native is ILine) { return(Convert(native as ILine)); } else if (native is IBezier) { return(Convert(native as IBezier)); } else if (native is IQuadraticBezier) { return(Convert(native as IQuadraticBezier)); } else if (native is IArc) { return(Convert(native as IArc)); } else if (native is IRectangle) { return(Convert(native as IRectangle)); } else if (native is IEllipse) { return(Convert(native as IEllipse)); } else if (native is IText) { return(Convert(native as IText)); } else if (native is IBlock) { throw new NotImplementedException(); } else { throw new NotSupportedException(); } }
public NativeObjectILGenerator(INative native, Type nativeObjectType, string[] identifiers, Type[] parameterTypes, Type returnType) : base( native, Enumerable.Repeat(typeof(int), identifiers?.Length ?? 0) .Concat(parameterTypes ?? new Type[0]) .ToArray(), returnType) { if (nativeObjectType == null) { throw new ArgumentNullException(nameof(nativeObjectType)); } if (identifiers == null) { throw new ArgumentNullException(nameof(identifiers)); } _nativeObjectType = nativeObjectType; _identifiers = identifiers; }
public override async Task <ICompletion <INative> > ExecuteAsync(Scope scope) { var target = await Target.ExecuteAsync(scope).GetResult(); if (!target.Is <Function>(out var function)) { throw new NativeException($"'{Target}' no es una función", Position); } var args = new INative[Params.Count]; for (var i = 0; i < args.Length; i++) { args[i] = await Params[i].ExecuteAsync(scope).GetResult(); } if (IsAsync) { return(new Completion(new Promise(function.InvokeAsync(scope, args)))); } return(await function.InvokeAsync(scope, args)); }
private void Write(INative child) { if (child is IPin) { Write(child as IPin); } else if (child is ILine) { Write(child as ILine); } else if (child is IBezier) { Write(child as IBezier); } else if (child is IQuadraticBezier) { Write(child as IQuadraticBezier); } else if (child is IArc) { Write(child as IArc); } else if (child is IRectangle) { Write(child as IRectangle); } else if (child is IEllipse) { Write(child as IEllipse); } else if (child is IText) { Write(child as IText); } else if (child is IBlock) { Write(child as IBlock); } }
internal static void InitProperties(INative native) { var properties = native.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (var property in properties) { if (property.HasLocatorAttribute() && property.IsWebElement()) { var element = Create(property.PropertyType, native, property.GetLocatorAttribute()); property.SetValue(native, element); } if (property.HasLocatorAttribute() && property.IsWebElementsCollection()) { var collection = WebElementsCollectionFactory.Create(property.PropertyType, native, property.GetLocatorAttribute()); property.SetValue(native, collection); } if (property.HasLocatorAttribute() && !(property.IsWebElement() || property.IsWebElementsCollection())) { throw new InvalidOperationException($"Property {property.Name} has FindBy attribute but is not collection or element"); } } }
public static INative Execute(INative left, string op, INative right) { return(op switch { "==" => Helpers.CompareEquality(left, op, right), "!=" => Helpers.CompareEquality(left, op, right), "<" => Helpers.CompareEquality(left, op, right), ">" => Helpers.CompareEquality(left, op, right), "<=" => Helpers.CompareEquality(left, op, right), ">=" => Helpers.CompareEquality(left, op, right), "+" => left + right, "+=" => left + right, "-" => left - right, "-=" => left - right, "*" => left * right, "*=" => left * right, "/" => left / right, "/=" => left / right, "&&" => (left.ToBool() && right.ToBool()).ToNative(), "||" => (left.ToBool() || right.ToBool()).ToNative(), "=" => right, _ => Number.NaN });
public App( string appHostBaseUrl, string appHostInitialUrl, string oneSignalIdentifier, ICollection <string> ignoreUrls) { _ignoreUrls = ignoreUrls ?? new List <string>(); _appMainPage = new AppMainPage($"{DDAppLocalUrl}{appHostInitialUrl}"); MainPage = _appMainPage; StartWebProxy(); _nativeService = DependencyService.Get <INative>(); var cacheBaseDir = _nativeService.GetCacheDir(); _cache = new ApplicationCache(appHostBaseUrl, cacheBaseDir); Task.Run(async() => { _nativeService.LoadPreCache(); await Task.Delay(1000); Device.BeginInvokeOnMainThread(() => { _appMainPage.ToWebState(); if (!string.IsNullOrWhiteSpace(oneSignalIdentifier)) { Task.Run(async() => { await Task.Delay(3000); OneSignal.Current.StartInit(oneSignalIdentifier).EndInit(); }); } }); }); }
public PropertyData SetProperty(string name, INative value) => Helpers.SetProperty(this, name, value);
public bool Lesser(INative b) => false;
public void Render(INative context) { }
private void Reset(INative child) { if (child is IPin) { Reset(child as IPin); } else if (child is ILine) { Reset(child as ILine); } else if (child is IBezier) { Reset(child as IBezier); } else if (child is IQuadraticBezier) { Reset(child as IQuadraticBezier); } else if (child is IArc) { Reset(child as IArc); } else if (child is IRectangle) { Reset(child as IRectangle); } else if (child is IEllipse) { Reset(child as IEllipse); } else if (child is IText) { Reset(child as IText); } else if (child is IBlock) { Reset(child as IBlock); } }
private void HideSelected() { _selected.Bounds.Hide(); _selected = null; _state = _state & ~State.Selected; Debug.Print("_state: {0}", _state); }
private void Down(Vector2 p) { bool render = false; if (IsState(State.Selected)) { HideSelected(); render = true; } if (IsState(State.Hover)) { HideHover(); render = true; } _selected = Helper.HitTest(_canvas.Children, p.X, p.Y); if (_selected != null) { ShowSelected(); InitMove(p); _canvas.Capture(); render = true; } if (render) { _canvas.Render(null); } }
private void Reset() { bool render = false; if (_hover != null) { _hover.Bounds.Hide(); _hover = null; render = true; } if (_selected != null) { _selected.Bounds.Hide(); _selected = null; render = true; } _state = State.None; Debug.Print("_state: {0}", _state); if (render) { _canvas.Render(null); } }
private void HideHover() { _hover.Bounds.Hide(); _hover = null; _state = _state & ~State.Hover; Debug.Print("_state: {0}", _state); }
public void Render(INative context) { _panel.Invalidate(); }
public void Remove(INative value) { Children.Remove(value); }
public void Add(INative value) { Children.Add(value); }
internal static IElementsCollection <T> Create <T>(INative parent, Locator locator) where T : IElement, new() => new WebElementsCollection <T>(parent, locator);
private void Drag(Vector2 p) { if (_canvas.IsCaptured) { if (IsState(State.Move)) { Move(p); } } else { bool render = false; var result = Helper.HitTest(_canvas.Children, p.X, p.Y); if (IsState(State.Hover)) { if (IsState(State.Selected)) { if (_hover != _selected && _hover != result) { HideHover(); render = true; } else { return; } } else { if (result != _hover) { HideHover(); render = true; } else { return; } } } if (result != null) { if (IsState(State.Selected)) { if (result != _selected) { _hover = result; ShowHover(); render = true; } } else { _hover = result; ShowHover(); render = true; } } if (render) { _canvas.Render(null); } } }