/// <summary>
        /// Retrieves and prints the access control lists of all
        /// of the authenticated user's calendars.
        /// </summary>
        /// <param name="service">The authenticated CalendarService object.</param>
        static void RetrieveAcls(CalendarService service)
        {
            FeedQuery query = new FeedQuery();

            query.Uri = new Uri("http://www.google.com/calendar/feeds/default");
            AtomFeed calFeed = service.Query(query);

            Console.WriteLine();
            Console.WriteLine("Sharing permissions for your calendars:");

            // Retrieve the meta-feed of all calendars.
            foreach (AtomEntry calendarEntry in calFeed.Entries)
            {
                Console.WriteLine("Calendar: {0}", calendarEntry.Title.Text);
                AtomLink link = calendarEntry.Links.FindService(
                    AclNameTable.LINK_REL_ACCESS_CONTROL_LIST, null);

                // For each calendar, retrieve its ACL feed.
                if (link != null)
                {
                    AclFeed feed = service.Query(new AclQuery(link.HRef.ToString()));
                    foreach (AclEntry aclEntry in feed.Entries)
                    {
                        Console.WriteLine("\tScope: Type={0} ({1})", aclEntry.Scope.Type,
                                          aclEntry.Scope.Value);
                        Console.WriteLine("\tRole: {0}", aclEntry.Role.Value);
                    }
                }
            }
        }
        /// <summary>
        /// Retrieves and prints a list feed of the specified worksheet.
        /// </summary>
        /// <param name="service">an authenticated SpreadsheetsService object</param>
        /// <param name="entry">the worksheet to retrieve</param>
        /// <param name="reverseRows">true if the rows in the worksheet should
        /// be reversed when returned from the server</param>
        private static void RetrieveListFeed(SpreadsheetsService service, WorksheetEntry entry,
                                             bool reverseRows)
        {
            AtomLink listFeedLink = entry.Links.FindService(GDataSpreadsheetsNameTable.ListRel, null);

            Console.WriteLine();
            Console.WriteLine("This worksheet's list feed URL is:");
            Console.WriteLine(listFeedLink.HRef);

            ListQuery query = new ListQuery(listFeedLink.HRef.ToString());

            if (reverseRows)
            {
                query.OrderByPosition = true;
                query.Reverse         = true;
            }
            ListFeed feed = service.Query(query);

            Console.WriteLine();
            Console.WriteLine("Worksheet has {0} rows:", feed.Entries.Count);
            foreach (ListEntry worksheetRow in feed.Entries)
            {
                ListEntry.CustomElementCollection elements = worksheetRow.Elements;
                foreach (ListEntry.Custom element in elements)
                {
                    Console.Write(element.Value + "\t");
                }
                Console.WriteLine();
            }
        }
        /// <summary>
        /// Modifies the <see cref="AtomEntry"/> collection entities to match the supplied <see cref="XPathNavigator"/> data source.
        /// </summary>
        /// <param name="entry">The <see cref="AtomEntry"/> to be filled.</param>
        /// <param name="source">The <see cref="XPathNavigator"/> to extract information from.</param>
        /// <param name="manager">The <see cref="XmlNamespaceManager"/> used to resolve XML namespace prefixes.</param>
        /// <param name="settings">The <see cref="SyndicationResourceLoadSettings"/> used to configure the fill operation.</param>
        /// <remarks>
        ///     This method expects the supplied <paramref name="source"/> to be positioned on the XML element that represents a <see cref="AtomEntry"/>.
        /// </remarks>
        /// <exception cref="ArgumentNullException">The <paramref name="entry"/> is a null reference (Nothing in Visual Basic).</exception>
        /// <exception cref="ArgumentNullException">The <paramref name="source"/> is a null reference (Nothing in Visual Basic).</exception>
        /// <exception cref="ArgumentNullException">The <paramref name="manager"/> is a null reference (Nothing in Visual Basic).</exception>
        /// <exception cref="ArgumentNullException">The <paramref name="settings"/> is a null reference (Nothing in Visual Basic).</exception>
        private static void FillEntryCollections(AtomEntry entry, XPathNavigator source, XmlNamespaceManager manager, SyndicationResourceLoadSettings settings)
        {
            Guard.ArgumentNotNull(entry, "entry");
            Guard.ArgumentNotNull(source, "source");
            Guard.ArgumentNotNull(manager, "manager");
            Guard.ArgumentNotNull(settings, "settings");

            XPathNodeIterator authorIterator      = source.Select("atom:author", manager);
            XPathNodeIterator categoryIterator    = source.Select("atom:category", manager);
            XPathNodeIterator contributorIterator = source.Select("atom:contributor", manager);
            XPathNodeIterator linkIterator        = source.Select("atom:link", manager);

            if (authorIterator != null && authorIterator.Count > 0)
            {
                while (authorIterator.MoveNext())
                {
                    AtomPersonConstruct author = new AtomPersonConstruct();
                    if (author.Load(authorIterator.Current, settings))
                    {
                        entry.Authors.Add(author);
                    }
                }
            }

            if (categoryIterator != null && categoryIterator.Count > 0)
            {
                while (categoryIterator.MoveNext())
                {
                    AtomCategory category = new AtomCategory();
                    if (category.Load(categoryIterator.Current, settings))
                    {
                        entry.Categories.Add(category);
                    }
                }
            }

            if (contributorIterator != null && contributorIterator.Count > 0)
            {
                while (contributorIterator.MoveNext())
                {
                    AtomPersonConstruct contributor = new AtomPersonConstruct();
                    if (contributor.Load(contributorIterator.Current, settings))
                    {
                        entry.Contributors.Add(contributor);
                    }
                }
            }

            if (linkIterator != null && linkIterator.Count > 0)
            {
                while (linkIterator.MoveNext())
                {
                    AtomLink link = new AtomLink();
                    if (link.Load(linkIterator.Current, settings))
                    {
                        entry.Links.Add(link);
                    }
                }
            }
        }
        /// <summary>
        /// Inserts a new row in the specified worksheet.
        /// </summary>
        /// <param name="service">an authenticated SpreadsheetsService object</param>
        /// <param name="entry">the worksheet into which the row will be inserted</param>
        /// <returns>the inserted ListEntry object, representing the new row</returns>
        private static ListEntry InsertRow(SpreadsheetsService service, WorksheetEntry entry)
        {
            AtomLink listFeedLink = entry.Links.FindService(GDataSpreadsheetsNameTable.ListRel, null);

            ListQuery query = new ListQuery(listFeedLink.HRef.ToString());
            ListFeed  feed  = service.Query(query);

            ListEntry firstRow = feed.Entries[0] as ListEntry;
            ListEntry newRow   = new ListEntry();

            Console.WriteLine();
            Console.WriteLine("Inserting a new row...");
            foreach (ListEntry.Custom element in firstRow.Elements)
            {
                Console.Write("Enter the value of column \"{0}\": ", element.LocalName);
                String elementValue = Console.ReadLine();

                ListEntry.Custom curElement = new ListEntry.Custom();
                curElement.LocalName = element.LocalName;
                curElement.Value     = elementValue;

                newRow.Elements.Add(curElement);
            }

            ListEntry insertedRow = feed.Insert(newRow);

            Console.WriteLine("Successfully inserted new row: \"{0}\"",
                              insertedRow.Content.Content);

            return(insertedRow);
        }
        /// <summary>
        /// Updates a single cell in the specified worksheet.
        /// </summary>
        /// <param name="service">an authenticated SpreadsheetsService object</param>
        /// <param name="entry">the worksheet to update</param>
        private static void UpdateCell(SpreadsheetsService service, WorksheetEntry entry)
        {
            AtomLink  cellFeedLink = entry.Links.FindService(GDataSpreadsheetsNameTable.CellRel, null);
            CellQuery query        = new CellQuery(cellFeedLink.HRef.ToString());

            Console.WriteLine();

            Console.Write("Row of cell to update? ");
            string row = Console.ReadLine();

            Console.Write("Column of cell to update? ");
            string column = Console.ReadLine();

            query.MinimumRow    = query.MaximumRow = uint.Parse(row);
            query.MinimumColumn = query.MaximumColumn = uint.Parse(column);

            CellFeed  feed = service.Query(query);
            CellEntry cell = feed.Entries[0] as CellEntry;

            Console.WriteLine();
            Console.WriteLine("Current cell value: {0}", cell.Cell.Value);
            Console.Write("Enter a new value: ");
            string newValue = Console.ReadLine();

            cell.Cell.InputValue = newValue;
            AtomEntry updatedCell = cell.Update();

            Console.WriteLine("Successfully updated cell: {0}", updatedCell.Content.Content);
        }
        public void CreateTemplate()
        {
            DocumentsService service = new DocumentsService(applicationName);

            DocumentEntry entry = new DocumentEntry();

            // Set the document title
            entry.Title.Text    = spreadsheetName;
            entry.IsSpreadsheet = true;

            // Set the media source
            entry.MediaSource = new MediaFileSource(GetStreamWithTemplate(), applicationName, "text/csv");

            // Define the resumable upload link
            Uri      createUploadUrl = new Uri("https://docs.google.com/feeds/upload/create-session/default/private/full");
            AtomLink link            = new AtomLink(createUploadUrl.AbsoluteUri);

            link.Rel = ResumableUploader.CreateMediaRelation;
            entry.Links.Add(link);

            // Set the service to be used to parse the returned entry
            entry.Service = service;

            // Instantiate the ResumableUploader component.
            ResumableUploader uploader = new ResumableUploader();


            // Start the upload process
            uploader.Insert(new ClientLoginAuthenticator(applicationName, ServiceNames.Documents, userName, password), entry);
        }
