public SubList GetDetailASOIById(string id) { SubList result = new SubList(); var ds = AsDetailSAOIRepository.GetDetailASOIById(id); if (ds != null && ds.Tables.Count != 0 && ds.Tables[0].Rows.Count != 0) { result.Id = ds.Tables[0].Rows[0]["id"].ToString(); result.Rp_id = ds.Tables[0].Rows[0]["rp_id"].ToString(); result.Prog_desc = ds.Tables[0].Rows[0]["prog_desc"].ToString(); result.Prog_organizer = ds.Tables[0].Rows[0]["prog_organizer"].ToString(); result.Start_date = DateTime.Parse(ds.Tables[0].Rows[0]["start_date"].ToString()).ToString("dd/MM/yyyy"); result.End_date = DateTime.Parse(ds.Tables[0].Rows[0]["end_date"].ToString()).ToString("dd/MM/yyyy"); result.Income = Convert.ToDecimal(ds.Tables[0].Rows[0]["income"].ToString()); result.Pe = Convert.ToDecimal(ds.Tables[0].Rows[0]["pe"].ToString()); result.Oc = Convert.ToDecimal(ds.Tables[0].Rows[0]["oc"].ToString()); result.Remarks = ds.Tables[0].Rows[0]["remarks"].ToString(); if (result.Start_date.ToString() == "01/01/1900") { result.Start_date = ""; } if (result.End_date.ToString() == "01/01/1900") { result.End_date = ""; } } return(result); }
public CombinedList(SubList sl) { this.left = sl.Indices; this.middle = new List<int>(); this.right = new List<int>(); this.subLists.Add(new Tuple<int, SubList>(0x00, sl)); }
public SubListIter(int i, SubList root) { this.rootSubList = root; this.root = root.root; this.expected = this.root.list; this.iter = rootSubList.get(expected).listIterator(i); }
public void Can_Remove_all() { ActivityType type1 = new ActivityType { ActivityTypeId = Guid.NewGuid(), ActivityTypeTitle = "Один" }; ActivityType type2 = new ActivityType { ActivityTypeId = Guid.NewGuid(), ActivityTypeTitle = "Два" }; // Организация - создание нескольких тестовых игр Activity act1 = new Activity { ActivityId = Guid.NewGuid(), ActivityName = "Игра1", ActivityTypeCurrent = type1 }; Activity act2 = new Activity { ActivityId = Guid.NewGuid(), ActivityName = "Игра2", ActivityTypeCurrent = type1 }; // Организация - создание корзины SubList SubList = new SubList(); // Действие SubList.SubActivity(act1); SubList.SubActivity(act2); SubList.Clear(); List <Activity> results = SubList.Line.ToList(); // Утверждение Assert.AreEqual(results.Count(), SubList.ComputeTotalSubs()); }
public List <String> sumTo(double V) { double listSum = 0; foreach (double x in choices.Values) { listSum += x; } if (listSum < V) { return(new List <String>()); } else { SubList opt = new SubList(); HashSet <SubList> sums = new HashSet <SubList>(); sums.Add(opt); List <KeyValuePair <String, Double> > sortedChoices = choices.ToList(); sortedChoices.Sort( (a, b) => b.Value - a.Value > 0 ? 1 : -1 ); foreach (KeyValuePair <String, Double> input in sortedChoices) { HashSet <SubList> newSums = new HashSet <SubList>(); listSum -= input.Value; foreach (SubList sum in sums) { List <KeyValuePair <String, Double> > newSubList = new List <KeyValuePair <String, Double> >(sum.subList); newSubList.Add(input); SubList newSum = new SubList(sum.size + input.Value, newSubList); // Ignore too small sums. if (newSum.size + listSum > V) { newSums.Add(newSum); } if (newSum.size >= V) { if (opt.size < V || newSum.size < opt.size) { opt = newSum; } } } sums.UnionWith(newSums); } List <String> result = new List <string>(); foreach (KeyValuePair <String, Double> e in opt.subList) { result.Add(e.Key); } return(result); } }
private static SubList <Subspan> TrimEnd(SubList <Subspan> subspans) { while (subspans.Count > 1 && CanTrim(subspans.Last())) { subspans = subspans.WithoutLast(); } return(subspans); }
/*public static SubList CreateSubList(Transform parent) * { * return CreateSubList(parent, null); * }*/ public static SubList CreateSubList(Transform parent, Personalization personalize) { GameObject obj = new GameObject(ROW_NAME); SubList sublist = obj.AddComponent <SubList>(); sublist.Initialize(); obj.transform.SetParent(parent); return(sublist); }
private bool TryAllocateNewStrip(BuildingContext context, SubList <Subspan> firstAtomicSubspans) { var firstSize = MeasureSubspans(context, firstAtomicSubspans); // todo: consider directions context.StripStartPoint = context.RemainingShape.MinMin; return(firstSize.Width <= context.RemainingShape.Width && firstSize.Height <= context.RemainingShape.Height); }
private bool CanFitSubspans(BuildingContext context, SubList <Subspan> subspans, float tabOffset) { var size = MeasureSubspans(context, subspans); var availableWidth = context.RemainingShape.Width; var availableHeight = context.RemainingShape.Height; return(size.Width <= availableWidth - tabOffset && size.Height <= availableHeight); }
public CombinedList(SubList sl1, SubList sl2) { Tuple<List<int>,List<int>,List<int>> res = Combine(sl1, sl2); this.left = res.Item1; this.middle = res.Item2; this.right = res.Item3; this.subLists.Add(new Tuple<int, SubList>(0x00, sl1)); this.subLists.Add(new Tuple<int, SubList>(this.left.Count, sl2)); }
private Size2 MeasureSubspans(BuildingContext context, SubList <Subspan> subspans) { // todo: cache measurments for a context // todo: consider directions subspans = TrimEnd(subspans); var sizes = subspans.Select(MeasureSubspan).ToArray(); return(new Size2(sizes.Sum(x => x.Width), sizes.Max(x => x.Height))); }
private void navBarItem13_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e) { panelControl1.Controls.Clear(); SubList sL = new SubList(); sL.Dock = DockStyle.Fill; panelControl1.Controls.Add(sL); btnSearch.Visibility = DevExpress.XtraBars.BarItemVisibility.Never; }
private void RefreshSubList() { substitutionsList.Items.Clear(); mySubList = new SubList(); string[] Keys = mySubList.Characters.Keys.ToArray <string>(); foreach (string K in Keys) { string Substitution = K + " => " + mySubList.Characters[K]; substitutionsList.Items.Add(Substitution); } }
public SubList GetList() { SubList subList = (SubList)Session["Cart"]; //if (subList == null) //{ // subList = new SubList(); // Session["Cart"] = subList; //} return(subList); }
public Row AddRow(List <Data.Item> dataItems) { SubList parent = GetLastSublist(); if (parent == null) { parent = Helper.UIObjectCreator.CreateSubList(itemsReference, personalize); } List.Row row = Helper.UIObjectCreator.CreateRow(parent.GetTransform(), personalize); parent.Add(row); AddItemsToParent(dataItems, row); return(row); }
private async Task CallListLoad() { SubList.Clear(); // Android "Amimations can only be run on looper threads" when the _isForegroundAwait/notThreaded parameter is true // Or it just hangs // await FakeStringService.LoadOneList(SubList, _listNum, _isForegroundAwait, (returnList) => await FakeStringService.LoadOneList(SubList, _listNum, false, (returnList) => { SubList = returnList; PopulationCompleted?.Invoke(); }).WithoutChangingContext(); }
//Добавить строку подтаблицы public void AddRow(TablRow row, bool addIndices) //Добавлять индексирование по полям Code и Num { row.Parent = this; SubList.Add(row); if (addIndices) { SubNums.Add(row.Num, row); if (!row.Code.IsEmpty()) { SubCodes.Add(row.Code, row); } } }
public void AddSublist() { GameObject obj = new GameObject("Sublist"); SubList list = obj.AddComponent <SubList>(); list.Initialize(); list.transform.SetParent(itemsReference); //TODO možda: //Sublist.Initialize(); -> IMultiList.Initialize(); -> AddComponentWithParameters Data.Item data = new Data.Item("HEADER"); List.Item item1 = CreateItem(data, obj.transform); item1.transform.SetParent(obj.transform); list.Add(item1); }
string DoSubs(string m, SubList l) { string res = l.res; int adj = 0; while (l != null) { switch (l.typ) { case SubType.zero: string s = zero.ToString(); res = res.Insert(l.loc + adj, s); adj += s.Length; zero++; break; case SubType.one: s = one.ToString(); res = res.Insert(l.loc + adj, s); adj += s.Length; one++; break; case SubType.alphaUpper: s = ToAlphaString(alphaUpper, 'A'); res = res.Insert(l.loc + adj, s); adj += s.Length; alphaUpper++; break; case SubType.alphaLower: s = ToAlphaString(alphaLower, 'a'); res = res.Insert(l.loc + adj, s); adj += s.Length; alphaLower++; break; case SubType.match: res = res.Insert(l.loc + adj, m); adj += m.Length; break; } l = l.nxt; } return(res); }
public void InsertAsDetailASOI(SubList model, string user_name) { int totalDetailASOI = CountTotalDetailASOI(); int id = 0; if (totalDetailASOI == 0) { id = 1; } else { id = AsDetailSAOIRepository.GetLatestDetailASOIId() + 1; } AsDetailSAOIRepository.InsertAsDetailASOI(id, model.Rp_id, model.Prog_desc, model.Prog_organizer, model.Start_date, model.End_date, model.Income, model.Pe, model.Oc, model.Remarks, user_name); }
/// <summary> /// Adds List of Strings as new Row of data /// New Row will be added at last Sublist /// </summary> /// <param name="data"></param> public void AddRow(List <string> data) { List <Data.Item> dataItems = new List <Data.Item>(); foreach (string d in data) { dataItems.Add(new Data.Item(d)); } SubList parent = GetLastSublist(); if (parent != null) { AddRow(dataItems, parent); } else { Debug.LogWarning("There is no Sublist Component attached in last child in Content"); } }
private void BuildParagraph(BuildingContext context, int paragraphIndex) { var para = context.Text.Paragraphs[paragraphIndex]; ApplyMarginUp(context, para); var subspans = BuildParagraphSubspans(context, paragraphIndex); var flushedSubspanCount = 0; while (flushedSubspanCount < subspans.Count) { var minimalSubspans = new SubList <Subspan>(subspans, flushedSubspanCount, 0); for (var i = flushedSubspanCount; i < subspans.Count; i++) { minimalSubspans = minimalSubspans.WithNext(); if (subspans[i].CanBreakAfter) { break; } } if (!TryAllocateNewStrip(context, minimalSubspans)) { return; } var subspansToFlush = minimalSubspans; var subspansToTry = subspansToFlush.WithNext(); var tabOffset = context.Text.Paragraphs[paragraphIndex].Style.TabCount * 80f; while (flushedSubspanCount + subspansToFlush.Count < subspans.Count && CanFitSubspans(context, subspansToTry, tabOffset)) { subspansToFlush = subspansToTry; subspansToTry = subspansToFlush.WithNext(); } var isFirstStrip = flushedSubspanCount == 0; var isLastStrip = flushedSubspanCount + subspansToFlush.Count == subspans.Count; FlushStrip(context, paragraphIndex, tabOffset, subspansToFlush, isFirstStrip, isLastStrip); flushedSubspanCount += subspansToFlush.Count; } }
// Method to check if both nodes are within the same list public bool CheckSubset(NodeState x, NodeState y, List <List <NodeState> > OldList) { foreach (List <NodeState> SubList in OldList) { if (SubList.Contains(x.a) && SubList.Contains(y.a)) { foreach (List <NodeState> otherList in OldList) { if (otherList.Contains(x.b) && otherList.Contains(y.b)) { //Console.WriteLine("Yay sets match"); return(true); } } } } //Console.Write("Nay subsets don't match"); return(false); }
public ISubInsertable <T> AddSubList(Expression <Func <T, SubInsertTree> > tree) { try { var lamda = (tree as LambdaExpression); var memInit = lamda.Body as MemberInitExpression; if (memInit.Bindings != null) { MemberAssignment memberAssignment = (MemberAssignment)memInit.Bindings[0]; SubList.Add(new SubInsertTreeExpression() { Expression = memberAssignment.Expression, Childs = GetSubInsertTree(((MemberAssignment)memInit.Bindings[1]).Expression) }); } } catch { Check.Exception(true, tree.ToString() + " format error "); } return(this); }
private static IReadOnlyList <Subspan> MergeSubspans(SubList <Subspan> subspans) { var resultList = new List <Subspan>(); var toMerge = new List <Subspan>(); var index = 0; while (index < subspans.Count) { var first = subspans[index]; index++; if (first.EmbeddingImage != null) { resultList.Add(first); continue; } toMerge.Clear(); toMerge.Add(first); // todo: consider span direction while (index < subspans.Count && subspans[index].TextRelPosition.SpanIndex == toMerge[0].TextRelPosition.SpanIndex) { toMerge.Add(subspans[index]); index++; } resultList.Add(new Subspan { TextRelPosition = first.TextRelPosition, Text = toMerge.Select(x => x.Text).Aggregate((x, y) => x + y), Style = first.Style, CanBreakAfter = toMerge.Last().CanBreakAfter, ParagraphDirection = first.ParagraphDirection, TextDirection = first.TextDirection }); } return(resultList); }
public List <SubList> GetDetailList(string rp_id) { List <SubList> result = new List <SubList>(); var ds = AsDetailSAOIRepository.GetDetailASOIByRpId(rp_id); if (ds != null && ds.Tables.Count != 0 && ds.Tables[0].Rows.Count != 0) { foreach (DataRow dr in ds.Tables[0].Rows) { SubList item = new SubList(); item.Id = dr["id"].ToString(); item.Rp_id = rp_id; item.Prog_desc = dr["prog_desc"].ToString(); item.Prog_organizer = dr["prog_organizer"].ToString(); item.Start_date = DateTime.Parse(dr["start_date"].ToString()).ToString("dd/MM/yyyy"); item.End_date = DateTime.Parse(dr["end_date"].ToString()).ToString("dd/MM/yyyy"); item.Income = Convert.ToDecimal(dr["income"].ToString()); item.Pe = Convert.ToDecimal(dr["pe"].ToString()); item.Oc = Convert.ToDecimal(dr["oc"].ToString()); //item.Income = dr["income"].ToString(); //item.Pe = dr["pe"].ToString(); //item.Oc = dr["oc"].ToString(); item.Remarks = dr["remarks"].ToString(); if (item.Start_date.ToString() == "01/01/1900") { item.Start_date = ""; } if (item.End_date.ToString() == "01/01/1900") { item.End_date = ""; } result.Add(item); } } return(result); }
public static Tuple<List<int>, List<int>, List<int>> Combine(SubList a, SubList b) { List<int> left = new List<int>(), middle = new List<int>(), right = new List<int>(); IEnumerator<int> ea = a.Indices.GetEnumerator(); IEnumerator<int> eb = b.Indices.GetEnumerator(); bool aa = ea.MoveNext(), ab = eb.MoveNext(); while(aa && ab) { if(ea.Current < eb.Current) { left.Add(ea.Current); aa = ea.MoveNext(); } else if(ea.Current > eb.Current) { right.Add(eb.Current); ab = eb.MoveNext(); } else { middle.Add(ea.Current); aa = ea.MoveNext(); ab = eb.MoveNext(); } } while(aa) { left.Add(ea.Current); aa = ea.MoveNext(); } while(ab) { right.Add(eb.Current); ab = eb.MoveNext(); } return new Tuple<List<int>, List<int>, List<int>>(left, middle, right); }
public bool AddSubList(SubList list) { List<int> sli = list.Indices; if(sli.Count < this.middle.Count) { int offset = this.middle.BinarySearch(sli[0x00]); if(offset >= 0x00 && offset < this.middle.Count-list.Indices.Count) { for(int i = 1; i < list.Indices.Count; i++) { if(list.Indices[i] != this.middle[offset+i]) { return false; } } this.subLists.Add(new Tuple<int,SubList>(offset+this.left.Count, list)); return true; } } return false; }
private void FlushStrip(BuildingContext context, int paragraphIndex, float tabOffset, SubList <Subspan> subspans, bool isFirstStrip, bool isLastStrip) { // todo: consider direction var paragraph = context.Text.Paragraphs[paragraphIndex]; //if (!isLastStrip) // subspans = TrimEnd(subspans); var commonSize = MeasureSubspans(context, subspans); var stripSize = new Size2(context.RemainingShape.Width, commonSize.Height); if (paragraph.Style.Alignment != RtParagraphAlignment.Justify || isLastStrip) { // todo: tabs var mergedSubspans = MergeSubspans(subspans); var newRectangles = new RichTextBoxLayoutSpan[mergedSubspans.Count]; var strip = AaRectangle2.FromCornerAndDimensions( context.StripStartPoint.X, context.StripStartPoint.Y, commonSize.Width, commonSize.Height); var rectOffsetX = context.StripStartPoint.X + tabOffset; var charIndex = 0; for (var i = 0; i < mergedSubspans.Count; i++) { var subspan = mergedSubspans[i]; var subspanSize = MeasureSubspan(subspan); var charWidths = subspan.Text.Select(x => measurer.GetCharSize(x, subspan.Style).Width).ToArray(); var subspanWidthWithoutKerning = charWidths.Sum(); var kerningAdjustment = subspanSize.Width / subspanWidthWithoutKerning; var adjustedCharWidths = charWidths.Select(x => x * kerningAdjustment).ToArray(); var charOffsets = Enumerable.Range(0, subspan.Text.Length).Select(x => adjustedCharWidths.Take(x).Sum()).ToArray(); newRectangles[i] = new RichTextBoxLayoutSpan { TextRelPosition = subspan.TextRelPosition, TextAbsPosition = context.Text.GetGlobalIndex(subspan.TextRelPosition), Bounds = new AaRectangle2( new Vector2(rectOffsetX, context.StripStartPoint.Y), new Vector2(rectOffsetX + subspanSize.Width, context.StripStartPoint.Y + commonSize.Height)), Strip = strip, CharOffsets = charOffsets, Text = subspan.Text, Style = subspan.Style, Embedding = subspan.Embedding, EmbeddingHandler = subspan.EmbeddingHandler, EmbeddingImage = subspan.EmbeddingImage }; rectOffsetX += subspanSize.Width; charIndex += subspan.Text.Length; } var adjustment = 0f; switch (paragraph.Style.Alignment) { case RtParagraphAlignment.Left: break; case RtParagraphAlignment.Center: var leftCenterX = rectOffsetX / 2; var stripCenter = stripSize.Width / 2; adjustment = stripCenter - leftCenterX; break; case RtParagraphAlignment.Right: adjustment = stripSize.Width - rectOffsetX; break; case RtParagraphAlignment.Justify: default: throw new ArgumentOutOfRangeException(); } for (var i = 0; i < newRectangles.Length; i++) { newRectangles[i].Bounds.Center.X += adjustment; } context.LayoutSpans.AddRange(newRectangles); context.RemainingShape = new AaRectangle2(context.RemainingShape.MinMin + Vector2.UnitY * stripSize.Height, context.RemainingShape.MaxMax); if (isFirstStrip) { // todo: adjust for other directions var bulletStr = paragraph.Style.ListStyle.GetIconFor(paragraph.Style.TabCount, /*todo*/ 0); FlushBullet(context, new Vector2(tabOffset, strip.MaxY), bulletStr, subspans.First().Style); } } else { throw new NotImplementedException(); } }
public static int CalculateReduction(SubList sublist1, SubList sublist2) { int n = 0x00; IEnumerator<int> ea = sublist1.Indices.GetEnumerator(); IEnumerator<int> eb = sublist2.Indices.GetEnumerator(); bool aa = ea.MoveNext(), ab = eb.MoveNext(); while(aa && ab) { if(ea.Current < eb.Current) { aa = ea.MoveNext(); } else if(ea.Current > eb.Current) { ab = eb.MoveNext(); } else { n++; aa = ea.MoveNext(); ab = eb.MoveNext(); } } return n; }
public Enumerator(SubList <V> items) { this.items = items; }
SubList PrepForSub(ref string s, bool allowmatch) { SubList l = new SubList(SubType.match, 0); SubList lt = l; string res = ""; int i = 0; subMode md = subMode.scan; char c = '\0'; char pc = '\0'; while (i < s.Length) { pc = c; c = s[i]; switch (md) { case subMode.scan: switch (c) { case '\\': md = subMode.esc; break; case '&': md = subMode.sub; break; default: res += c; break; } break; case subMode.esc: md = subMode.scan; break; case subMode.sub: switch (c) { case 'Z': lt.nxt = new SubList(SubType.zero, res.Length); lt = lt.nxt; md = subMode.scan; break; case 'O': lt.nxt = new SubList(SubType.one, res.Length); lt = lt.nxt; md = subMode.scan; break; case 'U': lt.nxt = new SubList(SubType.alphaUpper, res.Length); lt = lt.nxt; md = subMode.scan; break; case 'L': lt.nxt = new SubList(SubType.alphaLower, res.Length); lt = lt.nxt; md = subMode.scan; break; default: if (allowmatch) { switch (c) { case '\\': lt.nxt = new SubList(SubType.match, res.Length); lt = lt.nxt; md = subMode.scan; break; case '&': lt.nxt = new SubList(SubType.match, res.Length); lt = lt.nxt; break; default: lt.nxt = new SubList(SubType.match, res.Length); lt = lt.nxt; md = subMode.scan; res += c; break; } } else { switch (c) { case '\\': //throw new ssException("substitution not allowed"); md = subMode.esc2; res += pc; break; default: md = subMode.scan; res += pc; res += c; break; } } break; } break; case subMode.esc2: md = subMode.scan; res += c; break; } i++; } if (md == subMode.sub) { if (allowmatch) { lt.nxt = new SubList(SubType.match, res.Length); } else { if (i > 1) { res += pc; } else { res += '&'; } } } if (l.nxt != null) { l.nxt.res = res; } else if (res != s) { s = res; } //MsgLn("/" + res + "/"); //for (SubList x = l; x != null; x = x.nxt) MsgLn(x.loc.ToString() + " " + x.typ.ToString()); return(l.nxt); }
public void AddNewItem(A newItem, Func<A, bool> checkForItemInMasterList) { if (checkForItemInMasterList.Invoke(newItem) SubList.Add(newItem); }
/// <summary> /// Row by this definition will be inside (at least) Sublist (IMultiList type) /// </summary> /// <param name="dataItems"></param> /// <param name="parent"></param> public Row AddRow(List <Data.Item> dataItems, SubList parent) { List.Row row = Helper.UIObjectCreator.CreateRow(parent.GetTransform(), personalize); AddItemsToParent(dataItems, row); return(row); }
private void ValidateFromTo(SubList list, XmlDocument document, XmlReader reader) { var lastitem = list.NodeSelf; var comments = new List<XmlNode>(); while (reader.Read()) { if (reader.Depth == 2 && reader.NodeType == XmlNodeType.Element) { var item = (XmlElement)null; if (reader.IsEmptyElement && reader.AttributeCount == 2 && reader.Name == list.ItemName) { var from = reader["from"]; var to = reader["to"]; if (!string.IsNullOrEmpty(from) && to != null) { var key = string.Format("{0}\0{1}", from, to); if (list.Elements.ContainsKey(key)) { item = list.Elements[key]; _factory.Logger.Verbose(string.Format("Removed duplicate |{0}| ==> |{1}|", from, to)); } else { item = document.CreateElement(list.ItemName); item.SetAttribute("from", from); item.SetAttribute("to", to); list.NodeSelf.AppendChild(item); list.Elements.Add(key, item); } } } if (item != null) { if (lastitem == null) { lastitem = item; } if (comments.Count > 0) { foreach (var c in comments) { lastitem.ParentNode.InsertBefore(c, lastitem); } comments.Clear(); } lastitem = item; } else { throw new Exception(string.Format("Invalid element <{0}…> in <{1}>", reader.Name, list.NodeSelf.Name)); } } else if (reader.Depth == 2 && reader.NodeType == XmlNodeType.Whitespace) { if (lastitem != null && reader.Value.ContainsLinefeed()) { if (comments.Count > 0) { foreach (var c in comments) { lastitem.ParentNode.InsertBefore(c, lastitem); } comments.Clear(); } lastitem = null; } } else if (reader.Depth == 2 && reader.NodeType == XmlNodeType.Comment) { comments.Add(document.CreateComment(reader.Value.ReplaceWhiteSpace(" "))); } else if (reader.Depth == 2 && reader.NodeType == XmlNodeType.CDATA) { comments.Add(document.CreateCDataSection(reader.Value.ReplaceWhiteSpace())); } else if (reader.Depth == 1 && reader.NodeType == XmlNodeType.EndElement) { if (comments.Count > 0) { foreach (var c in comments) { list.NodeSelf.AppendChild(c); } comments.Clear(); } return; } else { break; } } throw new Exception(string.Format("Unexpected {0} node in <{1}>", reader.NodeType, list.NodeSelf.Name)); }
private void ValidateRegularExpressions(SubList list, XmlDocument document, XmlReader reader) { var lastitem = list.NodeSelf; var comments = new List<XmlNode>(); while (reader.Read()) { if (reader.Depth == 2 && reader.NodeType == XmlNodeType.Element) { var item = (XmlElement)null; if (reader.IsEmptyElement && reader.AttributeCount == 2 && reader.Name == list.ItemName) { var find = reader["find"]; var repl = reader["replaceWith"]; if (!string.IsNullOrEmpty(find) && repl != null) { var key = find + "\u0000" + repl; if (list.Elements.ContainsKey(key)) { item = list.Elements[key]; _factory.Logger.Verbose(string.Format("Removed duplicate |{0}| ==> |{1}|", find, repl)); } else { list.NodeSelf.AppendChild(item = document.CreateElement(list.ItemName)); list.Elements.Add(key, item); try { _regex = new Regex(reader.Value, RegexOptions.CultureInvariant); } catch (Exception ex) { throw new Exception(string.Format("Invalid regex \"{0}\": {1}", reader.Value, ex.Message)); } item.SetAttribute("find", find); item.SetAttribute("replaceWith", repl); } } } if (item != null) { if (lastitem == null) { lastitem = item; } if (comments.Count > 0) { foreach (var c in comments) { lastitem.ParentNode.InsertBefore(c, lastitem); } comments.Clear(); } lastitem = item; } else { throw new Exception(string.Format("Invalid element <{0}…> in <{1}>", reader.Name, list.NodeSelf.Name)); } } else if (reader.Depth == 2 && reader.NodeType == XmlNodeType.Whitespace) { if (lastitem != null && reader.Value.ContainsLinefeed()) { if (comments.Count > 0) { foreach (var c in comments) { lastitem.ParentNode.InsertBefore(c, lastitem); } comments.Clear(); } lastitem = null; } } else if (reader.Depth == 2 && reader.NodeType == XmlNodeType.Comment) { comments.Add(document.CreateComment(reader.Value.ReplaceWhiteSpace(" "))); } else if (reader.Depth == 2 && reader.NodeType == XmlNodeType.CDATA) { comments.Add(document.CreateCDataSection(reader.Value.ReplaceWhiteSpace())); } else if (reader.Depth == 1 && reader.NodeType == XmlNodeType.EndElement) { if (comments.Count > 0) { foreach (var c in comments) { list.NodeSelf.AppendChild(c); } comments.Clear(); } return; } else { break; } } throw new Exception(string.Format("Unexpected {0} node in <{1}>", reader.NodeType, list.NodeSelf.Name)); }
public void UpdateAsDetailASOI(SubList model, string user_name) { AsDetailSAOIRepository.UpdateAsDetailASOI(Convert.ToInt32(model.Id), model.Rp_id, model.Prog_desc, model.Prog_organizer, model.Start_date, model.End_date, model.Income, model.Pe, model.Oc, model.Remarks, user_name); }