Esempio n. 1
0
 public void Deconstruct(
     out ContentItem item,
     out LanguageVariant variant
     )
 {
     item    = Item ?? throw new ArgumentNullException(nameof(Item));
     variant = Variant ?? throw new ArgumentNullException(nameof(Variant));
 }
Esempio n. 2
0
 public void Deconstruct(
     out Reference languageReference,
     out LanguageVariant variant
     )
 {
     languageReference = LanguageReference ?? throw new ArgumentNullException(nameof(LanguageReference));
     variant           = Variant ?? throw new ArgumentNullException(nameof(Variant));
 }
Esempio n. 3
0
 public void Deconstruct(
     out string codename,
     out LanguageVariant variant
     )
 {
     codename = Codename ?? throw new ArgumentNullException(nameof(Codename));
     variant  = Variant ?? throw new ArgumentNullException(nameof(Variant));
 }
Esempio n. 4
0
        public override bool Equals(object other)
        {
            if (!(other is IPage) || !base.Equals(other))
            {
                return false;
            }

            return LanguageVariant.Equals(((IPage) other).LanguageVariant);
        }
Esempio n. 5
0
 public void Deconstruct(
     out Guid itemId,
     out string language,
     out LanguageVariant variant
     )
 {
     itemId   = ItemId;
     language = Language ?? throw new ArgumentNullException(nameof(Language));
     variant  = Variant ?? throw new ArgumentNullException(nameof(Variant));
 }
Esempio n. 6
0
        private static LanguageVariant GetNewTransferLanguageVariant(CreateTransferItemParameters createTransferItemParameters)
        {
            var(_, customer, fields) = createTransferItemParameters;

            var variant = new LanguageVariant
            {
                Elements =
                {
                    new CustomElement
                    {
                        Element = new Reference
                        {
                            Codename = "info"
                        },
                        Value = CoreHelper.Serialize(new
                        {
                            customer
                        })
                    },
                    new RichTextElement
                    {
                        Element = new Reference
                        {
                            Codename = "fields"
                        }
                    }
                }
            };

            if (variant.Elements[1] is RichTextElement richTextElement)
            {
                var fieldHtmlBuilder = new StringBuilder();

                if (fields != default)
                {
                    foreach (var field in fields)
                    {
                        AbstractComponent?component = default;

                        switch (field.Type)
                        {
                        case Field.heading:
                            component = new HeadingComponent(field);
                            break;

                        case Field.write_text:
                            component = new WriteTextComponent(field);
                            break;

                        case Field.upload_file:
                            component = new UploadFileComponent(field);
                            break;

                        case Field.download_asset:
                            component = new DownloadAssetComponent(field);
                            break;
                        }

                        if (component != default)
                        {
                            fieldHtmlBuilder.Append($"<object type=\"application/kenticocloud\" data-type=\"component\" data-id=\"{component.Id}\"></object>");

                            richTextElement.Components.Add(component);
                        }
                    }
                }

                fieldHtmlBuilder.Append("<p><br/></p>");

                richTextElement.Value = fieldHtmlBuilder.ToString();
            }

            return(variant);
        }
Esempio n. 7
0
 public override int GetHashCode()
 {
     return Guid.GetHashCode() + 3 * LanguageVariant.GetHashCode();
 }