public void Apply(CanvasDocument document)
        {
            var resources = document._resourcesJson.Resources.ToDictionary(res => res.Name);

            resources[_name] = _resource;
            document._resourcesJson.Resources = resources.Values.ToArray();

            document._assetFiles.Remove(_assetKey);

            if (_file != null)
            {
                document.AddAssetFile(_file);
            }
        }
        public void Apply(CanvasDocument document)
        {
            var resources = document._resourcesJson.Resources.ToDictionary(res => res.Name);

            if (resources.ContainsKey(Name))
            {
                return;
            }

            resources.Add(Name, Resource);
            if (Resource.ResourceKind == ResourceKind.LocalFile)
            {
                document.AddAssetFile(File);
            }

            document._resourcesJson.Resources = resources.Values.ToArray();
        }