示例#1
0
        public static Feed.Base.Dynamic Create(FeedType type, int id, bool threaded)
        {
            object feed = null;
            switch (type)
            {
                case FeedType.User:
                    feed = new User(id, threaded);
                    break;
                case FeedType.Bot:
                    feed = new Bot(id, threaded);
                    break;
                case FeedType.Favorites:
                    feed = new Favorites(id, threaded);
                    break;
                case FeedType.Group:
                    feed = new Group(id, threaded);
                    break;
                case FeedType.Tag:
                    feed = new Tag(id, threaded);
                    break;
                case FeedType.Thread:
                    feed = new Thread(id);
                    break;
            }

            return feed as Feed.Base.Dynamic;
        }
示例#2
0
 public RssResult(SyndicationFeed feed, FeedType feedType, bool isCssStyles)
     : base("application/rss+xml")
 {
     _feed = feed;
     _feedType = feedType;
     _isCssStyles = isCssStyles;
 }
        public async Task<FeedData> GetFeedAsync(FeedType feed)
        {
            string feedUri = String.Empty;

            if (feed == FeedType.Dota2)
                feedUri = "http://blog.dota2.com/feed/";
            else if (feed == FeedType.SteamWorkshop)
                feedUri = "http://steamcommunity.com/games/SteamWorkshop/rss";
            else if (feed == FeedType.Left4Dead)
                feedUri = "http://www.l4d.com/blog/rss.xml";
            else if (feed == FeedType.TeamFortress2)
                feedUri = "http://www.teamfortress.com/rss.xml";
            else if (feed == FeedType.Portal2)
                feedUri = "http://www.thinkwithportals.com/rss.xml";
            else if (feed == FeedType.SourceFilmmaker)
                feedUri = "http://www.sourcefilmmaker.com/rss.xml";
            else if (feed == FeedType.RamblingsInValveTime)
                feedUri = "http://blogs.valvesoftware.com/feed/?cat=3";
            else if (feed == FeedType.ValveEconomics)
                feedUri = "http://blogs.valvesoftware.com/feed/?cat=6";
            else if (feed == FeedType.ValveLinuxTeamBlog)
                feedUri = "http://blogs.valvesoftware.com/feed/?cat=7";
            else if (feed == FeedType.TeachWithPortals)
                feedUri = "http://www.teachwithportals.com/index.php/feed/";
            else if (feed == FeedType.CounterStrikeGo)
                feedUri = "http://blog.counter-strike.net/index.php/feed/";
            else if (feed == FeedType.SteamStore)
                feedUri = "http://store.steampowered.com/feeds/news.xml";

            return await steamFeedRequest.GetFeedAsync(feedUri);
        }
示例#4
0
		public FeedPage (FeedType feedType)
		{
			InitializeComponent ();

			var itemsSource = new List<PostModel> ();
			var item = new PostModel ();
			item.AuthorName = "@S***n";
			item.Rating = 125;
			item.PostTime ="2 часа назад";
			item.Title = "Как-то так приложение some test";
			item.Description = "Мастерим очередное приложение для сайта some test на xamarin";
			item.Tags = "#xamarin #мобильное приложение #длиннопост";
			item.Comments = Int32.MaxValue;
			item.CardRating = "5741 плюсов";
			item.CardComments = "1041 комментариев";
			item.RatingString = "+ " + item.Rating;
			itemsSource.Add (item);
			itemsSource.Add (item);
			itemsSource.Add (item);
			itemsSource.Add (item);
			itemsSource.Add (item);
			for (var i = 0; i < 150; i++) {
				itemsSource.Add (item);
			}
			FeedListView.ItemsSource = itemsSource;
		}
示例#5
0
        public static Feed.Base.Static Create(FeedType type)
        {
            object feed = null;
            switch (type)
            {
                case FeedType.All:
                    feed = new All();
                    break;
                case FeedType.My:
                    feed = new My();
                    break;
                case FeedType.Received:
                    feed = new Received();
                    break;
                case FeedType.Sent:
                    feed = new Sent();
                    break;
                case FeedType.Liked:
                    feed = new Liked();
                    break;
                case FeedType.Bookmarked:
                    feed = new Bookmarked();
                    break;
            }

            return feed as Feed.Base.Static;
        }
示例#6
0
 public int TestFromLocal(string extension, FeedType type)
 {
     var content = File.ReadAllText (Path.Combine (
         AppDomain.CurrentDomain.BaseDirectory,
         @"..\..\File\test" + extension));
     return FeedParser.Parse (content, type).Count ();
 }
        public ActivitiesResponse GetAllActivities(int page, int count, FilterType filter, FeedType feed, string hash, string start)
		{
			var parameters = BuildPagingParametersWithCount(page, count);
			if (filter != FilterType.All) parameters.Add("filter", filter.ToString().ToLower());
            if (feed != FeedType.AuthenticatedUser) parameters.Add("feed", feed.ToString().ToLower());
            if (!string.IsNullOrEmpty(hash)) parameters.Add("hash", hash.ToString().ToLower());
            if (!string.IsNullOrEmpty(start)) parameters.Add("start", start.ToString().ToLower());
			return _restTemplate.GetForObject<ActivitiesResponse>(BuildUrl("activity", parameters));
		}
