public Channel(ProfileEntry profile, string _user, int _userID) { Name = _user; ID = _userID; if (profile.Statistics.Attributes.ContainsKey("subscriberCount")) { TotalSubscribers = profile.Statistics.Attributes["subscriberCount"].ToString().ConvertStringToInt(0); } else { TotalSubscribers = 0; } if (profile.Statistics.Attributes.ContainsKey("totalUploadViews")) { TotalVideoViews = profile.Statistics.Attributes["totalUploadViews"].ToString().ConvertStringToInt(0); } else { TotalVideoViews = 0; } Feed = new List <ChannelVideo>(); }
public static (string DataDirectoryPath, string ConfigFilePath) GetOrCreateDataDirectory(string applicationDataDirectoryBase, string profileName) { var profileDataAccess = new ProfileListDataAccess(Path.Combine(applicationDataDirectoryBase, "profiles.xml")); var profiles = profileDataAccess.Load(); var profile = profiles.FirstOrDefault(p => String.Compare(p.ProfileName, profileName, StringComparison.OrdinalIgnoreCase) == 0); if (profile == null) { var profileGuid = Guid.NewGuid(); profile = new ProfileEntry() { ProfileName = profileName, ConfigFileName = "options.xml", DataDirectoryName = profileGuid.ToString() }; profiles = profiles.Union(new[] { profile }).ToArray(); profileDataAccess.Save(profiles); } var dataDirectory = string.IsNullOrEmpty(profile.DataDirectoryName) ? applicationDataDirectoryBase : Path.Combine(applicationDataDirectoryBase, profile.DataDirectoryName); if (!Directory.Exists(dataDirectory)) { Directory.CreateDirectory(dataDirectory); } return( dataDirectory, Path.Combine(dataDirectory, profile.ConfigFileName)); }
public void Equals_ReturnTrue_When_ComparingObjectsWithAllDefaultFields() { var entry1 = new ProfileEntry(); var entry2 = new ProfileEntry(); Assert.AreEqual(entry1, entry2); }
private void BuildChannel(string channelQuery) { //Get profile and create channel object try { YouTubeService service = new YouTubeService(_appName, _devKey); if (!Object.Equals(service, null)) { ProfileEntry profile = (ProfileEntry)service.Get(channelQuery); if (!Object.Equals(profile, null)) { _channel = new Channel(profile, _user, _userID); } } } catch (GDataRequestException gdre) { using (var logClient = new BILoggerServiceClient()) logClient.HandleException(gdre.Message, "Query: " + channelQuery, Utility.ApplicationName, LogTypeEnum.Error, LogActionEnum.LogAndEmail, "ChannelManager.BuildChannel()", "Drone.API.YouTube Exception", string.Empty, string.Empty, System.Environment.MachineName); } catch (Exception e) { using (var logClient = new BILoggerServiceClient()) logClient.HandleBIException(e.ConvertToBIException(LogActionEnum.Log, LogTypeEnum.Error, "Drone.API.YouTube Exception", "ChannelManager.BuildChannel()", "nouser", System.Environment.MachineName, "Query: " + channelQuery)); } }
public void Add_PutsItemToInnerCollection() { var newItem = new ProfileEntry(); this.subject.Add(newItem); Assert.IsTrue(this.innerCollection.Last() == newItem); }
protected bool PersistStructureTree(StructureHelper source, string fileName) { uint marker = 0; foreach (ProfileEntry item in source.StructureEntries) { item.RecordNumber = marker++; } foreach (ProfileEntry item in source.StructureEntries) { ProfileEntry parent = item.Parent; if (parent != null) { item.ParentRecordNumber = parent.RecordNumber; } } if (!fileName.EndsWith(".gz")) { fileName += ".gz"; } byte[] bytesToCompress = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(source)); using (FileStream fileToCompress = File.Create(fileName)) using (GZipStream compressionStream = new GZipStream(fileToCompress, CompressionMode.Compress)) { compressionStream.Write(bytesToCompress, 0, bytesToCompress.Length); } return(true); }
private void PopulateNode(string structureName, ProfileEntry parent, ulong offset, bool expanded = false) { List <Structure> results = _profile.GetEntries(structureName); foreach (Structure s in results) { ProfileEntry next = new ProfileEntry(); next.Name = s.Name + " [" + (s.Offset + offset).ToString() + " , " + s.Size + " , " + s.EntryType + "]"; next.Parent = parent; next.IsExpanded = expanded; next.Offset = (uint)(s.Offset + offset); next.Length = (uint)s.Size; _profileEntries.Add(next); int structureSize = 0; try { structureSize = (int)_profile.GetStructureSize(s.EntryType); if (structureSize != -1) { PopulateNode(s.EntryType, next, s.Offset + offset); } } catch (Exception) { continue; } } }
public async Task Get_DoesNotCutDownNotPublicProfileEntriesFromResult_When_PassingOwnUserId() { this.SetUserIdToRequest(this.validUserId); var privateProfileInfo = new ProfileEntry() { Type = ProfileEntryType.FirstName, Value = "a", IsPublic = false }; var publicProfileInfo = new ProfileEntry() { Type = ProfileEntryType.MiddleName, Value = "b", IsPublic = true }; this.validProfile.ProfileInfo = new[] { privateProfileInfo, publicProfileInfo }.ToList(); Value <Profile_OLD> result = await this.subject.Get(new DTO.ProfileRequest { UserId = this.validUserId.ToString() }); Assert.AreEqual(result.Payload.ProfileInfo.Count, 2); Assert.AreEqual(result.Payload.ProfileInfo.First(), privateProfileInfo); Assert.AreEqual(result.Payload.ProfileInfo.Last(), publicProfileInfo); }
public GenericListItemCollections HomeGetList(SiteItemEntry entry) { GenericListItemCollections res = new GenericListItemCollections(); string feedUrl = "http://gdata.youtube.com/feeds/api/users/" + entry.GetValue("id"); ProfileEntry profile = (ProfileEntry)Youtube2MP.service.Get(feedUrl); string img = ""; try { foreach (IExtensionElementFactory factory in profile.ExtensionElements) { if (factory.XmlName == "thumbnail") { img = ((Google.GData.Extensions.XmlExtension)factory).Node.Attributes[0].Value; } } } catch { } entry.SetValue("imgurl", img); GenericListItem listItem = new GenericListItem() { Title = entry.Title, IsFolder = true, LogoUrl = img, Tag = entry }; res.Items.Add(listItem); return(res); }
public void FeedLinksTest() { ProfileEntry target = new ProfileEntry(); // TODO: Initialize to an appropriate value ExtensionCollection <FeedLink> actual; actual = target.FeedLinks; Assert.IsNotNull(actual); }
public EditDialog(Window parent, ProfileEntry profile) { this.Parent = (WPFWindow)parent; this.profile = profile; InitializeComponent(); this.ProfileName.Text = profile.ProfileName; }
public void CreateFeedEntryTest() { Uri uriBase = null; // TODO: Initialize to an appropriate value IService iService = null; // TODO: Initialize to an appropriate value ProfileFeed target = new ProfileFeed(uriBase, iService); // TODO: Initialize to an appropriate value ProfileEntry entry = target.CreateFeedEntry() as ProfileEntry; Assert.IsNotNull(entry); }
public void Start(string activity) { Timestamp = DateTime.Now.Ticks; if (!Profiles.TryGetValue(activity, out CurrentProfile)) { CurrentProfile = new ProfileEntry(activity); Profiles[activity] = CurrentProfile; } }
private void PopulateInfoTree(string structureName) { int structureSize = 0; try { structureSize = (int)_profile.GetStructureSize(structureName); if (structureSize == -1) { return; } } catch (Exception) { return; } _profileEntries.Clear(); // first let's see if it already exists FileInfo cachedFile = new FileInfo(_dataProvider.CacheFolder + "\\structure_" + structureName + ".gz"); if (cachedFile.Exists) { StructureHelper cachedMap = RetrieveStructureTree(cachedFile); if (cachedMap != null) { foreach (ProfileEntry item in cachedMap.StructureEntries) { _profileEntries.Add(item); } } NotifyPropertyChange("ProfileTreeItems"); return; } string realName = structureName.TrimStart(new char[] { '_' }); ProfileEntry root = new ProfileEntry(); root.Name = realName + " [" + structureSize + "]"; root.Parent = null; root.IsExpanded = true; root.Offset = 0; root.Length = (uint)structureSize; _profileEntries.Add(root); PopulateNode(structureName, root, 0); NotifyPropertyChange("ProfileTreeItems"); // persist the tree records to save time next time StructureHelper sh = new StructureHelper(); sh.StructureEntries = new List <ProfileEntry>(); foreach (ProfileEntry e in _profileEntries) { sh.StructureEntries.Add(e); } PersistStructureTree(sh, _dataProvider.CacheFolder + "\\structure_" + structureName); }
public void UserNameTest() { ProfileEntry target = new ProfileEntry(); // TODO: Initialize to an appropriate value string expected = "secret text string"; // TODO: Initialize to an appropriate value string actual; target.UserName = expected; actual = target.UserName; Assert.AreEqual(expected, actual); }
public void AgeTest() { ProfileEntry target = new ProfileEntry(); // TODO: Initialize to an appropriate value int expected = 91; // TODO: Initialize to an appropriate value int actual; target.Age = expected; actual = target.Age; Assert.AreEqual(expected, actual); }
public void StatisticsTest() { ProfileEntry target = new ProfileEntry(); // TODO: Initialize to an appropriate value Statistics expected = new Statistics(); Statistics actual; target.Statistics = expected; actual = target.Statistics; Assert.AreEqual(expected, actual); }
public void Equals_ReturnTrue_When_ComparingObjectsWithAllEqualsFields() { var entry1 = new ProfileEntry { Type = ProfileEntryType.FirstName, Value = "a", IsPublic = true }; var entry2 = new ProfileEntry { Type = ProfileEntryType.FirstName, Value = "a", IsPublic = true }; Assert.AreEqual(entry1, entry2); }
public void Equals_ReturnFalse_When_ComparingObjectsWithDifferentPublicFlags() { var entry1 = new ProfileEntry { IsPublic = false }; var entry2 = new ProfileEntry { IsPublic = true }; Assert.AreNotEqual(entry1, entry2); }
public void Equals_ReturnTrue_When_BothObjectsHasSameValueAndOtherFieldsAreDefault() { var entry1 = new ProfileEntry { Value = "a" }; var entry2 = new ProfileEntry { Value = "a" }; Assert.AreEqual(entry1, entry2); }
public void Equals_ReturnFalse_When_OneOfObjectsHasNullValue() { var entry1 = new ProfileEntry { Value = "a" }; var entry2 = new ProfileEntry { Value = null }; Assert.AreNotEqual(entry1, entry2); }
public void Equals_ReturnFalse_When_ComparingObjectsWithDifferentValue() { var entry1 = new ProfileEntry { Value = "a" }; var entry2 = new ProfileEntry { Value = "b" }; Assert.AreNotEqual(entry1, entry2); }
public void Equals_ReturnTrue_When_ComparingObjectsWithSameTypesAndOtherFieldsAreDefault() { var entry1 = new ProfileEntry { Type = ProfileEntryType.FirstName }; var entry2 = new ProfileEntry { Type = ProfileEntryType.FirstName }; Assert.AreEqual(entry1, entry2); }
public void Equals_ReturnFalse_When_ComparingObjectsWithDifferentTypes() { var entry1 = new ProfileEntry { Type = ProfileEntryType.FirstName }; var entry2 = new ProfileEntry { Type = ProfileEntryType.LastName }; Assert.AreNotEqual(entry1, entry2); }
private ProfileEntry addEntry(string canonical) { var entry = _allEntries.SingleOrDefault(e => e.Reference == canonical); if (entry != null) { return(entry); } else { var newEntry = new ProfileEntry(canonical); _allEntries.Add(newEntry); return(newEntry); } }
static ProfileEntry Entry(object target, string label, string property, string key, Type type, Action act = null) { return(entries[key] = new ProfileEntry( target, label, property, key, new Traverse(target).Field(property).GetValue(), type, act )); }
public static string GetOrCreateConfigFileName(string applicationDataDirectory, string profileName) { var profileDataAccess = new ProfileListDataAccess(Path.Combine(applicationDataDirectory, "profiles.xml")); var profiles = profileDataAccess.Load(); var profile = profiles.FirstOrDefault(p => String.Compare(p.ProfileName, profileName, StringComparison.OrdinalIgnoreCase) == 0); if (profile == null) { profile = new ProfileEntry() { ProfileName = profileName, ConfigFileName = string.Format("options_{0}.xml", Guid.NewGuid()) }; profiles = profiles.Union(new[] { profile }).ToArray(); profileDataAccess.Save(profiles); } return(profile.ConfigFileName); }
public void Equals_ReturnTrye_When_ComparingObjectsWithSamePublicFlagsAndOtherFieldsAreDefault() { var entry1 = new ProfileEntry { IsPublic = true }; var entry2 = new ProfileEntry { IsPublic = true }; Assert.AreEqual(entry1, entry2); entry1 = new ProfileEntry { IsPublic = false }; entry2 = new ProfileEntry { IsPublic = false }; Assert.AreEqual(entry1, entry2); }
private ProfileEntry addEntry(StructureDefinition definition) { var entry = _allEntries.SingleOrDefault(e => e.Reference == definition.Url); if (entry != null) { if (entry.Unresolved) { entry.StructureDefinition = definition; } return(entry); } else { var newEntry = new ProfileEntry(definition); _allEntries.Add(newEntry); return(newEntry); } }
public void ProfileEntryConstructorTest() { ProfileEntry target = new ProfileEntry(); Assert.IsNotNull(target); Assert.AreEqual(target.Age, 0); Assert.IsNull(target.Books); Assert.IsNull(target.Statistics); Assert.IsNull(target.School); Assert.IsNull(target.Occupation); Assert.IsNull(target.Music); Assert.IsNull(target.Movies); Assert.IsNull(target.Location); Assert.IsNull(target.Lastname); Assert.IsNull(target.Hobbies); Assert.IsNull(target.Gender); Assert.IsNull(target.Firstname); Assert.IsNull(target.Company); Assert.IsNotNull(target.FeedLinks); }
public async Task Get_CutDownNotPublicProfileEntriesFromResult_When_AnonymousCall() { var publicProfileInfo = new ProfileEntry() { Type = ProfileEntryType.MiddleName, Value = "a", IsPublic = true }; this.validProfile.ProfileInfo = new[] { new ProfileEntry() { Type = ProfileEntryType.FirstName, Value = "a", IsPublic = false }, publicProfileInfo }.ToList(); Value <Profile_OLD> result = await this.subject.Get(new DTO.ProfileRequest { UserId = this.validUserId.ToString() }); Assert.AreEqual(result.Payload.ProfileInfo.Count, 1); Assert.AreEqual(result.Payload.ProfileInfo.First(), publicProfileInfo); }