Example #1
0
        public TProperty TryGetAssociatedItemProperty <TProperty>(uint itemId) where TProperty : class, IItemProperty
        {
            if (typeof(TProperty).IsAbstract)
            {
                ExceptionUtil.ThrowInvalidOperationException($"Cannot call this method with an abstract type, type: { typeof(TProperty).Name }.");
            }

            ItemPropertiesBox itemPropertiesBox = this.metaBox.ItemProperties;
            IReadOnlyList <ItemPropertyAssociationEntry> items = itemPropertiesBox.TryGetAssociatedProperties(itemId);

            if (items != null)
            {
                for (int i = 0; i < items.Count; i++)
                {
                    IItemProperty property = itemPropertiesBox.TryGetProperty(items[i].PropertyIndex);

                    if (property is TProperty requestedProperty)
                    {
                        return(requestedProperty);
                    }
                }
            }

            return(null);
        }
Example #2
0
        public bool HasUnsupportedEssentialProperties(uint itemId)
        {
            ItemPropertiesBox itemPropertiesBox = this.metaBox.ItemProperties;
            IReadOnlyList <ItemPropertyAssociationEntry> items = itemPropertiesBox.TryGetAssociatedProperties(itemId);

            if (items != null)
            {
                for (int i = 0; i < items.Count; i++)
                {
                    ItemPropertyAssociationEntry entry = items[i];

                    if (entry.Essential)
                    {
                        IItemProperty property = itemPropertiesBox.TryGetProperty(entry.PropertyIndex);

                        if (property is null)
                        {
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
Example #3
0
        public void GetTransformationProperties(uint itemId,
                                                out CleanApertureBox cleanAperture,
                                                out ImageRotateBox imageRotate,
                                                out ImageMirrorBox imageMirror)
        {
            cleanAperture = null;
            imageRotate   = null;
            imageMirror   = null;

            ItemPropertiesBox itemPropertiesBox = this.metaBox.ItemProperties;
            IReadOnlyList <ItemPropertyAssociationEntry> items = itemPropertiesBox.TryGetAssociatedProperties(itemId);

            if (items != null)
            {
                for (int i = 0; i < items.Count; i++)
                {
                    IItemProperty property = itemPropertiesBox.TryGetProperty(items[i].PropertyIndex);

                    if (property != null)
                    {
                        if (property.Type == BoxTypes.CleanAperture)
                        {
                            cleanAperture = (CleanApertureBox)property;
                        }
                        else if (property.Type == BoxTypes.ImageRotation)
                        {
                            imageRotate = (ImageRotateBox)property;
                        }
                        else if (property.Type == BoxTypes.ImageMirror)
                        {
                            imageMirror = (ImageMirrorBox)property;
                        }
                    }
                }
            }
        }