Skip to content

Commit

Permalink
Fixed ViewService from IOC speed up
Browse files Browse the repository at this point in the history
  • Loading branch information
InvertGames committed Oct 21, 2015
1 parent a92d4ca commit 9328a3e
Show file tree
Hide file tree
Showing 11 changed files with 91 additions and 20 deletions.
9 changes: 9 additions & 0 deletions Base.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions Base/Bindings.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions Base/Views.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions Editor/UndoSystem.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Editor/uFrameEditors/GameManagerInspector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ public override void OnInspectorGUI()
if (GUIHelpers.DoTriggerButton(new UFStyle()
{
Label =
string.Format("'{0}': {1}->{2}", instance.Name, instance.Base.Name,
instance.Instance.GetType().Name),
string.Format("'{0}': {1}->{2}", instance.Key.Item1, instance.Key.Item2,
instance.Value.GetType().Name),
BackgroundStyle = ElementDesignerStyles.EventButtonStyleSmall
}))
{
Debug.Log(instance.Instance);
Debug.Log(instance.Value);
}


Expand All @@ -50,7 +50,7 @@ public override void OnInspectorGUI()
if (GUIHelpers.DoTriggerButton(new UFStyle()
{
BackgroundStyle = ElementDesignerStyles.EventButtonStyleSmall,
Label = string.Format("{0}: {1}->{2}", instance.Name, instance.From.Name, instance.To.Name)
Label = string.Format("{0}: {1}->{2}", instance.Key.Item2, instance.Key.Item1.Name, instance.Value.Name)
}))
{

Expand Down
8 changes: 4 additions & 4 deletions Editor/uFrameEditors/uFrameMVVMKernelInspector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,12 @@ public override void OnInspectorGUI()
if (GUIHelpers.DoTriggerButton(new UFStyle()
{
Label =
string.Format("'{0}': {1}->{2}", instance.Name, instance.Base.Name,
instance.Instance.GetType().Name),
string.Format("'{0}': {1}->{2}", instance.Key.Item1, instance.Key.Item2,
instance.Value.GetType().Name),
BackgroundStyle = ElementDesignerStyles.EventButtonStyleSmall
}))
{
Debug.Log(instance.Instance);
Debug.Log(instance.Value);
}


Expand All @@ -124,7 +124,7 @@ public override void OnInspectorGUI()
if (GUIHelpers.DoTriggerButton(new UFStyle()
{
BackgroundStyle = ElementDesignerStyles.EventButtonStyleSmall,
Label = string.Format("{0}: {1}->{2}", instance.Name, instance.From.Name, instance.To.Name)
Label = string.Format("{0}: {1}->{2}", instance.Key.Item2, instance.Key.Item1.Name, instance.Value.Name)
}))
{
}
Expand Down
9 changes: 9 additions & 0 deletions Kernel.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions Kernel/Serialization.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions Kernel/Serialization/Json.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions Kernel/Serialization/Storage.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 11 additions & 12 deletions MVVM/Services/ViewService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public override void Setup()

this.OnEvent<ViewDestroyedEvent>()
.Subscribe(ViewDestroyed);
this.OnEvent<ViewModelDestroyedEvent>()

this.OnEvent<ViewModelDestroyedEvent>()
.Subscribe(ViewModelDestroyed);
}

Expand Down Expand Up @@ -99,7 +99,7 @@ protected virtual void ViewCreated(ViewCreatedEvent viewCreatedEvent)
if (view.ViewModelObject == null && view.BindOnStart)
{
var viewModel = FetchViewModel(viewCreatedEvent.View);

}
Views.Add(view);
}
Expand All @@ -116,14 +116,13 @@ protected virtual void ViewDestroyed(ViewDestroyedEvent data)
});
}
}
protected virtual void ViewModelDestroyed(ViewModelDestroyedEvent data)

protected virtual void ViewModelDestroyed(ViewModelDestroyedEvent data)
{
var instanceIndex = uFrameKernel.Container.Instances.FindIndex(x => x.Name == data.ViewModel.Identifier);
if (instanceIndex >= 0)
{
uFrameKernel.Container.Instances.RemoveAt(instanceIndex);
}
var instanceIndex = uFrameKernel.Container.Instances.FirstOrDefault(x => x.Key.Item2 == data.ViewModel.Identifier);

uFrameKernel.Container.Instances.Remove(instanceIndex.Key);

}

/// <summary>
Expand All @@ -138,7 +137,7 @@ public static ViewModel FetchViewModel(ViewBase viewBase)
{
return viewBase.ViewModelObject;
}

// Attempt to resolve it by the identifier
//var contextViewModel = uFrameMVVMKernel.Container.Resolve<ViewModel>(viewBase.Identifier);
// It now only registers under the viewmodeltype to allow multip different view-models with the same identifier
Expand Down Expand Up @@ -174,7 +173,7 @@ public static ViewModel FetchViewModel(ViewBase viewBase)
}
return viewBase.ViewModelObject = contextViewModel;
}

return contextViewModel;
}

Expand Down

0 comments on commit 9328a3e

Please sign in to comment.