当前位置: 首页>>代码示例>>C#>>正文


C# Client.Service类代码示例

本文整理汇总了C#中Google.GData.Client.Service的典型用法代码示例。如果您正苦于以下问题:C# Service类的具体用法?C# Service怎么用?C# Service使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Service类属于Google.GData.Client命名空间,在下文中一共展示了Service类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Index

        public void Index()
        {
            var g = new Service("local", "application");//, "ABQIAAAACPMbozlNv9AIzNvsWUm6vhSvnLMDprvOSMH9Qt_oH5Ww7FTw1hRHT7gTSie1yM34rowNwVfw424XPA");

            Assert.Fail("Need to put password here");
            g.setUserCredentials("[email protected]", "zzz");
            var entry = new AtomEntry();
            entry.Content.ExtensionFactories.Add(new MapsExtension());
            entry.Title.Text = "test";
               entry.Content.Type = "application/vnd.google-earth.kml+xml";
               XmlDocument doc = new XmlDocument();
            doc.LoadXml(@"<Placemark xmlns='http://www.opengis.net/kml/2.2'>
                   <name>Faulkner's Birthplace</name>
                   <description/>
                   <Point>
                     <coordinates>-89.520753,34.360902,0.0</coordinates>
                   </Point>
                 </Placemark>");
            entry.Content.ExtensionElements.Add(new XmlExtension((XmlNode)doc.DocumentElement));
                 //    doc.LoadXml(@"@"<m:Placemark>
                 //  <m:name>Faulkner's Birthplace</m:name>
                 //  <m:description/>
                 //  <m:Point>
                 //    <m:coordinates>-89.520753,34.360902,0.0</m:coordinates>
                 //  </m:Point>
                 //</m:Placemark>";

            //entry.Content.Content = ;
            //entry.AddExtension(new MapsExtension());
            var m = new MemoryStream();
            //var mapStuff = entry.Content.CreateExtension("PlaceMark", "http://www.opengis.net/kml/2.2");

               // entry.Update();
            try
            {
                entry.SaveToXml(m);
            }
            catch (Exception e)
            {
                var s = e.ToString();
                throw;
            }
            m.Position = 0;
            var mm = new StreamReader(m).ReadToEnd();
             var q = g.Insert(new Uri("http://maps.google.com/maps/feeds/features/208433541473729117510/0004779109f86bbabd62d/full"), entry);

            var p = g.Query(new Uri("http://maps.google.com/maps/feeds/maps/default/full"));

            var z = new StreamReader(p).ReadToEnd();

            //// Arrange
            //HomeController controller = new HomeController();

            //// Act
            //ViewResult result = controller.Index() as ViewResult;

            //// Assert
            //ViewDataDictionary viewData = result.ViewData;
            //Assert.AreEqual("Welcome to ASP.NET MVC!", viewData["Message"]);
        }
开发者ID:hankbeasley,项目名称:hoahome,代码行数:60,代码来源:HomeControllerTest.cs

示例2: SelectUserBlog

        /** Lists the user's blogs and returns the URI for posting new entries
         * to the blog which the user selected.
         */
        static Uri SelectUserBlog(Service service)
        {
            Console.WriteLine("\nPlease select a blog on which to post.");
            FeedQuery query = new FeedQuery();
            // Retrieving a list of blogs
            query.Uri = new Uri("http://www.blogger.com/feeds/default/blogs");
            AtomFeed feed = service.Query(query);

            // Publishing a blog post
            Uri blogPostUri = null;
            if (feed != null)
            {
                foreach (AtomEntry entry in feed.Entries)
                {
                    // Print out the title of the Blog
                    Console.WriteLine("  Blog name: " + entry.Title.Text);
                    Console.Write("  Post to this blog? (y/n): ");
                    if (Console.ReadLine().Equals("y"))
                    {
                        // find the href in the link with a rel pointing to the blog's feed
                        for (int i = 0; i < entry.Links.Count; i++)
                        {
                            if (entry.Links[i].Rel.Equals("http://schemas.google.com/g/2005#post"))
                            {
                                blogPostUri = new Uri(entry.Links[i].HRef.ToString());
                                Console.WriteLine("  Your new posts will be sent to " + blogPostUri.AbsoluteUri.ToString());
                            }
                        }
                        return blogPostUri;
                    }
                }
            }
            return blogPostUri;
        }
开发者ID:Zelxin,项目名称:RPiKeg,代码行数:37,代码来源:ConsoleSample.cs

示例3: PostNewEntry

        /** Creates a new blog entry and sends it to the specified Uri */
        static AtomEntry PostNewEntry(Service service, Uri blogPostUri)
        {
            Console.WriteLine("\nPublishing a blog post");
            AtomEntry createdEntry = null;
            if (blogPostUri != null)
            {
                // construct the new entry
                AtomEntry newPost = new AtomEntry();
                newPost.Title.Text = "Marriage!";
                newPost.Content = new AtomContent();
                newPost.Content.Content = "<div xmlns='http://www.w3.org/1999/xhtml'>" +
                    "<p>Mr. Darcy has <em>proposed marriage</em> to me!</p>" +
                    "<p>He is the last man on earth I would ever desire to marry.</p>" +
                    "<p>Whatever shall I do?</p>" +
                    "</div>";
                newPost.Content.Type = "xhtml";
                newPost.Authors.Add(new AtomPerson());
                newPost.Authors[0].Name = "Elizabeth Bennet";
                newPost.Authors[0].Email = "[email protected]";

                createdEntry = service.Insert(blogPostUri, newPost);
                if (createdEntry != null)
                {
                    Console.WriteLine("  New blog post created with title: " + createdEntry.Title.Text);
                }
            }
            return createdEntry;
        }
开发者ID:Zelxin,项目名称:RPiKeg,代码行数:29,代码来源:ConsoleSample.cs

示例4: Main

        static void Main(string[] args)
        {
            Console.WriteLine("Suchwort:");
            string searchTerm = Console.ReadLine();

            string uriSearchTerm = HttpUtility.UrlEncode(searchTerm);
            string url = "http://gdata.youtube.com/feeds/videos?q=" + uriSearchTerm;
            
            Console.WriteLine("Connection to YouTube - Searching: " + searchTerm);

            FeedQuery query = new FeedQuery("");
            Service service = new Service("youtube", "sample");
            query.Uri = new Uri(url);
            query.StartIndex = 0;
            query.NumberToRetrieve = 20;
            AtomFeed resultFeed = service.Query(query);

            foreach (AtomEntry entry in resultFeed.Entries)
            {
                Console.WriteLine("Title: " + entry.Title.Text);
                Console.WriteLine("Link: " + entry.AlternateUri.Content);
                Console.WriteLine("Tags:");
                foreach (AtomCategory cat in entry.Categories)
                {
                    Console.Write(cat.Term + ", ");
                }
                Console.WriteLine();
            }

            Console.ReadLine();
        }
开发者ID:davidalmas,项目名称:Samples,代码行数:31,代码来源:Program.cs

示例5: GetGoogleCalendar

        public AtomFeed GetGoogleCalendar()
        {
            Service service = new Service();
            FeedQuery query = new FeedQuery();
            query.Uri = new Uri(publicCalendarUrl);
            return service.Query(query);

        }
开发者ID:mukhtiarlander,项目名称:git_demo_torit,代码行数:8,代码来源:CalendarSyncGoogle.cs

示例6: Google2uManualWorkbook

 public Google2uManualWorkbook(WorksheetFeed in_feed, string in_url, string in_name, Service in_service)
 {
     _Service = in_service;
     WorkbookUrl = in_url;
     Workbook = in_feed;
     WorkbookName = in_name;
     Worksheets = new List<Google2uWorksheet>();
 }
开发者ID:joenarus,项目名称:Stressident,代码行数:8,代码来源:Google2uManualWorkbook.cs

示例7: UriTest

 public void UriTest()
 {
     Uri uri = new Uri("http://www.test.com/");
     IService service = new Service();
     ServiceEventArgs target = new ServiceEventArgs(uri, service); // TODO: Initialize to an appropriate value
     Uri actual;
     actual = target.Uri;
     Assert.AreEqual(actual, uri);
 }
开发者ID:Zelxin,项目名称:RPiKeg,代码行数:9,代码来源:ServiceEventArgsTest.cs

示例8: GoogleClientLogin

        /// <summary>
        /// allows you to construct the dialog with a given service
        /// </summary>
        /// <param name="serviceToUse">the service object to use</param>
        public GoogleClientLogin(Service serviceToUse)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            this.service = serviceToUse;
        }