예제 #7
0
        static void Main(string[] args)
        {
            Environment.CurrentDirectory = Environment.CurrentDirectory.Substring(0, Environment.CurrentDirectory.LastIndexOf("osum", StringComparison.Ordinal)) + @"\osum\osum\Localisation\";
            ss.setUserCredentials("*****@*****.**", "osumisawsum");

            SpreadsheetFeed feed = ss.Query(new SpreadsheetQuery());

            SpreadsheetEntry sheet = null;

            //get spreadsheet
            foreach (var entry in feed.Entries.OfType <SpreadsheetEntry>())
            {
                if (entry.Title.Text == "osu!stream localisation")
                {
                    sheet = entry;
                    break;
                }
            }

            if (sheet == null)
            {
                Console.WriteLine("failed to get spreadsheet");
                Console.ReadLine();
            }

            //get worksheet
            AtomLink       link  = sheet.Links.FindService(GDataSpreadsheetsNameTable.WorksheetRel, null);
            WorksheetQuery query = new WorksheetQuery(link.HRef.ToString());
            WorksheetFeed  wfeed = ss.Query(query);


            WorksheetEntry worksheet = wfeed.Entries[0] as WorksheetEntry;

            ProcessWorksheet(worksheet);
        }
예제 #8
0
        private string ToGoogleTable()
        {
            WorksheetFeed  wsFeed    = TargetTable.Worksheets;
            WorksheetEntry worksheet = (WorksheetEntry)wsFeed.Entries[0];
            // Define the URL to request the list feed of the worksheet.
            AtomLink listFeedLink = worksheet.Links.FindService(GDataSpreadsheetsNameTable.ListRel, null);

            // Fetch the list feed of the worksheet.
            ListQuery listQuery = new ListQuery(listFeedLink.HRef.ToString());
            ListFeed  listFeed  = service.Query(listQuery);

            CellQuery cellQuery = new CellQuery(worksheet.CellFeedLink);
            CellFeed  cellFeed  = service.Query(cellQuery);

            CellEntry cellEntry = new CellEntry(1, 1, "oid");

            cellFeed.Insert(cellEntry);
            cellEntry = new CellEntry(1, 2, "value");
            cellFeed.Insert(cellEntry);
            cellEntry = new CellEntry(1, 3, "type");
            cellFeed.Insert(cellEntry);
            ProgressBarSetStartParams(progressBar1, ListData[ListData.Count - 1].Count);
            tabControlShow(progressBar1);
            tabControlShow(label3);
            for (int i = 0; i < ListData[ListData.Count - 1].Count; i++)
            {
                IncrementProgressbar(progressBar1);
                IncrementGeneralLabel(string.Format("Выполнено {0}/{1}", i + 1, ListData[ListData.Count - 1].Count));
                service.Insert(listFeed, ListData[ListData.Count - 1].GetCustom(i));
            }
            tabControlShow(progressBar1, false);
            tabControlShow(label3, false);
            return("Данные записаны");
        }
        static void Main(string[] args)
        {
            DocumentsService service = new DocumentsService("MyDocumentsListIntegration-v1");
            // TODO: Instantiate an Authenticator object according to your authentication
            // mechanism (e.g. OAuth2Authenticator).
            // Authenticator authenticator =  ...
            // Instantiate a DocumentEntry object to be inserted.
            DocumentEntry entry = new DocumentEntry();

            // Set the document title
            entry.Title.Text = "Legal Contract";
            // Set the media source
            entry.MediaSource = new MediaFileSource("c:\\contract.txt", "text/plain");
            // Define the resumable upload link
            Uri      createUploadUrl = new Uri("https://docs.google.com/feeds/upload/create-session/default/private/full");
            AtomLink link            = new AtomLink(createUploadUrl.AbsoluteUri);

            link.Rel = ResumableUploader.CreateMediaRelation;
            entry.Links.Add(link);
            // Set the service to be used to parse the returned entry
            entry.Service = service;
            // Instantiate the ResumableUploader component.
            ResumableUploader uploader = new ResumableUploader();

            // Set the handlers for the completion and progress events
            uploader.AsyncOperationCompleted += new AsyncOperationCompletedEventHandler(OnDone);
            uploader.AsyncOperationProgress  += new AsyncOperationProgressEventHandler(OnProgress);
            // Start the upload process
            uploader.InsertAsync(authenticator, entry, new object());
        }
