I am trying to check if map centre is inside a polygon or not. My code for creating mulitple polygons on map is this:
for (int i = 0; i < Constant.arr_zone.size(); i++) {
LatLngBounds.Builder builder = new LatLngBounds.Builder();
ArrayList<LatLng> list = new ArrayList<>();
for (int j = 0; j < Constant.arr_zone.get(i).polygon.length; j++) {
list.add(new LatLng(Constant.arr_zone.get(i).polygon[j].geo_x,
Constant.arr_zone.get(i).polygon[j].geo_y));
builder.include(list.get(j));
}
polygonOptions = new PolygonOptions();
polygonOptions.addAll(list);
polygonOptions.strokeColor(R.color.theme_color);
polygonOptions.strokeWidth(2);
polygonOptions.fillColor(Color.parseColor("#33000040"));
Polygon polygon = mMap.addPolygon(polygonOptions);
ltbounds = builder.build();
arr_ltlngbounds.add(ltbounds);
}
Next I am checking if map center is inside any polygon or not
map.setOnCameraChangeListener(new OnCameraChangeListener() {
#Override
public void onCameraChange(CameraPosition cameraPosition) {
if (arr_ltlngbounds != null && arr_ltlngbounds.size() > 0) {
for (LatLngBounds l : arr_ltlngbounds) {
if (l.contains(mMap.getCameraPosition().target)) {
snackbar = Snackbar
.make(inflatedView, "Service available here", Snackbar.LENGTH_INDEFINITE)
.setAction("GET", new View.OnClickListener() {
#Override
public void onClick(View view) {
String arr[] = {user_location.latitude + "", user_location.longitude + "", "4"};
new Get_service(activity, A.this, get_service).execute(arr);
}
});
snackbar.show();
break;
}
}
}
}
});
This is my build.gradle just incase
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "22.0.1"
defaultConfig {
multiDexEnabled true
applicationId "com.aaa.bbb"
minSdkVersion 14
targetSdkVersion 23
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
dependencies {
compile project(':library')
compile 'com.android.support:appcompat-v7:23.1.0'
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:design:23.2.0'
compile 'com.android.support:recyclerview-v7:23.1.0'
compile 'com.newrelic.agent.android:android-agent:5.3.1'
compile 'com.github.bumptech.glide:glide:3.6.1'
compile 'com.android.support:cardview-v7:23.1.0'
compile 'com.github.jaydeepw:poly-picker:v1.0.22'
compile 'com.xgc1986.android:parallaxpagertransformer:1.0.3'
compile 'com.google.code.gson:gson:2.6.2'
compile 'me.dm7.barcodescanner:zxing:1.8.4'
compile 'com.github.castorflex.smoothprogressbar:library:1.0.0'
compile 'com.github.clans:fab:1.6.2'
compile 'com.google.android.gms:play-services:8.3.0'
compile 'com.google.maps.android:android-maps-utils:0.4+'
compile('com.google.api-client:google-api-client-android:1.20.0') {
exclude group: 'org.apache.httpcomponents'
}
compile('com.google.apis:google-api-services-drive:v3-rev6-1.20.0') {
exclude group: 'org.apache.httpcomponents'
}
}
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath "com.newrelic.agent.android:agent-gradle-plugin:5.3.1"
}
}
repositories {
mavenCentral()
// for downloading polypicker dependency cwac-camera
maven {
url "https://repo.commonsware.com.s3.amazonaws.com"
}
// for downloading poly-picker now we are using jitpack.
// Goodbye Maven Central
maven {
url "https://jitpack.io"
}
}
apply plugin: 'android'
apply plugin: 'newrelic'
dependencies {
compile 'com.android.support:support-v4:22.2.1'
}
android {
useLibrary 'org.apache.http.legacy'
}
The problem about this implementation is, it still shows snackbar (that latlng is inside bounds) even if latlng is outside bounds up to a certain level like there is some buffer area where it will still detect the latlng. I want it to be precise. How can I rectify this?
You can use the PolyUtil.containsLocation method from the Google Maps Android API Utility Library to check if a given location lies inside a polygon represented by a List<LatLng> instead of just checking if the location is in the boundary.
Example:
// Construct a List<LatLng> representing a Polygon
List<LatLng> polygon = new ArrayList<>();
polygon.add(new LatLng(3,0));
polygon.add(new LatLng(3,3));
polygon.add(new LatLng(0,3));
polygon.add(new LatLng(3,0));
// Find the LatLngBounds of the Polygon
LatLngBounds.Builder builder = new LatLngBounds.Builder();
for (LatLng point : polygon) {
builder.include(point);
}
LatLng test = new LatLng(1,1);
boolean isInsideBoundary = builder.build().contains(test); // true as the test point is inside the boundary
boolean isInside = PolyUtil.containsLocation(test, polygon, true); // false as the test point is outside the polygon
Related
I wanted to hook some functions from instagram apk using frida, decompiled the apk with
jadx/JEB, one of the functions I wanted to hook was in this:
public static void A00(HGf arg8, I1Y arg9) {
arg8.A0P();
Boolean v0 = arg9.A0v;
if(v0 != null) {
arg8.A0l("about_your_account_bloks_entrypoint_enabled", v0.booleanValue());
}
//some other code here
}
Tried to hook the function with this frida script:
try {
//
let I1X = Java.use("X.I1X")
console.log("this is instance: ", I1X)
console.log(
"these are the methods:: ",
Java.use("X.I1X").class.getDeclaredMethods()
)
I1X.A00.overload().implemention = function (HGf, I1Y) {
console.log("A0l is called")
let ret = this.A0l(str, z)
console.log("A0l ret value is " + ret)
}
} catch (e) {
console.log("failed!" + e)
}
})
this script outputs:
this is instance: <class: X.I1X>
these are the methods::
failed!TypeError: not a function
apparently the A00 here is not a function, so back to jadx in the compiled code there is another class with the same name within same package but consisting of some other code, here it is:
/* renamed from: X.I1x reason: case insensitive filesystem */
/* loaded from: classes7.dex */
public final class C39227I1x {
public C39229I1z A00 = null;
}
apparently Frida is hooking this variable instance A00 In my opinion that is why
it is returning not a function here.
So my question, how can I hook like this situation?
Edit:
the two classes are somewhat different in jadx.
We have a two forge viewers in one div. We has initialize those viewers same time and showing different models.
Is it possible to initialize Autodesk Forge viewer as extension for another viewer and show in that viewers different models?
There is no official extension for showing one Forge Viewer inside another, but implementing this is possible. You could reuse one of the UI components of the viewer (for example, DockingPanel, also explained in this tutorial), and host the second viewer in it.
Here's how such an extension might look like:
class MyExtension extends Autodesk.Viewing.Extension {
constructor(viewer, options) {
super(viewer, options);
this._group = null;
this._button = null;
this._panel = null;
}
load() {
return true;
}
unload() {
return true;
}
onToolbarCreated() {
this._group = new Autodesk.Viewing.UI.ControlGroup('allMyAwesomeExtensionsToolbar');
this._button = new Autodesk.Viewing.UI.Button('MyExtensionButton');
this._button.setToolTip('My Extension Button');
this._group.addControl(this._button);
this._panel = new MyPanel(this.viewer, this.viewer.container, 'MyPanel', 'My Panel Title');
this._button.onClick = (ev) => {
this._panel.setVisible(true);
};
this.viewer.toolbar.addControl(this._group);
}
}
class MyPanel extends Autodesk.Viewing.UI.DockingPanel {
constructor(viewer, container, id, title, options) {
super(container, id, title, options);
this.viewer = viewer;
this.secondViewer = null;
this.container.style.width = '640px';
this.container.style.height = '480px';
this.container.style.left = '1em';
this.container.style.top = '1em';
}
setVisible(show) {
super.setVisible(show);
if (show && !this.secondViewer) {
this.secondViewer = new Autodesk.Viewing.GuiViewer3D(this.container);
this.secondViewer.start();
Autodesk.Viewing.Document.load(
'urn:<your model urn>',
this.onDocumentLoadSuccess.bind(this),
this.onDocumentLoadFailure.bind(this)
);
}
}
onDocumentLoadSuccess(doc) {
const viewables = doc.getRoot().getDefaultGeometry();
this.secondViewer.loadDocumentNode(doc, viewables);
}
onDocumentLoadFailure(viewerErrorCode) {
console.error('onDocumentLoadFailure() - errorCode:' + viewerErrorCode);
}
}
Autodesk.Viewing.theExtensionManager.registerExtension('MyExtension', MyExtension);
I have just migrated my project from .net core 2.2 to 3.0 preview 7. I am using Swashbuckle.AspNetCore (v4.0.1) in it. This is my startup class.
public class Startup
{
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlServer(
Configuration["ConnectionStrings:ConnectionStringAzureSQL"]));
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_3_0);
services.AddApplicationInsightsTelemetry();
services.AddLocalization(options => options.ResourcesPath = #"Resources");
services.AddMemoryCache();
services.Configure<RequestLocalizationOptions>(options =>
{
var supportedCultures = new List<CultureInfo>
{
new CultureInfo("en-US")
};
options.DefaultRequestCulture = new RequestCulture("en-US");
options.SupportedCultures = supportedCultures;
options.SupportedUICultures = supportedCultures;
});
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new Info { Title = "GetAJobToday", Description = "GetAJobTodayAPIs" });
var xmlPath = AppDomain.CurrentDomain.BaseDirectory + #"PlatformAPI.xml";
c.IncludeXmlComments(xmlPath);
c.AddSecurityDefinition("Bearer",
new ApiKeyScheme
{
In = "header",
Description = "Please enter token into the field",
Name = "Authorization",
Type = "apiKey"
});
c.AddSecurityRequirement(new Dictionary<string, IEnumerable<string>>
{
{"Bearer", new string[] { }},
});
});
services.AddSingleton<ITelemetryInitializer, HttpContextItemsTelemetryInitializer>();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseRouting();
app.UseMiddleware<ApiLoggingMiddleware>();
app.UseHttpsRedirection();
app.UseRequestLocalization(app.ApplicationServices.GetService<IOptions<RequestLocalizationOptions>>().Value);
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
endpoints.MapControllerRoute("default", "{controller=Auth}/{action=RequestVerificationCode}/{id?}");
});
app.UseSwagger();
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "GetAJobToday");
});
}
}
But it is throwing this exception when I run it:
AggregateException: Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType: Swashbuckle.AspNetCore.Swagger.ISwaggerProvider Lifetime: Transient ImplementationType: Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator': Failed to compare two elements in the array.) (Error while validating the service descriptor 'ServiceType: Swashbuckle.AspNetCore.SwaggerGen.ISchemaRegistryFactory Lifetime: Transient ImplementationType: Swashbuckle.AspNetCore.SwaggerGen.SchemaRegistryFactory': Failed to compare two elements in the array.)
Upgrading Swashbuckle.AspNetCore and Swashbuckle.AspNetCore.Filters to v 5.0.0-rc2 solved the problem.
Upgrading Swashbuckle.AspNetCore to the latest version v 5.0.0-rc4 solved the problem.
I am trying to build libGDX project for Android via Gradle.
I get following error: Could not find org.jetbrains.trove4j: trove4j: 20160824.
I have tried every combination of:
jCenter(), mavenLocal(), mavenCentral(), google()
In my build.gradle files, root and android's one.
Also tried different orders of it, as suggested by others in other forums.
What sould I do?
Full error:
Could not resolve all files for configuration ':android:debugCompileClasspath'.
> Could not find org.jetbrains.trove4j:trove4j:20160824.
Searched in the following locations:
- file:/media/mruser/Data/AndroidSDK/extras/m2repository/org/jetbrains/trove4j/trove4j/20160824/trove4j-20160824.pom
- file:/media/mruser/Data/AndroidSDK/extras/m2repository/org/jetbrains/trove4j/trove4j/20160824/trove4j-20160824.jar
- file:/media/mruser/Data/AndroidSDK/extras/google/m2repository/org/jetbrains/trove4j/trove4j/20160824/trove4j-20160824.pom
- file:/media/mruser/Data/AndroidSDK/extras/google/m2repository/org/jetbrains/trove4j/trove4j/20160824/trove4j-20160824.jar
- file:/media/mruser/Data/AndroidSDK/extras/android/m2repository/org/jetbrains/trove4j/trove4j/20160824/trove4j-20160824.pom
- file:/media/mruser/Data/AndroidSDK/extras/android/m2repository/org/jetbrains/trove4j/trove4j/20160824/trove4j-20160824.jar
- file:/home/mruser/.m2/repository/org/jetbrains/trove4j/trove4j/20160824/trove4j-20160824.pom
- file:/home/mruser/.m2/repository/org/jetbrains/trove4j/trove4j/20160824/trove4j-20160824.jar
- https://repo.maven.apache.org/maven2/org/jetbrains/trove4j/trove4j/20160824/trove4j-20160824.pom
- https://repo.maven.apache.org/maven2/org/jetbrains/trove4j/trove4j/20160824/trove4j-20160824.jar
- https://dl.google.com/dl/android/maven2/org/jetbrains/trove4j/trove4j/20160824/trove4j-20160824.pom
- https://dl.google.com/dl/android/maven2/org/jetbrains/trove4j/trove4j/20160824/trove4j-20160824.jar
- https://oss.sonatype.org/content/repositories/snapshots/org/jetbrains/trove4j/trove4j/20160824/trove4j-20160824.pom
- https://oss.sonatype.org/content/repositories/snapshots/org/jetbrains/trove4j/trove4j/20160824/trove4j-20160824.jar
- https://oss.sonatype.org/content/repositories/releases/org/jetbrains/trove4j/trove4j/20160824/trove4j-20160824.pom
- https://oss.sonatype.org/content/repositories/releases/org/jetbrains/trove4j/trove4j/20160824/trove4j-20160824.jar
- file:/home/mruser/GDX/ColorGame/libs/trove4j-20160824.jar
- file:/home/mruser/GDX/ColorGame/libs/trove4j.jar
Required by:
project :android
Root build.gradle:
buildscript {
repositories {
mavenLocal()
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.mobidevelop.robovm:robovm-gradle-plugin:2.3.3'
}
}
allprojects {
apply plugin: "eclipse"
apply plugin: "idea"
version = '1.0'
ext {
appName = "ColorfulGame"
gdxVersion = '1.9.8'
roboVMVersion = '2.3.3'
box2DLightsVersion = '1.4'
ashleyVersion = '1.7.0'
aiVersion = '1.8.0'
}
repositories {
mavenLocal()
mavenCentral()
google()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "https://oss.sonatype.org/content/repositories/releases/" }
flatDir {
dir rootProject.file( 'libs' )
}
}
}
project(":desktop") {
apply plugin: "java"
dependencies {
compile project(":core")
compile "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
compile "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop"
compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"
}
}
project(":android") {
apply plugin: "android"
configurations { natives }
dependencies {
compile project(":core")
compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86_64"
compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86_64"
compile "com.badlogicgames.box2dlights:box2dlights:$box2DLightsVersion"
compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86_64"
compile 'com.android.support:support-v4:23.2.1'
compile 'com.android.support:design:23.1.1'
compile group: 'org.jetbrains.trove4j', name: 'trove4j', version: '20160824'
}
}
project(":ios") {
apply plugin: "java"
apply plugin: "robovm"
dependencies {
compile project(":core")
compile "com.mobidevelop.robovm:robovm-rt:$roboVMVersion"
compile "com.mobidevelop.robovm:robovm-cocoatouch:$roboVMVersion"
compile "com.badlogicgames.gdx:gdx-backend-robovm:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-ios"
compile "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-ios"
compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-ios"
}
}
project(":core") {
apply plugin: "java"
dependencies {
compile "com.badlogicgames.gdx:gdx:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
compile "com.badlogicgames.box2dlights:box2dlights:$box2DLightsVersion"
compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
compile files("libs/SGDX.jar")
}
}
tasks.eclipse.doLast {
delete ".project"
}
Android build.gradle:
android {
buildToolsVersion "28.0.3"
compileSdkVersion 28
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
jniLibs.srcDirs = ['libs']
}
}
packagingOptions {
exclude 'META-INF/robovm/ios/robovm.xml'
}
defaultConfig {
applicationId "sk.ap.cg"
minSdkVersion 9
targetSdkVersion 28
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
// called every time gradle gets executed, takes the native dependencies of
// the natives configuration, and extracts them to the proper libs/ folders
// so they get packed with the APK.
task copyAndroidNatives() {
file("libs/armeabi/").mkdirs();
file("libs/armeabi-v7a/").mkdirs();
file("libs/arm64-v8a/").mkdirs();
file("libs/x86_64/").mkdirs();
file("libs/x86/").mkdirs();
configurations.natives.files.each { jar ->
def outputDir = null
if(jar.name.endsWith("natives-arm64-v8a.jar")) outputDir = file("libs/arm64-v8a")
if(jar.name.endsWith("natives-armeabi-v7a.jar")) outputDir = file("libs/armeabi-v7a")
if(jar.name.endsWith("natives-armeabi.jar")) outputDir = file("libs/armeabi")
if(jar.name.endsWith("natives-x86_64.jar")) outputDir = file("libs/x86_64")
if(jar.name.endsWith("natives-x86.jar")) outputDir = file("libs/x86")
if(outputDir != null) {
copy {
from zipTree(jar)
into outputDir
include "*.so"
}
}
}
}
task run(type: Exec) {
def path
def localProperties = project.file("../local.properties")
if (localProperties.exists()) {
Properties properties = new Properties()
localProperties.withInputStream { instr ->
properties.load(instr)
}
def sdkDir = properties.getProperty('sdk.dir')
if (sdkDir) {
path = sdkDir
} else {
path = "$System.env.ANDROID_HOME"
}
} else {
path = "$System.env.ANDROID_HOME"
}
def adb = path + "/platform-tools/adb"
commandLine "$adb", 'shell', 'am', 'start', '-n', 'sk.ap.cg/sk.ap.cg.AndroidLauncher'
}
// sets up the Android Eclipse project, using the old Ant based build.
eclipse {
// need to specify Java source sets explicitly, SpringSource Gradle Eclipse plugin
// ignores any nodes added in classpath.file.withXml
sourceSets {
main {
java.srcDirs "src", 'gen'
}
}
jdt {
sourceCompatibility = 1.6
targetCompatibility = 1.6
}
classpath {
plusConfigurations += [ project.configurations.compile ]
containers 'com.android.ide.eclipse.adt.ANDROID_FRAMEWORK', 'com.android.ide.eclipse.adt.LIBRARIES'
}
project {
name = appName + "-android"
natures 'com.android.ide.eclipse.adt.AndroidNature'
buildCommands.clear();
buildCommand "com.android.ide.eclipse.adt.ResourceManagerBuilder"
buildCommand "com.android.ide.eclipse.adt.PreCompilerBuilder"
buildCommand "org.eclipse.jdt.core.javabuilder"
buildCommand "com.android.ide.eclipse.adt.ApkBuilder"
}
}
// sets up the Android Idea project, using the old Ant based build.
idea {
module {
sourceDirs += file("src");
scopes = [ COMPILE: [plus:[project.configurations.compile]]]
iml {
withXml {
def node = it.asNode()
def builder = NodeBuilder.newInstance();
builder.current = node;
builder.component(name: "FacetManager") {
facet(type: "android", name: "Android") {
configuration {
option(name: "UPDATE_PROPERTY_FILES", value:"true")
}
}
}
}
}
}
}
Problem was asociated with mavenCentral() and mavenLocal().
allproject and buildfile closures in root buildfile should look like this:
repositories {
jcenter()
google()
}
If someone still looks for solution and mavens are ok - in my case problem was with outdated react-native-document-picker library. I installed last version and problem has gone. So be sure problem is not caused by your libraries.
Are there any examples around using this ico with ES6 rather than Typescript for back-end Node/Express ?
I followed a few Typescript examples but nothing for ES6.
I've looked at the generated ES5 from Typescript but this seems a backwards step
The documentation covers this (also can be seen here):
var inversify = require("inversify");
require("reflect-metadata");
var TYPES = {
Ninja: "Ninja",
Katana: "Katana",
Shuriken: "Shuriken"
};
class Katana {
hit() {
return "cut!";
}
}
class Shuriken {
throw() {
return "hit!";
}
}
class Ninja {
constructor(katana, shuriken) {
this._katana = katana;
this._shuriken = shuriken;
}
fight() { return this._katana.hit(); };
sneak() { return this._shuriken.throw(); };
}
// Declare as injectable and its dependencies
inversify.decorate(inversify.injectable(), Katana);
inversify.decorate(inversify.injectable(), Shuriken);
inversify.decorate(inversify.injectable(), Ninja);
inversify.decorate(inversify.inject(TYPES.Katana), Ninja, 0);
inversify.decorate(inversify.inject(TYPES.Shuriken), Ninja, 1);
// Declare bindings
var container = new inversify.Container();
container.bind(TYPES.Ninja).to(Ninja);
container.bind(TYPES.Katana).to(Katana);
container.bind(TYPES.Shuriken).to(Shuriken);
// Resolve dependencies
var ninja = container.get(TYPES.Ninja);
return ninja;