开发者ID:nagyist,项目名称:GoogleAnalytics-MonoMac-Demo,代码行数:13,代码来源:GoogleClientLogin.cs

示例9: RequestFactoryTest

 public void RequestFactoryTest()
 {
     Service target = new Service(); // TODO: Initialize to an appropriate value
     IGDataRequestFactory expected = new GDataGAuthRequestFactory("cl", "test");
     IGDataRequestFactory actual;
     target.RequestFactory = expected;
     actual = target.RequestFactory;
     Assert.AreEqual(expected, actual);
 }
开发者ID:Zelxin,项目名称:RPiKeg,代码行数:9,代码来源:ServiceTest.cs

示例10: FeedCleanup

        //////////////////////////////////////////////////////////////////////
        /// <summary>empty a feed</summary> 
        //////////////////////////////////////////////////////////////////////
        protected void FeedCleanup(String uriToClean, String userName, String pwd)
        {
            Tracing.TraceCall();
            Tracing.TraceCall("Cleaning URI: " + uriToClean);

            if (!this.wipeFeeds)
            {
                Tracing.TraceInfo("Skipped cleaning URI due to configuration.");
                return;
            }

            FeedQuery query = new FeedQuery();
            Service service = new Service();

            if (uriToClean != null)
            {
                if (userName != null)
                {
                    service.Credentials = new GDataCredentials(userName, pwd);
                }

                GDataLoggingRequestFactory factory = (GDataLoggingRequestFactory)this.factory;
                factory.MethodOverride = true;
                service.RequestFactory = this.factory; 

                query.Uri = new Uri(uriToClean);

                Tracing.TraceCall("Querying " + uriToClean);
                AtomFeed feed = service.Query(query);
                Tracing.TraceCall("Queryed " + uriToClean);
                if (feed != null)
                    Tracing.TraceCall("Entries: " + feed.Entries.Count.ToString());

                int iCount = 0; 

                if (feed.Entries.Count > 0)
                {
                    while (feed.Entries.Count > 0)
                    {
                        Tracing.TraceCall("Feed has still " + feed.Entries.Count.ToString() + " entries left.");
                        foreach (AtomEntry entry in feed.Entries)
                        {
                            Tracing.TraceCall("Deleting entry " + iCount);
                            entry.Delete();
                            iCount++; 
                            Tracing.TraceCall("Deleted entry " + iCount);
                        }
                        feed = service.Query(query);
                    }

                    Assert.AreEqual(0, feed.Entries.Count, "Feed should have no more entries, it has: " + feed.Entries.Count); 
                    service.Credentials = null; 
                    factory.MethodOverride = false;
                }
            }
        }
