creating C# xamarin.ios webview application - xamarin.ios

I am developing the iPhone app using WebView and need to use MVC razor view approach. How to include jQuery for the WebView?
Which version it supports?
What is the right location to store jQuery files in project?
What will be the code for this method
public override void ViewDidLoad ()
{
WebView.LoadHtmlString (page, NSBundle.MainBundle.BundleUrl);
}

Related

Load external Assembly (RCL) to Blazor WebAssembly app

It is possible to load a RCL (Razor Component Library) to Blazor WebAssembly dynamically?
I found this Loading an external .NET Standard 2.0 assembly with blazor to load a standard classes
What I want is to develop a pluggable/extensible visual framework, where putting a dll in a ASP.NET Core Server folder where enought to access to that blazor component
Solution config:
ASP.NET Core WebAPI project
Blazor WebAssembly project
RCL project 1 with some components
RCL project 2 with another components
Steps:
Open a Blazor Page and OnInitializedAsync() retreive some dll from WebAPI as binary
Load binary to Assembly
Reference the assembly and use it dynamically in the page
Sorry for the late answer, but yes, you can do that.
To use dynamic components, follow these steps:
Load the assemblies using the Assembly.LoadfFrom(assemblyFilename)
In a .razor file, use the blazor render tree builder to render your component dynamically, like this:
RenderFragment EditContent = (__builder) =>
{
__builder.OpenComponent(0, TypeOfYourComponent);
__builder.AddAttribute(1, "attr1", attrValue);
...
__builder.AddAttribute(n, "attrn", attrNValue);
__builder.CloseComponent();
};
#EditContent
Implement a method that returns the type you want from the currently loaded assemblies. The following will provide you a list with all types exported by dynamically loaded assemblies:
var exportedTypes = new List<Type>();
var assemblies = AppDomain.CurrentDomain.GetAssemblies().ToList();
foreach (var assembly in assemblies)
{
exportedTypes.AddRange(assembly.GetExportedTypes().ToList());
}
In my case, I created a singleton that loads the assemblies from a folder when it is initialized, and created a method in this singleton to return the type from the list defined on step 3. So, in this way, you can call this service whenever you like by registering it on the Startup.cs and injecting it on your razor components:
public class CustomComponentService : ICustomComponentService
{
public CustomComponentService(...)
{
// load the assemblies here
}
public Type GetCustomComponent(...)
{
//search in the loaded assemblies by any criteria you like
}
}
In the Startup.cs ConfigureServices method:
_ = services.AddSingleton<ICustomComponentService, CustomComponentService>();
In the razor file:
#inject ICustomComponentService CustomComponentService
...
__builder.OpenComponent(0, CustomComponentService.GetCustomComponent(...));
...
I finally develop a solution I want to share with you. A Module Manager witch allows you to load any outside component dynamically
Check it out here:
https://github.com/elgransan/BlazorPluginComponents
Some example code
var componentPackage = "RazorClassLibrary2";
var component = "Component2";
var stream = await Http.GetStreamAsync($"{MyNavigationManager.BaseUri}/{componentPackage}/{componentPackage}.dll");
var assembly = AssemblyLoadContext.Default.LoadFromStream(stream);
componentType = assembly.GetType(componentPackage + "." + component);
await DOMinterop.IncludeLink(componentPackage, $"/{componentPackage}/{componentPackage}.styles.css");
Where the files are in the server

Xamarin.Android Cannot pull table from Azure database in Android 10 Q

I did read that because lack of support for Netcore 2.1 the
myItemsList = await App.MobileServiceAndroid.GetTable<MyTable>().ToListAsync();
does not currently work on Android, and there is a workaround to pass an HttpClientHandler() in the constructor of the MobileServiceClient, and so I did like this:
public static MobileServiceClient MobileServiceAndroid =
new MobileServiceClient(AppConstants.AZURE_PRODUCTION_WEB_API_URL, new HttpClientHandler());
But this is incomplete,its still not working, what exactly do I have to do to make this work, any guidance is much appreciated.
From my understanding, you are using a Forms/PCL project whereas the other solution was implementing this code inside their Android project.
For you, once you add using Xamarin.Android.Net; to the class, you should be able to just do this:
public static MobileServiceClient MobileServiceAndroid =
new MobileServiceClient(AppConstants.AZURE_PRODUCTION_WEB_API_URL, new AndroidClientHandler());
Most likely you might have issues getting that using statement, for that you will have to follow steps shown here, or customized for you in the following steps:
Add the Xamarin Forms project to all your projects.
Create an interface ICustomClientHandler in the Core project
using System;
using System.Net.Http;
namespace Test
{
public interface ICustomClientHandler
{
HttpClientHandler GetHandler();
}
}
Then create a CustomClientHandler in the Droid project, which will be the Android part of the dependency service that will help you retrieve the native AndroidClientHandler
using System.Net.Http;
using Xamarin.Android.Net;
using System.Runtime.CompilerServices;
using Xamarin.Forms;
using Test;
[assembly: Xamarin.Forms.Dependency(typeof(Test.Droid.CustomClientHandler))]
namespace Test.Droid
{
public class CustomClientHandler : ICustomClientHandler
{
public HttpClientHandler GetHandler()
{
return new AndroidClientHandler();
}
}
}
Implement an iOS version as well in a similar way, but it will instead return new HttpClientHandler();
Finally, use the code as shown, in your Core project:
var clientHandler = DependencyService.Get<ICustomClientHandler>().GetHandler();
public static MobileServiceClient MobileServiceAndroid =
new MobileServiceClient(AppConstants.AZURE_PRODUCTION_WEB_API_URL, clientHandler);

