Example #1
0
        public static Dictionary<string, string> GetOutputOptionsPairs(OutputOptions outputOptions)
        {
            var pairs = new Dictionary<string, string>();

            var basic = (BasicOutputOptions)outputOptions;
            pairs.AddIfNotNull("Author", basic.Author);
            pairs.AddIfNotNull("Comments", basic.Comments);
            pairs.AddIfNotNull("Company", basic.Company);
            pairs.AddIfNotNull("Keywords", basic.Keywords);
            pairs.AddIfNotNull("Subject", basic.Subject);
            pairs.AddIfNotNull("Title", basic.Title);

            if (outputOptions is PdfOutputOptions)
            {
                var pdf = (PdfOutputOptions)outputOptions;
                pairs.AddIfNotNull("EmbedFonts", pdf.EmbedFonts);
                pairs.AddIfNotNull("PdfA", pdf.PdfA);
                pairs.AddIfNotNull("TaggedPdf", pdf.TaggedPdf);
                pairs.AddIfNotNull("KeepFillablePdf", pdf.KeepFillablePdf);
                pairs.AddIfNotNull("TruncateFields", pdf.TruncateFields);
                pairs.AddIfNotNull("Permissions", pdf.Permissions);
                pairs.AddIfNotNull("OwnerPassword", pdf.OwnerPassword);
                pairs.AddIfNotNull("UserPassword", pdf.UserPassword);
            }
            else if (outputOptions is HtmlOutputOptions)
            {
                pairs.AddIfNotNull("Encoding", ((HtmlOutputOptions)outputOptions).Encoding);
            }
            else if (outputOptions is TextOutputOptions)
            {
                pairs.AddIfNotNull("Encoding", ((TextOutputOptions)outputOptions).Encoding);
            }

            return pairs;
        }
Example #2
0
        // See https://developers.facebook.com/docs/graph-api/reference/user/events
        public async Task<string> PublishEvent(IdentityUser user, FacebookEvent ev)
        {
            var accessToken = GetAccessToken(user);
            var client = new FacebookClient(accessToken);

            var eventdata = new Dictionary<string, object>();
            eventdata.AddIfNotNull("name", ev.Name);
            eventdata.AddIfNotNull("description", ev.Description);
            eventdata.AddIfNotNull("start_time", "2014-04-30"); // Use DateTimeConverter To.... here
            eventdata.AddIfNotNull("location", "Lincoln, NE");
            eventdata.AddIfNotNull("privacy_type", "OPEN");

            var result = await client.PostTaskAsync(string.Format("me/events"), eventdata);

            var settings = new JsonSerializerSettings
            {
                MissingMemberHandling = MissingMemberHandling.Ignore,
                NullValueHandling = NullValueHandling.Ignore
            };
            var id = JsonConvert.DeserializeObject<FacebookIdentity>(result.ToString(), settings);

            Log.InfoFormat("Published a Facebook event.  UserId={0} CreatedId={1} Name={2}", user.Id, id.Id, ev.Name);

            return id.Id;
        }