private static string getKewords(HTMLchunk[] chunks, Menees.DiffUtils.EditScript edits) { System.Text.StringBuilder sb = new System.Text.StringBuilder(); //get an iterator for the changes System.Collections.IEnumerator it = edits.GetEnumerator(); while (it.MoveNext()) { Menees.DiffUtils.Edit curr = (Menees.DiffUtils.Edit)it.Current; //append only new text additions to versionB if (curr.Type == EditType.Insert || curr.Type == EditType.Change) { for (int i = 0; i < curr.Length; i++) { //append only text changes if (chunks[curr.StartB + i].oType == HTMLchunkType.Text) { sb.Append(" " + chunks[curr.StartB + i].oHTML); } } } } return(sb.ToString()); }
private static string getMarkedUpHtml(HTMLchunk[] chunks, Menees.DiffUtils.EditScript edits, bool isOlderVersion) { string[] str = new string[chunks.Length]; for (int i = 0; i < str.Length; i++) { str[i] = chunks[i].oHTML; } //get an iterator for the changes System.Collections.IEnumerator it = edits.GetEnumerator(); //for now only mark up text nodes!!! this needs improvement while (it.MoveNext()) { Menees.DiffUtils.Edit curr = (Menees.DiffUtils.Edit)it.Current; int start = (isOlderVersion ? curr.StartA : curr.StartB); switch (curr.Type) { case Menees.DiffUtils.EditType.Change: for (int i = 0; i < curr.Length; i++) { if (chunks[start + i].oType == HTMLchunkType.Text) { str[start + i] = (isOlderVersion ? Tags.changeDelete : Tags.changeAdd) + str[start + i] + Tags.close; } } break; case Menees.DiffUtils.EditType.Delete: //deletes are marked in the older version if (isOlderVersion) { for (int i = 0; i < curr.Length; i++) { if (chunks[start + i].oType == HTMLchunkType.Text) { str[start + i] = Tags.delete + str[start + i] + Tags.close; } } } break; case Menees.DiffUtils.EditType.Insert: //Inserts are marked in the newer version if (!isOlderVersion) { for (int i = 0; i < curr.Length; i++) { if (chunks[start + i].oType == HTMLchunkType.Text) { str[start + i] = Tags.add + str[start + i] + Tags.close; } } } break; } } return(String.Join("", str)); }
public void printMultiArray(int[,] myArr) { System.Collections.IEnumerator myEnumerator = myArr.GetEnumerator(); int i = 0; int cols = myArr.GetLength(myArr.Rank - 1); // two dimensions - 1 = column Console.Write("Element:"); Console.Write("\tFrequency:"); Console.WriteLine(); while (myEnumerator.MoveNext()) { if (i < cols) { i++; } else { Console.WriteLine(); // next row i = 1; } Console.Write("\t{0}", myEnumerator.Current); } Console.WriteLine(); // so that words do not proceed after the last element! }
public void TestValidateTaxonomyRecursively() { Taxonomy tx = new Taxonomy(); int errors = 0; DateTime start = DateTime.Now; Assert.AreEqual(true, tx.Load(US_GAAP_FILE, out errors), "Could not load US GAAP File"); Assert.AreEqual(0, errors); Console.WriteLine("=========================="); ValidationStatus VS = tx.Validate(); Console.WriteLine("Number of Errros: " + tx.ValidationErrors.Count); Console.WriteLine("Number of Warnings: " + tx.ValidationWarnings.Count); Console.WriteLine("Validation Status: " + VS.ToString()); if (tx.ValidationWarnings.Count > 0) { System.Collections.IEnumerator vwarnings = tx.ValidationWarnings.GetEnumerator(); while (vwarnings.MoveNext()) { Console.WriteLine(" Warning > " + vwarnings.Current); } } if (tx.ValidationErrors.Count > 0) { System.Collections.IEnumerator verrors = tx.ValidationErrors.GetEnumerator(); while (verrors.MoveNext()) { Console.WriteLine(" Error > " + verrors.Current); } } Console.WriteLine("=========================="); }
private bool validata(string theme) { DropdownColumn dropdownColumn = (DropdownColumn)this.grdCategries.Columns[1]; System.Collections.IEnumerator enumerator = this.grdCategries.Rows.GetEnumerator(); bool result; try { while (enumerator.MoveNext()) { System.Web.UI.WebControls.GridViewRow gridViewRow = (System.Web.UI.WebControls.GridViewRow)enumerator.Current; string a = dropdownColumn.SelectedValues[gridViewRow.RowIndex]; if (a == theme) { result = false; return(result); } } return(true); } finally { System.IDisposable disposable = enumerator as System.IDisposable; if (disposable != null) { disposable.Dispose(); } } return(result); }
/// <summary> /// 添加块参照对象属性 /// </summary> /// <param name="blockEnt"></param> private void AppendBlock(BlockReference blockEnt) { System.Data.DataRow dr = GetPointTable().NewRow(); dr[POSITION] = PntToString(blockEnt.Position); BlockTableRecord blR = (BlockTableRecord)mAcTrans.GetObject(blockEnt.BlockTableRecord, OpenMode.ForRead); dr[BLOCKNAME] = blR.Name; if (mCompareList.Contains(blR.Name)) { // 如果在对照表中,则替换为对照配置 dr[BLOCKNAME] = mCompareList[blR.Name].ToString(); } string strAttribute = ""; if (blockEnt.AttributeCollection.Count != 0) { System.Collections.IEnumerator bRefEnum = blockEnt.AttributeCollection.GetEnumerator(); AttributeReference aRef; ObjectId aId; while (bRefEnum.MoveNext()) { aId = (ObjectId)bRefEnum.Current; // 这一句非常重要 aRef = (AttributeReference)mAcTrans.GetObject(aId, OpenMode.ForRead, false, true); strAttribute += aRef.Tag + ":" + aRef.TextString + ";"; } } dr[ATTRIBUTE] = strAttribute; dr[LAYER] = BelongLayer; mPointTable.Rows.Add(dr); }
public bool GetNext() { Constraint candidate; currentObject = null; while (tables != null) { if (constraints == null) { if (!tables.MoveNext()) { tables = null; return(false); } constraints = ((DataTable)tables.Current).Constraints.GetEnumerator(); } if (!constraints.MoveNext()) { constraints = null; continue; } Debug.Assert(constraints.Current is Constraint, "ConstraintEnumerator, contains object which is not constraint"); candidate = (Constraint)constraints.Current; if (IsValidCandidate(candidate)) { currentObject = candidate; return(true); } } return(false); }
protected void btnDel_Click(object sender, System.EventArgs e) { System.Collections.IEnumerator enumerator = this.gvResource.Rows.GetEnumerator(); try { while (enumerator.MoveNext()) { GridViewRow gridViewRow = (GridViewRow)enumerator.Current; CheckBox cb = gridViewRow.FindControl("cbBox") as CheckBox; if (cb != null && cb.Checked) { using (pm2Entities pm2Entities = new pm2Entities()) { if (base.Request["num"] == "1") { Res_Template res_Template = ( from m in pm2Entities.Res_Template where m.TemplateId == cb.ToolTip select m).FirstOrDefault <Res_Template>(); if (res_Template != null) { res_Template.IsValid = new bool?(false); pm2Entities.SaveChanges(); } } else { IQueryable <Res_TemplateItem> queryable = from m in pm2Entities.Res_TemplateItem where m.Res_Template.TemplateId == cb.ToolTip select m; foreach (Res_TemplateItem current in queryable) { pm2Entities.DeleteObject(current); } Res_Template res_Template2 = ( from m in pm2Entities.Res_Template where m.TemplateId == cb.ToolTip select m).FirstOrDefault <Res_Template>(); if (res_Template2 != null) { pm2Entities.DeleteObject(res_Template2); pm2Entities.SaveChanges(); } } } } } } finally { System.IDisposable disposable = enumerator as System.IDisposable; if (disposable != null) { disposable.Dispose(); } } base.RegisterScript("location.href=location.href;"); }
private void BindData(ISheet sheet) { try { _dataTable = null; System.Collections.IEnumerator rows = sheet.GetRowEnumerator(); while (rows.MoveNext()) { IRow row = (XSSFRow)rows.Current; if (_dataTable == null) { _dataTable = new DataTable(); for (int i = 0; i < row.LastCellNum; i++) { _dataTable.Columns.Add(row.GetCell(i).StringCellValue); } } else { DataRow dr = _dataTable.NewRow(); for (int i = 0; i < row.LastCellNum; i++) { ICell cell = row.GetCell(i); if (cell == null) { dr[i] = null; } else { if (cell.CellType == CellType.Formula) { dr[i] = cell.NumericCellValue.ToString("f2"); } else { dr[i] = cell.ToString(); } } } _dataTable.Rows.Add(dr); } } if (_dataTable == null) { this.datagrid1.ItemsSource = null; } else { this.datagrid1.ItemsSource = _dataTable.DefaultView; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
// Override 'CreateChildControls'. protected override void CreateChildControls() { System.Collections.IEnumerator myEnumerator = items.GetEnumerator(); while (myEnumerator.MoveNext()) { this.Controls.Add((TextBox)myEnumerator.Current); } }
public void CopyTo(DataViewSetting[] ar, int index) { System.Collections.IEnumerator Enumerator = GetEnumerator(); while (Enumerator.MoveNext()) { ar.SetValue(Enumerator.Current, index++); } }
public static void PrintElementDiff(IEnumerable mylist) { System.Collections.IEnumerator myEnumberator = mylist.GetEnumerator(); while (myEnumberator.MoveNext()) { Console.WriteLine("\t{0}", myEnumberator.Current); } }
public void AddTags(ArrayList tags) { System.Collections.IEnumerator myEnumerator = tags.GetEnumerator(); while (myEnumerator.MoveNext()) { ParseTag((MyTag)(myEnumerator.Current)); } }
public void AddPrice() { string id = this.hdGuid.Value; if (!string.IsNullOrEmpty(this.resourceId)) { id = this.resourceId; } using (pm2Entities pm2Entities = new pm2Entities()) { IQueryable <Res_Price> queryable = from m in pm2Entities.Res_Price where m.ResourceId == id select m; foreach (Res_Price current in queryable) { pm2Entities.DeleteObject(current); } pm2Entities.SaveChanges(); } System.Collections.IEnumerator enumerator2 = this.gvwPriceType.Rows.GetEnumerator(); try { while (enumerator2.MoveNext()) { GridViewRow gridViewRow = (GridViewRow)enumerator2.Current; TextBox tb = gridViewRow.FindControl("txtPrice") as TextBox; using (pm2Entities pm2Entities2 = new pm2Entities()) { Res_Price res_Price = new Res_Price(); if (!string.IsNullOrEmpty(tb.Text)) { res_Price.PriceValue = System.Convert.ToDecimal(tb.Text); } Res_PriceType res_PriceType = ( from m in pm2Entities2.Res_PriceType where m.PriceTypeId == tb.ToolTip select m).First <Res_PriceType>(); res_PriceType.Res_Price.Add(res_Price); Res_Resource res_Resource = ( from m in pm2Entities2.Res_Resource where m.ResourceId == id select m).First <Res_Resource>(); res_Resource.Res_Price.Add(res_Price); pm2Entities2.AddToRes_Price(res_Price); pm2Entities2.SaveChanges(); } } } finally { System.IDisposable disposable = enumerator2 as System.IDisposable; if (disposable != null) { disposable.Dispose(); } } }
public static void PrintValues(IEnumerable myCollection) { System.Collections.IEnumerator myEnumerator = myCollection.GetEnumerator(); while (myEnumerator.MoveNext()) { Console.Write("\t{0}", myEnumerator.Current); } }
protected void btnDel_Click(object sender, System.EventArgs e) { System.Collections.Generic.List <string> list = new System.Collections.Generic.List <string>(); bool flag = false; System.Collections.IEnumerator enumerator = this.gvResource.Rows.GetEnumerator(); try { while (enumerator.MoveNext()) { GridViewRow gridViewRow = (GridViewRow)enumerator.Current; CheckBox cb = gridViewRow.FindControl("cbBox") as CheckBox; if (cb != null && cb.Checked) { using (pm2Entities pm2Entities = new pm2Entities()) { IQueryable <Res_Resource> source = from m in pm2Entities.Res_Resource where m.Res_Unit.UnitId == cb.ToolTip select m; if (source.Count <Res_Resource>() > 0) { flag = true; break; } list.Add(cb.ToolTip); } } } } finally { System.IDisposable disposable = enumerator as System.IDisposable; if (disposable != null) { disposable.Dispose(); } } if (flag) { base.RegisterScript("alert('系统提示:\\n\\n请先删除子项!')"); return; } foreach (string item in list) { using (pm2Entities pm2Entities2 = new pm2Entities()) { Res_Unit entity = ( from m in pm2Entities2.Res_Unit where m.UnitId == item select m).First <Res_Unit>(); pm2Entities2.DeleteObject(entity); pm2Entities2.SaveChanges(); } } base.RegisterScript("location.href=location.href;"); }
public static bool unzipFile(Stream inputStream, string targetDirectory, bool overwrite, OnUnzipProgress callback) { bool ret = false; callback(0, 0); using (ZipFile zipFile_ = new ZipFile(inputStream)) { int totalBytes = (int)zipFile_.unzipSize; UnzipCach cach = new UnzipCach(); cach.start(totalBytes, callback, overwrite); INameTransform extractNameTransform_ = new WindowsNameTransform(targetDirectory); System.Collections.IEnumerator enumerator = zipFile_.GetEnumerator(); while (enumerator.MoveNext()) { try { ZipEntry entry = (ZipEntry)enumerator.Current; if (entry.IsFile) { string fileName = extractNameTransform_.TransformFile(entry.Name); string dirName = Path.GetDirectoryName(Path.GetFullPath(fileName)); if (!Directory.Exists(dirName)) { Directory.CreateDirectory(dirName); } Stream source = zipFile_.GetInputStream(entry); cach.addFile(fileName, (int)entry.Size, source); source.Close(); } else { string dirName = extractNameTransform_.TransformDirectory(entry.Name); if (!Directory.Exists(dirName)) { Directory.CreateDirectory(dirName); } } } catch (Exception e) { cach.setState(UnzipCach.State.Error); //LogManager.GetInstance().LogException(e.Message, e, LogManager.ModuleFilter.RES); } if (cach.isError()) { break; } } cach.setState(UnzipCach.State.Ok); ret = cach.stop(); callback(1, ret?0:1); return(ret); } }
/// <summary> /// Recursively forces loading of each NHibernate proxy in the tree that matches an entry in the map. /// </summary> /// <param name="parent">Top-level object</param> /// <param name="map">Map of properties to initialize for each type</param> /// <param name="remainingDepth">How deep to follow the tree; prevents infinite looping</param> public static void InitializeWithCascade(object parent, IDictionary <Type, List <String> > map, int remainingDepth) { if (remainingDepth < 0 || parent == null) { return; } remainingDepth--; var type = parent.GetType(); List <string> propNames; if (map.ContainsKey(type)) { propNames = map[type]; } else { if ((type.Name.StartsWith("<") || type.Name.StartsWith("_")) && map.ContainsKey(typeof(Type))) { // anonymous type - get the values using "Type" propNames = map[typeof(Type)]; } else { return; } } foreach (var name in propNames) { // Get the child object for the property name var propInfo = type.GetProperty(name); var methInfo = propInfo.GetGetMethod(); var child = methInfo.Invoke(parent, null); var collection = child as System.Collections.ICollection; if (collection != null) { System.Collections.IEnumerator iter = collection.GetEnumerator(); while (iter.MoveNext()) { NHibernateUtil.Initialize(iter.Current); InitializeWithCascade(iter.Current, map, remainingDepth); } } else { NHibernateUtil.Initialize(child); var proxy = child as INHibernateProxy; if (proxy != null) { child = proxy.HibernateLazyInitializer.GetImplementation(); } InitializeWithCascade(child, map, remainingDepth); } } }
protected internal virtual void RenderAssociations(StringBuilder @out) { System.Collections.IEnumerator it = _associations.GetEnumerator(); while (it.MoveNext()) { Renderable renderable = (Renderable)it.Current; @out.Append(renderable.Render()); } }
public void LoadLuaTable(LuaTable reqs) { System.Collections.IEnumerator luatb = reqs.Values.GetEnumerator(); while (luatb.MoveNext()) { AddReqToQueue((CRequest)luatb.Current); } BeginQueue(); }
// Uses the enumerator. // NOTE: The foreach statement is the preferred way of enumerating the contents of a collection. public static void PrintValues2(ROCollection myCol) { System.Collections.IEnumerator myEnumerator = myCol.GetEnumerator(); while (myEnumerator.MoveNext()) { Console.WriteLine(" {0}", myEnumerator.Current); } Console.WriteLine(); }
IEnumerator <LevelMA> IEnumerable <LevelMA> .GetEnumerator() { System.Collections.IEnumerable enumer = this as System.Collections.IEnumerable; System.Collections.IEnumerator iterator = enumer.GetEnumerator(); while (iterator.MoveNext()) { yield return(iterator.Current as LevelMA); } }
IEnumerator <AppUserGroupProgram> IEnumerable <AppUserGroupProgram> .GetEnumerator() { System.Collections.IEnumerable enumer = this as System.Collections.IEnumerable; System.Collections.IEnumerator iterator = enumer.GetEnumerator(); while (iterator.MoveNext()) { yield return(iterator.Current as AppUserGroupProgram); } }
IEnumerator <VwFundPrices> IEnumerable <VwFundPrices> .GetEnumerator() { System.Collections.IEnumerable enumer = this as System.Collections.IEnumerable; System.Collections.IEnumerator iterator = enumer.GetEnumerator(); while (iterator.MoveNext()) { yield return(iterator.Current as VwFundPrices); } }
public static void AddCustomXmlPart(Excel.Workbook workbook, string namespaceName, string xmlString) { System.Collections.IEnumerator enumerator = workbook.CustomXMLParts.SelectByNamespace(namespaceName).GetEnumerator(); enumerator.Reset(); if (!(enumerator.MoveNext())) // false if XmlPart already exists { Office.CustomXMLPart p = workbook.CustomXMLParts.Add(xmlString); } }
public static void AddAll(System.Collections.Hashtable hashtable, System.Collections.ICollection items) { System.Collections.IEnumerator iter = items.GetEnumerator(); System.Object item; while (iter.MoveNext()) { item = iter.Current; hashtable.Add(item, item); } }
/// <summary> /// Converts an ICollection instance to an ArrayList instance. /// </summary> /// <param name="c">The ICollection instance to be converted.</param> /// <returns>An ArrayList instance in which its elements are the elements of the ICollection instance.</returns> public static System.Collections.ArrayList ToArrayList(System.Collections.ICollection c) { System.Collections.ArrayList tempArrayList = new System.Collections.ArrayList(); System.Collections.IEnumerator tempEnumerator = c.GetEnumerator(); while (tempEnumerator.MoveNext()) { tempArrayList.Add(tempEnumerator.Current); } return(tempArrayList); }
IEnumerator <PeriodeAnggaran> IEnumerable <PeriodeAnggaran> .GetEnumerator() { System.Collections.IEnumerable enumer = this as System.Collections.IEnumerable; System.Collections.IEnumerator iterator = enumer.GetEnumerator(); while (iterator.MoveNext()) { yield return(iterator.Current as PeriodeAnggaran); } }
public static void closeAllProjects() { System.Collections.IEnumerator iterator = s_utilInstanceMap.Keys.GetEnumerator(); while (iterator.MoveNext()) { ProjectDBUtil projectDBUtil = (ProjectDBUtil)s_utilInstanceMap[iterator.Current]; projectDBUtil.closeProject(); } s_utilInstanceMap.Clear(); }
IEnumerator <TransaksiBKU> IEnumerable <TransaksiBKU> .GetEnumerator() { System.Collections.IEnumerable enumer = this as System.Collections.IEnumerable; System.Collections.IEnumerator iterator = enumer.GetEnumerator(); while (iterator.MoveNext()) { yield return(iterator.Current as TransaksiBKU); } }
/// <summary> Creates a new iterator for the specified graph. Iteration will start at /// the specified start vertex. If the specified start vertex is /// <code>null</code>, Iteration will start at an arbitrary graph vertex. /// /// </summary> /// <param name="g">the graph to be iterated. /// </param> /// <param name="startVertex">the vertex iteration to be started. /// /// </param> /// <throws> NullPointerException </throws> /// <throws> IllegalArgumentException </throws> public CrossComponentIterator(Graph g, System.Object startVertex) { InitBlock(); if (g == null) { throw new System.NullReferenceException("graph must not be null"); } m_specifics = createGraphSpecifics(g); m_vertexIterator = g.vertexSet().GetEnumerator(); setCrossComponentTraversal(startVertex == null); m_reusableEdgeEvent = new FlyweightEdgeEvent(this, null); m_reusableVertexEvent = new FlyweightVertexEvent(this, (System.Object) null); if (startVertex == null) { // pick a start vertex if graph not empty //UPGRADE_TODO: Method 'java.util.Iterator.hasNext' was converted to 'System.Collections.IEnumerator.MoveNext' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilIteratorhasNext'" if (m_vertexIterator.MoveNext()) { //UPGRADE_TODO: Method 'java.util.Iterator.next' was converted to 'System.Collections.IEnumerator.Current' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilIteratornext'" m_startVertex = ((DictionaryEntry)m_vertexIterator.Current).Value; } else { m_startVertex = null; } } else if (g.containsVertex(startVertex)) { m_startVertex = startVertex; } else { throw new System.ArgumentException("graph must contain the start vertex"); } }
/// <summary> /// Move to the next example in the example set. Returns null /// if the set is empty, and will wrap around when it gets to the /// end of the set. /// </summary> /// <returns>The next example.</returns> public Example NextExample() { if(examples.Count == 0) { return null; } if((exampleIterator == null) || (!exampleIterator.MoveNext())) { exampleIterator = examples.GetEnumerator(); exampleIterator.MoveNext(); } return (Example)exampleIterator.Current; }