Skip to content

Commit

Permalink
0.2.0 version.
Browse files Browse the repository at this point in the history
Refactoring (now all writed in MVVM style). Code and design cleaning.
  • Loading branch information
mfandreich committed Jul 16, 2017
1 parent 90d0093 commit f469c0f
Show file tree
Hide file tree
Showing 76 changed files with 2,449 additions and 1,474 deletions.
4 changes: 1 addition & 3 deletions UnityLauncher/App.xaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<Application x:Class="UnityLauncher.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:UnityLauncher"
StartupUri="MainWindow.xaml">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Application.Resources>

</Application.Resources>
Expand Down
12 changes: 11 additions & 1 deletion UnityLauncher/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
namespace UnityLauncher
using UnityLauncher.Core;
using UnityLauncher.Core.Common;

namespace UnityLauncher
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App
{
public App()
{
var mainWindow = new MainWindowView();
var mainViewModel = new MainWindowModelView(mainWindow);
Behaviors.Init(mainViewModel);
mainWindow.Show();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,30 @@

namespace UnityLauncher.Core
{
public static class Behaviours
public static class Behaviors
{
private static readonly Dictionary<Type, IList> BehaviourLists = new Dictionary<Type, IList>();
private static readonly List<IBaseObject> WorkedBehavours = new List<IBaseObject>();
private static bool isInited;
private static readonly List<IBehavior> WorkedBehavours = new List<IBehavior>();
private static bool _isInited;

public static void Init(params IBaseObject[] predefinedBaseObjects)
public static void Init(params IBehavior[] predefinedBehaviors)
{
if(isInited) return;
isInited = true;
if(_isInited) return;
_isInited = true;

if (predefinedBaseObjects != null)
if (predefinedBehaviors != null)
{
WorkedBehavours.AddRange(predefinedBaseObjects);
WorkedBehavours.AddRange(predefinedBehaviors);
}

var behavioursType = typeof(Behaviours).Assembly.GetTypes()
.Where(type => typeof(IBehaviour).IsAssignableFrom(type) && !type.IsAbstract && !type.IsInterface).ToArray();
var behavioursType = typeof(Behaviors).Assembly.GetTypes()
.Where(type => typeof(IUIBehavior).IsAssignableFrom(type) && !type.IsAbstract && !type.IsInterface).ToArray();

foreach (var type in behavioursType)
{
try
{
var instance = Activator.CreateInstance(type) as IBehaviour;
var instance = Activator.CreateInstance(type) as IUIBehavior;
if (instance != null)
{
WorkedBehavours.Add(instance);
Expand All @@ -42,7 +42,7 @@ public static void Init(params IBaseObject[] predefinedBaseObjects)
}
}

public static IList<T> GetBehaviourList<T>() where T: IBehaviour
public static IList<T> GetBehaviourList<T>() where T: IBehavior
{
IList tmp;
if (!BehaviourLists.TryGetValue(typeof(T), out tmp) || !(tmp is List<T>))
Expand All @@ -66,7 +66,7 @@ public static void SendMessage<T>(T message)
{
foreach (var behavour in WorkedBehavours)
{
var receiver = behavour as IMessageReceiver<T>;
var receiver = behavour?.MessageReceiver as IMessageReceiver<T>;
receiver?.OnMessage(message);
}
}
Expand Down

This file was deleted.

31 changes: 0 additions & 31 deletions UnityLauncher/Core/Commands/Projects/Project.xaml

This file was deleted.

35 changes: 0 additions & 35 deletions UnityLauncher/Core/Commands/Projects/Project.xaml.cs

This file was deleted.

11 changes: 0 additions & 11 deletions UnityLauncher/Core/Commands/Projects/ProjectInfo.cs

This file was deleted.

39 changes: 0 additions & 39 deletions UnityLauncher/Core/Commands/Projects/ProjectSelect.xaml

This file was deleted.

Loading

0 comments on commit f469c0f

Please sign in to comment.