/// <summary> /// Initializes a new instance of the <see cref="YouTubeSong" /> class. /// </summary> /// <param name="artist">You tube artist.</param> /// <param name="title">You tube song title.</param> /// <param name="songId">The song identifier.</param> /// <param name="playlistItemId">The playlist item identifier.</param> /// <param name="resourceId">The resource identifier.</param> public YouTubeSong(string artist, string title, string songId, string playlistItemId, ResourceId resourceId) { this.Artist = artist; this.Title = title; this.SongId = songId; this.PlayListItemId = playlistItemId; this.ResourceId = resourceId; }
public bool IsMetBy(ResourceId componentId) { string path = componentId.Uri.LocalPath; string dir = Path.GetDirectoryName(path); string fileName = Path.GetFileNameWithoutExtension(path); string fileExt = Path.GetExtension(path); string fileNameToSearch = _constraintConfig; fileNameToSearch = fileNameToSearch.Replace("[filename]", fileName); fileNameToSearch = fileNameToSearch.Replace("[fileext]", fileExt); string fullPathToSearch = Path.Combine(dir, fileNameToSearch); return File.Exists(fullPathToSearch); }
public YoutubePlaylistItem(Playlist item, int relevance) : base(item.Snippet.Title, item, relevance) { ChannelTitle = item.Snippet.ChannelTitle; ChannelId = item.Snippet.ChannelId; ResourceId = new ResourceId(); ResourceId.Kind = "youtube#playlist"; ResourceId.PlaylistId = item.Id; Thumbnail = item.Snippet.Thumbnails; PublishedAt = item.Snippet.PublishedAt; Description = item.Snippet.Description; PlaylistId = item.Id; }
public bool IsMetBy(ResourceId componentId) { try { var doc = XElement.Load(componentId.Uri.LocalPath); var elems = from e in doc.DescendantsAndSelf() where e.Name == _elementName select e; if (_attributeValues == null) return (elems.FirstOrDefault() != null); else if (_attributeValues.Count() > 0) //add logic that compares attributeValues to elem.attributes - if an elem is found with all attributes - return true; throw new NotImplementedException(); else return false; } catch { return false; } }
public static GetRecordRequest.IGetRecordWithResource GetRecords(ResourceId resourceId) { return(GetRecordRequest.Builder(resourceId)); }
public NotifierInventoryDefinition(ResourceId guid, int count) { Guid = guid; Count = count; }
public NotifierTalentDefinition(ResourceId talent) { ChampionTalentData data = TemplateManager.Instance.GetChampionTalentTemplate(talent); if (data != null) { Name = data.Name; Guid = talent; } }
public static bool Register() { ResourceId resource_type = new ResourceId(ResourceType.RT_CURSOR); return ResourceType.Register(resource_type, typeof(CursorResource)); }
/// <summary> /// When resuming an order by query we need to filter the document producers. /// </summary> /// <param name="producer">The producer to filter down.</param> /// <param name="sortOrders">The sort orders.</param> /// <param name="continuationToken">The continuation token.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns>A task to await on.</returns> private async Task FilterAsync( DocumentProducerTree producer, SortOrder[] sortOrders, OrderByContinuationToken continuationToken, CancellationToken cancellationToken) { // When we resume a query on a partition there is a possibility that we only read a partial page from the backend // meaning that will we repeat some documents if we didn't do anything about it. // The solution is to filter all the documents that come before in the sort order, since we have already emitted them to the client. // The key is to seek until we get an order by value that matches the order by value we left off on. // Once we do that we need to seek to the correct _rid within the term, // since there might be many documents with the same order by value we left off on. foreach (DocumentProducerTree tree in producer) { if (!ResourceId.TryParse(continuationToken.Rid, out ResourceId continuationRid)) { this.TraceWarning(string.Format( CultureInfo.InvariantCulture, "Invalid Rid in the continuation token {0} for OrderBy~Context.", continuationToken.CompositeContinuationToken.Token)); throw new BadRequestException(RMResources.InvalidContinuationToken); } Dictionary <string, ResourceId> resourceIds = new Dictionary <string, ResourceId>(); int itemToSkip = continuationToken.SkipCount; bool continuationRidVerified = false; while (true) { OrderByQueryResult orderByResult = new OrderByQueryResult(tree.Current); // Throw away documents until it matches the item from the continuation token. int cmp = 0; for (int i = 0; i < sortOrders.Length; ++i) { cmp = ItemComparer.Instance.Compare( continuationToken.OrderByItems[i].Item, orderByResult.OrderByItems[i].Item); if (cmp != 0) { cmp = sortOrders[i] != SortOrder.Descending ? cmp : -cmp; break; } } if (cmp < 0) { // We might have passed the item due to deletions and filters. break; } if (cmp == 0) { ResourceId rid; if (!resourceIds.TryGetValue(orderByResult.Rid, out rid)) { if (!ResourceId.TryParse(orderByResult.Rid, out rid)) { this.TraceWarning(string.Format( CultureInfo.InvariantCulture, "Invalid Rid in the continuation token {0} for OrderBy~Context.", continuationToken.CompositeContinuationToken.Token)); throw new BadRequestException(RMResources.InvalidContinuationToken); } resourceIds.Add(orderByResult.Rid, rid); } if (!continuationRidVerified) { if (continuationRid.Database != rid.Database || continuationRid.DocumentCollection != rid.DocumentCollection) { this.TraceWarning(string.Format( CultureInfo.InvariantCulture, "Invalid Rid in the continuation token {0} for OrderBy~Context.", continuationToken.CompositeContinuationToken.Token)); throw new BadRequestException(RMResources.InvalidContinuationToken); } continuationRidVerified = true; } // Once the item matches the order by items from the continuation tokens // We still need to remove all the documents that have a lower rid in the rid sort order. // If there is a tie in the sort order the documents should be in _rid order in the same direction as the first order by field. // So if it's ORDER BY c.age ASC, c.name DESC the _rids are ASC // If ti's ORDER BY c.age DESC, c.name DESC the _rids are DESC cmp = continuationRid.Document.CompareTo(rid.Document); if (sortOrders[0] == SortOrder.Descending) { cmp = -cmp; } // We might have passed the item due to deletions and filters. // We also have a skip count for JOINs if (cmp < 0 || (cmp == 0 && itemToSkip-- <= 0)) { break; } } if (!await tree.MoveNextAsync(cancellationToken)) { break; } } } }
public bool IsMetBy(ResourceId componentId) { return (_constraint1.IsMetBy(componentId) && _constraint2.IsMetBy(componentId)); }
//========================================================================================== // Methods //========================================================================================== /// <summary> /// Gets a localized string from the satellite assembly. /// </summary> /// <param name="resourceId">The string to retrieve from the satellite assembly.</param> /// <returns>A localized string from the satellite assembly.</returns> public string GetString(ResourceId resourceId) { Guid packageGuid = this.PackageTypeGuid; string stringResource; IVsShell vsShell = Package.Instance.Context.ServiceProvider.GetVsShell(classType, "GetString"); int hr = vsShell.LoadPackageString(ref packageGuid, (uint)resourceId, out stringResource); NativeMethods.ThrowOnFailure(hr); return stringResource; }
public void SearchUpdateDateEqualsToCondition(ResourceId resource, SearchHelpers.ValidTestCases testCase, string fieldName, SearchHelpers.Directions direction) { SearchHelpers.VerifySearchByDateField(resource, testCase, fieldName, direction, CurrentDateTime, Timezone, NumRecords, RecordsCreatorForEqualsTo); }
/// <summary> /// Shows an error-type message box (with an exclamation icon and an OK button) with the specified message. /// </summary> /// <param name="messageId">The resource identifier of the message to show.</param> /// <param name="args">An array of arguments to use for formatting the message.</param> public void ShowErrorMessageBox(ResId messageId, params object[] args) { string message = this.NativeResources.GetString(messageId); if (args != null && args.Length > 0) { message = String.Format(CultureInfo.CurrentUICulture, message, args); } this.ShowErrorMessageBox(null, message); }
internal ResourceMap(AssetManager manager, AssetLoader loader) : base(manager, loader.Name) { var reader = loader.Reader; Path = loader.Name; FileManager = loader.FileManager; Version = DetectVersion(loader); Dictionary<ResourceType, FolderAsset> folders = new Dictionary<ResourceType, FolderAsset>(); using (reader) { if (Version == ResourceMapVersion.Sci0) { // Simple list of entries of type (short typeAndIndex, int offsetAndPage), terminated with a (-1, -1) while (true) { ResourceId id = new ResourceId(reader, Version); if (id.IsEnd) break; AddResource(id, folders); } } else if (Version == ResourceMapVersion.Sci1) { List<KeyValuePair<ResourceType, int>> types = new List<KeyValuePair<ResourceType, int>>(); while (true) { ResourceType type = (ResourceType)reader.ReadByte(); int offset = reader.ReadUInt16(); types.Add(new KeyValuePair<ResourceType, int>(type == ResourceType.End ? type : (ResourceType)((int)type & 0x7F), offset)); if (type == ResourceType.End) break; } for (int typeIndex = 0; typeIndex < types.Count - 1; typeIndex++) { ResourceType type = types[typeIndex].Key; int end = types[typeIndex + 1].Value; while (reader.BaseStream.Position < end) { ResourceId id = new ResourceId(reader, Version, type); AddResource(id, folders); } } } else if(Version == ResourceMapVersion.Sci2) { List<KeyValuePair<ResourceType, int>> types = new List<KeyValuePair<ResourceType, int>>(); while (true) { ResourceType type = (ResourceType)reader.ReadByte(); int offset = reader.ReadUInt16(); types.Add(new KeyValuePair<ResourceType, int>(type, offset)); if (type == ResourceType.End) break; } Unknowns.ReadInt32s(reader, 1, "Post offsets"); for (int typeIndex = 0; typeIndex < types.Count - 1; typeIndex++) { ResourceType type = types[typeIndex].Key; int offset = types[typeIndex].Value; int end = types[typeIndex + 1].Value; if ((end - offset) % 6 != 0) throw new InvalidDataException(); int count = (end - offset) / 6; for (int index = 0; index < count; index++) { ResourceId id = new ResourceId(reader, Version, type); AddResource(id, folders); } } } else throw new NotImplementedException(); } SortChildrenRecursively(); }
public static bool Register() { ResourceId resource_type = new ResourceId(ResourceType.RT_VERSION); return ResourceType.Register(resource_type, typeof(VersionResource)); }
void AddResource(ResourceId id, Dictionary<ResourceType, FolderAsset> folders) { foreach (FolderAsset childFolder in Children) { foreach (Resource resource in childFolder.Children) { if (resource.Id.Type == id.Type && resource.Id.Id == id.Id) return; } } FolderAsset folder; if (!folders.TryGetValue(id.Type, out folder)) folder = folders[id.Type] = new FolderAsset(this, id.Type.ToString()); new Resource(folder, this, id); }
static bool DetectVersionSci0(AssetLoader loader) { var version = ResourceMapVersion.Sci0; var reader = loader.Reader; var length = loader.Length; // File is a simple list of 6-byte resource ids. if (length % 6 != 0 || length / 6 > short.MaxValue) return false; int count = (int)(length / 6); for (int index = 0; index < count - 1; index++) { ResourceId id = new ResourceId(reader, version); if (id.IsEnd) return false; } ResourceId end = new ResourceId(reader, version); if (!end.IsEnd) return false; return true; }
/// <summary> /// Initialise the resource. /// </summary> /// <param name="parent"></param> /// <param name="map"></param> /// <param name="id"></param> public Resource(FolderAsset parent, ResourceMap map, ResourceId id) : base(parent, id.ToString()) { Map = map; Id = id; }
public static void SendAndVerifyMergeRequest(HrbcRecordCreator record, MergeManager mergeHandler, ResourceId resourceId, int baseIndex, int mergeIndex, bool IsValidRequest = true) { var requestContent = new Dictionary <string, object>() { ["baseId"] = record.Data[$"{resourceId}{baseIndex}"].Id, ["mergedId"] = new List <ulong>() { record.Data[$"{resourceId}{mergeIndex}"].Id }, ["mapping"] = GetMapping(resourceId, record.Data[$"{resourceId}{baseIndex}"].Id, record.Data[$"{ResourceId.Client}{baseIndex}"].Id), }; var response = mergeHandler.MergeRecords <MergeResponse>(resourceId, requestContent, System.Net.Http.HttpMethod.Post); if (IsValidRequest) { PrAssert.That(response, PrIs.SuccessfulResponse()); PrAssert.That(response.Result.Id, PrIs.Not.Null); LoopAndVerifyCompleteMerge(response.Result.Id); } else { PrAssert.That(response, PrIs.ErrorResponse().With.HttpCode((int)HttpStatusCode.BadRequest)); PrAssert.That(response.Errors.Code, PrIs.EqualTo((int)ResultCode.InvalidParameter)); PrAssert.That(response.Errors.Error, PrIs.EqualTo("Invalid Parameter.")); } }
private GatewayStoreModel GetGatewayStoreModelForConsistencyTest() { Func <HttpRequestMessage, Task <HttpResponseMessage> > messageHandler = async request => { String content = await request.Content.ReadAsStringAsync(); if (content.Equals("document")) { IEnumerable <string> sessionTokens = request.Headers.GetValues("x-ms-session-token"); string sessionToken = ""; foreach (string singleToken in sessionTokens) { sessionToken = singleToken; break; } Assert.AreEqual(sessionToken, "range_0:1#9#4=8#5=7"); } else { IEnumerable <string> enumerable; Assert.IsFalse(request.Headers.TryGetValues("x-ms-session-token", out enumerable)); } return(new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent("Response") }); }; Mock <IDocumentClientInternal> mockDocumentClient = new Mock <IDocumentClientInternal>(); mockDocumentClient.Setup(client => client.ServiceEndpoint).Returns(new Uri("https://foo")); mockDocumentClient.Setup(client => client.ConsistencyLevel).Returns(Documents.ConsistencyLevel.Session); GlobalEndpointManager endpointManager = new GlobalEndpointManager(mockDocumentClient.Object, new ConnectionPolicy()); SessionContainer sessionContainer = new SessionContainer(string.Empty); sessionContainer.SetSessionToken( ResourceId.NewDocumentCollectionId(42, 129).DocumentCollectionId.ToString(), "dbs/db1/colls/coll1", new DictionaryNameValueCollection() { { HttpConstants.HttpHeaders.SessionToken, "range_0:1#9#4=8#5=7" } }); DocumentClientEventSource eventSource = DocumentClientEventSource.Instance; HttpMessageHandler httpMessageHandler = new MockMessageHandler(messageHandler); GatewayStoreModel storeModel = new GatewayStoreModel( endpointManager, sessionContainer, TimeSpan.FromSeconds(50), ConsistencyLevel.Session, eventSource, null, new UserAgentContainer(), ApiType.None, httpMessageHandler); return(storeModel); }
public static bool Register() { ResourceId resource_type = new ResourceId(ResourceType.RT_BITMAP); return ResourceType.Register(resource_type, typeof(BitmapResource)); }
public static bool Register() { ResourceId resource_type = new ResourceId(ResourceType.RT_DIALOG); return ResourceType.Register(resource_type, typeof(DialogResource)); }
/// <summary> /// Shows a message box with the specified error message and the specified debug information (if it's a debug build). /// </summary> /// <param name="messageId">The resource identifier of the message to show.</param> /// <param name="debugInformation">The extra information to show in a debug build.</param> public void NotifyInternalError(ResId messageId, string debugInformation) { string title = this.NativeResources.GetString(messageId); string message = String.Empty; PackageUtility.AppendConsultTraceMessage(ref message); PackageUtility.AppendDebugInformation(ref message, debugInformation); this.ShowErrorMessageBox(title, message); }
public CardUpdated(string user, CardRepresentation card) : base(user) { try { Cost = card.Cost; Gems = card.Gems; Name = card.Name; State = card.State; Attack = card.Attack; Shards = card.Colors; Defense = card.Defense; Message = GetMessageName(); Attributes = card.Attributes; Controller = card.Controller.GetInstanceId(); Collection = card.Collection; BaseTemplate = card.TemplateId; Abilities = new List<string>(); foreach (ResourceId id in card.Abilities) if (TemplateManager.Instance.Abilities.ContainsKey(id)) Abilities.Add(TemplateManager.Instance.Abilities[id].m_GameText); } catch (Exception ex) { Log.Exception("Notifier", ex); } }
/// <summary> /// Shows an error-type message box (with an exclamation icon and an OK button) with the specified message. /// </summary> /// <param name="titleId">The resource identifier of the first line of the message box (not the caption).</param> /// <param name="messageId">The resource identifier of the second line (or paragraph) of the message box.</param> public void ShowErrorMessageBox(ResId titleId, ResId messageId) { string title = this.NativeResources.GetString(titleId); string message = this.NativeResources.GetString(messageId); this.ShowErrorMessageBox(title, message); }
public NotifierCardDefinition(ICard card) { if (card.Template != null) { Guid = card.Template.m_Id; if (card.IsExtended) Flags = "ExtendedArt"; } Id = card.CardId.InstanceId; }
/// <summary> /// Gets a formatted, localized string from the satellite assembly. /// </summary> /// <param name="resourceId">The string to retrieve from the satellite assembly.</param> /// <param name="args">Array of arguments to use in formatting the localized string.</param> /// <returns>A formatted, localized string from the satellite assembly.</returns> public string GetString(ResourceId resourceId, params object[] args) { string rawString = this.GetString(resourceId); return String.Format(CultureInfo.CurrentUICulture, rawString, args); }
public NotifierCardDefinition(card_instance_bits card) { if (TemplateManager.Instance.Cards.ContainsKey(card.TemplateID)) Guid = card.TemplateID; Id = card.Id; }
public bool IsMetBy(ResourceId componentId) { return Regex.IsMatch(componentId.Uri.AbsoluteUri, _pattern); }
public NotifierCardSet(ResourceId guid, string flags, int count) { Guid = guid; Flags = flags; Count = count; }
public NotifierGemDefinition(EGemTypes gem) { InventoryGemData gem_data = TemplateManager.Instance.GetGemData(gem); if (gem_data != null) { Name = gem_data.Name; Guid = gem_data.Id; } }
public IBuilderWithData Append(ResourceId resource, params ulong[] ids) { return(Append(resource, ids.AsEnumerable())); }