public CentralContext(IServiceProvider services, BleCentralConfiguration config) { this.services = services; var opts = new CBCentralInitOptions { ShowPowerAlert = config.iOSShowPowerAlert }; if (!config.iOSRestoreIdentifier.IsEmpty()) { opts.RestoreIdentifier = config.iOSRestoreIdentifier; } if (!PlatformExtensions.HasPlistValue("NSBluetoothPeripheralUsageDescription")) { Console.WriteLine("NSBluetoothPeripheralUsageDescription needs to be set - you will likely experience a native crash after this log"); } if (!PlatformExtensions.HasPlistValue("NSBluetoothAlwaysUsageDescription", 13)) { Console.WriteLine("NSBluetoothAlwaysUsageDescription needs to be set - you will likely experience a native crash after this log"); } this.Manager = new CBCentralManager(this, null, opts); }
protected override bool LoadInternal() { RegisterMembers(BindingServiceProvider.MemberProvider); #if !APPCOMPAT if (!PlatformExtensions.IsApiGreaterThanOrEqualTo17) { return(false); } #endif var isActionBar = PlatformExtensions.IsActionBar; var isFragment = PlatformExtensions.IsFragment; var tabChangedDelegate = TabHostItemsSourceGenerator.TabChangedDelegate; var removeTabDelegate = TabHostItemsSourceGenerator.RemoveTabDelegate; PlatformExtensions.IsActionBar = o => isActionBar(o) || o is ActionBar; PlatformExtensions.IsFragment = o => isFragment(o) || o is Fragment; PlatformExtensions.AddContentViewManager(new FragmentContentViewManager()); TabHostItemsSourceGenerator.RemoveTabDelegate = (generator, info) => OnRemoveTab(removeTabDelegate, generator, info); TabHostItemsSourceGenerator.TabChangedDelegate = (generator, o, arg3, arg4, arg5) => OnTabChanged(tabChangedDelegate, generator, o, arg3, arg4, arg5); TypeCache <Fragment> .Initialize(null); return(true); }
private static void UpdateContent(ViewGroup sender, object newContent, object[] args) { if (newContent == null && args == RemoveViewValue) { return; } //NOTE cheking if it's a view group listener. if (args != null && args.Length == 2 && args[1] == AddViewValue) { return; } var templateId = sender.GetBindingMemberValue(AttachedMembers.ViewGroup.ContentTemplate); var templateSelector = sender.GetBindingMemberValue(AttachedMembers.ViewGroup.ContentTemplateSelector); newContent = PlatformExtensions.GetContentView(sender, sender.Context, newContent, templateId, templateSelector); var contentViewManager = sender.GetBindingMemberValue(AttachedMembers.ViewGroup.ContentViewManager); if (contentViewManager == null) { PlatformExtensions.SetContentView(sender, newContent); } else { contentViewManager.SetContent(sender, newContent); } }
private object FindComponent(string name) { if (DesignMode) { var container = Site.Container; if (container == null) { return(null); } for (int i = 0; i < container.Components.Count; i++) { var cmp = container.Components[i]; if (PlatformExtensions.TryGetValue(cmp, "Name") == name) { return(cmp); } } return(null); } var containerControl = ContainerControl; if (containerControl == null || containerControl.Name == name) { return(containerControl); } var field = _containerControlType.GetFieldEx(name, MemberFlags.Public | MemberFlags.NonPublic | MemberFlags.Instance); if (field == null) { return(BindingServiceProvider.VisualTreeManager.FindByName(containerControl, name)); } return(field.GetValueEx <object>(containerControl)); }
protected WindowsPhoneBootstrapperBase([NotNull] PhoneApplicationFrame rootFrame, PlatformInfo platform = null) { Should.NotBeNull(rootFrame, "rootFrame"); _rootFrame = rootFrame; _platform = platform ?? PlatformExtensions.GetPlatformInfo(); PhoneApplicationService.Current.Launching += OnLaunching; }
/// <summary> /// Initializes a new instance of the <see cref="WinFormsBootstrapperBase" /> class. /// </summary> protected WinFormsBootstrapperBase(bool autoRunApplication = true) { _autoRunApplication = autoRunApplication; _platform = PlatformExtensions.GetPlatformInfo(); ShutdownOnMainViewModelClose = autoRunApplication; DynamicViewModelNavigationPresenter.CanShowViewModelDefault = (model, context, arg3) => false; }
public virtual void Inflate(int menuRes, IMenu menu, object parent) { using (XmlReader reader = _context.Resources.GetLayout(menuRes)) { //NOTE XDocument throws an error. var document = new XmlDocument(); document.Load(reader); if (IsDefaultMenu(document)) { MenuInflater menuInflater = NestedMenuInflater; if (menuInflater == null) { base.Inflate(menuRes, menu); } else { menuInflater.Inflate(menuRes, menu); } } else { using (var stringReader = new StringReader(PlatformExtensions.XmlTagsToUpper(document.InnerXml))) { var menuWrapper = (MenuTemplate)Serializer.Deserialize(stringReader); menuWrapper.Apply(menu, _context, parent); } } } }
public ManagerContext(IServiceProvider services, BleConfiguration config, ILogger <IBleManager> logger) { this.Services = services; this.logger = logger; this.managerLazy = new Lazy <CBCentralManager>(() => { if (!PlatformExtensions.HasPlistValue("NSBluetoothPeripheralUsageDescription")) { this.logger.LogCritical("NSBluetoothPeripheralUsageDescription needs to be set - you will likely experience a native crash after this log"); } var background = services.GetService(typeof(IBleDelegate)) != null; if (!background) { return(new CBCentralManager(this, null)); } if (!PlatformExtensions.HasPlistValue("NSBluetoothAlwaysUsageDescription", 13)) { this.logger.LogCritical("NSBluetoothAlwaysUsageDescription needs to be set - you will likely experience a native crash after this log"); } var opts = new CBCentralInitOptions { ShowPowerAlert = config.iOSShowPowerAlert, RestoreIdentifier = config.iOSRestoreIdentifier ?? "shinyble" }; return(new CBCentralManager(this, null, opts)); }); }
protected WpfBootstrapperBase([NotNull] Application application, bool autoStart = true, PlatformInfo platform = null) { Should.NotBeNull(application, nameof(application)); _platform = platform ?? PlatformExtensions.GetPlatformInfo(); application.Startup += ApplicationOnStartup; AutoStart = autoStart; }
/// <summary> /// Tries to restore view controller. /// </summary> public virtual UIViewController GetViewController(string[] restorationIdentifierComponents, NSCoder coder, IDataContext context = null) { string id = restorationIdentifierComponents.LastOrDefault(); Type type = PlatformExtensions.GetTypeFromRestorationIdentifier(id); if (type == null) { return(null); } UIViewController controller = null; Func <Type, NSCoder, IDataContext, UIViewController> factory = ViewControllerFactory; if (factory != null) { controller = factory(type, coder, context); } if (controller == null) { if (type == typeof(MvvmNavigationController)) { controller = new MvvmNavigationController(); } else { controller = (UIViewController)ServiceProvider.IocContainer.Get(type); } } controller.RestorationIdentifier = id; return(controller); }
private void SetIndicator(TabHost.TabSpec tabSpec, object item) { (item as IViewModel)?.Settings.Metadata.AddOrUpdate(ViewModelConstants.StateNotNeeded, true); var templateId = _itemTemplateProvider.GetTemplateId(); var selector = _itemTemplateProvider.GetDataTemplateSelector(); if (templateId == null && selector == null) { selector = EmptyTemplateSelector.Instance; } object content = PlatformExtensions.GetContentView(TabHost, TabHost.Context, item, templateId, selector); if (content == EmptyTemplateSelector.EmptyView) { content = null; if (item is IHasDisplayName) { BindingServiceProvider.BindingProvider.CreateBindingsFromString(tabSpec, "Title DisplayName", null); } else { tabSpec.SetIndicator(item.ToStringSafe("(null)")); } } var view = content as View; if (view == null) { tabSpec.SetIndicator(content.ToStringSafe("(null)")); } else { tabSpec.SetIndicator(view); } }
/// <summary> /// Initializes a new instance of the <see cref="WinRTBootstrapperBase" /> class. /// </summary> protected WinRTBootstrapperBase([NotNull] Frame rootFrame, bool overrideAssemblies) { Should.NotBeNull(rootFrame, "rootFrame"); _rootFrame = rootFrame; _overrideAssemblies = overrideAssemblies; _platform = PlatformExtensions.GetPlatformInfo(); }
protected TouchBootstrapperBase([NotNull] UIWindow window, PlatformInfo platform = null) { Should.NotBeNull(window, nameof(window)); _window = window; _platform = platform ?? PlatformExtensions.GetPlatformInfo(); WrapToNavigationController = true; }
public void Apply(IMenu menu, Context context, object parent) { PlatformExtensions.ValidateTemplate(ItemsSource, Items); var setter = new XmlPropertySetter <IMenu>(menu, context, new BindingSet()); menu.SetBindingMemberValue(AttachedMembers.Object.Parent, parent); setter.SetBinding(nameof(DataContext), DataContext, false); setter.SetBoolProperty(nameof(IsVisible), IsVisible); setter.SetBoolProperty(nameof(IsEnabled), IsEnabled); if (!string.IsNullOrEmpty(Bind)) { setter.BindingSet.BindFromExpression(menu, Bind); } if (string.IsNullOrEmpty(ItemsSource)) { if (Items != null) { for (int index = 0; index < Items.Count; index++) { Items[index].Apply(menu, context, index, index); } } } else { menu.SetBindingMemberValue(AttachedMembers.Menu.ItemsSourceGenerator, new MenuItemsSourceGenerator(menu, context, ItemTemplate)); setter.SetBinding(nameof(ItemsSource), ItemsSource, true); } setter.Apply(); }
private bool AddCompleteItem(IComponent result, out string name, out Type type) { type = null; name = null; try { if (result is Binder) { return(false); } name = PlatformExtensions.GetComponentName(result); if (string.IsNullOrWhiteSpace(name)) { return(false); } type = result.GetType(); SortedDictionary <string, AutoCompleteItem> completeItems; if (!_controlsDictionary.TryGetValue(name, out completeItems)) { completeItems = new SortedDictionary <string, AutoCompleteItem>(StringComparer.CurrentCulture); _controlsDictionary[name] = completeItems; } AddCompleteItems(type, completeItems); _controlsCompleteItems.Add(new AutoCompleteItem(string.Format("{0} ({1})", name, type.Name), name)); } catch (Exception) { return(false); } return(true); }
public void Apply(IMenu menu, Context context, object parent) { PlatformExtensions.ValidateTemplate(ItemsSource, Items); var setter = new XmlPropertySetter <MenuTemplate, IMenu>(menu, context, new BindingSet()); BindingExtensions.AttachedParentMember.SetValue(menu, parent); setter.SetBinding(template => template.DataContext, DataContext, false); setter.SetBoolProperty(template => template.IsVisible, IsVisible); setter.SetBoolProperty(template => template.IsEnabled, IsEnabled); if (string.IsNullOrEmpty(ItemsSource)) { if (Items != null) { for (int index = 0; index < Items.Count; index++) { Items[index].Apply(menu, context, index, index); } } } else { MenuItemsSourceGenerator.Set(menu, context, ItemTemplate); setter.SetBinding(template => template.ItemsSource, ItemsSource, true); } setter.Apply(); }
public void OnActivityDestroyed(Activity activity) { if (IsAlive() && !(activity is IActivityView)) { PlatformExtensions.SetCurrentActivity(activity, true); } }
public override void OnDestroy(Action baseOnDestroy) { if (Tracer.TraceInformation) { Tracer.Info("OnDestroy activity({0})", Target); } ServiceProvider.EventAggregator.Unsubscribe(this); var handler = Destroyed; if (handler != null) { handler(Target, EventArgs.Empty); } _view.RemoveFromParent(); if (_attachedViews == null) { _view.ClearBindingsRecursively(true, true); } else { CleanupItems(); } _view = null; if (_metadata != null) { _metadata.Clear(); _metadata = null; } MenuTemplate.Clear(_menu); _menu = null; if (_menuInflater != null) { _menuInflater.Dispose(); _menuInflater = null; } if (_layoutInflater != null) { _layoutInflater.Dispose(); _layoutInflater = null; } base.OnDestroy(baseOnDestroy); PlatformExtensions.SetCurrentActivity(Target, true); Target.ClearBindings(false, true); OptionsItemSelected = null; ConfigurationChanged = null; PostCreate = null; BackPressing = null; Created = null; Started = null; Paused = null; SaveInstanceState = null; Stoped = null; Restarted = null; Resume = null; Destroyed = null; }
public virtual void ViewWillAppear(Action <bool> baseViewWillAppear, bool animated) { baseViewWillAppear(animated); var viewController = ViewController; if (viewController != null && !_isAppeared) { if (viewController.View != null) { ParentObserver.Raise(viewController.View, true); } UINavigationItem navigationItem = viewController.NavigationItem; if (navigationItem != null) { SetParent(navigationItem, viewController); SetParent(navigationItem.LeftBarButtonItem, viewController); SetParent(navigationItem.LeftBarButtonItems, viewController); SetParent(navigationItem.RightBarButtonItem, viewController); SetParent(navigationItem.RightBarButtonItems, viewController); } SetParent(viewController.EditButtonItem, viewController); SetParent(viewController.ToolbarItems, viewController); var dialogViewController = viewController as DialogViewController; if (dialogViewController != null) { SetParent(dialogViewController.Root, viewController); } var viewControllers = viewController.ChildViewControllers; foreach (var controller in viewControllers) { controller.TryRaiseAttachedEvent(AttachedMembers.Object.Parent); } var tabBarController = viewController as UITabBarController; if (tabBarController == null) { var splitViewController = viewController as UISplitViewController; viewControllers = splitViewController == null ? null : splitViewController.ViewControllers; } else { viewControllers = tabBarController.ViewControllers; } if (viewControllers != null) { foreach (var controller in viewControllers) { controller.TryRaiseAttachedEvent(AttachedMembers.Object.Parent); PlatformExtensions.SetHasState(controller, false); } } viewController.TryRaiseAttachedEvent(AttachedMembers.Object.Parent); _isAppeared = true; } Raise(ViewWillAppearHandler, animated); }
private void RaiseNew(Activity activity) { if (IsAlive() && !(activity is IActivityView) && _service.CurrentContent != activity) { PlatformExtensions.SetCurrentActivity(activity, false); _service.RaiseNavigated(activity, NavigationMode.New, null); } }
public virtual void OnViewCreated(View view, Bundle savedInstanceState, Action <View, Bundle> baseOnViewCreated) { if (!(Target is DialogFragment)) { PlatformExtensions.NotifyActivityAttached(Target.Activity, view); } baseOnViewCreated(view, savedInstanceState); }
public ErrorButton(BindingErrorProvider errorProvider, UITextField textField) : base(new CGRect(0, 0, 25, 25)) { _errorProvider = errorProvider; _textFieldHandle = textField.Handle; TouchUpInside += OnTouchUpInside; PlatformExtensions.AddOrientationChangeListener(this); }
protected SilverlightBootstrapperBase([NotNull] Application application, bool autoStart = true, PlatformInfo platform = null) { Should.NotBeNull(application, "application"); _application = application; _platform = platform ?? PlatformExtensions.GetPlatformInfo(); AutoStart = autoStart; application.Startup += ApplicationOnStartup; }
/// <summary> /// Initializes a new instance of the <see cref="WpfBootstrapperBase" /> class. /// </summary> protected WpfBootstrapperBase([NotNull] Application application, bool autoStart = true) { Should.NotBeNull(application, "application"); if (autoStart) { application.Startup += ApplicationOnStartup; } _platform = PlatformExtensions.GetPlatformInfo(); }
protected bool TryUpdateItems(NotifyCollectionChangedEventArgs args) { var tableView = TableView; if (tableView == null) { return(false); } switch (args.Action) { case NotifyCollectionChangedAction.Add: NSIndexPath[] newIndexPaths = PlatformExtensions.CreateNSIndexPathArray(args.NewStartingIndex, args.NewItems.Count); tableView.BeginUpdates(); tableView.InsertRows(newIndexPaths, AddAnimation); tableView.EndUpdates(); newIndexPaths.DisposeEx(); return(true); case NotifyCollectionChangedAction.Remove: NSIndexPath[] oldIndexPaths = PlatformExtensions.CreateNSIndexPathArray(args.OldStartingIndex, args.OldItems.Count); tableView.BeginUpdates(); tableView.DeleteRows(oldIndexPaths, RemoveAnimation); tableView.EndUpdates(); oldIndexPaths.DisposeEx(); return(true); case NotifyCollectionChangedAction.Move: if (args.NewItems.Count != 1 && args.OldItems.Count != 1) { return(false); } NSIndexPath oldIndexPath = NSIndexPath.FromRowSection(args.OldStartingIndex, 0); NSIndexPath newIndexPath = NSIndexPath.FromRowSection(args.NewStartingIndex, 0); tableView.BeginUpdates(); tableView.MoveRow(oldIndexPath, newIndexPath); tableView.EndUpdates(); oldIndexPath.Dispose(); newIndexPath.Dispose(); return(true); case NotifyCollectionChangedAction.Replace: if (args.NewItems.Count != args.OldItems.Count) { return(false); } NSIndexPath indexPath = NSIndexPath.FromRowSection(args.NewStartingIndex, 0); tableView.BeginUpdates(); tableView.ReloadRows(new[] { indexPath }, ReplaceAnimation); tableView.EndUpdates(); indexPath.Dispose(); return(true); default: return(false); } }
public static void Reset() { foreach (var rawSerializeType in HasSerializeFn.ToArray()) { Reset(rawSerializeType); } foreach (var rawSerializeType in HasIncludeDefaultValue.ToArray()) { Reset(rawSerializeType); } foreach (var uniqueType in __uniqueTypes.ToArray()) { Reset(uniqueType); } sModelFactory = ReflectionExtensions.GetConstructorMethodToCache; sTryToParsePrimitiveTypeValues = null; sTryToParseNumericType = null; sConvertObjectTypesIntoStringDictionary = null; sIncludeNullValues = null; sExcludeTypeInfo = null; sEmitCamelCaseNames = null; sEmitLowercaseUnderscoreNames = null; sDateHandler = null; sTimeSpanHandler = null; sPreferInterfaces = null; sThrowOnDeserializationError = null; sTypeAttr = null; sJsonTypeAttrInObject = null; sJsvTypeAttrInObject = null; sTypeWriter = null; sTypeFinder = null; sTreatEnumAsInteger = null; sAlwaysUseUtc = null; sAssumeUtc = null; sAppendUtcOffset = null; sEscapeUnicode = null; sIncludePublicFields = null; sReuseStringBuffer = null; HasSerializeFn = new HashSet <Type>(); HasIncludeDefaultValue = new HashSet <Type>(); TreatValueAsRefTypes = new HashSet <Type> { typeof(KeyValuePair <,>) }; sPropertyConvention = null; sExcludePropertyReferences = null; sExcludeTypes = new HashSet <Type> { typeof(Stream) }; __uniqueTypes = new HashSet <Type>(); sMaxDepth = 50; sParsePrimitiveIntegerTypes = null; sParsePrimitiveFloatingPointTypes = null; PlatformExtensions.ClearRuntimeAttributes(); ReflectionExtensions.Reset(); JsState.Reset(); }
public void Apply(Activity activity) { PlatformExtensions.ValidateTemplate(ItemsSource, Tabs); var actionBar = activity.GetActionBar(); var setter = new XmlPropertySetter <ActionBarTemplate, ActionBar>(actionBar, activity, new BindingSet()); setter.SetEnumProperty <ActionBarNavigationMode>(template => template.NavigationMode, NavigationMode); setter.SetProperty(template => template.DataContext, DataContext); setter.SetProperty(template => template.ContextActionBarTemplate, ContextActionBarTemplate); setter.SetBinding(template => template.ContextActionBarVisible, ContextActionBarVisible, false); setter.SetProperty(template => template.BackgroundDrawable, BackgroundDrawable); setter.SetProperty(template => template.CustomView, CustomView); setter.SetEnumProperty <ActionBarDisplayOptions>(template => template.DisplayOptions, DisplayOptions); setter.SetBoolProperty(template => template.DisplayHomeAsUpEnabled, DisplayHomeAsUpEnabled); setter.SetBoolProperty(template => template.DisplayShowCustomEnabled, DisplayShowCustomEnabled); setter.SetBoolProperty(template => template.DisplayShowHomeEnabled, DisplayShowHomeEnabled); setter.SetBoolProperty(template => template.DisplayShowTitleEnabled, DisplayShowTitleEnabled); setter.SetBoolProperty(template => template.DisplayUseLogoEnabled, DisplayUseLogoEnabled); setter.SetBoolProperty(template => template.HomeButtonEnabled, HomeButtonEnabled); setter.SetProperty(template => template.Icon, Icon); setter.SetProperty(template => template.Logo, Logo); setter.SetProperty(template => template.SplitBackgroundDrawable, SplitBackgroundDrawable); setter.SetProperty(template => template.StackedBackgroundDrawable, StackedBackgroundDrawable); setter.SetBoolProperty(template => template.IsShowing, IsShowing); setter.SetStringProperty(template => template.Subtitle, Subtitle); setter.SetStringProperty(template => template.Title, Title); setter.SetBoolProperty(template => template.Visible, Visible); setter.SetBinding("HomeButton.Click", HomeButtonClick, false); if (string.IsNullOrEmpty(ItemsSource)) { if (Tabs != null) { ActionBar.Tab firstTab = null; for (int index = 0; index < Tabs.Count; index++) { var tab = Tabs[index].CreateTab(actionBar); if (firstTab == null) { firstTab = tab; } actionBar.AddTab(tab); } TryRestoreSelectedIndex(activity, actionBar); } } else { ActionBarTabItemsSourceGenerator.Set(actionBar, TabTemplate); setter.SetBinding(template => template.ItemsSource, ItemsSource, false); } setter.SetBinding(template => template.SelectedItem, SelectedItem, false); setter.Apply(); }
private static object FindByNameControlMember(IBindingMemberInfo bindingMemberInfo, Control control, object[] arg3) { var root = PlatformExtensions.GetRootControl(control); if (root != null) { control = root; } return(control.Controls.Find((string)arg3[0], true).FirstOrDefault()); }
private void ClearView() { if (_view != null) { _view.ClearBindingsRecursively(true, true, PlatformExtensions.AggressiveViewCleanup); _view.RemoveFromParent(); _view = null; PlatformExtensions.CleanupWeakReferences(false); } }
public virtual void Dispose() { TaskCompletionSource.TrySetResult(null); View.RemoveFromSuperview(); View.ClearBindingsRecursively(true, true); View.DisposeEx(); PlatformExtensions.RemoveOrientationChangeListener(this); ServiceProvider.AttachedValueProvider.Clear(this); _label = null; }