Using .Net Micro Framework, how do I get the value of "socket_id" out of the following string:
{"event":"pusher:connection_established","data":"{"socket_id":"2475.1248660"}"}
It's not exactly getting a substring, but have you considered using the netduino Helpers library. It has some lightweight helpers for .NET MF (including a JSON parser).
Related
I've recently switched jobs from a AWS shop to an Azure shop, both using dotnet. AWS publishes Amazon.Lambda.AspNetCoreServer, which is a magic Nuget package that allows you to write a plain ol' ASP.NET core Web API and deploy it as into a lambda with only a few lines on config. I really loved this pattern because it allows developers to just write a normal web api without having the host runtime leak into their coding.
Does anything like this exist in Azure? Even something that is community supported? Or is there some any way to achieve something like this in Azure Functions?
Unfortunately there is no simple way to do that since Azure function format is a bit different.
[FunctionName(nameof(GetAll))]
public IActionResult GetAll([HttpTrigger("get", Route = "entity")]HttpRequest request)
Then it will generate json with meta data for AF.
If you wish to host pure .net core without any changes I would look into Containers option
PS0: Theoretically it would be possible to do it with little bit of reflection. For instance you create project with all your Asp.Net core apis, which you can use in asp.net core hosting. Then you write tool which grabs your dll and using reflection you find all actions in your controllers and generate code for AF
PS1: Have a look https://github.com/tntwist/NL.Serverless.AspNetCore
I have a cross platform (iOS, watchOS and macOS) app. So I created a framework in Xcode and put the share files, the source code that works in all platform, into the framework.
Then I translated them. The app works fine. The only issue is that the translated string resources in the framework are never used by the app.
If I copy the content of the string resources out of the framework and insert them in to the app's string resources, it works. But I don't think it is a good idea to do things in that way.
Any idea on how to making the app use the string resources in the framework directly?
Is this on purpose or it is a bug that I should file to Apple?
Xcode 9.1 (9B55), macOS High Sierra 10.13.1 (17B48)
Swift 4.0.2
A sample project can be found here. https://www.dropbox.com/s/c6bdp28rmk9rxii/Framework%20Translation%20Issue.zip?dl=0
It turns out that NSLocalizedString in a framework must tell the bundle of the framework explicitly. Or the app that calls the framework will use main bundle to find the localization resources.
NSLocalizedString("Test", tableName: nil, bundle: bundle, comment: "Test")
You can use either init(for: AnyClass) or allFrameworks: [Bundle] with a filter to get the framework's bundle.
You must not use the id of the bundle directly, unless your are sure it is only fixed to one platform and won't be changed in future.
I am developing an API in WebApi (current version 2017), which is using Antaris Razor engine 3.10. Today's current non-beta version.
A concern was raised that the "Razor engine is powerful" and could make a REST call. Is this possible?
I understood it to be a templating engine. Is it possible that during the compilation stage or the run stage that the engine could make a REST call?
I am not rendering the end result of the template in the browser. It is used only to format a JSON/XMl string content to post to a subsequent REST call in the compiled C# API that I am building.
Does the Antaris Razor Engine have the ability to make a REST call internally?
The answer is yes. The Antaris Razor Engine can make a REST call during the run stage.
It is essentially able to run .Net code. It does more than data binding and token replacement. It joins a model to your template and runs any .Net code you can get to compile.
Some things are slightly more difficult to use, for instance, an implicit conversion to a string doesn't really work. I found .ToString() is required to be called where it may not be if you were writing in Visual Studio. Also, null checking sometimes throws an Object Reference error, even when done as recommended by the project. I found deserializing the object model to a dynamic made null checking more reliable.
All in all, it is a great project, with a ton of power. A little quirkiness won't stop me from using it.
I have a written a sample project in which i have created an index using SOLR.NET (.NET Wrapper Java Based SOLR)
I want to remove the dependency of Java. So i am trying Lucene.NET.
Now is it possible to re-use the same indexed data (Created with SOLR.NET & SOLR) and perform searches / updates to that index data using LUCENE.NET?
Environment: VS2013, C#, .NET Framework 4.0, WinForms
The Lucene codec format evolves over time, and most alternative Lucene implementation are only compatible with a specific range of versions. So the answer is "it depends, but probably not". You'd have to try to read the segment files present in your Solr installation with Lucene.NET instead.
Remember that this moves Solr from being a distributed dependency (running as a separate server) to an in-process dependency instead - requiring you to write your own service on top of Lucene.NET if you want to keep it distributed.
As you've just written a sample project, drop everything you've indexed and re-index with your own code for Lucene.NET instead.
As I code I want to share across both (App Insights, REST API Calls..) I am trying to figure out what type of project to make. At first I was looking at Portable Class Libraries but they seem to be for the past and not for UWP/.NET core.
When you use a Portable Class Library type, you can select the supported targets.