예제 #10
0
        /// <summary>
        /// insert a new video.
        /// </summary>
        /// <param name="row"></param>
        /// <param name="retryCounter"></param>
        /// <returns></returns>
        private bool InsertVideo(DataGridViewRow row, int retryCounter)
        {
            Trace.TraceInformation("Entering InsertVideo: starting a new upload");
            Video v = new Video();

            v.Title       = row.Cells[0].Value.ToString();
            v.Description = row.Cells[1].Value.ToString();
            v.Keywords    = row.Cells[2].Value.ToString();
            v.Tags.Add(new MediaCategory(row.Cells[3].Value.ToString()));
            v.Private = row.Cells[4].Value.ToString().ToLower() == "true";

            string contentType = MediaFileSource.GetContentTypeForFileName(row.Cells[COLUMNINDEX_FILENAME].Value.ToString());

            v.MediaSource = new MediaFileSource(row.Cells[COLUMNINDEX_FILENAME].Value.ToString(), contentType);

            // add the upload uri to it
            AtomLink link = new AtomLink("http://uploads.gdata.youtube.com/resumable/feeds/api/users/" + this.youtubeAccount + "/uploads");

            link.Rel = ResumableUploader.CreateMediaRelation;
            v.YouTubeEntry.Links.Add(link);

            UserState u = new UserState(row);

            u.RetryCounter = retryCounter;

            lock (this.flag) {
                this.queue.Add(u);
            }
            ru.InsertAsync(this.youTubeAuthenticator, v.YouTubeEntry, u);

            row.Cells[COLUMNINDEX_STATUS].Value = "Queued up...";
            row.Cells[COLUMNINDEX_STATUS].Tag   = u;

            return(true);
        }