Default instance(maybe static) of Messenger plugin like MVVM Light

Is there an equivalent in MVVMCross to MVVM Light's Messenger.Default instance(for standalone projects that don't comply with MVVM in Xamarin.iOS).
After looking at threads such as this, this, this
I decided to add the "MvvmCross Messenger" plugin to the PCL and iOS project. Thought I'd have to register the Hub and resolve it from the PCL and iOS projects with something like
// Registering in ViewDidLoad() of iOS project
Mvx.RegisterSingleton<IMvxMessenger>(new MvxMessengerHub());
// Try to resolve and subscribe in PCL and iOS project - both have nuget packages added
_messenger = Mvx.Resolve<IMvxMessenger> ();
_token = _messenger.SubscribeOnMainThread<MyMessage> ((message) => {
OutputLabel.Text = message.Number;
});
However I get a null reference exception right at Mvx.RegisterSingleton. Not too sure what I'm missing. All I'm looking for is the Messenger to function. Do not want any other part of MVVM in this project for now
In MvvmCross we made our messenger optional - so it's in a plugin.
If you want to use it standalone, then you can boot the plugin system using code like that shown in the CrossLight demos - see N=30 and N=39 in http://mvvmcross.blogspot.co.uk/ - and see the android-only demos in https://github.com/MvvmCross/MvvmCross-Tutorials/blob/master/CrossLight/PluginUse/NoBinding/Setup.cs
For iOS, you'll probably need some one-time init code something like:
if (MvxSimpleIoCContainer.Instance != null)
return;
var ioc = MvxSimpleIoCContainer.Initialize();
ioc.RegisterSingleton<IMvxTrace>(new MvxDebugOnlyTrace());
var manager = new MvxLoaderPluginManager();
var registry = new MvxLoaderPluginRegistry(".Touch", manager);
ioc.RegisterSingleton<IMvxPluginManager>(manager);
The code for the messenger itself is in: https://github.com/MvvmCross/MvvmCross/blob/v3.1/Plugins/Cirrious/Messenger/Cirrious.MvvmCross.Plugins.Messenger/MvxMessengerHub.cs
Alternatively... if you don't want Mvx code for binding, dispatcher, etc, then it's probably easier to just use something like the excellent TinyMessenger - https://github.com/grumpydev/TinyMessenger

WebActivator is not working with Orchard

I have current version of Orchard CMS 1.6.1 and WebActivator 2.0.1.
Default installation of Orchard. WebActivator PreApplicationStartMethod is not fired.
In the same solution I have sample MVC application and the same WebActivator code works fine.
What is wrong with Orchard app. Is it breaks standard ASP.NET pipeline?
Sample code (I've used both Pre and PostApplicationStartMethod):
[assembly: WebActivatorEx.PreApplicationStartMethod(typeof(Go2See.Web.App_Start.LocalizationServiceStarter), "PreStart")]
namespace Go2See.Web.App_Start
{
public static class LocalizationServiceStarter
{
public static void PreStart()
{
throw new ApplicationException("x");
}
}
}

Examples of EventKitUi or EventKit in Monotouch

I am new to app development, but have developed in .Net sense inception. I was wondering if someone has any examples of how to use the EventKitUI.
My goal is to have a calendar view in my app and then if they choose to add it to their calendar they can.
I also want to be able to link to pdf documents from the content of the event.
Do you mean something like this?
class Testclass{
public event EventHandler Clicked;
public Testclass{
}
public void FireEvent(){
if(Clicked!=null){
this.Clicked(this,new EventArgs());
}
} }

Resources