Skip to content

Commit

Permalink
Fixes error to integrate with gateway
Browse files Browse the repository at this point in the history
  • Loading branch information
lillo42 committed Feb 12, 2020
1 parent bf7dc38 commit 0865b43
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 22 deletions.
2 changes: 1 addition & 1 deletion sample/Multi/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
app.UseDeveloperExceptionPage();
}

app.UseHttpsRedirection();
//app.UseHttpsRedirection();

app.UseRouting();

Expand Down
2 changes: 1 addition & 1 deletion sample/Multi/Things/ExampleDimmableLight.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public class FadeAction : Action

protected override async ValueTask ExecuteAsync(CancellationToken cancellation)
{
int value = Input["input"] as int? ?? 0;
int value = Input?["input"] as int? ?? 0;
await Task.Delay(value, cancellation);

var property = Thing.Properties.FirstOrDefault(x => x.Name == "brightness");
Expand Down
2 changes: 1 addition & 1 deletion sample/Multi/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"Logging": {
"LogLevel": {
"Default": "Warning"
"Default": "Debug"
}
},
"AllowedHosts": "*"
Expand Down
2 changes: 1 addition & 1 deletion sample/Single/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
app.UseDeveloperExceptionPage();
}

app.UseHttpsRedirection();
//app.UseHttpsRedirection();

app.UseRouting();

Expand Down
2 changes: 1 addition & 1 deletion sample/Single/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"Logging": {
"LogLevel": {
"Default": "Warning"
"Default": "Debug"
}
},
"AllowedHosts": "*"
Expand Down
5 changes: 5 additions & 0 deletions src/Mozilla.IoT.WebThing/Activator/ThingActivator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ public void Register<T>(IServiceProvider service) where T : Thing
{
string name = typeof(T).Name;
Register<T>(service, name.Replace("Thing", ""));

var thing = CreateInstance(service, name.Replace("Thing", ""));

_thingType.TryAdd(thing.Name, typeof(T));
}

public void Register<T>(IServiceProvider service, string thing)
Expand All @@ -53,6 +57,7 @@ public void Register<T>(IServiceProvider service, T thing)
{
_thingType.TryAdd(thing.Name, typeof(T));
_typeActivatorCache.TryAdd(typeof(T), thing);

BindingThingNotify(thing, service, thing.Name);
}

Expand Down
14 changes: 1 addition & 13 deletions src/Mozilla.IoT.WebThing/Property.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,7 @@ public Property(string name, object value, IDictionary<string, object> metadata)
{
}

public new virtual T Value
{
get
{
if (base.Value == null)
{
return default;
}

return (T)base.Value;
}
set => base.Value = value;
}
public new virtual T Value { get; set; }

internal override Type Type => typeof(T);

Expand Down
2 changes: 1 addition & 1 deletion src/Mozilla.IoT.WebThing/ServiceRouteBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ internal IEnumerable<IEndpointConventionBuilder> Build(IEndpointRouteBuilder end

if (!_option.IsSingleThing)
{
prefix = "/{{thing}}";
prefix = "/things/{thing}";
result.AddLast(endpointRouteBuilder.MapGet("/", GetThings.Invoke));
result.AddLast(endpointRouteBuilder.MapGet(prefix, GetThing.Invoke));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,7 @@ public static ThingEndpointConventionBuilder MapThing<T>(this IEndpointRouteBuil

var activator = builder.ServiceProvider.GetService<IThingActivator>();
activator.Register<T>(builder.ServiceProvider, thing);




var serviceRouteBuilder = builder.ServiceProvider.GetRequiredService<ServiceRouteBuilder>();
var endpointConventionBuilders = serviceRouteBuilder.Build(builder);

Expand Down

0 comments on commit 0865b43

Please sign in to comment.