예제 #11
0
    public async Task UploadToYouTube(HttpPostedFile postedFile, string title)
    {
        UploadingDispatcher.SetProgress(uploadId, 2);
        Video video = new Video();

        video.Title = title;
        video.Tags.Add(new MediaCategory("Autos", YouTubeNameTable.CategorySchema));
        video.Private     = false;
        video.MediaSource = new MediaFileSource(postedFile.InputStream, postedFile.FileName, postedFile.ContentType);

        var link = new AtomLink("http://uploads.gdata.youtube.com/resumable/feeds/api/users/default/uploads");

        link.Rel = ResumableUploader.CreateMediaRelation;
        video.YouTubeEntry.Links.Add(link);

        var youtubeApiKey    = ConfigurationManager.AppSettings["youtubeApiKey"];
        var applicationName  = ConfigurationManager.AppSettings["applicationName"];
        var youtubeUserName  = ConfigurationManager.AppSettings["youtubeUserName"];
        var youtubePassword  = ConfigurationManager.AppSettings["youtubePassword"];
        var youtubeChunksize = int.Parse(ConfigurationManager.AppSettings["youtubeChunksize"]);

        var resumableUploader = new ResumableUploader(youtubeChunksize);

        resumableUploader.AsyncOperationCompleted += resumableUploader_AsyncOperationCompleted;
        resumableUploader.AsyncOperationProgress  += resumableUploader_AsyncOperationProgress;


        var youTubeAuthenticator = new ClientLoginAuthenticator(applicationName, ServiceNames.YouTube, youtubeUserName, youtubePassword);

        youTubeAuthenticator.DeveloperKey = youtubeApiKey;

        resumableUploader.InsertAsync(youTubeAuthenticator, video.YouTubeEntry, uploadId);
    }
