Exemplo n.º 1
0
        public async Task Upload(Stream stream, string fileName)
        {
            var media      = new MediaDefinition(stream, fileName ?? "img");
            var attachment = await Client.UploadMedia(media);

            attachments.Add(attachment);
        }
Exemplo n.º 2
0
        // private bool IsNegated = false;
        #endregion

        #region Constructors
        /// <summary>
        /// Creates a new 'boolean' type media feature
        /// </summary>
        /// <param name="name"></param>
        public MediaFeature(EMediaFeatureName Name)
        {
            Context = EMediaFeatureContext.Boolean;

            MediaDefinition def = MediaDefinition.Lookup(Name);

            if (def != null)
            {
                IsValid = true;
                /* if an allowed type is keywords and 'none' is an option then we match it against that keyword */
                if (0 != (def.AllowedTypes & ECssValueTypes.KEYWORD) && def.KeywordWhitelist.Contains("none"))
                {
                    Values = new CssValue[] { CssValue.From(Name), CssValue.None };
                }
                else if (0 != (def.AllowedTypes & ECssValueTypes.INTEGER))
                {
                    Values = new CssValue[] { CssValue.From(Name), CssValue.From(0) };
                }
                else if (0 != (def.AllowedTypes & ECssValueTypes.DIMENSION))
                {
                    Values = new CssValue[] { CssValue.From(Name), CssValue.From(0, ECssUnit.PX) };
                }
                else if (0 != (def.AllowedTypes & ECssValueTypes.RESOLUTION))
                {
                    Values = new CssValue[] { CssValue.From(Name), CssValue.From(0, ECssUnit.DPPX) };
                }
            }
            else
            {
                /* This isnt a supported feature, therefore it should always evaluate to false */
                IsValid = false;
            }

            /* For sanity just catch the case where we dont have values to compare here */
            if (Values.Length <= 0)
            {
                IsValid = false;
            }
        }
Exemplo n.º 3
0
 public async Task UploadAvatar(Stream stream, string fileName)
 {
     var media   = new MediaDefinition(stream, fileName ?? "img");
     var profile = await Client.UpdateCredentials(null, null, media);
 }