示例#8
0
        public long SearchFeedsCount(string s, FeedType feedType, Guid userId)
        {
            if (s != null && s.Length < minSearchLength)
            {
                return 0;
            }

            return dbManager.ExecuteScalar<long>(Query("events_feed").SelectCount().Where(GetWhere(s, feedType, userId)));
        }
        public FeedResult GetFeedXml(FeedType feedType) {
            switch (feedType) {
                case FeedType.atom:
                    return new FeedResult(new Atom10FeedFormatter(_feed));
                case FeedType.rss:
                    return new FeedResult(new Rss20FeedFormatter(_feed));
            }

            throw new Exception("Unknown feed type");
        }
示例#10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Feed"/> class.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="feedType">Type of the feed.</param>
 /// <param name="title">The title.</param>
 /// <param name="license">The license.</param>
 public Feed(Name name, FeedType feedType = FeedType.Direct, Title title = null, Name license = null)
 {
     Type = feedType;
     Name = name;
     Title = title;
     License = license;
     Version = new AggregateVersion(0);
     Href = new Uri(string.Format(FEED_URI_FORMAT, Globals.HostName, Name.Value));
     Joins = new RoutingTable();
 }
示例#11
0
		public static FeedTypeInfo FromFeedType(FeedType feedType)
		{
			switch (feedType)
			{
				case FeedType.News: return new FeedTypeInfo(feedType, NewsResource.FeedTypeNews, "32x_news.png");
				case FeedType.Order: return new FeedTypeInfo(feedType, NewsResource.NewsOrdersTypeName, "32x_order.png");
                case FeedType.Advert: return new FeedTypeInfo(feedType, NewsResource.NewsAnnouncementsTypeName, "32x_advert.png");
                case FeedType.Poll: return new FeedTypeInfo(feedType, NewsResource.FeedTypePoll, "32x_poll.png");
				default: throw new ArgumentOutOfRangeException(string.Format("Unknown feed type: {0}.", feedType));
			}
		}
示例#12
0
        public async Task<FeedData> GetFeedAsync(FeedType feed)
        {
            string feedUri = String.Empty;

            if (feed == FeedType.SteamGameSalesCom)
                feedUri = "http://www.steamgamesales.com/rss/?region=us&stores=steam/";
            //else if (feed == FeedType.SteamDailyDeals)
            //    feedUri = "http://store.steampowered.com/feeds/daily_deals.xml";

            return await steamFeedRequest.GetFeedAsync(feedUri);
        }
示例#13
0
 public EventWrapperFull CreateEvent(string content, string title, FeedType type)
 {
     var feed = new ASC.Web.Community.News.Code.Feed
                    {
                        Caption = title,
                        Text = content,
                        Creator = SecurityContext.CurrentAccount.ID.ToString(),
                        Date = DateTime.UtcNow
                    };
     FeedStorage.SaveFeed(feed, false, type);
     return new EventWrapperFull(feed);
 }
示例#14
0
 /// <summary>
 /// Parse a feed base on its own type.
 /// </summary>
 /// <param name="feed">the feed to be parsed</param>
 /// <param name="type">the feed's own type</param>
 /// <returns>The content as a enumerable of item</returns>
 /// <example>
 /// var feed = FeedParser.Parse (File.ReadAllText ("./feed.rss), FeedType.Rss);
 /// foreach (var item in feed)
 ///     Console.WriteLine ($"{item.PublishDate} {item.Title}");
 /// </example>
 public static IEnumerable<IItem> Parse(string feed, FeedType type)
 {
     var root = XDocument.Parse (feed).Root;
     if (root == null)
         throw new FormatException (nameof (root));
     switch (type) {
         case FeedType.Atom: return new Atom (root);
         case FeedType.Rss: return new Rss (root);
         case FeedType.Rdf: return new Rdf (root);
         default: throw new NotSupportedException (type + " is not supported");
     }
 }
示例#15
0
        public IFeed CreateFeed(Uri feeduri, FeedType feedtype)
        {
#if FRAMEWORK
            var feedxml = this.DownloadXml(feeduri);
#endif

#if SILVERLIGHT || WINDOWS_PHONE
            var feedXmlResult = this.BeginDownloadXml(feeduri, null);
            var feedxml = this.EndDownloadXml(feedXmlResult).FeedContent;
#endif

            return this.CreateFeed(feeduri, feedtype, feedxml);
        }
 /// <summary>
 /// Parses the given <see cref="FeedType"/> and returns a <see cref="IList&lt;FeedDTO&gt;"/>.
 /// </summary>
 /// <returns></returns>
 public IList<FeedDTO> Parse(string url, FeedType feedType)
 {
     switch (feedType)
     {
         case FeedType.RSS:
             return ParseRss(url);
         case FeedType.RDF:
             return ParseRdf(url);
         case FeedType.Atom:
             return ParseAtom(url);
         default:
             throw new NotSupportedException(string.Format("{0} is not supported", feedType.ToString()));
     }
 }