예제 #12
0
        private Dictionary <string, JobInfo> getGoogleDocsJobs()
        {
            Dictionary <string, JobInfo> jobs = new Dictionary <string, JobInfo>();

            WorksheetEntry ws        = this.getDataWorksheet();
            AtomLink       feedLink  = ws.Links.FindService(GDataSpreadsheetsNameTable.ListRel, null);
            ListQuery      listQuery = new ListQuery(feedLink.HRef.ToString());
            ListFeed       feed      = this.service.Query(listQuery);

            foreach (ListEntry row in feed.Entries)
            {
                string key  = null;
                string col1 = null;
                string col2 = null;
                foreach (ListEntry.Custom element in row.Elements)
                {
                    if (key == null)
                    {
                        key = element.Value;
                    }
                    else if (col1 == null)
                    {
                        col1 = element.Value;
                    }
                    else if (col2 == null)
                    {
                        col2 = element.Value;
                    }
                }
                jobs.Add(key, new JobInfo(key, col1, col2));
            }
            return(jobs);
        }
        //Fetch all worksheets for given Spreadsheet

        public static ArrayList getWorksheetList(string userName, string passWord, string spreadSheetName)
        {
            ArrayList worksheetList = new ArrayList();

            SpreadsheetsService service = new SpreadsheetsService(spreadSheetName + "Service");

            //You could set it up from DB or config file also. This is not a reccomended way. Just an easy way to show fetching
            service.setUserCredentials(userName, passWord);

            SpreadsheetQuery query = new SpreadsheetQuery();

            SpreadsheetFeed feed = service.Query(query);

            foreach (SpreadsheetEntry entry in feed.Entries)
            {
                if (entry.Title.Text == spreadSheetName)
                {
                    AtomLink link = entry.Links.FindService(GDataSpreadsheetsNameTable.WorksheetRel, null);

                    WorksheetQuery wquery = new WorksheetQuery(link.HRef.ToString());
                    WorksheetFeed  wfeed  = service.Query(wquery);

                    foreach (WorksheetEntry worksheet in wfeed.Entries)
                    {
                        worksheetList.Add(worksheet.Title.Text);
                    }
                }
            }

            return(worksheetList);
        }
예제 #14
0
        public void ListQuery(WorksheetEntry worksheet)
        {
            // Define the URL to request the list feed of the worksheet.
            AtomLink listFeedLink = worksheet.Links.FindService(GDataSpreadsheetsNameTable.ListRel, null);

            // Fetch the list feed of the worksheet.
            ListQuery listQuery = new ListQuery(listFeedLink.HRef.ToString());

            //listQuery.MinPublication = new DateTime(2013, 9, 18);
            //listQuery.ModifiedSince = new DateTime(2013, 9, 18);
            listQuery.StartDate = new DateTime(2013, 9, 18);

            ListFeed listFeed = this.Service.Query(listQuery);

            Console.WriteLine("Results {0}", listFeed.Entries.Count);

            for (int rowIdx = 0; rowIdx < 10; rowIdx++)
            {
                // TODO: Choose a row more intelligently based on your app's needs.
                ListEntry row = (ListEntry)listFeed.Entries[rowIdx];


                // Update the row's data.
                foreach (ListEntry.Custom element in row.Elements)
                {
                    Console.WriteLine(element.LocalName + " : " + element.Value);
                    Console.ReadLine();
                }
            }
        }
