Ejemplo n.º 1
0
    private SceneCardView RemoveScene(ISceneData sceneData, bool notify)
    {
        bool wasDeployed = scenesRefreshHelper.WasDeployedScene(sceneData);
        var  dictionary  = wasDeployed ? scenesRefreshHelper.oldDeployedScenes : scenesRefreshHelper.oldProjectsScenes;

        if (dictionary.TryGetValue(sceneData.id, out SceneCardView sceneCardView))
        {
            dictionary.Remove(sceneData.id);

            if (notify)
            {
                if (wasDeployed)
                {
                    OnDeployedSceneRemoved?.Invoke(sceneCardView);
                }
                else
                {
                    OnProjectSceneRemoved?.Invoke(sceneCardView);
                }
            }

            return(sceneCardView);
        }

        return(null);
    }
Ejemplo n.º 2
0
    /// <summary>
    /// Set current user scenes (deployed and projects)
    /// </summary>
    /// <param name="scenesData">list of scenes</param>
    public void SetScenes(ISceneData[] scenesData)
    {
        scenesRefreshHelper.Set(deployedScenes, projectScenes);

        deployedScenes = new Dictionary <string, SceneCardView>();
        projectScenes  = new Dictionary <string, SceneCardView>();

        // update or create new scenes view
        for (int i = 0; i < scenesData.Length; i++)
        {
            SetScene(scenesData[i]);
        }

        // remove old deployed scenes
        if (scenesRefreshHelper.oldDeployedScenes != null)
        {
            using (var iterator = scenesRefreshHelper.oldDeployedScenes.GetEnumerator())
            {
                while (iterator.MoveNext())
                {
                    OnDeployedSceneRemoved?.Invoke(iterator.Current.Value);
                    DestroyCardView(iterator.Current.Value);
                }
            }
        }

        // remove old project scenes
        if (scenesRefreshHelper.oldProjectsScenes != null)
        {
            using (var iterator = scenesRefreshHelper.oldProjectsScenes.GetEnumerator())
            {
                while (iterator.MoveNext())
                {
                    OnProjectSceneRemoved?.Invoke(iterator.Current.Value);
                    DestroyCardView(iterator.Current.Value);
                }
            }
        }

        // notify scenes set if needed
        if (scenesRefreshHelper.isOldDeployedScenesEmpty && deployedScenes.Count > 0)
        {
            OnDeployedScenesSet?.Invoke(deployedScenes);
        }

        if (scenesRefreshHelper.isOldProjectScenesEmpty && projectScenes.Count > 0)
        {
            OnProjectScenesSet?.Invoke(projectScenes);
        }
    }