Ejemplo n.º 1
0
        protected void On(AssetCreated @event)
        {
            SimpleMapper.Map(@event, this);

            TotalSize += @event.FileSize;

            AppId = @event.AppId;
        }
Ejemplo n.º 2
0
    /// <summary>
    /// Create an asset using an existing meta data set (Can be useful when an online player shares an asset he/she has created before)
    /// </summary>
    protected PlayerAsset CreateAssetInternal(Guid guid, PlayerAssetType assetType)
    {
        if (assetType == PlayerAssetType.Invalid)
        {
            throw new Exception($"Unsupported asset type.");
        }

        PlayerAsset asset = (PlayerAsset)Activator.CreateInstance(AssetTypeFromEnum(assetType), guid);

        _assetMap.Add(asset.Guid, asset);

        AssetCreated?.InvokeCatchException(asset);

        return(asset);
    }
Ejemplo n.º 3
0
        public async Task Should_not_repair_created_asset_if_found()
        {
            var @event = new AssetCreated {
                AppId = appId, AssetId = DomainId.NewGuid()
            };

            SetupEvent(@event);

            A.CallTo(() => assetFileStore.GetFileSizeAsync(appId.Id, @event.AssetId, 0, default))
            .Returns(100);

            await sut.RepairAsync();

            A.CallTo(() => assetFileStore.UploadAsync(appId.Id, @event.AssetId, 0, A <Stream> ._, default))
            .MustNotHaveHappened();
        }
Ejemplo n.º 4
0
        public async Task Should_repair_created_asset_if_not_found()
        {
            var @event = new AssetCreated {
                AppId = appId, AssetId = DomainId.NewGuid()
            };

            SetupEvent(@event);

            A.CallTo(() => assetFileStore.GetFileSizeAsync(appId.Id, @event.AssetId, 0, null, default))
            .Throws(new AssetNotFoundException("file"));

            await sut.RepairAsync();

            A.CallTo(() => assetFileStore.UploadAsync(appId.Id, @event.AssetId, 0, null, A <Stream> ._, true, default))
            .MustHaveHappened();
        }
Ejemplo n.º 5
0
        protected void On(AssetCreated @event)
        {
            SimpleMapper.Map(@event, this);

            FileName = @event.FileName;

            if (string.IsNullOrWhiteSpace(@event.Slug))
            {
                Slug = @event.FileName.ToAssetSlug();
            }
            else
            {
                Slug = @event.Slug;
            }

            TotalSize += @event.FileSize;
        }
Ejemplo n.º 6
0
        private void CreateAsset()
        {
            if (creationMode == AssetCreationMode.Single)
            {
                SingleCreationInfo[0].CreationInfo = CreationInfo;
            }
            else
            {
                foreach (AssetCreationArgs assetCreationArgs in SingleCreationInfo)
                {
                    assetCreationArgs.CreationInfo = CreationInfo;
                }
            }

            WasAssetSuccesfullyCreated = DoCreateAsset();
            AssetCreated?.Invoke(this);

            if (WasAssetSuccesfullyCreated)
            {
                CloseWindow();
            }
        }
Ejemplo n.º 7
0
        private void AddAssetInternal(Asset asset, bool silent = false)
        {
            var guid = AssetGuidManager.GetGuid(asset.Path);

            if (guid != default(Guid))
            {
                asset.SetGuid(guid);
            }

            GuidAssetTable.Add(asset.Guid, asset);
            GuidPathTable.Add(asset.Guid, asset.Path);
            GuidHashTable.Add(asset.Guid, asset.Hash);

            AssetGuidManager.AddNewGuid(asset.Guid, asset.Path, asset.Hash);
            if (!IsEditingAssets)
            {
                AssetGuidManager.Save();
            }

            if (!silent)
            {
                AssetCreated?.Invoke(asset.Path);
            }
        }
 protected Task On(AssetCreated @event, EnvelopeHeaders headers)
 {
     return(UpdateSizeAsync(@event.AppId.Id, headers.Timestamp().ToDateTimeUtc().Date, @event.FileSize, 1));
 }