예제 #15
0
        public AtomEntry createWebPage(String originalUrl, String path, String title, String html, String pageName, DateTime lastModified, bool isIndexPage, string indexHtmlPath = "")
        {
            if (cancel())
            {
                return(null);
            }
            String parentUrl = originalUrl.Substring(0, originalUrl.LastIndexOf("/"));

            pageName = originalUrl.Substring(originalUrl.LastIndexOf("/") + 1);
            AtomEntry    parent   = m_service.Get(parentUrl);
            SiteEntry    entry    = new SiteEntry();
            AtomCategory category = new AtomCategory(SitesService.WEBPAGE_TERM, SitesService.KIND_SCHEME);

            category.Label = "webpage";
            entry.Categories.Add(category);
            AtomLink link = new AtomLink("application/atom+xml", "http://schemas.google.com/sites/2008#parent");

            link.HRef = parent.EditUri;
            entry.Links.Add(link);
            entry.Title.Text      = m_convertCase ? IndianBridge.Common.Utilities.ConvertCaseString(title) : title;
            entry.Content.Type    = "html";
            entry.Content.Content = m_replaceLinks ? replaceLinks(html, originalUrl, isIndexPage, indexHtmlPath) : html;
            entry.ExtensionElements.Add(makePageNameExtension(pageName));
            AtomEntry newEntry = null;
            String    url      = "https://sites.google.com/feeds/content/site/" + m_siteName;

            newEntry = m_service.Insert(new Uri(url), entry);
            m_lastRunTimes[originalUrl] = lastModified;
            printMessage("CREATED.");
            numberOfPagesAlreadyUploaded++;
            reportProgress(title);
            return(newEntry);
        }
        /// <summary>
        /// overwritten Query method
        /// </summary>
        /// <param name="feedQuery">The FeedQuery to use</param>
        /// <returns>the retrieved NicknameFeed</returns>
        public NicknameFeed Query(NicknameQuery feedQuery)
        {
            try
            {
                Stream       feedStream = Query(feedQuery.Uri);
                NicknameFeed feed       = new NicknameFeed(feedQuery.Uri, this);
                feed.Parse(feedStream, AlternativeFormat.Atom);
                feedStream.Close();

                if (feedQuery.RetrieveAllNicknames)
                {
                    AtomLink next, prev = null;
                    while ((next = feed.Links.FindService("next", null)) != null && next != prev)
                    {
                        feedStream = Query(new Uri(next.HRef.ToString()));
                        feed.Parse(feedStream, AlternativeFormat.Atom);
                        feedStream.Close();

                        prev = next;
                    }
                }

                return(feed);
            }
            catch (GDataRequestException e)
            {
                AppsException a = AppsException.ParseAppsException(e);
                throw (a == null ? e : a);
            }
        }
        public void AtomLinkConstructorTest2()
        {
            AtomLink target = new AtomLink();

            Assert.IsNotNull(target);
            Assert.IsNull(target.AbsoluteUri);
        }
예제 #18
0
        public void IsPreviousLinkReturnsTrueForPreviousLink(
            Uri href)
        {
            bool actual = AtomLink.CreatePreviousLink(href).IsPreviousLink;

            Assert.True(actual, "Should be previous link.");
        }
예제 #19
0
        public void IsNextLinkReturnsTrueForNextLink(
            Uri href)
        {
            bool actual = AtomLink.CreateNextLink(href).IsNextLink;

            Assert.True(actual, "Should be next link.");
        }
예제 #20
0
        public static AtomLink CreateEditMediaLink(Uri href, string contentType, CultureInfo contentLanguage)
        {
            AtomLink link = AtomMemberResources.CreateEditMediaLink(href, contentType);

            link.ContentLanguage = contentLanguage;
            return(link);
        }
 /// <summary>
 /// overwritten Query method
 /// </summary>
 /// <param name="uri">The URI for the query</param>
 /// <returns>the retrieved AppsExtendedFeed</returns>
 public AppsExtendedFeed QueryGroups(Uri uri)
 {
     try
     {
         Stream           feedStream = Query(uri);
         AppsExtendedFeed feed       = new AppsExtendedFeed(uri, this);
         feed.Parse(feedStream, AlternativeFormat.Atom);
         feedStream.Close();
         if (true)
         {
             AtomLink next, prev = null;
             while ((next = feed.Links.FindService("next", null)) != null && next != prev)
             {
                 feedStream = Query(new Uri(next.HRef.ToString()));
                 feed.Parse(feedStream, AlternativeFormat.Atom);
                 feedStream.Close();
                 prev = next;
             }
         }
         return(feed);
     }
     catch (GDataRequestException e)
     {
         AppsException a = AppsException.ParseAppsException(e);
         throw (a == null ? e : a);
     }
 }
        /// <summary>
        /// Sets the list view on the Worksheets page with the titles of the worksheets,
        /// and the row and column counts for demonstration of these extension elements
        /// </summary>
        /// <param name="feed">The worksheets feed for the spreadsheet selected on the Spreadsheets page</param>
        void SetWorksheetListView(WorksheetFeed feed)
        {
            this.worksheetListView.Items.Clear();

            AtomEntryCollection entries = feed.Entries;

            for (int i = 0; i < entries.Count; i++)
            {
                // Get the cells feed URI
                AtomLink cellsLink = entries[i].Links.FindService(GDataSpreadsheetsNameTable.CellRel, AtomLink.ATOM_TYPE);

                // Get the list feed URI
                AtomLink listLink = entries[i].Links.FindService(GDataSpreadsheetsNameTable.ListRel, AtomLink.ATOM_TYPE);

                // Create an item that will display the title and hide the cells and list feed URIs
                ListViewItem item = new ListViewItem(new string[3] {
                    entries[i].Title.Text + " (Rows:"
                    + ((WorksheetEntry)entries[i]).RowCount.Count
                    + ", Cols:" + ((WorksheetEntry)entries[i]).ColCount.Count + ")",
                    cellsLink.HRef.Content, listLink.HRef.Content
                });

                this.worksheetListView.Items.Add(item);
            }
        }
