private LockingDictionary <StorageKey, ObjectDecorator> GetSingleKeySpace(DataBuffer keySpace) { var hash = keySpace.GetHashCode(); LockingDictionary <StorageKey, ObjectDecorator> keySpaceDct; // upgradeable blocks other upgradeable, so try read first using (_keySpaces.Lock(LockType.Read)) { if (_keySpaces.TryGetValue(hash, out keySpaceDct)) { return(keySpaceDct); } } // didn't find it, so now try upgradeable to write if need be using (_keySpaces.Lock(LockType.ReadUpgradable)) { if (!_keySpaces.TryGetValue(hash, out keySpaceDct)) { using (_keySpaces.Lock(LockType.Write)) { keySpaceDct = new LockingDictionary <StorageKey, ObjectDecorator>(); _keySpaces.Add(hash, keySpaceDct); } } return(keySpaceDct); } }
public void ResolveStrings(LockingDictionary <uint, string> StringResources, bool RaiseChangedEvent) { string res_name; string res_mainoverlayname; StringResources.TryGetValue(nameRID, out res_name); StringResources.TryGetValue(overlayFileRID, out res_mainoverlayname); if (RaiseChangedEvent) { if (res_name != null) { Name = res_name; } else { Name = String.Empty; } if (res_mainoverlayname != null) { OverlayFile = res_mainoverlayname; } else { OverlayFile = String.Empty; } } else { if (res_name != null) { name = res_name; } else { name = String.Empty; } if (res_mainoverlayname != null) { overlayFile = res_mainoverlayname; } else { overlayFile = String.Empty; } } foreach (SubOverlay obj in subOverlays) { obj.ResolveStrings(StringResources, RaiseChangedEvent); } foreach (SubOverlay obj in motionSubOverlays) { obj.ResolveStrings(StringResources, RaiseChangedEvent); } }
public void ResolveStrings(LockingDictionary <uint, string> StringResources, bool RaiseChangedEvent) { string bg_res; string bg_name; StringResources.TryGetValue(nameRID, out bg_res); StringResources.TryGetValue(overlayFileRID, out bg_name); if (RaiseChangedEvent) { if (bg_res != null) { OverlayFile = bg_res; } else { OverlayFile = String.Empty; } if (bg_name != null) { Name = bg_name; } else { Name = String.Empty; } } else { if (bg_res != null) { overlayFile = bg_res; } else { overlayFile = String.Empty; } if (bg_name != null) { name = bg_name; } else { name = String.Empty; } } }
public void ResolveStrings(LockingDictionary <uint, string> StringResources, bool RaiseChangedEvent) { string skill_name; string skill_description; StringResources.TryGetValue(skillNameID, out skill_name); StringResources.TryGetValue(skillDescriptionID, out skill_description); if (RaiseChangedEvent) { if (skill_name != null) { SkillName = skill_name; } else { SkillName = String.Empty; } if (skill_description != null) { SkillDescription = skill_description; } else { SkillDescription = String.Empty; } } else { if (skill_name != null) { skillName = skill_name; } else { skillName = String.Empty; } if (skill_description != null) { skillDescription = skill_description; } else { skillDescription = String.Empty; } } }
public static void SaveFromPluginFile(string strPluginFileElement, Character character, SINner mySINnerLoading = null) { if (character == null) { throw new ArgumentNullException(nameof(character)); } if (string.IsNullOrEmpty(strPluginFileElement)) { return; } CharacterExtended objReturn = new CharacterExtended(character, mySINnerLoading, new CharacterCache(), false); objReturn.MyCharacterCache.LoadFromFile(character.FileName); try { if (!s_dicCachedPluginFileSINners.TryGetValue(strPluginFileElement, out SINner objSiNner)) { objSiNner = JsonConvert.DeserializeObject <SINner>(strPluginFileElement); s_dicCachedPluginFileSINners.AddOrUpdate(strPluginFileElement, objSiNner, (x, y) => objSiNner); } objReturn.MySINnerFile = objSiNner; } catch (Exception e) { Log.Error(e); } SaveSINnerIds(); }
public void ResolveStrings(LockingDictionary <uint, string> StringResources, bool RaiseChangedEvent) { string res_mainoverlayname; StringResources.TryGetValue(overlayFileRID, out res_mainoverlayname); if (RaiseChangedEvent) { if (res_mainoverlayname != null) { OverlayFile = res_mainoverlayname; } else { OverlayFile = String.Empty; } } else { if (res_mainoverlayname != null) { overlayFile = res_mainoverlayname; } else { overlayFile = String.Empty; } } }
public virtual void ResolveStrings(LockingDictionary <uint, string> StringResources, bool RaiseChangedEvent) { string res_name; StringResources.TryGetValue(headlineResourceID, out res_name); if (RaiseChangedEvent) { if (res_name != null) { Headline = res_name; } else { Headline = String.Empty; } } else { if (res_name != null) { headline = res_name; } else { headline = String.Empty; } } }
public override void ResolveStrings(LockingDictionary <uint, string> StringResources, bool RaiseChangedEvent) { base.ResolveStrings(StringResources, RaiseChangedEvent); string res_icon; StringResources.TryGetValue(resourceIconID, out res_icon); if (RaiseChangedEvent) { if (res_icon != null) { ResourceIconName = res_icon; } else { ResourceIconName = String.Empty; } } else { if (res_icon != null) { resourceIconName = res_icon; } else { resourceIconName = String.Empty; } } }
/// <summary> /// Update the PIDecoder from values attached to PingReply message /// </summary> /// <param name="NewDecodeByte">Is attached on PingReply</param> /// <param name="ResourceID">Is attached on PingReply</param> public void Update(byte NewDecodeByte, uint ResourceID) { // Update the decode byte currentDecodeByte = (uint)(NewDecodeByte ^ XORValue); // zero resourceid indicates use of fallbackstring if (ResourceID == 0) { stringBytes = Encoding.Default.GetBytes(FALLBACKSTRING); } else { string iterateString; // try to get the string from dictionary if (stringResources.TryGetValue(ResourceID, out iterateString)) { stringBytes = Encoding.Default.GetBytes(iterateString); } else { // THIS MOST LIKELY KILLS YOUR CONNECTION // AND SHOULD NOT BE REACHED stringBytes = Encoding.Default.GetBytes(FALLBACKSTRING); } } // Reset the cursor on the local iteration string cursor = 0; // Mark as enabled enabled = true; }
public void ResolveStrings(LockingDictionary <uint, string> StringResources, bool RaiseChangedEvent) { string res_name; StringResources.TryGetValue(resourceID, out res_name); if (RaiseChangedEvent) { if (res_name != null) { ResourceName = res_name.Replace(FileExtensions.MID, FileExtensions.MP3); } else { ResourceName = String.Empty; } } else { if (res_name != null) { resourceName = res_name.Replace(FileExtensions.MID, FileExtensions.MP3); } else { resourceName = String.Empty; } } }
public void ResolveStrings(LockingDictionary<uint, string> StringResources, bool RaiseChangedEvent) { string res_mainoverlayname; StringResources.TryGetValue(overlayFileRID, out res_mainoverlayname); if (RaiseChangedEvent) { if (res_mainoverlayname != null) OverlayFile = res_mainoverlayname; else OverlayFile = String.Empty; } else { if (res_mainoverlayname != null) overlayFile = res_mainoverlayname; else overlayFile = String.Empty; } }
public void ResolveStrings(LockingDictionary<uint, string> StringResources, bool RaiseChangedEvent) { string res_name; StringResources.TryGetValue(resourceID, out res_name); if (RaiseChangedEvent) { if (res_name != null) ResourceName = res_name; else ResourceName = String.Empty; } else { if (res_name != null) resourceName = res_name; else resourceName = String.Empty; } }
public void ResolveStrings(LockingDictionary<uint, string> StringResources, bool RaiseChangedEvent) { string res_name; string res_mainoverlayname; StringResources.TryGetValue(nameRID, out res_name); StringResources.TryGetValue(overlayFileRID, out res_mainoverlayname); if (RaiseChangedEvent) { if (res_name != null) Name = res_name; else Name = String.Empty; if (res_mainoverlayname != null) OverlayFile = res_mainoverlayname; else OverlayFile = String.Empty; } else { if (res_name != null) name = res_name; else name = String.Empty; if (res_mainoverlayname != null) overlayFile = res_mainoverlayname; else overlayFile = String.Empty; } foreach (SubOverlay obj in subOverlays) obj.ResolveStrings(StringResources, RaiseChangedEvent); foreach (SubOverlay obj in motionSubOverlays) obj.ResolveStrings(StringResources, RaiseChangedEvent); }
public void ResolveStrings(LockingDictionary <uint, string> StringResources, bool RaiseChangedEvent) { string avatar_name; string avatar_overlay; string room_file; string room_name; string background_file; string wading_file; StringResources.TryGetValue(avatarOverlayRID, out avatar_overlay); StringResources.TryGetValue(avatarNameRID, out avatar_name); StringResources.TryGetValue(roomFileRID, out room_file); StringResources.TryGetValue(roomNameRID, out room_name); StringResources.TryGetValue(backgroundFileRID, out background_file); StringResources.TryGetValue(wadingSoundFileRID, out wading_file); if (RaiseChangedEvent) { if (avatar_name != null) { AvatarName = avatar_name; } else { AvatarName = String.Empty; } if (avatar_overlay != null) { AvatarOverlay = avatar_overlay; } else { AvatarOverlay = String.Empty; } if (room_file != null) { RoomFile = room_file; } else { RoomFile = String.Empty; } if (room_name != null) { RoomName = room_name; } else { RoomName = String.Empty; } if (background_file != null) { BackgroundFile = background_file; } else { BackgroundFile = String.Empty; } if (wading_file != null) { WadingSoundFile = wading_file; } else { WadingSoundFile = String.Empty; } } else { if (avatar_name != null) { avatarName = avatar_name; } else { avatarName = String.Empty; } if (avatar_overlay != null) { avatarOverlay = avatar_overlay; } else { avatarOverlay = String.Empty; } if (room_file != null) { roomFile = room_file; } else { roomFile = String.Empty; } if (room_name != null) { roomName = room_name; } else { roomName = String.Empty; } if (background_file != null) { backgroundFile = background_file; } else { backgroundFile = String.Empty; } if (wading_file != null) { wadingSoundFile = wading_file; } else { wadingSoundFile = String.Empty; } } }
public virtual int ReadFrom(byte[] Buffer, int StartIndex = 0) { int cursor = StartIndex; resourceID = BitConverter.ToUInt32(Buffer, cursor); cursor += TypeSizes.INT; string resourceName; stringResources.TryGetValue(resourceID, out resourceName); this.resourceName = resourceName; // start filling up variables (example: %s) with values // their values are attached to the packet/buffer and make it a variable length // also there might be more than one iteration necessary as varibles may be nested into variable-strings fullString = String.Copy(resourceName); int index = HasVariable(fullString); while (index > -1) { // which type of inline var switch (fullString[index + 1]) { case INTEGERFLAG: case INTEGERFLAG2: InlineVariable var1 = new InlineVariable(InlineVariableType.Integer, Buffer, cursor); cursor += var1.ByteLength; Variables.Add(var1); int j = (int)var1.Data; // remove the %i and insert the integer fullString = fullString.Remove(index, 2); fullString = fullString.Insert(index, j.ToString()); break; case EMBEDDEDSTRINGFLAG: InlineVariable var2 = new InlineVariable(InlineVariableType.String, Buffer, cursor); cursor += var2.ByteLength; Variables.Add(var2); string s = (string)var2.Data; // remove the %q and insert the string fullString = fullString.Remove(index, 2); fullString = fullString.Insert(index, s); break; case STRINGRESOURCEFLAG: InlineVariable var3 = new InlineVariable(InlineVariableType.Resource, Buffer, cursor); cursor += var3.ByteLength; Variables.Add(var3); uint resourceid = (uint)var3.Data; // try to get it from strings string resourcestr; stringResources.TryGetValue(resourceid, out resourcestr); // still null? use dummy if (resourcestr == null) { resourcestr = String.Empty; } // remove the %s and insert the resourcestr fullString = fullString.Remove(index, 2); fullString = fullString.Insert(index, resourcestr); break; default: break; } // check if there is more inline vars (may start loop again) index = HasVariable(fullString); } // extract and remove the inline styles (~B ...) Styles = ChatStyle.GetStyles(fullString, chatMessageType); fullString = ChatStyle.RemoveInlineStyles(fullString); return(cursor - StartIndex); }
public void ResolveStrings(LockingDictionary<uint, string> StringResources, bool RaiseChangedEvent) { string skill_name; string skill_description; StringResources.TryGetValue(skillNameID, out skill_name); StringResources.TryGetValue(skillDescriptionID, out skill_description); if (RaiseChangedEvent) { if (skill_name != null) SkillName = skill_name; else SkillName = String.Empty; if (skill_description != null) SkillDescription = skill_description; else SkillDescription = String.Empty; } else { if (skill_name != null) skillName = skill_name; else skillName = String.Empty; if (skill_description != null) skillDescription = skill_description; else skillDescription = String.Empty; } }