开发者ID:mintwans,项目名称:cpsc483,代码行数:59,代码来源:baselivetestclass.cs

示例11: DefaultHostInsertOneAndDelete

        /////////////////////////////////////////////////////////////////////////////



        //////////////////////////////////////////////////////////////////////
        /// <summary>[Test] creates a new entry, saves and loads it back</summary> 
        //////////////////////////////////////////////////////////////////////
        [Test] public void DefaultHostInsertOneAndDelete()
        {
            Tracing.TraceMsg("Entering DefaultHostInsertOneAndDelete");
            AtomEntry entry = ObjectModelHelper.CreateAtomEntry(1); 
            Service service = new Service();
            FeedQuery query = new FeedQuery();
            service.RequestFactory = this.factory; 

            int iCount=0; 

            string strTitle = "DefaultHostInsertOneAndDelete" + Guid.NewGuid().ToString(); 
            entry.Title.Text = strTitle; 

            query.Uri = new Uri(this.defaultHost);
            AtomFeed returnFeed = service.Query(query);

            iCount = returnFeed.Entries.Count; 


            for (int i = 0; i < this.iIterations; i++)
            {
                Tracing.TraceMsg("DefaultHostInsertOneAndDelete, iteration : " + i); 

                Stream s = service.EntrySend(new Uri(this.defaultHost), entry, GDataRequestType.Insert); 
                s.Close();

                returnFeed = service.Query(query);
                Assert.AreEqual(iCount+1, returnFeed.Entries.Count, "feed should have one more entry now"); 

                AtomEntry returnEntry = null;

                foreach (AtomEntry feedEntry in returnFeed.Entries )
                {
                    if (String.Compare(feedEntry.Title.Text, strTitle) == 0)
                    {
                        // got him
                        returnEntry = feedEntry; 
                        break;
                    }
                }

                Assert.IsTrue(returnEntry != null, "did not find the just inserted entry"); 

                returnEntry.Delete();

                // query again and check count

                returnFeed = service.Query(query);

                Assert.AreEqual(iCount, returnFeed.Entries.Count, "feed has different number of entries as expected"); 
            }
        }