示例#17
0
        public IFeed CreateFeed(Uri feeduri, FeedType feedtype)
        {
#if FRAMEWORK
            var feedxml = this.DownloadXml(feeduri);
#endif

#if SILVERLIGHT || WINDOWS_PHONE
            var feedXmlResult = this.BeginDownloadXml(feeduri, null);
            var feedxml = this.EndDownloadXml(feedXmlResult).FeedContent;
#endif
            //TODO: Verificar como fazer para segregar por esse tipo de Projeto, tentei o "#if PORTABLE" não não funcionou
            var feedXmlResult = this.BeginDownloadXml(feeduri, null);
            var feedxml = this.EndDownloadXml(feedXmlResult).FeedContent;

            return this.CreateFeed(feeduri, feedtype, feedxml);
        }
示例#18
0
        public EventWrapperFull CreateEvent(string content, string title, FeedType type)
        {
            CommunitySecurity.DemandPermissions(NewsConst.Action_Add);

            if (string.IsNullOrWhiteSpace(title))
                throw new ArgumentException("Can't create feed with empty title", "title");

            var feed = new Web.Community.News.Code.Feed
                           {
                               Caption = title,
                               Text = content,
                               Creator = SecurityContext.CurrentAccount.ID.ToString(),
                               Date = DateTime.UtcNow,
                               FeedType = type
                           };

            FeedStorage.SaveFeed(feed, false, type);
            
            return new EventWrapperFull(feed);
        }
示例#19
0
文件: FeedModel.cs 项目: flq/Rf.Sites
        public FeedModel(FeedSetup feedSetup)
        {
            var items = feedSetup.Content
              .Select(vm =>
                new SyndicationItem(vm.Title, vm.Teaser, new Uri(feedSetup.UrlTemplate.Replace("{Id}", vm.Id.ToString())))
                {
                    Id = vm.Id.ToString(),
                    LastUpdatedTime = new DateTimeOffset(vm.Created)
                });

            var lastUpdate = feedSetup.Content.Max(vm => vm.Created);
            
            _feed = new SyndicationFeed(items)
            {
                Id = feedSetup.FeedId,
                Title = new TextSyndicationContent(feedSetup.Title, TextSyndicationContentKind.Plaintext),
                LastUpdatedTime = new DateTimeOffset(lastUpdate),
            };
            _feed.Authors.Add(new SyndicationPerson(null, feedSetup.SiteMasterName, null));
            _feed.Copyright = new TextSyndicationContent(feedSetup.CopyrightNotice);
            _feedTypeToGenerate = feedSetup.FeedType;
        }
示例#20
0
 public long GetFeedsCount(FeedType feedType, Guid userId)
 {
     return SearchFeedsCount(null, feedType, userId);
 }
示例#21
0
文件: Feed.cs 项目: mike442144/FBS
        /// <summary>
        /// 新鲜事
        /// </summary>
        /// <param name="uid">用户编号</param>
        /// <param name="uname">用户昵称</param>
        /// <param name="uhead">头像</param>
        /// <param name="subject">标题</param>
        /// <param name="content">内容</param>
        public Feed(Guid uid, string uname, string uhead, string subject, string content, FeedType ftype)
        {
            this._feedId    = Guid.NewGuid();
            this._createdOn = DateTime.Now;

            this._uid         = uid;
            this._uname       = uname;
            this._uhead       = uhead;
            this._subject     = subject;
            this._content     = content;
            this._ftype       = ftype;
            this._replayCount = 0;
        }
