I saw the following code snippet
val settings = configuration.underlying.as[CookieSecretSettings]("silhouette.oauth1TokenSecretProvider")
I believe configuration is of type play.api.Configuration and underlying is of typeConfig` (https://www.playframework.com/documentation/2.6.x/api/scala/index.html#play.api.Configuration)
I copied the code in my Apploader (as I am using Compile Time Injection). The BuiltInComponentsFromContext has a configuration variable. I thought to use that as follows val config = configuration.underlying.as[CookieAuthenticatorSettings]("silhouette.authenticator") but the compiler cannot resolve as. What am I doing wrong?
The Config library seem to have asInstanceOf instead of as but I get other errors if I use that. I notice that the code for which as works uses play version 2.4.2 while I am using 2.6.12.
I realize this is an old question, but I stumbled upon this exact problem today and couldn't find anything helpful.
The as method is provided by a third-party library (Ficus) to read case classes and Scala types from Typesafe config. You need to include it in your build dependencies, then add to imports:
import net.ceedubs.ficus.Ficus._
import net.ceedubs.ficus.readers.ArbitraryTypeReader._
Related
Can someone tell me how to get protoc to generate dart files with a leading library directive?
I'm using the dart-protoc-plugin (v0.10.2) to generate my dart, c++, c#, js and java models from proto files. I was under the impression there was no way to get protoc to add a 'library' directive to the generated dart files, until I noticed the directive appearing in another project (see date.pb.dart).
If I take the same file (date.proto) I cannot get protoc to generate a dart file containing a 'library' directive.
In short: I want to take a .proto file with the following content
syntax = "proto3";
package another.proj.nspace;
message MyObj {
...
}
and produce a .dart file with a leading 'library' directive similar to the following snippet
///
// Generated code. Do not modify.
///
// ignore_for_file: non_constant_identifier_names,library_prefixes
library another.proj.nspace;
...
NOTE: I don't care about the actual value of the directive since I can restructure my code to get the desired result. I just need a way for protoc to add the library directive...
The basic command I'm using to generate the dart files is
protoc --proto_path=./ --dart_out="./" ./another/proj/nspace/date.proto
Unfortunately the dart-protoc-plugin's README isn't very helpful and I had to go through the source to find out which options are available; and currently it seems like the only dart-specific option is related to grpc.
I've tried options from the other languages (e.g. 'library', and 'basepath') without any success.
It would simplify my workflow quite a bit if this is possible, but I'm starting to get the impression that the library directive in date.pb.dart is added after the code was generated...
After asking around a little bit, it seems that the library directive was removed from the protoc plugin at some stage (see pull request), thus it is no longer supported.
I am trying to use ros::pluginlib to load a plugin called A_Plugin which has been registered to ROS Package System correctly. One thing to note is that A_Plugin depends on Opensplice DDS, and it need to link the DDS libraries "libddskernel.so" ,"libdcpsisocpp.so". In CmakeLists.txt file, I write like this:
```
add_library(A_Plugin
src/aplugin.cpp
)
target_link_libraries(A_Plugin
$ENV{OSPL_HOME}/lib/libddskernel.so
$ENV{OSPL_HOME}/lib/libdcpsisocpp.so
)
```
It can be registered to ROS package system correctly, but when I use pluginlib::ClassLoader to load A_plugin, I got the following errors:terminate called after throwing an instance of 'pluginlib::CreateClassException'what(): MultiLibraryClassLoader: Could not create object of class type test::A_Plugin as no factory exists for it. Make sure that the library exists and was explicitly loaded through MultiLibraryClassLoader::loadLibrary(). How can I solve this problem? Thanks!
I had a similar problem, turns out I was missing the plugin class declaration in the *.cpp file. I included it and it worked fine. The declaration should be something like:
PLUGINLIB_DECLARE_CLASS(rqt_example_cpp, MyPlugin, rqt_example_cpp::MyPlugin, rqt_gui_cpp::Plugin)
This can be seen in the example from the rqt tutorial github repo, line 62:
https://github.com/lucasw/rqt_mypkg/blob/master/rqt_example_cpp/src/rqt_example_cpp/my_plugin.cpp
I am developing an app using Angular 2 and Ionic. I am using a bluetooth library for Cordova, so not writing using ES6-modules and exports.
The library defines a global variable called 'bluetoothle', and it works as expected when I run it. However, I get a lot of complaints from the typescript compiler. I would like to either:
(Preferred) Have some better way to import the ES5-library to my typescript-project.
Tell the compiler to ignore this error.
Declare the variable, and then let the library assign value to it(however, I don't know how to declare globals in typescript the way it was possible in ES6.
Thanks in advance,
Markus
You have two options there which depend on how much work you want to put in them.
The first and easy option is to just declare the variable at the top. This will tell TypeScript that this is a variable of type any and that it doesn't need to care about where it came from or which members it has:
declare var bluetoothle;
The other route, which would be cleaner but is way more work is writing a type definition file.
I'm currently playing with the Dart version of Angular 2.
I have seen that the library is using a lot of Metadata as #Component for example.
I would like to know how are those directives working?
I went on http://www.darlang.org. They explain how to define an annotation but not how to use it to construct an object as it is done in angular.io.
Could someone explain how the magic is working?
In Dart annotations by itself don't do anything than exist beside the code element where they are added.
At runtime:
You can use dart:mirrors to query the imported libraries for elements like fields, functions, classes, parameters, ... for these annotations.
dart:mirrors is discouraged for browser applications. In this case you can use the reflectable package with quite similar capabilities.
See also:
https://www.dartlang.org/articles/reflection-with-mirrors/
https://api.dartlang.org/1.14.1/dart-mirrors/dart-mirrors-library.html
https://stackoverflow.com/search?q=%5Bdart-mirrors%5D+annotations
At buildtime
You can create a transformer and register it in pubspec.yaml to be run by pub serve and pub build.
In this case the Dart analyzer can be utilized to query the source files for annotations and, like Angular does, modify the source code in a build step to add/replace/remove arbitrary code.
For more details about transformers
- https://www.dartlang.org/tools/pub/assets-and-transformers.html
- https://www.dartlang.org/tools/pub/transformers/
- https://www.dartlang.org/tools/pub/transformers/examples/
- https://www.dartlang.org/tools/pub/transformers/aggregate.html
- https://pub.dartlang.org/packages/code_transformers
Many of the samples I have seen for angular2 have the following import statement:
import {bind} from 'angular2/di';
I am working in VS Code (with TypeScript) and it complains about not being able to find the angular2/di module.
However I do see a bind function defined in angular2/angular2.d.ts. If I change the import statement to the following, then the error goes away.
import {bind} from 'angular2/angular2';
Is the question in the title off-base and I am making some erroneous assumption?
If not, why do many samples reference one module to import the bind function from, yet I seem to be able to get it from a different module?
Most likely because you looked at versions from older alphas. Look at the angular2.ts file. Everything is exported from it. Also note that the d.ts is going to contain everything to resolve types in your IDE and at compilation time. What import does is actually importing the .js files.