public void CreateDictionary(DictionaryData data) { GameObject prefab = Resources.Load <GameObject>("Dictionary"); GameObject dictionary = Instantiate(prefab, components.content); dictionary.GetComponent <Vocabulary>().Init(data); }
// Start is called before the first frame update void Start() { PropertyFloatData weapondData = new PropertyFloatData("weapondData.csv"); weapondData.Load(); Dictionary <string, float> data = weapondData.Get("LightningGauntlet"); print(data["damage"]); print(weapondData.Get("DancingArrow")["coolTime"]); TableData tableData = new TableData("test.txt"); tableData.Load(); print(tableData.Get("fields")["def"]); print(tableData.Get("bos1", "id")); print(tableData["bos1"]["id"]); DictionaryData dicData = new DictionaryData("test.txt"); dicData.Load(); print(dicData.Get("bos1")); print(dicData["bos1"]); }
public bool Set(string key, object value) { bool result = false; using (X42DbContext dbContext = new X42DbContext(databaseSettings.ConnectionString)) { var item = dbContext.DictionaryItems.Where(d => d.Key == key).FirstOrDefault(); if (item == null) { var newDictionaryItem = new DictionaryData() { Key = key, Value = ConvertType <string>(value) }; var addedItem = dbContext.Add(newDictionaryItem); if (addedItem.State == EntityState.Added) { dbContext.SaveChanges(); result = true; } } else { item.Value = ConvertType <string>(value); dbContext.SaveChanges(); result = true; } } return(result); }
public override CollectedData OnAcquire() { bool collected = false; ulong sum_bps = 0; ulong sum_bandwidth = 0; OnAcquireDelegate( dict => { ulong bps = (ulong)dict["BytesTotalPerSec"]; ulong bandwidth = (ulong)dict["CurrentBandwidth"]; sum_bps += bps; sum_bandwidth += bandwidth; collected = true; } ); DictionaryData d = new DictionaryData(Context); if (collected) { // CurrentBandwidth is in bits-per-second, so convert it to bytes sum_bandwidth /= 8; double avg = ((double)sum_bps / (double)sum_bandwidth) * 100.0f; d.Data["BPS"] = sum_bps.ToString(); d.Data["Capacity"] = sum_bandwidth.ToString(); d.Data["Avg"] = avg.ToString("0.0"); } return(new CollectedData(Context, collected, d)); }
public override CollectedData OnAcquire() { DictionaryData d = null; OnAcquireDelegate( dict => { d = new DictionaryData(Context); string battery_status_str = dict["BatteryStatus"].ToString(); int battery_status = int.Parse(battery_status_str); EUPSBatteryStatus eups_battery_status = (EUPSBatteryStatus)battery_status; d.Data["BatteryStatusInt"] = battery_status_str; d.Data["BatteryStatus"] = eups_battery_status.GetDescription(); d.Data["EstimatedChargeRemaining"] = dict["EstimatedChargeRemaining"].ToString(); // https://superuser.com/questions/618589/win32-battery-estimatedruntime string estimated_run_time_str = dict["EstimatedRunTime"].ToString(); if (estimated_run_time_str == "71582788") { estimated_run_time_str = "Charging"; } d.Data["EstimatedRunTime"] = estimated_run_time_str; d.Data["Name"] = dict["Name"].ToString(); d.Data["Status"] = dict["Status"].ToString(); }); return(new CollectedData(Context, d != null, d)); }
private void btnXoa_Click(object sender, EventArgs e) { string Key = ""; string Meaning = ""; string Explanation = ""; if (cbWord.Text.ToString() != "") { Key = cbWord.Text; } if (tbMeanning.Text.ToString() != "") { Meaning = tbMeanning.Text; } if (tbExplanation.Text.ToString() != "") { Explanation = tbExplanation.Text; } dicData = new DictionaryData(); dicData.setUp(Key, Meaning, Explanation); dicBLL = new DictionaryBLL(); dicBLL.Xoa(dicData); dictionary = new DictionaryManager(); dictionary.LoadDataToCombobox(cbWord); }
private void IncreaseVersion_NoLock(DictionaryData data, DocumentId documentId, VersionStamp version) { var strongBox = data.VersionTrackingMap.GetOrAdd(version, s_createStrongBoxMap); // actually increase one strongBox.Value++; }
public ActionResult RebuildCacheData() { DictionaryData.InitailDictionaryData(); var result = DictionaryData.Enabled; return(Json(new { Result = result })); }
public override CollectedData OnAcquire() { bool success = false; List <Data> dataList = new List <Data>(); // Default acquire: just make a comma-delimited string of all the values. OnAcquireDelegate( dict => { DictionaryData d = new DictionaryData(Context); // Assume there are multiple thing in PropertiesList. foreach (var prop in WmiContext.PropertiesList) { if (dict.ContainsKey(prop)) { object o = dict[prop]; if (o != null) { d.Data[prop] = o.ToString(); success = true; } } } dataList.Add(d); }); return(new CollectedData(Context, success, dataList)); }
protected void ImageButton3_Click(object sender, ImageClickEventArgs e) { try { ImageButton imgbtn = (ImageButton)sender; int id = Convert.ToInt32(imgbtn.CommandArgument.ToString()); DictionaryData ddate = db.DictionaryData.FirstOrDefault(t => t.ID == id); if (ddate != null) { ddate.IsDel = true; } else { ShowMessage("删除失败"); return; } db.SaveChanges(); ShowMessage("删除成功"); DataBindList(); new SysLogDAO().AddLog(LogType.操作日志_删除, "删除字典信息", UserID); } catch (Exception ex) { ShowMessage(ex.Message); new SysLogDAO().AddLog(LogType.系统日志, ex.Message, UserID); return; } }
private MemberRanges GetSavedMemberRange_NoLock(DictionaryData data, int providerId, Document document) { VersionStamp version; SyntaxNode root; ImmutableArray <TextSpan> range; if (!data.VersionMap.TryGetValue(providerId, out version)) { // it is first time for this provider Contract.ThrowIfFalse(document.TryGetSyntaxRoot(out root)); Contract.ThrowIfFalse(document.TryGetTextVersion(out version)); this.TryCreateOrGetMemberRange_NoLock(data, document, version, out range); return(new MemberRanges(version, range)); } if (!data.MemberRangeMap.TryGetValue(version, out range)) { // it is first time this version is used. Contract.ThrowIfFalse(document.TryGetSyntaxRoot(out root)); this.TryCreateOrGetMemberRange_NoLock(data, document, version, out range); return(new MemberRanges(version, range)); } return(new MemberRanges(version, range)); }
public void Setup(DictionaryData data) { SetTranslator(); LoadWords(data); TryLoadWord(false); }
/// <summary> /// Does bulk Brunet DHT gets by calling the bulk DHT operation API of its /// XML-RPC interface. /// </summary> /// <returns>Null if not all the pieces are successfully retrieved and parsed.</returns> /// <exception cref="Exception">Parsing errors.</exception> private MemBlock GetFragsInBulk(byte[] base_key, int piece_num, out int largest_age, out int smallest_ttl) { largest_age = 0; smallest_ttl = Int32.MaxValue; MemBlock fragments = new MemBlock(); byte[][] keys = new byte[piece_num][]; for (int i = 0; i < piece_num; i++) { byte[] piece_key = BuildFragmentKey(base_key, i); keys[i] = piece_key; } DhtGetResult[] dgrs = _dht.BulkGet(keys); for (int i = 0; i < dgrs.Length; i++) { DhtGetResult dgr = dgrs[i]; if (dgr == null) { Logger.WriteLineIf(LogLevel.Error, _log_props, string.Format("Piece #{0} is null. Retrying...", i)); dgr = GetWithRetries(keys[i], 2); if (dgr == null) { Logger.WriteLineIf(LogLevel.Error, _log_props, string.Format("Piece #{0} is null after retries. Skipping " + "further parsing and returning...", i)); return(null); } } FingerprintedData fpd; try { fpd = (FingerprintedData)DictionaryData.CreateDictionaryData(dgr.value); } catch (Exception ex) { Logger.WriteLineIf(LogLevel.Error, _log_props, ex); throw ex; } Logger.WriteLineIf(LogLevel.Verbose, _log_props, string.Format("Piece #{0} retrieved and successfully parsed", i)); RegularData rd = fpd.InnerData as RegularData; fragments = MemBlock.Concat(fragments, MemBlock.Reference(rd.PayLoad)); if (smallest_ttl > dgr.ttl) { smallest_ttl = dgr.ttl; } if (largest_age < dgr.age) { largest_age = dgr.age; } //Now it's safe to say, this attempt succeeded. } return(fragments); }
/// <summary> /// Gets the first data item of the given name and possibly gets the /// indicated pieces from DHT. /// </summary> /// <param name="getPieces">Whether to get pieces if the data at the /// specified DHT name is a FragmentationInfo</param> public DhtGetResult GetOneDatum(byte[] key, bool getPieces, OneDatumMode mode) { DhtGetResult[] results = _dht.Get(key); DhtGetResult ret; if (results.Length == 0) { ret = null; } else { DhtGetResult dgr; if (mode == OneDatumMode.FirstOne) { dgr = results[0]; } else if (mode == OneDatumMode.LastOne) { dgr = results[results.Length - 1]; } else { throw new NotImplementedException( "This OneDatumMode not implemented."); } DictionaryData dd = null; try { dd = DictionaryData.CreateDictionaryData(dgr.value); } catch (Exception ex) { // Not an error in this case. Log with verbose level. Logger.WriteLineIf(LogLevel.Verbose, _log_props, ex); } if (dd != null && dd is FragmentationInfo) { FragmentationInfo frag_info = dd as FragmentationInfo; BrunetDhtEntry bde = null; try { bde = GetFragments(frag_info) as BrunetDhtEntry; RegularData rd = (RegularData)DictionaryData.CreateDictionaryData( bde.Value); //Only 1 entry (if any) in this array ret = new DhtGetResult(rd.PayLoad, bde.Age, bde.Ttl); } catch (Exception ex) { Logger.WriteLineIf(LogLevel.Error, _log_props, string.Format("Can't get fragments."), ex); ret = null; } } else { ret = dgr; } } return(ret); }
public DictionaryObjectTreeItem(ObjectTreeItem parent, string propertyName, DictionaryData source, int depth) : base(parent, propertyName, source) { var builder = new List <ObjectTreeItem>(source.Dictionary.Count); foreach (var item in source.Dictionary) { builder.Add(StateFormatter.ToTreeHierarchy(this, item.Value, depth + 1, Convert.ToString(item.Key))); } Children = builder.ToArray(); }
protected void OnEnable() { DictionaryData myDictionaryData = Resources.Load <DictionaryData>("myDictionaryData"); if (myDictionaryData != null) { englishWord = myDictionaryData.englishWord; alienWord = myDictionaryData.alienWord; } }
public void Xoa(DictionaryData wordCu) { XmlNode dicCu = root.SelectSingleNode("DictionaryData[Key ='" + wordCu.Key + "']"); if (wordCu.Key != "") { root.RemoveChild(dicCu); doc.Save(fileName); } }
public static void ResetData() { lock (_locker) { if (DictionaryData != null && DictionaryData.Any()) { DictionaryData.Clear(); } _hasBeenConstruted = false; } }
protected void UpdateCachedData(TModel newData) { if (DictionaryData.ContainsKey(newData.DictionaryKey)) { DictionaryData[newData.DictionaryKey] = newData; } else { DictionaryData.TryAdd(newData.DictionaryKey, newData); } }
public Data AsData(DataCollectorContext context) { DictionaryData d = new DictionaryData(context); d.Data["Message"] = Message; d.Data["TimeGenerated"] = TimeGeneratedAsDateTimeOffset.ToString("o"); d.Data["Source"] = SourceName; d.Data["RecordNumber"] = RecordNumber.ToString(); d.Data["EventCode"] = EventCode.ToString(); return(d); }
public Task <MethodResult <DictionaryData> > GetEvents(ClientConnection clt, Empty empty) { DictionaryData dd = new DictionaryData(); foreach (var info in _events) { dd.Data.Add(info.Key, info.Value.PayloadType); } return(Task.FromResult(MethodResult <DictionaryData> .FromResult(dd))); }
public void Load(string pBasePath) { string dictionaryPath = pBasePath + "\\App_Data\\fr.dic"; string affixPath = pBasePath + "\\App_Data\\fr.aff"; string customDic = pBasePath + "\\App_Data\\custom.dic"; SpellDictCollection = new List <SpellCheckDictionary>(); var lDictionnaryData = new DictionaryData(1046, dictionaryPath, affixPath, customDic); SpellDictCollection.Add(new SpellCheckDictionary(lDictionnaryData)); }
public void RemoveDeleted(IEnumerable <string> changed) { foreach (var change in changed) { if (DictionaryData.ContainsKey(change.ToString())) { TModel model; DictionaryData.TryRemove(change.ToString(), out model); } } }
void SaveDictionaryData() { DictionaryData myDictionaryData = Resources.Load <DictionaryData>("myDictionaryData"); myDictionaryData = CreateInstance <DictionaryData>(); myDictionaryData.englishWord = englishWord; myDictionaryData.alienWord = alienWord; AssetDatabase.CreateAsset(myDictionaryData, "Assets/Resources/myDictionaryData.asset"); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); }
public void Init(DictionaryData data) { this.data = data; if (data.isComplite) { title.text = data.dictionaryName + " <color=green>(Complite)</color>"; } else { title.text = data.dictionaryName; } }
private void Start() { DictionaryData myDictionaryData = Resources.Load <DictionaryData>("myDictionaryData"); if (myDictionaryData != null) { for (int i = 0; i < myDictionaryData.englishWord.Count; i++) { AlienEnglishDictionary.Add(myDictionaryData.englishWord[i], myDictionaryData.alienWord[i]); } } }
public static Data Create(DataCollectorContext context, string value) { DictionaryData d = new DictionaryData(context); var definition = new { Value = new Dictionary <string, string>() }; var data = JsonConvert.DeserializeAnonymousType(value, definition); if (data != null) { d.Data = data.Value; } return(d); }
public override CollectedData OnAcquire() { List <string> drive_names = new List <string>(); AttributeRequest request = new AttributeRequest(Context.ID.Name + ".all.drives.descriptions", true); RequestBus.Instance.MakeRequest(request); if (request.IsHandled) { try { Dictionary <string, string> dict = JsonConvert.DeserializeObject <Dictionary <string, string> >(request.Value); drive_names = new List <string>(dict.Keys); } catch (Exception) { } } CollectedData basedata = base.OnAcquire(); List <Data> dataList = new List <Data>(); if (basedata.DataIsCollected) { List <DictionaryData> speedData = basedata.D.Select(w => w as DictionaryData).ToList(); while (speedData.Count > 0) { var speed = speedData[0]; speedData.RemoveAt(0); if (speed.Data.ContainsKey("PercentDiskTime") == false || speed.Data.ContainsKey("AvgDiskQueueLength") == false || speed.Data.ContainsKey("Name") == false) { continue; } var d = new DictionaryData(Context); string drive_name = speed.Data["Name"].Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries).Last(); d.Data["Disk Time %"] = speed.Data["PercentDiskTime"]; d.Data["Avg Disk Q Length"] = speed.Data["AvgDiskQueueLength"]; d.Data["Disk Name"] = drive_name; bool is_total = drive_name.ToLower().Contains("total"); if (is_total == false && (drive_names.Count == 0 || drive_names.Contains(drive_name.ToUpper()))) { dataList.Add(d); } } } return(new CollectedData(Context, basedata.DataIsCollected && dataList.Count > 0, dataList)); }
private void DecreaseVersion_NoLock(DictionaryData data, DocumentId documentId, VersionStamp version) { var strongBox = data.VersionTrackingMap.GetOrAdd(version, s_createStrongBoxMap); // decrease strongBox.Value--; if (strongBox.Value <= 0) { // remove those version from map data.VersionTrackingMap.Remove(version); data.MemberRangeMap.Remove(version); } }
private void cbWord_SelectedIndexChanged(object sender, EventArgs e) { ComboBox cb = sender as ComboBox; if (cb.DataSource == null) { return; } DictionaryData data = cb.SelectedItem as DictionaryData; tbMeanning.Text = data.Meaning; tbExplanation.Text = data.Explanation; }
public void WhenSerializingDictionariesItIncludesContent() { // Arrange DictionaryData data = new DictionaryData { MyInt = 20, MyDict = new Dictionary<string, object>(), MyNameValues = new NameValueCollection(), MyHashtable = new Hashtable() }; data.MyDict["A"] = "1234uio"; data.MyNameValues["X"] = "xxx"; data.MyHashtable["1"] = "aaa"; // Act CheckSerialization("MyInt=20&MyDict%5bA%5d=1234uio&MyNameValues%5bX%5d=xxx&MyHashtable%5b1%5d=aaa", data); }
private void Touch_NoLock(DictionaryData data, DiagnosticAnalyzer analyzer, Document document, VersionStamp version) { VersionStamp oldVersion; if (data.VersionMap.TryGetValue(analyzer, out oldVersion)) { DecreaseVersion_NoLock(data, document.Id, oldVersion); } IncreaseVersion_NoLock(data, document.Id, version); data.VersionMap[analyzer] = version; ImmutableArray<TextSpan> range; if (this.TryCreateOrGetMemberRange_NoLock(data, document, version, out range)) { data.MemberRangeMap[version] = range; } ValidateVersionTracking(); }
private void UpdateMemberRange_NoLock( DictionaryData data, Document document, VersionStamp newVersion, int memberId, TextSpan currentSpan, VersionStamp oldVersion) { SyntaxNode root; Contract.ThrowIfFalse(document.TryGetSyntaxRoot(out root)); ImmutableArray<TextSpan> range; if (data.MemberRangeMap.TryGetValue(newVersion, out range)) { // it is already updated by someone else. return; } // if range is invalid, create new member map if (memberId < 0 || !data.MemberRangeMap.TryGetValue(oldVersion, out range) || range.Length <= memberId) { if (this.TryCreateOrGetMemberRange_NoLock(data, document, newVersion, out range)) { // update version data.MemberRangeMap[newVersion] = range; } return; } // get old span var oldSpan = range[memberId]; // update member location var delta = currentSpan.End - oldSpan.End; if (delta == 0) { // nothing changed. simply update the version data.MemberRangeMap[newVersion] = range; return; } // simple case if (range.Length - 1 == memberId) { data.MemberRangeMap[newVersion] = range.RemoveAt(memberId).Add(currentSpan); return; } // normal case var length = root.FullSpan.Length; var list = new List<TextSpan>(range); list[memberId] = currentSpan; var start = range[memberId].End; for (int i = memberId + 1; i < list.Count; i++) { var span = list[i]; if (span.End < start) { continue; } var newStart = Math.Min(Math.Max(span.Start + delta, 0), length); var newSpan = new TextSpan(newStart, newStart >= length ? 0 : span.Length); list[i] = newSpan; } data.MemberRangeMap[newVersion] = list.ToImmutableArray(); }
private bool TryCreateOrGetMemberRange_NoLock(DictionaryData data, Document document, VersionStamp version, out ImmutableArray<TextSpan> range) { if (data.MemberRangeMap.TryGetValue(version, out range)) { // we already calculated this return false; } var service = document.Project.LanguageServices.GetService<ISyntaxFactsService>(); if (service == null) { // there is nothing we can do here range = ImmutableArray<TextSpan>.Empty; return false; } SyntaxNode root; Contract.ThrowIfFalse(document.TryGetSyntaxRoot(out root)); range = GetMemberRange(service, root); return true; }
private MemberRanges GetSavedMemberRange_NoLock(DictionaryData data, DiagnosticAnalyzer analyzer, Document document) { VersionStamp version; SyntaxNode root; ImmutableArray<TextSpan> range; if (!data.VersionMap.TryGetValue(analyzer, out version)) { // it is first time for this analyzer Contract.ThrowIfFalse(document.TryGetSyntaxRoot(out root)); Contract.ThrowIfFalse(document.TryGetTextVersion(out version)); this.TryCreateOrGetMemberRange_NoLock(data, document, version, out range); return new MemberRanges(version, range); } if (!data.MemberRangeMap.TryGetValue(version, out range)) { // it is first time this version is used. Contract.ThrowIfFalse(document.TryGetSyntaxRoot(out root)); this.TryCreateOrGetMemberRange_NoLock(data, document, version, out range); return new MemberRanges(version, range); } return new MemberRanges(version, range); }
/// <summary> /// Define data for dictionary (word list) with given name /// </summary> public void SetDictionaryData(DictionaryData data, string name) { mDictionaries[name] = data; }
public static void LoadInstance() { if (Application.isEditor) { //Debug.Log("Loading Dictionary. Is editor."); _instance = Serializer.LoadFromXml<DictionaryData>(GetEditorDataPath(), false); if (_instance == null) { _instance = new DictionaryData(); } } else { Debug.Log("Loading Dictionary. Is player."); if (File.Exists(GetPlayerDataPath())) { Debug.LogWarning("(not implemented)"); } else { var text = Resources.Load<TextAsset>(FileName); if (text != null) { _instance = Serializer.LoadFromXmlString<DictionaryData>(text.text); } else { _instance = new DictionaryData(); } } } _instance.PopulateIdMapping(); _instance.LoadAuxiliaryData(); }
private static void TransformRecord(DictionaryData dd, ISet<TranslatorItem> resultData) { var tempID = dd.ID ?? Guid.NewGuid(); resultData.Add(new TranslatorItem { BindingId = tempID, Domain = (Domain) Enum.Parse(typeof (Domain), dd.Domain.Replace("[", string.Empty).Replace("]", string.Empty)), Language = Constants.Language.Slovak, Item = dd.Sk, Created = DateTime.Now, Comment = null }); resultData.Add(new TranslatorItem { BindingId = tempID, Domain = (Domain) Enum.Parse(typeof (Domain), dd.Domain.Replace("[", string.Empty).Replace("]", string.Empty)), Language = Constants.Language.English, Item = dd.En, Created = DateTime.Now, Comment = null }); }