示例#22
0
        private async Task LoadFeed(FeedType type, RantSort sort = RantSort.Algo, RantRange range = RantRange.Day, bool filter = false)
        {
            currentFeedType = type;

            Func <int, int, Task <IReadOnlyCollection <Dtos.Rant> > > getter;

            ValuesCollection otherVals = new ValuesCollection();

            switch (type)
            {
            case FeedType.General:
                getter = async(skip, limit) => await api.Feeds.GetRantsAsync(sort : sort, range : range, skip : skip, limit : limit, settings : otherVals);

                break;

            case FeedType.Stories:
                getter = async(skip, limit) => await api.Feeds.GetStoriesAsync(range : range, sort : sort, skip : skip, limit : limit);

                break;

            default:
                return;
            }

            List <Dtos.Rant> rants = new List <Dtos.Rant>();

            //Used to remove duplicates
            List <long> ids = new List <long>();

            int  maxPages  = ds.MaxPages;
            bool useOffset = true; //ds.UseOffset

            var lim      = ds.ResultsLimit;
            int minScore = ds.MinScore;


            int page = 0;

            if (useOffset)
            {
                page     = maxPages * offset;
                maxPages = (offset + 1) * maxPages;
            }


            bool shouldIncrement = true;

            while (rants.Count < lim && page < maxPages)
            {
                int skip = page * lim;

                try
                {
                    var tmp = await getter.Invoke(skip, lim);

                    if (tmp == null || tmp.Count == 0)
                    {
                        ResetOffset();
                        shouldIncrement = false;
                        break;
                    }

                    foreach (var r in tmp)
                    {
                        if (ids.Contains(r.Id) ||
                            r.Username == LoggedInUser ||
                            VoteState.None != r.Voted ||
                            r.Score < minScore ||
                            (ds.FilterOutRead && db.IsRead(r.Id)))
                        {
                            continue;
                        }

                        rants.Add(r);
                        ids.Add(r.Id);
                    }
                }
                catch (Exception e)
                {
                }

                page++;
            }

            if (useOffset && shouldIncrement)
            {
                IncrementOffset();
            }

            lock (feed_lock)
            {
                feeds.Clear();

                foreach (var rant in rants)
                {
                    ViewModels.Rant r = new ViewModels.Rant(rant);
                    feeds.Add(r);
                }
            }

            if (otherVals.Count > 0 && otherVals.ContainsKey(ValuesCollection.NumNotifs))
            {
                int count = Convert.ToInt32(otherVals[ValuesCollection.NumNotifs]);
                if (count > 0)
                {
                    //Just refresh
                    nchecker.Check();
                }


                UpdateNotifications(new NotificationsChecker.UpdateArgs(count, count));
            }

            UpdateFollowedInRants();
            feedView.SortDescriptions.Clear();

            string message = "Loaded {0} rants from {1} pages";

            UpdateStatus(string.Format(message, rants.Count, page));
        }
示例#23
0
 public AsyncMissingFileSysFeedFactoryTest()
     : base(TestFileLoader.LoadMissingTestCases(TestFileLoader.TestFileType.FileSys))
 {
     Factory  = new FileSystemFeedFactory();
     FeedType = FeedType.Rss20;
 }
示例#24
0
 public static SourceRepository GetCoreV3(this Repository.RepositoryFactory factory, string source, FeedType type)
 {
     return(Repository.CreateSource(Repository.Provider.GetCoreV3(), source, type));
 }
示例#25
0
        private async Task <int> UploadPackageToCuratedFeed(string packageName, string version, FeedType feedType)
        {
            string packageFullPath = string.Empty;

            switch (feedType)
            {
            case FeedType.Windows8CuratedFeed:
                packageFullPath = await _packageCreationHelper.CreateWindows8CuratedPackage(packageName, version);

                break;

            case FeedType.WebMatrixCuratedFeed:
                packageFullPath = await _packageCreationHelper.CreateWindows8CuratedPackage(packageName, version);

                break;
            }
            var processResult = await _commandlineHelper.UploadPackageAsync(packageFullPath, UrlHelper.V2FeedPushSourceUrl);

            return(processResult.ExitCode);
        }
