public TWord() { EngWord = null; RusWords = null; EngWordType = WordType.NA; WordResult = Result.None; }
private void addNewBox(int y, bool init, WordType type) { Text newTxt = null; // Instantiat new text object if (type == WordType.ADJECTIVE) { newTxt = Instantiate(prefabLeft) as Text; newTxt.rectTransform.offsetMin = new Vector2(0, 0); newTxt.rectTransform.offsetMax = new Vector2(0, newTxt.rectTransform.sizeDelta.y); } else if (type == WordType.NOUN) { newTxt = Instantiate(prefabRight) as Text; newTxt.rectTransform.offsetMin = new Vector2(0, 0); newTxt.rectTransform.offsetMax = new Vector2(0, newTxt.rectTransform.sizeDelta.y); } // Setting parent as the gameObject attached to this script newTxt.transform.SetParent(this.transform, false); // this makes sure that the text object is rendered behind the button newTxt.transform.SetSiblingIndex(0); // Adding to array so we can keep track of it if (type == WordType.NOUN) { addNounBox(y, newTxt, init); } else { addAdjectiveBox(y, newTxt, init); } }
public TWord(string engW, List <string> rusW, WordType engWordType) { EngWord = engW; EngWordType = engWordType; RusWords = rusW.ToList <string>(); WordResult = Result.None; }
public IWord CreateNewWord(int id, string word, Side side, WordType type, bool isDefault) { if (word != null) { using (NpgsqlConnection con = PostgreSQLConn.CreateConnection(Parent.CurrentUser)) { using (NpgsqlCommand cmd = con.CreateCommand()) { cmd.CommandText = "INSERT INTO \"TextContent\" (cards_id, text, side, type, position, is_default) VALUES (:id, :text, :side, :type, " + "(COALESCE((SELECT position FROM \"TextContent\" WHERE cards_id=:id AND side=:side AND type=:type ORDER BY position DESC LIMIT 1), 0) + 10), " + ":isdefault) RETURNING id"; cmd.Parameters.Add("id", id); cmd.Parameters.Add("text", word); cmd.Parameters.Add("side", side.ToString()); cmd.Parameters.Add("type", type.ToString()); cmd.Parameters.Add("isdefault", isDefault); Parent.CurrentUser.Cache.Uncache(ObjectLifetimeIdentifier.GetIdentifier(ObjectLifetimeIdentifier.GetCacheObject(side, type), id)); return(new DbWord(Convert.ToInt32(PostgreSQLConn.ExecuteScalar(cmd, Parent.CurrentUser)), word, type, isDefault, Parent)); } } } else { return(null); } }
public State(CppWordReader wr) { this.lreader = wr.lreader; this.cword = wr.cword; this.line_count = wr.line_count; this.wtype = wr.wtype; }
public static string ChangeShowValue(WordType sourceType, WordType desType, uint value) { switch (desType) { case WordType.INT16: return(((short)value).ToString()); case WordType.POS_INT16: return(((ushort)value).ToString()); case WordType.INT32: return(((int)value).ToString()); case WordType.POS_INT32: return(value.ToString()); case WordType.BCD: if (!AssertValue(sourceType, value)) { throw new Exception(); } else { return(ToBCD((ushort)value).ToString()); } case WordType.FLOAT: return((*(float *)&value).ToString()); default: throw new Exception(); } }
// ListView den WordType deperlerini güncelleme ve silme işlemleri için ilgili yerlere alıyoruz. private void GetWordTypeFromListView() { WordType wordType = wtas.FindByID(int.Parse(lvWordTypes.FocusedItem.Tag.ToString())); txtWordType.Tag = wordType.typeID.ToString(); txtWordType.Text = wordType.typeName; }
public static Color GetTextColor(WordType type) { Color color; switch (type) { case WordType.Adjective: color = Color.Purple; break; case WordType.Verb: color = Color.Green; break; case WordType.Adverb: color = Color.DarkBlue; break; case WordType.Noun: color = Color.DarkOrange; break; default: color = Color.Black; break; } return(color); }
public WordInfo(Dict.PositionLength pl, string oringinalText, Match.MatchParameter parameters) { this.Word = oringinalText.Substring(pl.Position, pl.Length); this.Pos = pl.WordAttr.Pos; this.Frequency = pl.WordAttr.Frequency; this.WordType = WordType.SimplifiedChinese; this.Position = pl.Position; switch (pl.Level) { case 0: this.Rank = parameters.BestRank; break; case 1: this.Rank = parameters.SecRank; break; case 2: this.Rank = parameters.ThirdRank; break; case 3: this.Rank = parameters.SingleRank; break; default: this.Rank = parameters.BestRank; break; } }
public PhraseNode(string word, WordType wordType, Tense tense) : this() { BaseWord = word; WordType = wordType; Tense = tense; }
public AllWords_Kinnect(int?ty) { //wordtyped = ty; uow = ObjectFactory.GetInstance <IUnitOfWork>(); user = ObjectFactory.GetInstance <IUser>(); language = ObjectFactory.GetInstance <ILanguages>(); word = ObjectFactory.GetInstance <IWords>(); video = ObjectFactory.GetInstance <IVideo>(); registerMessenger(); if (ty.HasValue) { wt = UtilityClass.IntToWordType(ty.Value); wordData = new Words_ViewModel(new WordsModel(), wt, 1, uow); wordData.wt = wt; ttt = 1; } else { wordData = new Words_ViewModel(new WordsModel(), 2, uow); ttt = 2; } //MessageBox.Show(wordData.TT.ToString()); InitializeComponent(); DataContext = this; }
private void type() { switch (_token) { case ')': _state = DicParserState.Pinyin; break; case '[': _istypestarted = true; break; case ',': if (!_istypestarted) { error(); } else { _type = _temp.GetWordTypeFromString(); _temp = string.Empty; _istypestarted = false; _state = DicParserState.Frequency; } break; default: if (_istypestarted) { _temp += _token; } break; } }
public Noun(WordType wordType, Article article, string german, string polish) : base(wordType, german, polish) { this.PolishTranslation = polish; this.GermanTranslation = german; this.Article = article; }
public DbWords(int CardId, Side ListSide, WordType ListType, ParentClass parentClass) { id = CardId; side = ListSide; type = ListType; parent = parentClass; }
public Word(WordType wordType, string word, string translation) : this() { this.wordType = wordType; this.word = word; this.translation = translation; }
public Word(String ID, String word, String name, WordType type) { this.id = ID; this.nameImage = name; this.wordImage = word; this.type = type; }
private void UpdateTitleQualification(int qualifyIndex) { WordType wordType = LearningInfo.Instance.currentWordType; PlayerData playerData = GameManager.Instance.persistDataManager.LoadPlayerData(); switch (wordType) { case WordType.Simple: Player.mainPlayer.titleQualificationsOfSimple[qualifyIndex] = true; playerData.titleQualificationsOfSimple[qualifyIndex] = true; break; case WordType.Medium: Player.mainPlayer.titleQualificationsOfMedium[qualifyIndex] = true; playerData.titleQualificationsOfMedium[qualifyIndex] = true; break; case WordType.Master: Player.mainPlayer.titleQualificationsOfMedium[qualifyIndex] = true; playerData.titleQualificationsOfMedium[qualifyIndex] = true; break; } DataHandler.SaveInstanceDataToFile <PlayerData>(playerData, CommonData.playerDataFilePath); }
private static void SplitWords(ReadOnlyStringEntity source_str, NativeList <WordBlock> result) { result.Clear(); if (source_str.Length < 1) { return; } int start = 0; WordType type = CheckCharType(source_str[0]); for (int i = 1; i < source_str.Length; i++) { WordType next_type = CheckCharType(source_str[i]); if (type != next_type) { var block = new WordBlock(source_str.Slice(start, i), type); result.Add(block); start = i; type = next_type; } } if (start != source_str.Length) { result.Add(new WordBlock(source_str.Slice(start), type)); } }
public Words(string newsTitle, string newsUrl, int newsScore, WordType wordType) { title = newsTitle; url = newsUrl; score = newsScore; type = wordType; }
/// <summary> /// 添加 /// </summary> /// <param name="values"></param> public void Add(params string[] values) { lock (this) { if (values != null) { foreach (string item in values) { if (!string.IsNullOrEmpty(item) && item.Length > 1 && item.Length < 64) { WordType type = Utils.GetWordType(item); string value = ""; foreach (char c in item) { if (Utils.GetWordTypeWithChar(c) != WordType.Other) { value += c; } else { if (type == WordType.EN && c == ' ') { value += c; } } } if (value.Length > 1) { OnAdd(value); } } } } } }
internal XmlWord(string word, WordType type, bool isDefault, ParentClass parent) { m_word = (word == null) ? String.Empty : word; m_type = type; m_default = isDefault; this.parent = parent; }
/// <summary> /// Gets the cache object. /// </summary> /// <param name="side">The side.</param> /// <param name="type">The type.</param> /// <returns></returns> /// <remarks>Documented by Dev05, 2009-02-09</remarks> public static CacheObject GetCacheObject(Side side, WordType type) { switch (side) { case Side.Question: switch (type) { case WordType.Word: return(CacheObject.QuestionWords); case WordType.Sentence: return(CacheObject.QuestionExampleWords); case WordType.Distractor: return(CacheObject.QuestionDistractorWords); } break; case Side.Answer: switch (type) { case WordType.Word: return(CacheObject.AnswerWords); case WordType.Sentence: return(CacheObject.AnswerExampleWords); case WordType.Distractor: return(CacheObject.AnswerDistractorWords); } break; } return(CacheObject.Word); }
/// <summary> /// 移除第一词性 /// </summary> /// <param name="type"></param> public void RemoveFirstType(WordType type) { if (Contains(type)) { TypeInfo.Remove(type); } }
public ReminderForm(Word word, WordType wordType, Profile profile) { InitializeComponent(); currentWord = word; currentWordType = wordType; currentProfile = profile; }
public static uint ParseShowValue(string showValue, WordType type) { switch (type) { case WordType.INT16: return((uint)short.Parse(showValue)); case WordType.POS_INT16: return(ushort.Parse(showValue)); case WordType.INT32: return((uint)int.Parse(showValue)); case WordType.POS_INT32: return(uint.Parse(showValue)); case WordType.BCD: return(ToUINT16(ushort.Parse(showValue))); case WordType.FLOAT: return(FloatToUInt(float.Parse(showValue))); default: throw new FormatException(); } }
/// <summary> /// Creates the new word. /// </summary> /// <param name="id">The id.</param> /// <param name="word">The word.</param> /// <param name="side">The side.</param> /// <param name="type">The type.</param> /// <param name="isDefault">if set to <c>true</c> [is default].</param> /// <returns></returns> /// <remarks>Documented by Dev03, 2009-01-09</remarks> public IWord CreateNewWord(int id, string word, Side side, WordType type, bool isDefault) { if (word != null) { SqlCeCommand cmd = MSSQLCEConn.CreateCommand(Parent.CurrentUser); cmd.CommandText = "SELECT position FROM TextContent WHERE cards_id=@id AND side=@side AND type=@type ORDER BY position DESC"; cmd.Parameters.Add("@id", id); cmd.Parameters.Add("@side", side.ToString()); cmd.Parameters.Add("@type", type.ToString()); int currentPos = 0; object retval = MSSQLCEConn.ExecuteScalar(cmd); if (retval != DBNull.Value) { currentPos = Convert.ToInt32(retval); } cmd.Parameters.Clear(); cmd.CommandText = @"INSERT INTO TextContent (cards_id, text, side, type, position, is_default) VALUES (@id, @text, @side, @type, @position, @isdefault); SELECT @@IDENTITY;"; cmd.Parameters.Add("@id", id); cmd.Parameters.Add("@text", word); cmd.Parameters.Add("@side", side.ToString()); cmd.Parameters.Add("@type", type.ToString()); cmd.Parameters.Add("@position", currentPos + 10); cmd.Parameters.Add("@isdefault", isDefault); Parent.CurrentUser.Cache.Uncache(ObjectLifetimeIdentifier.GetIdentifier(ObjectLifetimeIdentifier.GetCacheObject(side, type), id)); return(new DbWord(Convert.ToInt32(MSSQLCEConn.ExecuteScalar(cmd)), word, type, isDefault, Parent)); } else { return(null); } }
public override bool ReadNext() { this.oword = this.cword; this.otype = this.wtype; this.cword = ""; this.wtype = WordType.Invalid; while (lreader.CurrentType.IsInvalid || lreader.CurrentType.IsSpace) { if (!lreader.MoveNext()) { return(false); } } this.lreader.StoreCurrentPos(0); switch (lreader.CurrentType.purpose) { case LetterType.P_Number: ReadNumber(); break; case LetterType.P_Token: ReadIdentifier(); break; case LetterType.P_Operator: ReadOperator(); break; } return(true); }
public PreviewWord(string word, WordType type, bool isDefault, ParentClass parent) { this.word = word; this.type = type; this._default = isDefault; this.parent = parent; }
public ResultPair identify(string str, WordType type) { int nowstate = Start, i; for (i = 0; i < str.Length; ++i) { if (StatusMap[nowstate].Next.ContainsKey(str[i])) { nowstate = StatusMap[nowstate].Next[str[i]]; } else { if (StatusMap[nowstate].IsEnd == 1) { return(new ResultPair(i, type)); } else { return(new ResultPair(i, WordType.Error)); } } } if (StatusMap[nowstate].IsEnd == 1) { return(new ResultPair(i, type)); } else { return(new ResultPair(i, WordType.Error)); } return(new ResultPair(0, WordType.Error)); }
private bool ReadSingleCharToken(ReadOnlySpan <char> span, WordType wordType) { currentPosition++; WordType = wordType; Word = span[0].ToString(); return(true); }
public void Add(string value) { int index = 1; char key = Utils.Cast(value[index]); WordItem wi = new WordItem(value); WordType = WordType | wi.Type; CharItem item = null; if (!Items.TryGetValue(key, out item)) { item = new CharItem(key); item.MaxBlank = MaxBlank; item.WordType |= wi.Type; Items.Add(key, item); LstItems.Add(item); } if (index + 1 == value.Length) { item.Eof = true; } else { item.Add(value, index + 1, wi); } }
/// <summary> /// 和后一个合并 /// </summary> /// <param name="t"></param> public void mergeWithAfter(WordType t) { Vertexes[CurrentPos].ChangeName(Vertexes[CurrentPos].Content.Name + Vertexes[CurrentPos + 1].Content.Name); Vertexes[CurrentPos].ChangeMaxType(t); Vertexes.RemoveAt(CurrentPos + 1); CurrentPos++; }
void LoadWords(string fileName) { string line; StreamReader theReader = new StreamReader(fileName, Encoding.Default); using (theReader) { do { line = theReader.ReadLine (); if (line != null) { WordType addWord = new WordType (); addWord.isUsed = false; addWord.lines = new List<string>(); if(line.Length <= characterLimit) addWord.lines.Add(line); else { while(line.Length >= characterLimit) { int cutoffPoint = characterLimit; while(line[cutoffPoint] != ' ') { cutoffPoint--; } addWord.lines.Add(line.Substring(0, cutoffPoint)); line = line.Substring(cutoffPoint + 1); } addWord.lines.Add(line); } possibleWords.Add (addWord); } } while (line != null); theReader.Close(); } }
public Token(int d,WordType type, string content,int row, int column) { this.Id = d; this.Type = type; this.Row = row; this.Column = column; this.Content = content; }
public static IEnumerable<WordCard> FilterByType(IEnumerable<WordCard> dictionary, WordType type) { var result = from c in dictionary where c.Type == type select c; return result; }
public DbWord(int id, string word, WordType type, bool isDefault, ParentClass parent) { loading = true; this.id = id; Word = word; Type = type; Default = isDefault; this.parent = parent; loading = false; }
public void AddDFA(string[] input, WordType type) { RegularGrammer rg = new RegularGrammer(input); NFA nfa = new NFA(rg); DFA dfa = new DFA(nfa); if (!DFAs.ContainsKey(type)) { DFAs.Add(type, dfa); } else { DFAs[type] = dfa; } }
internal DbMedia(int id, int cardid, bool checkId, EMedia mediaIdentifier, Side side, WordType type, bool isDefault, bool isExample, ParentClass parent) { this.parent = parent; if (checkId) connector.CheckCardMediaId(id, cardid); this.id = id; this.cardid = cardid; this.mediaIdentifier = mediaIdentifier; this.side = side; this.type = type; this.isDefault = isDefault; this.isExample = isExample; }
public string Conjugate(string input, ConjugationMode mode, WordType destWordType) { MethodInfo mi = GetType().GetMethod("Conjugate_" + mode.ToString() + "_" + destWordType.ToString(), BindingFlags.NonPublic | BindingFlags.Instance); if (mi != null) { if (mi.GetParameters().Length != 1 || mi.ReturnType != typeof(string)) { Debug.LogError("Conjugation Handler does not match expected signature: " + "Conjugate_" + mode.ToString() + "_" + destWordType.ToString()); return "Error"; } string result = mi.Invoke(this, new object[] {input} ) as string; return result; } else { Debug.LogError("No Conjugation Handler: " + "Conjugate_" + mode.ToString() + "_" + destWordType.ToString()); Debug.LogWarning("The conjugation might not be defined for the given WordType. Better handling of these cases will come later"); return "Error"; } }
public void AddWord(int id, Side side, WordType type, IWord word) { if (word != null && word.Word.Length > 0) { using (NpgsqlConnection con = PostgreSQLConn.CreateConnection(Parent.CurrentUser)) { using (NpgsqlCommand cmd = con.CreateCommand()) { cmd.CommandText = "SELECT \"InsertWordIfNotExists\"(:id,:cardid,:isdefault,:text,:side,:type);"; cmd.Parameters.Add("id", word.Id); cmd.Parameters.Add("isdefault", word.Default); cmd.Parameters.Add("cardid", id); cmd.Parameters.Add("text", word.Word); cmd.Parameters.Add("side", side.ToString()); cmd.Parameters.Add("type", type.ToString()); PostgreSQLConn.ExecuteNonQuery(cmd, Parent.CurrentUser); Parent.CurrentUser.Cache.Uncache(ObjectLifetimeIdentifier.GetIdentifier(ObjectLifetimeIdentifier.GetCacheObject(side, type), id)); } } } }
private string GetWord(WordType type) { switch (type) { case WordType.Verb: var verbCcount = Enum.GetNames(typeof(Verb)).Length; return ((Verb)_rndNoun.Next(0, verbCcount)).ToReadable(); case WordType.Adjective: var adjectiveCount = Enum.GetNames(typeof(Adjective)).Length; return ((Adjective)_rndAdjective.Next(0, adjectiveCount)).ToReadable(); case WordType.Noun: var nounCount = Enum.GetNames(typeof(Noun)).Length; return ((Noun)_rndVerb.Next(0, nounCount)).ToReadable(); default: return string.Empty; } }
/// <summary> /// Adds the word. /// </summary> /// <param name="id">The id.</param> /// <param name="side">The side.</param> /// <param name="type">The type.</param> /// <param name="word">The word.</param> /// <remarks>Documented by Dev03, 2009-01-09</remarks> public void AddWord(int id, Side side, WordType type, IWord word) { if (word != null && word.Word.Length > 0) { SqlCeCommand cmd = MSSQLCEConn.CreateCommand(Parent.CurrentUser); cmd.CommandText = "SELECT count(*) FROM TextContent WHERE id = @wordid AND text = @word AND type = @type AND is_default = @isdefault;"; cmd.Parameters.Add("@wordid", word.Id); cmd.Parameters.Add("@word", word.Word); cmd.Parameters.Add("@type", type.ToString()); cmd.Parameters.Add("@isdefault", word.Default); bool wordExists = (Convert.ToInt32(MSSQLCEConn.ExecuteScalar(cmd)) > 0); if (!wordExists) { cmd.CommandText = "SELECT position FROM TextContent WHERE cards_id=@id AND side=@side AND type=@type ORDER BY position DESC"; cmd.Parameters.Add("@id", id); cmd.Parameters.Add("@side", side.ToString()); cmd.Parameters.Add("@type", type.ToString()); int currentPos = 0; object retval = MSSQLCEConn.ExecuteScalar(cmd); if (retval != DBNull.Value) currentPos = Convert.ToInt32(retval); cmd.Parameters.Clear(); cmd.CommandText = @"INSERT INTO TextContent (cards_id, text, side, type, position, is_default) VALUES (@id, @text, @side, @type, @position, @isdefault); SELECT @@IDENTITY;"; cmd.Parameters.Add("@id", id); cmd.Parameters.Add("@text", word.Word); cmd.Parameters.Add("@side", side.ToString()); cmd.Parameters.Add("@type", type.ToString()); cmd.Parameters.Add("@position", currentPos + 10); cmd.Parameters.Add("@isdefault", word.Default); MSSQLCEConn.ExecuteNonQuery(cmd); } Parent.CurrentUser.Cache.Uncache(ObjectLifetimeIdentifier.GetIdentifier(ObjectLifetimeIdentifier.GetCacheObject(side, type), id)); } }
public static string WordTypeToString(WordType wordType) { switch (wordType) { case WordType.Abbreviation: return "Abbr."; case WordType.Adjective: return "Adj."; case WordType.Adverb: return "Adv."; case WordType.AdvOrAdj: return "Adv./Adj."; case WordType.AdvOrConj: return "Adv./Conj."; case WordType.Conjection: return "Conj."; case WordType.Interjection: return "Int."; case WordType.Noun: return "N."; case WordType.Numeral: return "Num."; case WordType.P1: return "PI."; case WordType.P2: return "PII."; case WordType.Phrase: return ""; case WordType.PluralNoun: return "Pl."; case WordType.Preposition: return "Prep."; case WordType.PronOrNum: return "Pron./Num."; case WordType.Pronoun: return "Pron."; case WordType.Vi: return "Vi."; case WordType.Vr: return "Vr."; case WordType.Vt: return "Vt."; case WordType.VtOrVi: return "Vt./Vi."; default: return ""; } }
public Word(int wordId, WordType wordType, string word, string translation) : this(wordType, word, translation) { this.wordId = wordId; }
public Word(string currentWord, int currentIndex) { WordInText = currentWord; IndexInText = currentIndex; Type = WordType.None; }
public Verb(int wordId, WordType wordType, string word, string translation, string presentForm, string pastForm, string perfectForm, PerfectAuxiliaryVerb perfectAuxiliaryVerb) : base(wordId, wordType, word, translation) { this.presentForm = presentForm; this.pastForm = pastForm; this.perfectForm = perfectForm; this.perfectAuxiliaryVerb = perfectAuxiliaryVerb; }
public IWord CreateWord(string word, WordType type, bool isDefault) { return new PreviewWord(word, type, isDefault, null); }
internal DbAudio(int id, int cardid, bool checkId, Side side, WordType type, bool isDefault, bool isExample, ParentClass parentClass) : base(id, cardid, checkId, EMedia.Audio, side, type, isDefault, isExample, parentClass) { }
/// <summary> /// Parse test case label element. /// </summary> /// <param name="labelNode">XML test case label node.</param> /// <param name="nsmgr">Xml namespace manager.</param> public void Parse(XmlNode labelNode, XmlNamespaceManager nsmgr) { XmlAttribute attribute = labelNode.Attributes["text"]; if (attribute != null) { Text = attribute.Value; } attribute = labelNode.Attributes["predictFeauteName"]; if (attribute != null) { PredictFeatureName = attribute.Value; } attribute = labelNode.Attributes["predictFeatureValue"]; if (attribute != null) { PredictFeatureValue = attribute.Value; } attribute = labelNode.Attributes["expectedFeatureValue"]; if (attribute != null) { ExpectedFeatureValue = attribute.Value; } attribute = labelNode.Attributes["predictFeatureValue"]; if (attribute != null) { PredictFeatureValue = attribute.Value; } attribute = labelNode.Attributes["probability"]; if (attribute != null) { Probability = float.Parse(attribute.Value); } attribute = labelNode.Attributes["confidence"]; if (attribute != null) { Confidence = float.Parse(attribute.Value); } attribute = labelNode.Attributes["difference"]; if (attribute != null) { Difference = float.Parse(attribute.Value); } attribute = labelNode.Attributes["source"]; if (attribute != null) { Source = attribute.Value; } attribute = labelNode.Attributes["wordType"]; if (attribute != null) { WordType = (WordType)Enum.Parse(typeof(WordType), attribute.Value, false); } XmlNodeList featureNodeList = labelNode.SelectNodes(@"tts:feature", nsmgr); foreach (XmlNode featureNode in featureNodeList) { string name = featureNode.Attributes["name"].Value; string value = featureNode.InnerText; if (Features.ContainsKey(name)) { throw new InvalidDataException(Helper.NeutralFormat("Duplicated name [{0}] detected", name)); } Features.Add(name, value); } }
public Word(string currentWord, int currentIndex, WordType wordType) { WordInText = currentWord; IndexInText = currentIndex; Type = wordType; }
private void AddWord(string currentWord, int currentIndex, WordType wordType) { Words.Add(new Word(currentWord, currentIndex, wordType)); }
public void SetType(WordType wordType) { Type = wordType; }
public void SetCardMedia(int id, int cardid, Side side, WordType type, bool isDefault, EMedia mediatype) { using (NpgsqlConnection con = PostgreSQLConn.CreateConnection(Parent.CurrentUser)) { NpgsqlTransaction tran = con.BeginTransaction(); ClearCardMedia(cardid, side, type, mediatype); using (NpgsqlCommand cmd = con.CreateCommand()) { cmd.CommandText = "INSERT INTO \"Cards_MediaContent\" (media_id, cards_id, side, type, is_default) VALUES (:mediaid, :cardid, :side, :type, :isdefault);"; cmd.Parameters.Add("mediaid", id); cmd.Parameters.Add("cardid", cardid); cmd.Parameters.Add("side", side.ToString()); cmd.Parameters.Add("type", type.ToString()); cmd.Parameters.Add("isdefault", isDefault); PostgreSQLConn.ExecuteNonQuery(cmd, Parent.CurrentUser); } tran.Commit(); Parent.CurrentUser.Cache.Uncache(ObjectLifetimeIdentifier.GetIdentifier(CacheObject.CardMedia, cardid)); } }
private IList<int> GetCardMedia(int cardid, Side side, WordType? type) { IList<int> ids = new List<int>(); IList<IMedia> mediaList = Parent.CurrentUser.Cache[ObjectLifetimeIdentifier.GetIdentifier(CacheObject.CardMedia, cardid)] as IList<IMedia>; if (mediaList != null) { foreach(DbMedia cms in mediaList) if(cms.Side == side && (!type.HasValue || cms.Type == type)) ids.Add(cms.Id); return ids; } using (NpgsqlConnection con = PostgreSQLConn.CreateConnection(Parent.CurrentUser)) { using (NpgsqlCommand cmd = con.CreateCommand()) { cmd.CommandText = "SELECT id, media_type,side,type,is_default FROM \"Cards_MediaContent\" JOIN \"MediaContent\" ON media_id=id WHERE cards_id=:cardid;"; cmd.Parameters.Add("cardid", cardid); NpgsqlDataReader reader = PostgreSQLConn.ExecuteReader(cmd, Parent.CurrentUser); mediaList = new List<IMedia>(); while (reader.Read()) { IMedia newMedia = null; int id = Convert.ToInt32(reader["id"]); EMedia mtype = (EMedia)Enum.Parse(typeof(EMedia), Convert.ToString(reader["media_type"])); Side cside = (Side)Enum.Parse(typeof(Side), Convert.ToString(reader["side"])); WordType wordtype = (WordType)Enum.Parse(typeof(WordType), Convert.ToString(reader["type"])); bool isDefault = Convert.ToBoolean(reader["is_default"]); switch (mtype) { case EMedia.Audio: newMedia = new DbAudio(id, cardid, false, cside, wordtype, isDefault, (wordtype == WordType.Sentence), Parent); break; case EMedia.Image: newMedia = new DbImage(id, cardid, false, cside, wordtype, isDefault, (wordtype == WordType.Sentence), Parent); break; case EMedia.Video: newMedia = new DbVideo(id, cardid, false, cside, wordtype, isDefault, (wordtype == WordType.Sentence), Parent); break; } mediaList.Add(newMedia); if ((newMedia as DbMedia).Side == side && (!type.HasValue || (newMedia as DbMedia).Type == type)) ids.Add((newMedia as DbMedia).Id); } Parent.CurrentUser.Cache[ObjectLifetimeIdentifier.Create(CacheObject.CardMedia, cardid)] = mediaList; return ids; } } }
public Word () { Type = WordType.Atom; }
public void ClearCardMedia(int cardid, Side side, WordType type, EMedia mediatype) { using (NpgsqlConnection con = PostgreSQLConn.CreateConnection(Parent.CurrentUser)) { using (NpgsqlCommand cmd = con.CreateCommand()) { cmd.CommandText = "DELETE FROM \"Cards_MediaContent\" WHERE cards_id=:cardid AND side=:side AND type=:type " + "AND media_id IN (SELECT id FROM \"MediaContent\" WHERE media_type=:mediatype);"; cmd.Parameters.Add("cardid", cardid); cmd.Parameters.Add("side", side.ToString()); cmd.Parameters.Add("type", type.ToString()); cmd.Parameters.Add("mediatype", mediatype.ToString()); cmd.ExecuteNonQuery(); } } Parent.CurrentUser.Cache.Uncache(ObjectLifetimeIdentifier.GetIdentifier(CacheObject.CardMedia, cardid)); }
public void SetType(int id, WordType Type) { using (NpgsqlConnection con = PostgreSQLConn.CreateConnection(Parent.CurrentUser)) { using (NpgsqlCommand cmd = con.CreateCommand()) { cmd.CommandText = "UPDATE \"TextContent\" SET type=:typ WHERE id=:id"; cmd.Parameters.Add("id", id); cmd.Parameters.Add("typ", Type); PostgreSQLConn.ExecuteNonQuery(cmd, Parent.CurrentUser); } } }
public IList<int> GetCardMedia(int cardid, Side side, WordType type) { return GetCardMedia(cardid, side, type); }