Skip to content

Commit

Permalink
Merge pull request #5 from akobr/develop
Browse files Browse the repository at this point in the history
Alfa version of .NET standard library
  • Loading branch information
akobr committed Nov 19, 2018
2 parents 2472d92 + e4ee4d6 commit ac81d3a
Show file tree
Hide file tree
Showing 490 changed files with 7,987 additions and 15,355 deletions.
145 changes: 70 additions & 75 deletions README.md

Large diffs are not rendered by default.

30 changes: 0 additions & 30 deletions StrongBeaver.Core.Droid/Properties/AssemblyInfo.cs

This file was deleted.

44 changes: 0 additions & 44 deletions StrongBeaver.Core.Droid/Resources/AboutResources.txt

This file was deleted.

Empty file.
62 changes: 0 additions & 62 deletions StrongBeaver.Core.Droid/StrongBeaver.Core.Droid.csproj

This file was deleted.

36 changes: 36 additions & 0 deletions StrongBeaver.Core.Platform/DelegatedPlatformFactory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System;

namespace StrongBeaver.Core.Platform
{
public class DelegatedPlatformFactory : IPlatformFactory
{
private readonly Func<IDeviceInfo> deviceInfoFactory;
private readonly Func<IPlatformInfo> platformInfoFactory;
private readonly Func<IApplicationInfo> applicationInfoFactory;

public DelegatedPlatformFactory(
Func<IDeviceInfo> deviceInfoFactory,
Func<IPlatformInfo> platformInfoFactory,
Func<IApplicationInfo> applicationInfoFactory)
{
this.deviceInfoFactory = deviceInfoFactory;
this.platformInfoFactory = platformInfoFactory;
this.applicationInfoFactory = applicationInfoFactory;
}

public IDeviceInfo BuildDeviceInfo()
{
return deviceInfoFactory?.Invoke();
}

public IPlatformInfo BuildPlatformInfo()
{
return platformInfoFactory?.Invoke();
}

public IApplicationInfo BuildApplicationInfo()
{
return applicationInfoFactory?.Invoke();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
namespace StrongBeaver.Core.Platform
{
public class DefaultPlatformModel : IPlatformModel
public class EnvironmentInfo : IEnvironmentInfo
{
public DefaultPlatformModel(IPlatformInfo platform, IDeviceInfo device, IApplicationInfo application)
public EnvironmentInfo(IPlatformInfo platform, IDeviceInfo device, IApplicationInfo application)
{
Platform = platform;
Device = device;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using System;

namespace StrongBeaver.Core.Platform
namespace StrongBeaver.Core.Platform
{
public interface IPlatformModel
public interface IEnvironmentInfo
{
IPlatformInfo Platform { get; }

Expand Down
11 changes: 11 additions & 0 deletions StrongBeaver.Core.Platform/IPlatformFactory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace StrongBeaver.Core.Platform
{
public interface IPlatformFactory
{
IDeviceInfo BuildDeviceInfo();

IPlatformInfo BuildPlatformInfo();

IApplicationInfo BuildApplicationInfo();
}
}
File renamed without changes.
13 changes: 13 additions & 0 deletions StrongBeaver.Core.Platform/IPlatformProvider.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace StrongBeaver.Core.Platform
{
public interface IPlatformProvider
{
IDeviceInfo DeviceInfo { get; }

IPlatformInfo PlatformInfo { get; }

IApplicationInfo ApplicationInfo { get; }

IEnvironmentInfo EnvironmentInfo { get; }
}
}
39 changes: 39 additions & 0 deletions StrongBeaver.Core.Platform/PlatformProvider.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System;
using System.Threading;

namespace StrongBeaver.Core.Platform
{
public class PlatformProvider : IPlatformProvider
{
private readonly Lazy<IDeviceInfo> deviceInfo;
private readonly Lazy<IPlatformInfo> platformInfo;
private readonly Lazy<IApplicationInfo> applicationInfo;
private readonly Lazy<IEnvironmentInfo> environmentInfo;

public PlatformProvider(IPlatformFactory factory)
{
if (factory == null)
{
throw new ArgumentNullException(nameof(factory));
}

deviceInfo = new Lazy<IDeviceInfo>(factory.BuildDeviceInfo, LazyThreadSafetyMode.PublicationOnly);
platformInfo = new Lazy<IPlatformInfo>(factory.BuildPlatformInfo, LazyThreadSafetyMode.PublicationOnly);
applicationInfo = new Lazy<IApplicationInfo>(factory.BuildApplicationInfo, LazyThreadSafetyMode.PublicationOnly);
environmentInfo = new Lazy<IEnvironmentInfo>(BuildEnvironmentInfo, LazyThreadSafetyMode.PublicationOnly);
}

public IDeviceInfo DeviceInfo => deviceInfo.Value;

public IPlatformInfo PlatformInfo => platformInfo.Value;

public IApplicationInfo ApplicationInfo => applicationInfo.Value;

public IEnvironmentInfo EnvironmentInfo => environmentInfo.Value;

private IEnvironmentInfo BuildEnvironmentInfo()
{
return new EnvironmentInfo(platformInfo.Value, deviceInfo.Value, applicationInfo.Value);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ public enum PlatformTypeEnum
Android,
WindowsPhone,
WindowsUWP,
WindowsDesktop
WindowsDesktop,
WebSite,
Server,
}
}
24 changes: 24 additions & 0 deletions StrongBeaver.Core.Platform/StrongBeaver.Core.Platform.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<PackageId>BeaverSoft.StrongBeaver.Core.Platform</PackageId>
<Version>0.9.1-alpha</Version>
<Authors>BeaverSoft (Ales Kobr)</Authors>
<Company>BeaverSoft (Ales Kobr)</Company>
<Product>Platform info objects for StrongBeaver Framework</Product>
<Description>Platform info objects for StrongBeaver Framework.</Description>
<Copyright>Copyright 2017</Copyright>
<PackageLicenseUrl>https://github.com/akobr/strong-beaver/blob/master/LICENSE</PackageLicenseUrl>
<PackageProjectUrl>https://github.com/akobr/strong-beaver</PackageProjectUrl>
<PackageIconUrl>https://github.com/akobr/strong-beaver/blob/master/doc/design/icon-nuget-package.png?raw=true</PackageIconUrl>
<PackageTags>Framework Strong Beaver Platform</PackageTags>
<PackageReleaseNotes>Alpha version created by BeaverSoft.</PackageReleaseNotes>
<NeutralLanguage>en-150</NeutralLanguage>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\StrongBeaver.Core\StrongBeaver.Core.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ void Register<TInterface>(Func<TInterface> factory, string key)
void Unregister<TInterface>()
where TInterface : class, TProvidedItem;

void Unregister<TInterface>(TInterface item)
where TInterface : class, TProvidedItem;

void Unregister<TInterface>(string key)
where TInterface : class, TProvidedItem;

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ public Provider(IContainer container)
this.container = container;
}

public Provider()
: this(new SimpleIocContainer())
{
// no operation
}

public TItem Get<TItem>()
where TItem : TProvidedItem
{
Expand Down Expand Up @@ -47,12 +53,6 @@ public void Unregister<TInterface>()
container.Unregister<TInterface>();
}

public void Unregister<TInterface>(TInterface item)
where TInterface : class, TProvidedItem
{
container.Unregister<TInterface>(item);
}

public void Unregister<TInterface>(string key)
where TInterface : class, TProvidedItem
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,19 @@ namespace StrongBeaver.Core
public class ProviderWithMessageBus<TItem> : Provider<TItem>, IMessageBusProvider
where TItem : class
{
private readonly IMessenger messenger;

public ProviderWithMessageBus(IContainer container)
: base(container)
{
messenger = new Messenger();
Messanger = new Messenger();
}

public ProviderWithMessageBus()
: this(new SimpleIocContainer())
{
// no operation
}

public IMessenger Messanger => messenger;
public IMessenger Messanger { get; }

public void RegisterToMessageBus<TRecipient, TMessage>(TRecipient recipient)
where TRecipient : class, IMessageBusRecipient<TMessage>
Expand All @@ -24,13 +28,13 @@ public ProviderWithMessageBus(IContainer container)
return;
}

messenger.Register<TMessage>(recipient, recipient.ProcessMessage);
Messanger.Register<TRecipient, TMessage>(recipient);
Provider.LogDebugMessage($"The message bus recipient '{typeof(TRecipient).Name}' has been registered with message type '{typeof(TMessage).Name}'.");
}

public void UnregisterFromMessageBus(object recipient)
{
messenger.Unregister(recipient);
Messanger.Unregister(recipient);
}
}
}
Loading

0 comments on commit ac81d3a

Please sign in to comment.