示例#26
0
 public long GetFeedsCount(FeedType feedType, Guid userId)
 {
     return(SearchFeedsCount(null, feedType, userId));
 }
        private async Task CheckCuratedFeedForDuplicates(FeedType feedType)
        {
            var request = WebRequest.Create(GetCuratedFeedUrl(feedType) + "Packages");
            request.Timeout = 15000;
            ArrayList packages = new ArrayList();

            // Get the response.
            var response = await request.GetResponseAsync();

            string responseText;
            using (var sr = new StreamReader(response.GetResponseStream()))
            {
                responseText = await sr.ReadToEndAsync();
            }

            responseText = responseText.Substring(responseText.IndexOf("<entry>", StringComparison.Ordinal));
            CheckPageForDuplicates(packages, responseText);

            while (responseText.Contains(@"<link rel=""next"" href="""))
            {
                // Get the link to the next page.
                string link = responseText.Split(new[] { @"<link rel=""next"" href=""" }, StringSplitOptions.RemoveEmptyEntries)[1];
                link = link.Substring(0, link.IndexOf(@"""", StringComparison.Ordinal));

                request = WebRequest.Create(link);
                request.Timeout = 2000;

                // Get the response.
                try
                {
                    response = (HttpWebResponse)await request.GetResponseAsync();
                    using (var sr = new StreamReader(response.GetResponseStream()))
                    {
                        responseText = await sr.ReadToEndAsync();
                    }

                    responseText = responseText.Substring(responseText.IndexOf("<entry>", StringComparison.Ordinal));
                    CheckPageForDuplicates(packages, responseText);
                }
                catch (WebException e)
                {
                    if (((HttpWebResponse)e.Response).StatusCode != HttpStatusCode.OK)
                    {
                        throw new Exception("Next page link is broken.  Expected 200, got " + ((HttpWebResponse)e.Response).StatusCode, e);
                    }
                }
            }
        }
示例#28
0
        private static void NotifyFeed(Feed feed, bool isEdit, FeedType type)
        {
            var initatorInterceptor = new InitiatorInterceptor(new DirectRecipient(feed.Creator, ""));

            try
            {
                NewsNotifyClient.NotifyClient.AddInterceptor(initatorInterceptor);
                var replyToTag = GetReplyToTag(feed, null);
                if (type == FeedType.Poll && feed is FeedPoll)
                {
                    NewsNotifyClient.NotifyClient.SendNoticeAsync(
                        NewsConst.NewFeed, null, null,
                        new TagValue(NewsConst.TagFEED_TYPE, "poll"),
                        new TagValue(NewsConst.TagAnswers, ((FeedPoll)feed).Variants.ConvertAll(v => v.Name)),
                        new TagValue(NewsConst.TagCaption, feed.Caption),
                        new TagValue(NewsConst.TagText, HtmlUtility.GetFull(feed.Text)),
                        new TagValue(NewsConst.TagDate, feed.Date.ToShortString()),
                        new TagValue(NewsConst.TagURL,
                                     CommonLinkUtility.GetFullAbsolutePath(
                                         "~/Products/Community/Modules/News/Default.aspx?docid=" + feed.Id)),
                        new TagValue(NewsConst.TagUserName,
                                     DisplayUserSettings.GetFullUserName(SecurityContext.CurrentAccount.ID)),
                        new TagValue(NewsConst.TagUserUrl,
                                     CommonLinkUtility.GetFullAbsolutePath(
                                         CommonLinkUtility.GetUserProfile(SecurityContext.CurrentAccount.ID))),
                        replyToTag
                        );
                }
                else
                {
                    NewsNotifyClient.NotifyClient.SendNoticeAsync(
                        NewsConst.NewFeed, null, null,
                        new TagValue(NewsConst.TagFEED_TYPE, "feed"),
                        new TagValue(NewsConst.TagCaption, feed.Caption),
                        new TagValue(NewsConst.TagText,
                                     HtmlUtility.GetFull(feed.Text)),
                        new TagValue(NewsConst.TagDate, feed.Date.ToShortString()),
                        new TagValue(NewsConst.TagURL,
                                     CommonLinkUtility.GetFullAbsolutePath(
                                         "~/Products/Community/Modules/News/Default.aspx?docid=" + feed.Id)),
                        new TagValue(NewsConst.TagUserName,
                                     DisplayUserSettings.GetFullUserName(SecurityContext.CurrentAccount.ID)),
                        new TagValue(NewsConst.TagUserUrl,
                                     CommonLinkUtility.GetFullAbsolutePath(
                                         CommonLinkUtility.GetUserProfile(SecurityContext.CurrentAccount.ID))),
                        replyToTag
                        );
                }

                // subscribe to new comments
                var subsciber = NewsNotifySource.Instance.GetSubscriptionProvider();
                var me        = (IDirectRecipient)NewsNotifySource.Instance.GetRecipientsProvider().GetRecipient(SecurityContext.CurrentAccount.ID.ToString());
                if (me != null && !subsciber.IsUnsubscribe(me, NewsConst.NewComment, feed.Id.ToString(CultureInfo.InvariantCulture)))
                {
                    subsciber.Subscribe(NewsConst.NewComment, feed.Id.ToString(CultureInfo.InvariantCulture), me);
                }
            }
            finally
            {
                NewsNotifyClient.NotifyClient.RemoveInterceptor(initatorInterceptor.Name);
            }
        }
示例#29
0
 public List <Feed> GetFeeds(FeedType feedType, Guid userId, int count, int offset)
 {
     return(SearchFeeds(null, feedType, userId, count, offset));
 }
示例#30
0
        public async Task <IFeed> CreateFeedAsync(Uri feeduri, FeedType feedtype)
        {
            var feedXml = await DownloadXmlAsync(feeduri);

            return(CreateFeed(feeduri, feedtype, feedXml));
        }
示例#31
0
 public FeedTypeInfo(FeedType feedType, string name, string logo)
 {
     Id           = (int)feedType;
     TypeName     = name;
     TypeLogoPath = logo;
 }
示例#32
0
 public AsyncHttpFeedFactoryTests()
     : base(TestFileLoader.LoadValidRssTestCases(TestFileLoader.TestFileType.Http))
 {
     Factory  = new HttpFeedFactory();
     FeedType = FeedType.Rss20;
 }
 public AsyncMissingHttpFeedFactoryTests()
     : base(TestFileLoader.LoadMissingTestCases(TestFileLoader.TestFileType.Http))
 {
     Factory = new HttpFeedFactory();
     FeedType = FeedType.Rss20;
 }
 /// <summary>
 /// Creates or gets a non-default source repository by PackageSource.
 /// </summary>
 public SourceRepository CreateRepository(PackageSource packageSource, FeedType feedType) =>
 _repositoryCache.GetOrAdd(packageSource, x => new SourceRepository(packageSource, _resourceProviders));
 private string GetCuratedFeedUrl(FeedType type)
 {
     string url = string.Empty;
     switch (type)
     {
         case FeedType.Windows8CuratedFeed:
             url = UrlHelper.Windows8CuratedFeedUrl;
             break;
         case FeedType.WebMatrixCuratedFeed:
             url = UrlHelper.WebMatrixCuratedFeedUrl;
             break;
         case FeedType.DotnetCuratedFeed:
             url = UrlHelper.DotnetCuratedFeedUrl;
             break;
     }
     return url;
 }
示例#36
0
        private static PackageInfo CreatePackageInfo(IPackageSearchMetadata packageSearchMetadata, FeedType feedType, IEnumerable <VersionInfo>?versionInfos)
        {
            var versionInfo = versionInfos?.FirstOrDefault(v => v.Version == packageSearchMetadata.Identity.Version);

            DateTimeOffset?published     = null;
            int?           downloadCount = null;

            if (packageSearchMetadata.Published.HasValue && packageSearchMetadata.Published.Value.Year > 1900)
            {
                // Note nuget.org reports 1900 for unlisted packages. Pretty sure it's was published later ;)
                published = packageSearchMetadata.Published;
            }

            downloadCount = (int)(versionInfo?.DownloadCount ?? packageSearchMetadata.DownloadCount.GetValueOrDefault());

            if (downloadCount == 0)
            {
                // Note nuget.org reports no correct download counts in for unlisted.
                downloadCount = null;
            }

            return(new PackageInfo(packageSearchMetadata.Identity)
            {
                Authors = packageSearchMetadata.Authors,
                Published = published,
                DownloadCount = downloadCount,
                IsRemotePackage = (feedType == FeedType.HttpV3 || feedType == FeedType.HttpV2),
                IsPrefixReserved = packageSearchMetadata.PrefixReserved,
                Description = packageSearchMetadata.Description,
                Tags = packageSearchMetadata.Tags,
                Summary = packageSearchMetadata.Summary,
                LicenseUrl = packageSearchMetadata.LicenseUrl?.ToString() ?? string.Empty,
                ProjectUrl = packageSearchMetadata.ProjectUrl?.ToString() ?? string.Empty,
                ReportAbuseUrl = packageSearchMetadata.ReportAbuseUrl?.ToString() ?? string.Empty,
                IconUrl = packageSearchMetadata.IconUrl?.ToString() ?? string.Empty
            });
        }
示例#37
0
 public static string GetFeedListUrl(FeedType feedType)
 {
     return GetFeedListUrl(feedType, Guid.Empty);
 }
 protected BaseFeedFactoryTests(IFeedFactory factory, FeedType feedtype, IEnumerable <TestCaseData> testcases) : base(testcases)
 {
     this.Factory  = factory;
     this.FeedType = feedtype;
 }
示例#39
0
        internal override void SetFeed(ProgramOperation program, double rapidFeed, double secureRapidFeed, FeedType feedType)
        {
            var nGiri      = GetNumeroGiri();
            var feed       = GetFeed(FeedType.ASync);
            var plungefeed = GetPlungeFeed(FeedType.ASync);

            program.AddFeedType(MoveType.Rapid, VelocitaType.ASync, nGiri, VelocitaType.ASync, rapidFeed);

            program.AddFeedType(MoveType.SecureRapidFeed, VelocitaType.ASync, nGiri, VelocitaType.ASync, secureRapidFeed);

            program.AddFeedType(new[] { MoveType.Work, MoveType.Cw, MoveType.Ccw }, VelocitaType.ASync, nGiri, VelocitaType.ASync, feed);

            program.AddFeedType(MoveType.PlungeFeed, VelocitaType.ASync, nGiri, VelocitaType.ASync, plungefeed);
        }
示例#40
0
        /// <summary>
        /// Create a SourceRepository
        /// </summary>
        public static SourceRepository CreateSource(IEnumerable <Lazy <INuGetResourceProvider> > resourceProviders, PackageSource source, FeedType type)
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }

            if (resourceProviders == null)
            {
                throw new ArgumentNullException(nameof(resourceProviders));
            }

            return(new SourceRepository(source, resourceProviders, type));
        }
示例#41
0
        public static void FollowToggle(IActivityProgresDialog activity, Button btnFollow, IFollowing model, string id, FeedType type, Action <bool> succeeded = null)
        {
            var oldText = btnFollow.Text;

            btnFollow.Text = "Loading";
            if (model.IsFollowing)
            {
                Task apiTask = null;
                if (type == FeedType.Team)
                {
                    apiTask = new ServiceApi().UnfollowTeam(id);
                }
                else if (type == FeedType.User)
                {
                    apiTask = new ServiceApi().UnfollowUser(id);
                }
                else if (type == FeedType.Sport)
                {
                    apiTask = new ServiceApi().UnfollowSport(id);
                }
                else if (type == FeedType.ContentSource)
                {
                    apiTask = new ServiceApi().UnfollowContentSource(id);
                }
                else if (type == FeedType.School)
                {
                    apiTask = new ServiceApi().UnfollowSchool(id);
                }

                apiTask.HandleError(activity, true, () =>
                {
                    btnFollow.Text = oldText;
                });
                apiTask.OnSucess(activity, response =>
                {
                    model.IsFollowing = false;
                    Views.SetFollowed(btnFollow, model.IsFollowing);
                    succeeded?.Invoke(false);
                });
            }
            else
            {
                Task apiTask = null;
                if (type == FeedType.Team)
                {
                    apiTask = new ServiceApi().FollowTeam(id);
                }
                else if (type == FeedType.User)
                {
                    apiTask = new ServiceApi().FollowUser(id);
                }
                else if (type == FeedType.Sport)
                {
                    apiTask = new ServiceApi().FollowSport(id);
                }
                else if (type == FeedType.ContentSource)
                {
                    apiTask = new ServiceApi().FollowContentSource(id);
                }
                else if (type == FeedType.School)
                {
                    apiTask = new ServiceApi().FollowSchool(id);
                }
                apiTask.HandleError(activity, true, () =>
                {
                    btnFollow.Text = oldText;
                });
                apiTask.OnSucess(activity, response =>
                {
                    model.IsFollowing = true;
                    Views.SetFollowed(btnFollow, model.IsFollowing);
                    succeeded?.Invoke(true);
                });
            }
        }
 protected BaseMissingFeedFactoryTest(IFeedFactory factory, FeedType feedtype, IEnumerable <TestCaseData> testcases)
     : base(factory, feedtype, testcases)
 {
 }
 public FeedSerializationTests()
 {
     Factory  = new FileSystemFeedFactory();
     FeedType = FeedType.Rss20;
 }
        private static PackageInfo CreatePackageInfo(IPackageSearchMetadata packageSearchMetadata, FeedType feedType, IEnumerable <VersionInfo>?versionInfos)
        {
            var versionInfo = versionInfos?.FirstOrDefault(v => v.Version == packageSearchMetadata.Identity.Version);

            return(new PackageInfo(packageSearchMetadata.Identity)
            {
                Authors = packageSearchMetadata.Authors,
                Published = packageSearchMetadata.Published,
                DownloadCount = (int)(versionInfo?.DownloadCount ?? packageSearchMetadata.DownloadCount.GetValueOrDefault()),
                IsRemotePackage = (feedType == FeedType.HttpV3 || feedType == FeedType.HttpV2),
                IsPrefixReserved = packageSearchMetadata.PrefixReserved,
                Description = packageSearchMetadata.Description,
                Tags = packageSearchMetadata.Tags,
                Summary = packageSearchMetadata.Summary,
                LicenseUrl = packageSearchMetadata.LicenseUrl?.ToString() ?? string.Empty,
                ProjectUrl = packageSearchMetadata.ProjectUrl?.ToString() ?? string.Empty,
                ReportAbuseUrl = packageSearchMetadata.ReportAbuseUrl?.ToString() ?? string.Empty,
                IconUrl = packageSearchMetadata.IconUrl?.ToString() ?? string.Empty
            });
        }
 /// <summary>
 /// Create a repository for one time use.
 /// </summary>
 public SourceRepository CreateRepository(PackageSource source, FeedType type)
 {
     return(new SourceRepository(source, _resourceProviders, type));
 }
示例#46
0
        public EventWrapperFull UpdateEvent(int feedid, string content, string title, FeedType type)
        {
            var feed = FeedStorage.GetFeed(feedid).NotFoundIfNull();

            CommunitySecurity.DemandPermissions(feed, NewsConst.Action_Edit);

            feed.Caption = title;
            feed.Text    = content;
            feed.Creator = SecurityContext.CurrentAccount.ID.ToString();

            FeedStorage.SaveFeed(feed, true, type);

            return(new EventWrapperFull(feed));
        }
 public AsyncMissingHttpFeedFactoryTests()
     : base(TestFileLoader.LoadMissingTestCases(TestFileLoader.TestFileType.Http))
 {
     Factory  = new HttpFeedFactory();
     FeedType = FeedType.Rss20;
 }
示例#48
0
 /// <summary>
 /// Creates an html feed link item
 /// </summary>
 /// <param name="title"></param>
 /// <param name="url"></param>
 /// <param name="feedtype"></param>
 public HtmlFeedLink(string title, string url, FeedType feedtype)
 {
     this.Title    = title;
     this.Url      = url;
     this.FeedType = feedtype;
 }
示例#49
0
文件: VkApi.cs 项目: nkomarov/VKSharp
		public async Task<EntityList<Photo>> PhotosGetAsync(
			 SpecialAlbum albumId ,
			 int? ownerId = null,
			 int[] photoIds = null,
			 bool rev = true,
			 bool extended = false,
			 FeedType? feedType = null,
			 uint? feed = null,
			 uint offset = 0,
			 uint count = 100
			){
			return (await Executor.ExecAsync(
				_reqapi.PhotosGet(
											albumId,
											ownerId,
											photoIds,
											rev,
											extended,
											feedType,
											feed,
											offset,
											count
									)
			)).Data.FirstOrDefault();
		}
示例#50
0
 public AsyncFileSysFeedFactoryTests()
     : base(TestFileLoader.LoadValidRssTestCases(TestFileLoader.TestFileType.FileSys))
 {
     Factory  = new FileSystemFeedFactory();
     FeedType = FeedType.Rss20;
 }
 private async Task<int> UploadPackageToCuratedFeed(string packageName, string version, FeedType feedType)
 {
     string packageFullPath = string.Empty;
     switch (feedType)
     {
         case FeedType.Windows8CuratedFeed:
             packageFullPath = await _packageCreationHelper.CreateWindows8CuratedPackage(packageName, version);
             break;
         case FeedType.WebMatrixCuratedFeed:
             packageFullPath = await _packageCreationHelper.CreateWindows8CuratedPackage(packageName, version);
             break;
     }
     var processResult = await _commandlineHelper.UploadPackageAsync(packageFullPath, UrlHelper.V2FeedPushSourceUrl);
     return processResult.ExitCode;
 }
示例#52
0
 public SourceRepository CreateRepository(PackageSource source, FeedType type)
 {
     return(_cachedSources.GetOrAdd(source, new SourceRepository(source, _resourceProviders, type)));
 }
        private bool CheckPackageExistInCuratedFeed(string packageName, FeedType feedType)
        {
            string curatedFeedUrl = GetCuratedFeedUrl(feedType);
            var maxAttempts = 10;
            var interval = 30;
            bool applied = false;

            TestOutputHelper.WriteLine("Starting package verification checks ({0} attempts, interval {1} seconds).", maxAttempts, interval);

            for (int i = 0; i < maxAttempts && applied == false; i++)
            {
                TestOutputHelper.WriteLine("[verification attempt {0}]: Waiting {1} seconds before next check...", i, interval);
                if (i != 0)
                {
                    Thread.Sleep(interval * 1000);
                }
                else
                {
                    Thread.Sleep(5000);
                }

                if (_clientSdkHelper.CheckIfPackageExistsInSource(packageName, curatedFeedUrl))
                {
                    applied = true;
                }
            }
            return applied;
        }
示例#54
0
        public EventWrapperFull UpdateEvent(int feedid, string content, string title, FeedType type)
        {
            var feed = FeedStorage.GetFeed(feedid).NotFoundIfNull();

            CommunitySecurity.DemandPermissions(feed, NewsConst.Action_Edit);

            if (string.IsNullOrWhiteSpace(title))
            {
                throw new ArgumentException("Can't update feed with empty title", "title");
            }

            if (type != FeedType.News && type != FeedType.Order && type != FeedType.Advert && type != FeedType.Poll)
            {
                throw new ArgumentOutOfRangeException(string.Format("Unknown feed type: {0}.", type));
            }

            feed.Caption = title;
            feed.Text    = content;
            feed.Creator = SecurityContext.CurrentAccount.ID.ToString();

            FeedStorage.SaveFeed(feed, true, type);

            return(new EventWrapperFull(feed));
        }
		public SourceRepository CreateRepository (PackageSource source, FeedType type)
		{
			return new SourceRepository (source, new INuGetResourceProvider[0]);
		}
示例#56
0
 /// <summary>
 /// Create a SourceRepository
 /// </summary>
 public static SourceRepository CreateSource(IEnumerable <Lazy <INuGetResourceProvider> > resourceProviders, string sourceUrl, FeedType type)
 {
     return(CreateSource(resourceProviders, new PackageSource(sourceUrl), type));
 }
示例#57
0
        public static string GetFeedListUrl(FeedType feedType, Guid userId)
        {
            var url = MainPageUrl;
            string p1 = null;
            string p2 = null;

            if (feedType != FeedType.All) p1 = "type=" + feedType.ToString();
            if (userId != Guid.Empty) p2 = "uid=" + userId.ToString();
            if (p1 == null && p2 == null) return url;

            url += "?";
            if (p1 != null) url += p1 + "&";
            if (p2 != null) url += p2 + "&";
            return url.Substring(0, url.Length - 1);
        }
示例#58
0
        /// <summary>
        /// Create a repository for one time use.
        /// </summary>
        public SourceRepository CreateRepository(PackageSource source, FeedType type)
        {
            EnsureInitialized();

            return(new SourceRepository(source, _resourceProviders, type));
        }
 public AsyncMissingFileSysFeedFactoryTest()
     : base(TestFileLoader.LoadMissingTestCases(TestFileLoader.TestFileType.FileSys))
 {
     Factory = new FileSystemFeedFactory();
     FeedType = FeedType.Rss20;
 }
 public override void TestFactoryFeedTypeDetection(string rsslocation)
 {
     Uri      feeduri  = new Uri(rsslocation);
     FeedType testType = Factory.CheckFeedType(feeduri);
 }