예제 #23
0
        /// <summary>
        /// Creates a new <see cref="AtomLink"/> that can be used to modify a media resource associated with an <see cref="AtomEntry"/> using the supplied parameters.
        /// </summary>
        /// <param name="href">A <see cref="Uri"/> that represents an IRI that can be used to modify a media resource associated with an <see cref="AtomEntry"/>.</param>
        /// <param name="contentType">An advisory MIME media type that provides a hint about the type of the representation that is expected to be returned by the Web resource.</param>
        /// <returns>A <see cref="AtomLink"/> object that can be can be used to modify a media resource associated with an <see cref="AtomEntry"/>.</returns>
        /// <remarks>
        ///     <para>
        ///         The <see cref="AtomLink"/> that is returned has a <see cref="AtomLink.Relation"/> of <b>edit-media</b>. The value of <i>edit-media</i> specifies
        ///         that the value of the <paramref name="href"/> attribute is an IRI that can be used to modify a media resource associated with an <see cref="AtomEntry"/>.
        ///     </para>
        ///     <para>
        ///         An <see cref="AtomEntry"/> <i>may</i> contain zero or more <i>edit-media</i> link relations.
        ///         An <see cref="AtomEntry"/> <b>must not</b> contain more than one <see cref="AtomLink"/> with a <see cref="AtomLink.Relation"/> value of <i>edit-media</i>
        ///         that has the same <see cref="AtomLink.ContentType"/> and <see cref="AtomLink.ContentLanguage"/> values.
        ///         All <i>edit-media</i> link relations in the same <see cref="AtomEntry"/> reference the same Resource.
        ///         If a client encounters multiple <i>edit-media</i> link relations in an <see cref="AtomEntry"/> then it <i>should</i> choose a link based on the client
        ///         preferences for <see cref="AtomLink.ContentType"/> and <see cref="AtomLink.ContentLanguage"/>. If a client encounters multiple <i>edit-media</i> link relations
        ///         in an <see cref="AtomEntry"/> and has no preference based on the <see cref="AtomLink.ContentType"/> and <see cref="AtomLink.ContentLanguage"/> then the
        ///         client <i>should</i> pick the first <i>edit-media</i> link relation in document order.
        ///     </para>
        /// </remarks>
        /// <exception cref="ArgumentNullException">The <paramref name="href"/> is a null reference (Nothing in Visual Basic).</exception>
        public static AtomLink CreateEditMediaLink(Uri href, string contentType)
        {
            AtomLink link = AtomMemberResources.CreateEditMediaLink(href);

            link.ContentType = contentType;
            return(link);
        }
예제 #24
0
        public void IsLastLinkReturnsFalseForNonLastLink(AtomLink sut)
        {
            Assert.NotEqual("last", sut.Rel);
            var actual = sut.IsLastLink;

            Assert.False(actual, "Should not be last link.");
        }
        public void ReadNonPersistedFeedReturnsCorrectFeed(
            AtomEventsInMemory sut,
            UuidIri id,
            IContentSerializer dummySerializer)
        {
            var expectedSelfLink = AtomLink.CreateSelfLink(
                new Uri(
                    ((Guid)id).ToString(),
                    UriKind.Relative));
            var before = DateTimeOffset.Now;

            using (var r = sut.CreateFeedReaderFor(expectedSelfLink.Href))
            {
                var actual = AtomFeed.ReadFrom(r, dummySerializer);

                Assert.Equal(id, actual.Id);
                Assert.Equal("Index of event stream " + (Guid)id, actual.Title);
                Assert.True(before <= actual.Updated, "Updated should be very recent.");
                Assert.True(actual.Updated <= DateTimeOffset.Now, "Updated should not be in the future.");
                Assert.Empty(actual.Entries);
                Assert.Contains(
                    expectedSelfLink,
                    actual.Links);
            }
        }
        /// <summary>
        /// returns the resumabled create media Uri for a given entry
        /// </summary>
        /// <param name="entry"></param>
        /// <returns></returns>
        public static Uri GetResumableCreateUri(AtomLinkCollection links)
        {
            // scan the link collection
            AtomLink link = links.FindService(CreateMediaRelation, null);

            return(link == null ? null : new Uri(link.AbsoluteUri));
        }
        public void AtomLinkConstructorTest1()
        {
            string   link   = "http://www.test.com/";
            AtomLink target = new AtomLink(link);

            Assert.AreEqual(target.AbsoluteUri, link);
        }
