public void Get_ReturnsValueFromKey(Object key, Object value) { Hashmap map = new Hashmap(1024); map.Add(key, value); Assert.Equal(value, map.Get(key)); }
/** Each font used in a document has an instance of this class. * This class stores the characters used in the document and other * specifics unique to the current working document. * @param fontName the font name * @param indirectReference the indirect reference to the font * @param baseFont the <CODE>BaseFont</CODE> */ internal FontDetails(PdfName fontName, PdfIndirectReference indirectReference, BaseFont baseFont) { this.fontName = fontName; this.indirectReference = indirectReference; this.baseFont = baseFont; fontType = baseFont.FontType; switch (fontType) { case BaseFont.FONT_TYPE_T1: case BaseFont.FONT_TYPE_TT: shortTag = new byte[256]; break; case BaseFont.FONT_TYPE_CJK: cjkTag = new IntHashtable(); cjkFont = (CJKFont)baseFont; break; case BaseFont.FONT_TYPE_TTUNI: longTag = new Hashmap(); ttu = (TrueTypeFontUnicode)baseFont; symbolic = baseFont.isFontSpecific(); break; } }
public void setAppearance(PdfName ap, string state, PdfAppearance template) { PdfDictionary dicAp = (PdfDictionary)get(PdfName.AP); if (dicAp == null) { dicAp = new PdfDictionary(); } PdfDictionary dic; PdfObject obj = dicAp.get(ap); if (obj != null && obj.Type == DICTIONARY) { dic = (PdfDictionary)obj; } else { dic = new PdfDictionary(); } dic.put(new PdfName(state), template.IndirectReference); dicAp.put(ap, dic); put(PdfName.AP, dicAp); if (!form) { return; } if (templates == null) { templates = new Hashmap(); } templates.Add(template, null); }
/** * Adds fieldTemplates. */ internal void addFieldTemplates(Hashmap ft) { foreach (object key in ft.Keys) { fieldTemplates.Add(key, ft[key]); } }
// constructors /** * Constructs a <CODE>PdfChunk</CODE>-object. * * @param string the content of the <CODE>PdfChunk</CODE>-object * @param font the <CODE>PdfFont</CODE> * @param attributes the metrics attributes * @param noStroke the non metric attributes */ internal PdfChunk(string str, PdfChunk other) { value = str; this.font = other.font; this.attributes = other.attributes; this.noStroke = other.noStroke; Object[] obj = (Object[])attributes[Chunk.IMAGE]; if (obj == null) { image = null; } else { image = (Image)obj[0]; offsetX = ((float)obj[1]); offsetY = ((float)obj[2]); changeLeading = bool.Parse(obj[3].ToString()); } encoding = font.Font.Encoding; splitCharacter = (ISplitCharacter)noStroke[Chunk.SPLITCHARACTER]; if (splitCharacter == null) { splitCharacter = this; } }
protected object ExecuteScalar(string queryOrProcedure, CommandType cmdType, Hashmap parameters) { object result = null; try { this.Conn.Open(); this.Conn.CreateTransaction(); result = this.Conn.ExecuteScalar(queryOrProcedure, cmdType, parameters); this.Conn.CommitTransaction(); } catch (Exception) { this.Conn.RollbackTransaction(); throw; } finally { this.Conn.Close(); } return(result); }
public void Add_AddsPairToCorrectIndex(Object key, Object value) { Hashmap map = new Hashmap(1024); map.Add(key, value); Assert.Equal(value, map.Buckets[(int)value].Find(key)); }
public void InsertTest() { Hashmap <string, int> hashmap = new Hashmap <string, int>(); hashmap.Insert("Hello!", 1); Assert.ThrowsException <ArgumentException>(() => { hashmap.Insert("Hello!", 2); }, "Failed to throw exception when duplicate keys were added."); }
protected int Execute(string queryOrProcedure, CommandType cmdType, Hashmap parameters) { int result = -100; try { this._Conn.Open(); this._Conn.BeginTransaction(); result = this._Conn.Execute(queryOrProcedure, cmdType, parameters.GetParameters()); this._Conn.CommitTransaction(); } catch (Exception e) { this._Conn.RollbackTransaction(); throw; } finally { this._Conn.DisposeTransaction(); this._Conn.Close(); } return(result); }
private void init() { _screenIndex = 0; Screens[0].SetActive(true); Screens[1].SetActive(false); Screens[2].SetActive(false); QuestData = new Hashmap(); }
public void Get_ReturnsValueFromCollidingKey(Object keyOne, Object keyTwo) { Hashmap map = new Hashmap(1024); map.Add(keyOne, 1); map.Add(keyTwo, 2); Assert.Equal(2, map.Get(keyTwo)); }
public void Add_AddsCollidingPairs(Object keyOne, Object keyTwo, Object value) { Hashmap map = new Hashmap(1024); map.Add(keyOne, value); map.Add(keyTwo, value); Assert.Equal(map.Buckets[(int)value].Find(keyOne), map.Buckets[(int)value].Find(keyTwo)); }
public void Get_ReturnsNullWhenNotPresent() { Hashmap map = new Hashmap(1024); map.Add("key", 1); map.Add("other key", 2); Assert.Null(map.Get("not there")); }
/* ------------------------------------------- */ #region [ Insert method ] /// <summary> /// Insert the record to table with table_name with given fields. /// </summary> /// <param name="table_name">table name</param> /// <param name="fields">column and values</param> /// <returns>Returns exec result of Insert.</returns> public virtual int Insert(string table_name, Hashmap fields) { int result = -100; try { if (string.IsNullOrWhiteSpace(table_name)) { throw new Exception("Table Name can not be null or empty."); } if (table_name.Contains("drop") || table_name.Contains("--")) { throw new Exception( "Table Name can not be contain restricted characters and text."); } if (fields == null) { throw new Exception( "Column list can not be null."); } if (fields.IsEmpty()) { throw new Exception( "Column list can not be empty."); } QueryFormat qf = new QueryFormat(QueryTypes.Insert); QueryAdds adds = new QueryAdds(this.conn_type); string query = "", cols = "", vals = ""; Hashmap h = new Hashmap(); foreach (var field in fields.Keys()) { cols = string.Format("{0}, {1}{2}{3}", cols, adds.Prefix, field, adds.Suffix); vals = string.Format("{0}, {1}{2}", cols, adds.ParameterPrefix, field); h.Set(string.Format("{0}{1}", adds.ParameterPrefix, field), fields.Get(field)); } cols = cols.TrimStart(',').TrimStart(); vals = vals.TrimStart(',').TrimStart(); query = string.Format(qf.Format, table_name, cols, vals); result = this.Execute(query, CommandType.Text, h); } catch (Exception) { throw; } return(result); }
/// <summary> /// Sets an arbitrary attribute. /// </summary> /// <param name="name">the key for the attribute</param> /// <param name="obj">the value of the attribute</param> /// <returns>this Chunk</returns> private Chunk setAttribute(string name, Object obj) { if (attributes == null) { attributes = new Hashmap(); } attributes.Add(name, obj); return(this); }
/** Creates a new TrueTypeFontSubSet * @param directoryOffset The offset from the start of the file to the table directory * @param fileName the file name of the font * @param glyphsUsed the glyphs used * @param includeCmap <CODE>true</CODE> if the table cmap is to be included in the generated font */ internal TrueTypeFontSubSet(string fileName, RandomAccessFileOrArray rf, Hashmap glyphsUsed, int directoryOffset, bool includeCmap) { this.fileName = fileName; this.rf = rf; this.glyphsUsed = glyphsUsed; this.includeCmap = includeCmap; this.directoryOffset = directoryOffset; glyphsInList = new ArrayList(glyphsUsed.Keys); }
public static IObservable <string> createQuest(string token, Hashmap data) { var d = Encoding.UTF8.GetBytes(JsonUtility.ToJson(data.generateDTO())); return(ObservableWWW.Post(URL + "/quests", d, new Hash() { { "X-Auth-Token", token }, { "Content-Type", "application/json" } })); }
public void CanReturnSingleUnmatchedRecord() { Hashmap mapA = new Hashmap(1024); mapA.Add("cats", "blue"); Hashmap mapB = new Hashmap(1024); mapB.Add("ants", "223"); Assert.Contains("cats, blue, no antonym", Program.LeftJoin(mapA, mapB)); }
public void CanHandleEmptyLeft() { Hashmap mapA = new Hashmap(1024); mapA.Add("cats", "blue"); mapA.Add("dogs", "green"); mapA.Add("llamas", "red"); mapA.Add("cows", "purple"); Hashmap mapB = new Hashmap(1024); Assert.Empty(Program.LeftJoin(mapB, mapA)); }
public void CanHandleEmptyRight() { Hashmap mapA = new Hashmap(1024); mapA.Add("cats", "blue"); mapA.Add("dogs", "green"); mapA.Add("llamas", "red"); mapA.Add("cows", "purple"); Hashmap mapB = new Hashmap(1024); Assert.Equal(4, Program.LeftJoin(mapA, mapB).Count); }
public static IConnection Build(DbProperty db_configuration) { IConnection conn = null; try { ConnectionTypes conn_type = ConnectionTypeBuilder.GetConnectionType(db_configuration.ConnType); if (conn_type == ConnectionTypes.Unknown) { throw new Exception("Unknown Connection type can not be allowed."); } string conn_str = ""; conn_str = db_configuration.ConnString; conn_str = conn_str ?? string.Empty; if (string.IsNullOrWhiteSpace(conn_str)) { Hashmap h = db_configuration.Keys; if (h != null) { string[] keys_ = h.Keys(); foreach (var key in keys_) { conn_str = string.Format("{0}{1}={2};", conn_str, key, h.Get(key)); } conn_str = conn_str.TrimEnd(';'); } } // IF CLAUSE 1 if (conn_type == ConnectionTypes.External) { conn = new ExternalConnection(db_configuration.InvariantName, conn_str); } else { conn = new Connection(conn_type, conn_str); } } catch (Exception) { throw; } // RETURN return(conn); }
public void CanReturnAllLeftRecords() { Hashmap mapA = new Hashmap(1024); mapA.Add("cats", "blue"); mapA.Add("dogs", "green"); mapA.Add("llamas", "red"); mapA.Add("cows", "purple"); Hashmap mapB = new Hashmap(1024); mapB.Add("ants", "223"); Assert.Equal(4, Program.LeftJoin(mapA, mapB).Count); }
public static List <Object> TreeIntersection(BinaryTree treeA, BinaryTree treeB) { // build structures List <object> list = new List <object>(); Queue queue = new Queue(); Hashmap map = new Hashmap(1024); Object temp = null; // traverse treeA queue.Enqueue(treeA.Root); while (queue.Front != null) { if (queue.Front.Left != null) { queue.Enqueue(queue.Front.Left); } if (queue.Front.Right != null) { queue.Enqueue(queue.Front.Right); } temp = queue.Front.Value.ToString(); if (!map.Contains(temp, temp)) { map.Add(temp, temp); } queue.Dequeue(); } // traverse treeB queue.Enqueue(treeB.Root); while (queue.Front != null) { if (queue.Front.Left != null) { queue.Enqueue(queue.Front.Left); } if (queue.Front.Right != null) { queue.Enqueue(queue.Front.Right); } temp = queue.Front.Value.ToString(); if (map.Contains(temp, temp)) { //map.Remove(temp, temp); list.Add(temp); } queue.Dequeue(); } return(list); }
/// <summary> /// Returns scalar execution value of Procedure with parameters. /// </summary> /// <param name="query">Sql Procedure</param> /// <param name="parameters">Hashmap contains parameters.</param> /// <returns>Returns scalar execution value of Procedure with parameters.</returns> public Object ExecuteScalarAsProcedure(string procedure, Hashmap parameters) { object result = null; try { result = this.ExecuteScalar(procedure, CommandType.StoredProcedure, parameters); } catch (Exception) { throw; } return(result); }
/* ------------------------------------------------- */ #region [ Execute Scalar Query with Parameters ] /// <summary> /// Returns scalar execution value of query with parameters. /// </summary> /// <param name="query">Sql Query</param> /// <param name="parameters">Prperty contains parameters.</param> /// <returns>Returns scalar execution value of query with parameters.</returns> public object ExecuteScalarAsQuery(string query, Hashmap parameters) { object result = null; try { result = this.ExecuteScalar(query, CommandType.Text, parameters); } catch (Exception) { throw; } return(result); }
/// <summary> /// Returns execution value of Procedure. /// </summary> /// <param name="query">Sql Procedure</param> /// <param name="parameters">Hashmap contains parameters.</param> /// <returns>Returns execution value of Procedure with parameters.</returns> public int ExecuteProcedure(string procedure, Hashmap parameters) { int result = -100; try { result = this.Execute(procedure, CommandType.StoredProcedure, parameters); } catch (Exception) { throw; } return(result); }
/* ------------------------------------------------- */ #region [ Execute Query with Parameters ] /// <summary> /// Returns execution value of query. /// </summary> /// <param name="query">Sql Query</param> /// <param name="parameters">Hashmap contains parameters.</param> /// <returns>Returns execution value of query with parameters.</returns> public int ExecuteQuery(string query, Hashmap parameters) { int result = -100; try { result = this.Execute(query, CommandType.Text, parameters); } catch (Exception) { throw; } return(result); }
/// <summary> /// Returns A DataSet with given Procedure without any parameter /// </summary> /// <param name="query">Sql Procedure</param> /// <param name="parameters">Hashmap parameters</param> /// <returns>Returns A DataSet with given Procedure without any parameter</returns> public DataSet GetResultSetOfProcedure(string procedure, Hashmap parameters) { DataSet ds = null; try { ds = this.GetResultSet(procedure, CommandType.StoredProcedure, parameters); } catch (Exception) { throw; } return(ds); }
/* ------------------------------------------------- */ #region [ Get ResultSet of Query with Parameters ] /// <summary> /// Returns A DataSet with given Query with parameter(s). /// </summary> /// <param name="query">Sql Query</param> /// <param name="parameters">Hashmap which contains parameters</param> /// <returns>Returns A DataSet with given Query without any parameter</returns> public DataSet GetResultSetOfQuery(string query, Hashmap parameters) { DataSet ds = null; try { ds = this.GetResultSet(query, CommandType.Text, parameters); } catch (Exception) { throw; } return(ds); }
public virtual int Delete(string table_name, string where_column, object where_value) { int result = -1; try { if (string.IsNullOrWhiteSpace(table_name)) { throw new Exception("Table Name can not be null or empty."); } if (table_name.Contains("drop") || table_name.Contains("--")) { throw new Exception( "Table Name can not be contain restricted characters and text."); } if (string.IsNullOrWhiteSpace(where_column)) { throw new Exception("Where Column Name can not be null or empty."); } if (where_column.Contains("drop") || where_column.Contains("--")) { throw new Exception( "Table Name can not be contain restricted characters and text."); } QueryFormat qf = new QueryFormat(QueryTypes.Delete); QueryAdds qo = new QueryAdds(this.conn_type); string query = "", vals = ""; vals = string.Format("{0}{1}{2}={3}{1}", qo.Prefix, where_column, qo.Suffix, qo.ParameterPrefix); query = string.Format(qf.Format, table_name, vals); Hashmap p = new Hashmap(); p.Set(string.Format("{0}{1}", qo.ParameterPrefix, where_column), where_value); result = this.ExecuteQuery(query, p); } catch (Exception) { throw; } return(result); }