开发者ID:nagyist,项目名称:GoogleAnalytics-MonoMac-Demo,代码行数:59,代码来源:writetest.cs

示例12: Google2uAccountWorkbook

        public Google2uAccountWorkbook(SpreadsheetEntry in_spreadsheet, Service in_service)
        {
            Workbook = in_spreadsheet;
            WorkbookName = in_spreadsheet.Title.Text;
            _Service = in_service;

            foreach (var link in in_spreadsheet.Links.Where(in_link => in_link.Rel.Equals("alternate", StringComparison.OrdinalIgnoreCase)))
            {
                WorkbookUrl = link.HRef.ToString();
                break;
            }
            Worksheets = new List<Google2uWorksheet>();
        }
开发者ID:DarkRay,项目名称:neverending-story,代码行数:13,代码来源:Google2uAccountWorkbook.cs

示例13: ListUserBlogs

 /** Lists the user's blogs. */
 static void ListUserBlogs(Service service)
 {
     Console.WriteLine("\nRetrieving a list of blogs");
     FeedQuery query = new FeedQuery();
     // Retrieving a list of blogs
     query.Uri = new Uri("http://www.blogger.com/feeds/default/blogs");
     AtomFeed feed = null;
     feed = service.Query(query);
     foreach (AtomEntry entry in feed.Entries)
     {
         Console.WriteLine("  Blog title: " + entry.Title.Text);
     }
 }
开发者ID:Zelxin,项目名称:RPiKeg,代码行数:14,代码来源:ConsoleSample.cs

示例14: GetFeed

        public static AtomFeed GetFeed(string url = "", int start = 0, int num_results = 0)
        {
            FeedQuery query = new FeedQuery("");
            Google.GData.Client.Service service = new Google.GData.Client.Service();
            query.Uri = new Uri(url);
            if (start > 0) {
                query.StartIndex = start;
            }
            if (num_results > 0) {
                query.NumberToRetrieve = num_results;
            }

            AtomFeed feed = service.Query(query);
            return feed;
        }
开发者ID:janiukjf,项目名称:curtmfg,代码行数:15,代码来源:MediaModel.cs

示例15: PublishNewEntry

        public void PublishNewEntry(BlogDescriptor blogDescriptor, String title, String content)
        {
            if (blogDescriptor == null)
                throw new ArgumentNullException("blogDescriptor");
            if (String.IsNullOrEmpty(blogDescriptor.Username))
                throw new ArgumentException("blogDescriptor.Username cannot be null or an empty string.");

            var entry = new gClient.AtomEntry();
            entry.Content.Content = content;
            entry.Content.Type = "html";
            entry.Title.Text = title;

            var service = new gClient.Service("blogger", GoogleSucks.GetApplicationName());
            service.Credentials = new gClient.GDataCredentials(blogDescriptor.Username, blogDescriptor.Password);
            service.Insert(new Uri(GetFeedUri(blogDescriptor)), entry);
        }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:16,代码来源:BloggerEngine.cs


注:本文中的Google.GData.Client.Service类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。