예제 #28
0
        public void IsSelfLinkReturnsTrueForSelfLink(
            Uri href)
        {
            bool actual = AtomLink.CreateSelfLink(href).IsSelfLink;

            Assert.True(actual, "Should be self link.");
        }
예제 #29
0
        public void IsViaLinkReturnsTrueForViaLink(
            Uri href)
        {
            bool actual = AtomLink.CreateViaLink(href).IsViaLink;

            Assert.True(actual, "Should be via link.");
        }
예제 #30
0
        public void WriteToXmlWriterWritesCorrectXml(
            AtomLink sut)
        {
            // Fixture setup
            var sb = new StringBuilder();

            using (var w = XmlWriter.Create(sb))
            {
                // Exercise system
                sut.WriteTo(w);

                // Verify outcome
                w.Flush();

                var expected = XDocument.Parse(
                    "<link" +
                    " href=\"" + sut.Href.ToString() + "\"" +
                    " rel=\"" + sut.Rel + "\"" +
                    " xmlns=\"http://www.w3.org/2005/Atom\" />");

                var actual = XDocument.Parse(sb.ToString());
                Assert.Equal(expected, actual, new XNodeEqualityComparer());
            }
            // Teardown
        }
예제 #31
0
 private bool IsExpectedSelfLink(AtomLink link)
 {
     if (!link.IsSelfLink)
         return false;
     return GetIdFromHref(link.Href) == (Guid)this.expectedId;
 }
예제 #32
0
		/// <summary>
		/// Determines whether the <see cref="AtomLinkCollection"/> contains a specific element.
		/// </summary>
		/// <param name="link">The <see cref="AtomLink"/> to locate in the <see cref="AtomLinkCollection"/>.</param>
		/// <returns>true if the <see cref="AtomLinkCollection"/> contains the specified item, otherwise false.</returns>
		public bool Contains(AtomLink link)
		{
			return this.List.Contains(link);
		}
예제 #33
0
		/// <summary>
		/// Adds an object to the end of the <see cref="AtomLinkCollection"/>.
		/// </summary>
		/// <param name="link">The <see cref="AtomLink"/> to be added to the end of the <see cref="AtomLinkCollection"/>.</param>
		/// <returns>The <see cref="AtomLinkCollection"/> index at which the value has been added.</returns>
		public int Add(AtomLink link)
		{
			//CheckInsertion(link);
			return this.List.Add(link);
		}
예제 #34
0
		/// <summary>
		/// Performs some checks inside the collection. Used for compliancy to the standard.
		/// </summary>
		/// <param name="link">The <see cref="AtomLink"/> to check.</param>
		private void CheckInsertion(AtomLink link)
		{
			if(this.List.Count != 0)
				if(link.Rel == Relationship.Alternate)
					foreach(AtomLink item in this)
						if(item.Rel == Relationship.Alternate)
							if(item.Type == link.Type)
								throw new DuplicateLinkException(
									"There can't be two links with the same relationship and type.");
		}
예제 #35
0
		/// <summary>Removes the first occurrence of a specific <see cref="AtomLink"/> from the <see cref="AtomLinkCollection"/>.</summary>
		/// <param name="link">The <see cref="AtomLink"/> to remove from the <see cref="AtomLinkCollection"/>.</param>
		public void Remove(AtomLink link)
		{
			List.Remove(link);
		}
예제 #36
0
		/// <summary>Inserts a <see cref="AtomLink"/> into this collection at the specified index.</summary>
		/// <param name="index">The zero-based index of the collection at which <i>link</i> should be inserted.</param>
		/// <param name="link">The <see cref="AtomLink"/> to insert into this collection.</param>
		public void Insert(int index, AtomLink link)
		{
			//CheckInsertion(link);
			List.Insert(index, link);
		}
예제 #37
0
		/// <summary>
		/// Searches for the specified <see cref="AtomLink"/> and returns the zero-based index of the first occurrence
		/// within the entire <see cref="AtomLinkCollection"/>.
		/// </summary>
		/// <param name="link">The <see cref="AtomLink"/> to locate in the <see cref="AtomLinkCollection"/>.</param>
		/// <returns>The zero-based index of the first occurrence of <i>link</i> within the entire <see cref="AtomLinkCollection"/>,
		/// if found; otherwise, -1.</returns>
		public int IndexOf(AtomLink link)
		{
			return List.IndexOf(link);
		}