private void SetCdnUris(long id, string versionId, IObjectElementPersistenceDescriptor objectElementDescriptor)
        {
            if (!(objectElementDescriptor.Value is IBinaryElementValue binaryElementValue) || string.IsNullOrEmpty(binaryElementValue.Raw))
            {
                return;
            }

            binaryElementValue.DownloadUri = _cdnOptions.AsRawUri(binaryElementValue.Raw);

            switch (binaryElementValue)
            {
            case ICompositeBitmapImageElementValue compositeBitmapImageElementValue:
                compositeBitmapImageElementValue.PreviewUri = _cdnOptions.AsCompositePreviewUri(id, versionId, objectElementDescriptor.TemplateCode);
                foreach (var image in compositeBitmapImageElementValue.SizeSpecificImages)
                {
                    image.DownloadUri = _cdnOptions.AsRawUri(image.Raw);
                }

                break;

            case IScalableBitmapImageElementValue scalableBitmapImageElementValue:
                scalableBitmapImageElementValue.PreviewUri = _cdnOptions.AsScalablePreviewUri(id, versionId, objectElementDescriptor.TemplateCode);
                break;

            case IImageElementValue imageElementValue:
                imageElementValue.PreviewUri = _cdnOptions.AsRawUri(imageElementValue.Raw);
                break;
            }
        }
Esempio n. 2
0
        public static void NormalizeValue(this IObjectElementPersistenceDescriptor descriptor)
        {
            switch (descriptor.Value)
            {
            case CompositeBitmapImageElementValue compositeBitmapImageElementValue:
                if (compositeBitmapImageElementValue.SizeSpecificImages == null)
                {
                    compositeBitmapImageElementValue.SizeSpecificImages = Enumerable.Empty <SizeSpecificImage>();
                }

                break;

            case ScalableBitmapImageElementValue scalableBitmapImageElementValue:
                if (!Enum.IsDefined(typeof(Anchor), scalableBitmapImageElementValue.Anchor))
                {
                    scalableBitmapImageElementValue.Anchor = DefaultAnchor;
                }

                break;
            }
        }