Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 14 additions & 18 deletions Netduino.Core/EmulatorBootstrapper.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Caliburn.Micro;
using System.ComponentModel.Composition;
using System.ComponentModel.Composition.Hosting;
Expand All @@ -10,9 +9,6 @@
using Netduino.Core.ViewModels;
using Netduino.Core.Services;
using System.IO;
using Microsoft.SPOT.Tasks;
using System.Xml;
using Netduino.Core.Service;

namespace Netduino.Core
{
Expand All @@ -21,11 +17,11 @@ namespace Netduino.Core
/// </summary>
public class EmulatorBootstrapper : Bootstrapper<IShellViewModel>
{
private CompositionContainer container;
private CompositionContainer _container;

static EmulatorBootstrapper()
{
LogManager.GetLog = type => new Log4netLogger(type);
LogManager.GetLog = type => new Log4NetLogger(type);
}

/// <summary>
Expand All @@ -34,25 +30,25 @@ static EmulatorBootstrapper()
protected override void Configure()
{

AggregateCatalog catalog = new AggregateCatalog(AssemblySource.Instance.Select(x => new AssemblyCatalog(x)).OfType<ComposablePartCatalog>());
container = new CompositionContainer(catalog);
var catalog = new AggregateCatalog(AssemblySource.Instance.Select(x => new AssemblyCatalog(x)).OfType<ComposablePartCatalog>());
_container = new CompositionContainer(catalog);

var batch = new CompositionBatch();

batch.AddExportedValue<IWindowManager>(new WindowManager());

IEventAggregator aggregator = new EventAggregator();
batch.AddExportedValue<IEventAggregator>(aggregator);
batch.AddExportedValue(aggregator);

EmulatorService service = new EmulatorService(aggregator);
batch.AddExportedValue<IEmulatorService>(service);
var emulatorService = new EmulatorService(aggregator);
batch.AddExportedValue<IEmulatorService>(emulatorService);

batch.AddExportedValue(container);
batch.AddExportedValue(_container);

container.Compose(batch);
_container.Compose(batch);

// Start the emulator
service.StartEmulator();
emulatorService.StartEmulator();
}

/// <summary>
Expand All @@ -64,7 +60,7 @@ protected override void Configure()
protected override object GetInstance(Type serviceType, string key)
{
string contract = string.IsNullOrEmpty(key) ? AttributedModelServices.GetContractName(serviceType) : key;
var exports = container.GetExportedValues<object>(contract);
var exports = _container.GetExportedValues<object>(contract);

if (exports.Count() > 0)
return exports.First();
Expand All @@ -74,12 +70,12 @@ protected override object GetInstance(Type serviceType, string key)

protected override IEnumerable<object> GetAllInstances(Type serviceType)
{
return container.GetExportedValues<object>(AttributedModelServices.GetContractName(serviceType));
return _container.GetExportedValues<object>(AttributedModelServices.GetContractName(serviceType));
}

protected override void BuildUp(object instance)
{
container.SatisfyImportsOnce(instance);
_container.SatisfyImportsOnce(instance);
}

/// <summary>
Expand All @@ -88,7 +84,7 @@ protected override void BuildUp(object instance)
/// <returns></returns>
protected override IEnumerable<Assembly> SelectAssemblies()
{
return new Assembly[] { Assembly.GetExecutingAssembly(), Assembly.LoadFrom(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Extensions\NetduinoEmulator.dll")) };
return new[] { Assembly.GetExecutingAssembly(), Assembly.LoadFrom(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Extensions\NetduinoEmulator.dll")) };
}

/// <summary>
Expand Down
26 changes: 5 additions & 21 deletions Netduino.Core/InputGpioEventArgs.cs
Original file line number Diff line number Diff line change
@@ -1,41 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SPOT.Emulator.Gpio;

namespace Netduino.Core
namespace Netduino.Core
{
/// <summary>
/// A simple DTO that represents the state of an input pin on the netduino
/// </summary>
public class InputGpioEventArgs
{
private int _pin;
private bool _edge;
public InputGpioEventArgs(int pin, bool edge)
{
_pin = pin;
_edge = edge;
Pin = pin;
Edge = edge;

}

/// <summary>
/// What pin this event is for
/// </summary>
public int Pin
{
get { return _pin; }
set { _pin = value; }
}
public int Pin { get; set; }

/// <summary>
/// What state the pin transitioned to
/// </summary>
public bool Edge
{
get { return _edge; }
set { _edge = value; }
}
public bool Edge { get; set; }
}
}
12 changes: 6 additions & 6 deletions Netduino.Core/Netduino.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@
<Compile Include="OutputGpioEventArgs.cs" />
<Compile Include="Pins.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Service\DebugLogger.cs" />
<Compile Include="Service\Emulator2.cs" />
<Compile Include="Service\EmulatorService.cs" />
<Compile Include="Service\IEmulatorService.cs" />
<Compile Include="Service\Log4NetLogger.cs" />
<Compile Include="Service\TextFileLogger.cs" />
<Compile Include="Services\DebugLogger.cs" />
<Compile Include="Services\Emulator2.cs" />
<Compile Include="Services\EmulatorService.cs" />
<Compile Include="Services\IEmulatorService.cs" />
<Compile Include="Services\Log4NetLogger.cs" />
<Compile Include="Services\TextFileLogger.cs" />
<Compile Include="ViewModels\IEmulatorViewModel.cs" />
<Compile Include="ViewModels\IShellViewModel.cs" />
<Compile Include="ViewModels\ShellViewModel.cs" />
Expand Down
41 changes: 12 additions & 29 deletions Netduino.Core/OutputGpioEventArgs.cs
Original file line number Diff line number Diff line change
@@ -1,44 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SPOT.Emulator.Gpio;

namespace Netduino.Core
namespace Netduino.Core
{
public class OutputGpioEventArgs
{
private int _pin;
private bool _edge;

/// <summary>
/// <summary>
/// A simple DTO that represents the state of an output pin on the netduino
/// </summary>
/// <param name="pin"></param>
/// <param name="edge"></param>
public OutputGpioEventArgs(int pin, bool edge)
{
_pin = pin;
_edge = edge;
Pin = pin;
Edge = edge;

}

/// <summary>
/// The pin this event belongs to
/// </summary>
public int Pin
{
get { return _pin; }
set { _pin = value; }
}
/// <summary>
/// The pin this event belongs to
/// </summary>
public int Pin { get; set; }

/// <summary>
/// The state the pin should transition to
/// </summary>
public bool Edge
{
get { return _edge; }
set { _edge = value; }
}
/// <summary>
/// The state the pin should transition to
/// </summary>
public bool Edge { get; set; }
}
}
Loading