/// <summary> /// GetStudentUserListByYear take StudentByYear sorted list created in the main program and the student years checkedlistbox and creates a hashtable /// that will be used to look up the user list to display in the combolistbox display. /// This does not use wmi service, but is the logical place add this method. /// </summary> /// <param name="slIn"></param> /// <param name="checkListBox"></param> /// <returns>sortlist</returns> public Hashtable GetStudentUserListByYear(SortedList slIn, CheckedListBox checkListBox) { Hashtable ht = new Hashtable(); try { foreach (object itemChecked in checkListBox.CheckedItems) { ICollection keys = slIn.GetKeyList(); foreach (string s in keys) { if (s == itemChecked.ToString()) { //this is the sortedlist of students for a given year IList values = ((SortedList)slIn[s]).GetValueList(); //create the hashtable entries available students - this will be used to lookup and match students by year foreach (string name in values) { ht.Add(name.ToUpper(), name.ToUpper()); } } } } } catch (Exception e) { //re-throw exception for main calling throw new Exception("WMIPropertiesHelper", e); } return (ht); }
public override IList GetKeyList() { lock (_root) { return(_list.GetKeyList()); } }
// Get the list of keys. public override IList GetKeyList() { lock (SyncRoot) { return(new SynchronizedList(list.GetKeyList())); } }
private void GatherNamespaceToRender(string nsPrefix, SortedList nsListToRender, Hashtable nsLocallyDeclared) { int num; foreach (object obj2 in nsListToRender.GetKeyList()) { if (Utils.HasNamespacePrefix((XmlAttribute) obj2, nsPrefix)) { return; } } XmlAttribute a = (XmlAttribute) nsLocallyDeclared[nsPrefix]; XmlAttribute nearestRenderedNamespaceWithMatchingPrefix = base.GetNearestRenderedNamespaceWithMatchingPrefix(nsPrefix, out num); if (a != null) { if (Utils.IsNonRedundantNamespaceDecl(a, nearestRenderedNamespaceWithMatchingPrefix)) { nsLocallyDeclared.Remove(nsPrefix); nsListToRender.Add(a, null); } } else { int num2; XmlAttribute nearestUnrenderedNamespaceWithMatchingPrefix = base.GetNearestUnrenderedNamespaceWithMatchingPrefix(nsPrefix, out num2); if (((nearestUnrenderedNamespaceWithMatchingPrefix != null) && (num2 > num)) && Utils.IsNonRedundantNamespaceDecl(nearestUnrenderedNamespaceWithMatchingPrefix, nearestRenderedNamespaceWithMatchingPrefix)) { nsListToRender.Add(nearestUnrenderedNamespaceWithMatchingPrefix, null); } } }
internal void LoadRenderedNamespaces(SortedList nsRenderedList) { foreach (object obj2 in nsRenderedList.GetKeyList()) { this.AddRendered((XmlAttribute) obj2); } }
public void TestGetKeyValueList() { var dic1 = new SortedList(); for (int i = 0; i < 100; i++) dic1.Add("Key_" + i, "Value_" + i); var ilst1 = dic1.GetKeyList(); var hsh1 = new Hashtable(); DoIListTests(dic1, ilst1, hsh1, DicType.Key); Assert.False(hsh1.Count != 2 || !hsh1.ContainsKey("IsReadOnly") || !hsh1.ContainsKey("IsFixedSize"), "Error, KeyList"); dic1 = new SortedList(); for (int i = 0; i < 100; i++) dic1.Add("Key_" + i, "Value_" + i); ilst1 = dic1.GetValueList(); hsh1 = new Hashtable(); DoIListTests(dic1, ilst1, hsh1, DicType.Value); Assert.False(hsh1.Count != 2 || !hsh1.ContainsKey("IsReadOnly") || !hsh1.ContainsKey("IsFixedSize"), "Error, ValueList"); }
internal override void GetNamespacesToRender(XmlElement element, SortedList attrListToRender, SortedList nsListToRender, Hashtable nsLocallyDeclared) { this.GatherNamespaceToRender(element.Prefix, nsListToRender, nsLocallyDeclared); foreach (object obj2 in attrListToRender.GetKeyList()) { string prefix = ((XmlAttribute) obj2).Prefix; if (prefix.Length > 0) { this.GatherNamespaceToRender(prefix, nsListToRender, nsLocallyDeclared); } } }
static public int GetKeyList(IntPtr l) { try { System.Collections.SortedList self = (System.Collections.SortedList)checkSelf(l); var ret = self.GetKeyList(); pushValue(l, true); pushValue(l, ret); return(2); } catch (Exception e) { return(error(l, e)); } }
public static string GetIdEntidades(string familia) { //retorno un string con una lista de todos los iddeentidades de una familia determinada string aux = string.Empty; if (!_loaded) { //DeclareTypes(pathFamilia, _nameFamilia); DeclareTypes(); } if (_nameFamilia.ContainsValue(familia)) { for (int i = 0; i < _nameFamilia.Count; i++) { if (Convert.ToString(_nameFamilia.GetValueList()[i]).Equals(familia)) { aux = aux + "," + Convert.ToString(_nameFamilia.GetKeyList()[i]); } } } if (familia.Equals(string.Empty)) { for (int i = 0; i < _nameFamilia.Count; i++) { aux = aux + "," + Convert.ToString(_nameFamilia.GetKeyList()[i]); } } if (aux != null && aux != string.Empty) { return(aux.Substring(1)); //saco la primer coma } else { return(string.Empty); } }
static void Main(string[] args) { ArrayList arr = new ArrayList(); //выделяет память на 4 элемента, по мере необходимости добавляет ещё на 4 arr.Add(10); arr.Add(2); arr.Add(9); arr.Add(-2); arr.Add(15); arr.Add(8); // arr.Add("Vasya"); arr.Sort(); //Vasya не можем сравнить для сортировки с числами arr.TrimToSize(); //устанавливает нужную ёмкость Console.WriteLine("Ёмкость: "+arr.Capacity+ "; количество элементов: "+arr.Count); foreach (object item in arr) Console.Write(item + " "); int x = 5; arr[0] = x; // x = arr[0]; //так нельзя x = (int)arr[1]; Console.WriteLine("\nx = arr[1] => "+x); foreach (object item in arr) Console.Write(item + " "); Console.WriteLine("\n>>>>>>>>>>>>>"); SortedList slist = new SortedList(); slist.Add(2, 200); slist.Add(1, 300); foreach (var item in slist.GetKeyList()) Console.WriteLine(item); Console.ReadKey(); }
public static void Main(string []args) { if (args.Length < 1) { Console.WriteLine("please specify the number of p2p nodes."); Environment.Exit(0); } else if (args.Length < 2) { Console.WriteLine("please specify the number of missing edges."); Environment.Exit(0); } int base_port = 54111; int network_size = Int32.Parse(args[0]); int missing_edges_count = Int32.Parse(args[1]); string brunet_namespace = "testing"; SortedList nodes = new SortedList(); Console.WriteLine("Initializing..."); ArrayList RemoteTA = new ArrayList(); for(int i = 0; i < network_size; i++) { RemoteTA.Add(TransportAddressFactory.CreateInstance("brunet.udp://127.0.0.1:" + (base_port + i))); } Random rand = new Random(); for(int i = 0; i < network_size; i++) { Console.WriteLine("Starting node: {0}", i); AHAddress address = new AHAddress(new RNGCryptoServiceProvider()); Node node = new StructuredNode(address, brunet_namespace); ArrayList arr_tas = new ArrayList(); for(int j = 0; j < missing_edges_count; j++) { int remote_port = 0; do { remote_port = rand.Next(0, network_size - 1) + base_port; } while(remote_port == base_port + i); PortTAAuthorizer port_auth = new PortTAAuthorizer(remote_port); arr_tas.Add(port_auth); } arr_tas.Add(new ConstantAuthorizer(TAAuthorizer.Decision.Allow)); TAAuthorizer ta_auth = new SeriesTAAuthorizer(arr_tas); node.AddEdgeListener(new UdpEdgeListener(base_port + i, null, ta_auth)); node.AddEdgeListener(new Tunnel.TunnelEdgeListener(node)); node.RemoteTAs = RemoteTA; Thread t = new Thread(new ThreadStart(node.Connect)); t.Start(); nodes.Add((Address) address, node); Console.WriteLine("Sleeping for 2 seconds"); System.Threading.Thread.Sleep(2000); } //wait for 60 more seconds int count = 0; while(true) { Console.WriteLine("Going to sleep for 5 seconds."); System.Threading.Thread.Sleep(5000); Console.WriteLine("Checking ring..."); Address start_addr = (Address) nodes.GetKeyList()[0]; Address curr_addr = start_addr; for (int i = 0; i < network_size; i++) { Node node = (Node) nodes[curr_addr]; ConnectionTable con_table = node.ConnectionTable; Connection con = con_table.GetLeftStructuredNeighborOf((AHAddress) curr_addr); Console.WriteLine("Hop {2}\t Address {0}\n\t Connection to left {1}\n", curr_addr, con, i); Address next_addr = con.Address; if (next_addr == null) { Console.WriteLine("Found disconnection."); break; } Connection lc = ((Node)nodes[next_addr]).ConnectionTable.GetRightStructuredNeighborOf((AHAddress) next_addr); if( (lc == null) || !curr_addr.Equals(lc.Address)) { Address left_addr = lc.Address; Console.WriteLine(curr_addr + " != " + left_addr); Console.WriteLine("Right had edge, but left has no record of it!\n{0} != {1}", con, lc); break; } else if(next_addr.Equals(start_addr) && i != network_size -1) { Console.WriteLine("Completed circle too early. Only {0} nodes in the ring.", (i + 1)); break; } curr_addr = next_addr; } count++; if(start_addr.Equals(curr_addr)) { Console.WriteLine("Ring properly formed!"); Console.WriteLine("This only took .... {0} seconds", (count * 5)); break; } } count = 0; while(true) { Console.WriteLine("Going to sleep for 5 seconds."); System.Threading.Thread.Sleep(5000); Console.WriteLine("Checking ring..."); Address start_addr = (Address) nodes.GetKeyList()[0]; Address curr_addr = start_addr; for (int i = 0; i < network_size; i++) { Node node = (Node) nodes[curr_addr]; ConnectionTable con_table = node.ConnectionTable; Connection con = con_table.GetRightStructuredNeighborOf((AHAddress) curr_addr); Console.WriteLine("Hop {2}\t Address {0}\n\t Connection to right {1}\n", curr_addr, con, i); Address next_addr = con.Address; if (next_addr == null) { Console.WriteLine("Found disconnection."); } Connection left_con = ((Node)nodes[next_addr]).ConnectionTable.GetLeftStructuredNeighborOf((AHAddress) next_addr); if(left_con == null) { Console.WriteLine("Found disconnection."); } else if(!curr_addr.Equals(left_con.Address)) { Address left_addr = left_con.Address; Console.WriteLine(curr_addr + " != " + left_addr); Console.WriteLine("Left had edge, but right has no record of it! {0}", left_con); break; } else if(next_addr.Equals(start_addr) && i != network_size -1) { Console.WriteLine("Completed circle too early. Only " + count + " nodes in the ring."); break; } curr_addr = next_addr; } count++; if(start_addr.Equals(curr_addr)) { Console.WriteLine("Ring properly formed!"); Console.WriteLine("This only took .... {0} seconds", (count * 5)); break; } } foreach(DictionaryEntry de in nodes) { Node node = (Node)de.Value; node.Disconnect(); } }
public void TestGetValueListBasic() { StringBuilder sblMsg = new StringBuilder(99); SortedList sl2 = null; IEnumerator en = null; StringBuilder sbl3 = new StringBuilder(99); StringBuilder sbl4 = new StringBuilder(99); StringBuilder sblWork1 = new StringBuilder(99); int i3 = 0; int i = 0; int j = 0; // // Constructor: Create SortedList using this as IComparer and default settings. // sl2 = new SortedList(); // Verify that the SortedList is not null. Assert.NotNull(sl2); // Verify that the SortedList is empty. Assert.Equal(0, sl2.Count); // Testcase: Set - null key, ArgExc expected Assert.Throws<ArgumentNullException>(() => { sl2[null] = 0; }); Assert.Equal(0, sl2.Count); // Testcase: Set - null val sl2[(object)100] = (object)null; Assert.Equal(1, sl2.Count); // Testcase: vanila Set sl2[(object)100] = 1; Assert.Equal(1, sl2.Count); sl2.Clear(); Assert.Equal(0, sl2.Count); // Testcase: add key-val pairs for (i = 0; i < 100; i++) { sl2.Add(i + 100, i); } Assert.Equal(100, sl2.Count); for (i = 0; i < 100; i++) { j = i + 100; Assert.True(sl2.ContainsKey((int)j)); Assert.True(sl2.ContainsValue(i)); object o2 = sl2[(int)j]; Assert.NotNull(o2); Assert.True(o2.Equals(i), "Error, entry for key " + j.ToString() + " is " + o2.ToString() + " but should have been " + i.ToString()); } // FOR // testcase: GetValueList // ICollection.GetEnumerator() first test the boundaries on the Remove method thru GetEnumerator implementation en = (IEnumerator)sl2.GetValueList().GetEnumerator(); // Boundary for Current Assert.Throws<InvalidOperationException>(() => { object throwaway = en.Current; } ); j = 0; // go over the enumarator en = (IEnumerator)sl2.GetValueList().GetEnumerator(); while (en.MoveNext()) { // Current to see the order i3 = (int)en.Current; Assert.Equal(i3, j); // GetObject again to see the same order i3 = (int)en.Current; Assert.Equal(i3, j); j++; } // Boundary for GetObject Assert.Throws<InvalidOperationException>(() => { object throwawayobj = en.Current; } ); // Boundary for MoveNext: call MoveNext to make sure it returns false Assert.False((en.MoveNext()) || (j != 100)); // call again MoveNext to make sure it still returns false Assert.False(en.MoveNext()); Assert.Equal(100, sl2.Count); // now modify the sortedlist while enumerator is still active en = (IEnumerator)sl2.GetKeyList().GetEnumerator(); //can remove an item thru en en.MoveNext(); sl2[1] = 0; // Set (int index, object val) // this works fine // Boundary for MoveNext Assert.Throws<InvalidOperationException>(() => { en.MoveNext(); }); }
public void TestGetKeyListBasic() { StringBuilder sblMsg = new StringBuilder(99); // SortedList sl2 = null; IEnumerator en = null; StringBuilder sbl3 = new StringBuilder(99); StringBuilder sbl4 = new StringBuilder(99); StringBuilder sblWork1 = new StringBuilder(99); int i3 = 0; int i = 0; int j = 0; // // Constructor: Create SortedList using this as IComparer and default settings. // sl2 = new SortedList(); //using default IComparable implementation from Integer4 // which is used here as key-val elements. // Verify that the SortedList is not null. Assert.NotNull(sl2); // Verify that the SortedList is empty. Assert.Equal(0, sl2.Count); // Testcase: Set - null key, ArgExc expected Assert.Throws<ArgumentNullException>(() => { sl2[null] = 0; }); Assert.Equal(0, sl2.Count); // Testcase: Set - null val sl2[(Object)100] = (Object)null; Assert.Equal(1, sl2.Count); // Testcase: vanila Set sl2[(Object)100] = 1; Assert.Equal(1, sl2.Count); sl2.Clear(); Assert.Equal(0, sl2.Count); // Testcase: add key-val pairs for (i = 0; i < 100; i++) { sl2.Add(i + 100, i); } Assert.Equal(100, sl2.Count); for (i = 0; i < 100; i++) { j = i + 100; Assert.True(sl2.ContainsKey((int)j)); Assert.True(sl2.ContainsValue(i)); } // testcase: GetKeyList // first test the boundaries on the Remove method thru GetEnumerator implementation en = (IEnumerator)sl2.GetKeyList().GetEnumerator(); // Boundary for Current Assert.Throws<InvalidOperationException>(() => { Object objThrowAway = en.Current; } ); j = 100; // go over the enumarator en = (IEnumerator)sl2.GetKeyList().GetEnumerator(); while (en.MoveNext()) { // Current to see the order i3 = (int)en.Current; Assert.Equal(i3, j); // Current again to see the same order i3 = (int)en.Current; Assert.Equal(i3, j); j++; } // Boundary for Current Assert.Throws<InvalidOperationException>(() => { Object objThrowAway = en.Current; } ); // Boundary for MoveNext: call MoveNext to make sure it returns false Assert.False((en.MoveNext()) || (j != 200)); // call again MoveNext to make sure it still returns false Assert.False(en.MoveNext()); }
public void WriteHash(HashAlgorithm hash, DocPosition docPos, AncestralNamespaceContextManager anc) { byte[] bytes; Hashtable nsLocallyDeclared = new Hashtable(); SortedList nsListToRender = new SortedList(new NamespaceSortOrder()); SortedList attrListToRender = new SortedList(new AttributeSortOrder()); UTF8Encoding encoding = new UTF8Encoding(false); XmlAttributeCollection attributes = this.Attributes; if (attributes != null) { foreach (XmlAttribute attribute in attributes) { if ((((CanonicalXmlAttribute) attribute).IsInNodeSet || System.Security.Cryptography.Xml.Utils.IsNamespaceNode(attribute)) || System.Security.Cryptography.Xml.Utils.IsXmlNamespaceNode(attribute)) { if (System.Security.Cryptography.Xml.Utils.IsNamespaceNode(attribute)) { anc.TrackNamespaceNode(attribute, nsListToRender, nsLocallyDeclared); } else if (System.Security.Cryptography.Xml.Utils.IsXmlNamespaceNode(attribute)) { anc.TrackXmlNamespaceNode(attribute, nsListToRender, attrListToRender, nsLocallyDeclared); } else if (this.IsInNodeSet) { attrListToRender.Add(attribute, null); } } } } if (!System.Security.Cryptography.Xml.Utils.IsCommittedNamespace(this, this.Prefix, this.NamespaceURI)) { string name = (this.Prefix.Length > 0) ? ("xmlns:" + this.Prefix) : "xmlns"; XmlAttribute attr = this.OwnerDocument.CreateAttribute(name); attr.Value = this.NamespaceURI; anc.TrackNamespaceNode(attr, nsListToRender, nsLocallyDeclared); } if (this.IsInNodeSet) { anc.GetNamespacesToRender(this, attrListToRender, nsListToRender, nsLocallyDeclared); bytes = encoding.GetBytes("<" + this.Name); hash.TransformBlock(bytes, 0, bytes.Length, bytes, 0); foreach (object obj2 in nsListToRender.GetKeyList()) { (obj2 as CanonicalXmlAttribute).WriteHash(hash, docPos, anc); } foreach (object obj3 in attrListToRender.GetKeyList()) { (obj3 as CanonicalXmlAttribute).WriteHash(hash, docPos, anc); } bytes = encoding.GetBytes(">"); hash.TransformBlock(bytes, 0, bytes.Length, bytes, 0); } anc.EnterElementContext(); anc.LoadUnrenderedNamespaces(nsLocallyDeclared); anc.LoadRenderedNamespaces(nsListToRender); foreach (XmlNode node in this.ChildNodes) { CanonicalizationDispatcher.WriteHash(node, hash, docPos, anc); } anc.ExitElementContext(); if (this.IsInNodeSet) { bytes = encoding.GetBytes("</" + this.Name + ">"); hash.TransformBlock(bytes, 0, bytes.Length, bytes, 0); } }
/// <summary> /// Uses the yearByStudentSL sorted list of years with array of all students within that year. Will display all the Year keys as items in the CheckedListBox /// </summary> /// <param name="slIn"></param> private void DisplayStudentClassCheckedListBox(SortedList slIn) { //clear the existing values this.checkedListBox1.Items.Clear(); //IList values = slIn.GetValueList(); ICollection keys = slIn.GetKeyList(); foreach (string s in keys) { this.checkedListBox1.Items.Add(s); } }
private StringCollection GetInterfacesInNamespace(string ANamespace, SortedList AInterfaceNames) { // get all the interfaces in the current namespace StringCollection InterfacesInNamespace = new StringCollection(); foreach (String InterfaceName in AInterfaceNames.GetKeyList()) { // see if the class that is implementing the interface is in the current namespace (considering the difference of Shared and Server) if ((AInterfaceNames[InterfaceName].ToString().Substring(0, AInterfaceNames[InterfaceName].ToString().LastIndexOf(".")).Replace("Instantiator.", "") == ANamespace.Replace("Ict.Petra.Shared.Interfaces", "Ict.Petra.Server")) /*&& (InterfaceName != "I" + ANamespace + "Namespace")*/) { InterfacesInNamespace.Add(InterfaceName); } } return InterfacesInNamespace; }
private void GatherNamespaceToRender(string nsPrefix, SortedList nsListToRender, Hashtable nsLocallyDeclared) { foreach (object a in nsListToRender.GetKeyList()) { if (Utils.HasNamespacePrefix((XmlAttribute) a, nsPrefix)) return; } int rDepth; XmlAttribute local = (XmlAttribute) nsLocallyDeclared[nsPrefix]; XmlAttribute rAncestral = GetNearestRenderedNamespaceWithMatchingPrefix(nsPrefix, out rDepth); if (local != null) { if (Utils.IsNonRedundantNamespaceDecl(local, rAncestral)) { nsLocallyDeclared.Remove(nsPrefix); nsListToRender.Add(local, null); } } else { int uDepth; XmlAttribute uAncestral = GetNearestUnrenderedNamespaceWithMatchingPrefix(nsPrefix, out uDepth); if (uAncestral != null && uDepth > rDepth && Utils.IsNonRedundantNamespaceDecl(uAncestral, rAncestral)) { nsListToRender.Add(uAncestral, null); } } }
/// <summary> /// create <see cref="SwfOp.ByteCode.Actions.ActionLabel">ActionLabel</see> pseudo actions for branch labels /// </summary> private void CreateBranchLabels(ArrayList actionRecord) { SortedList labelList = new SortedList(); int idx = 0; while (idx<actionRecord.Count) { // read action BaseAction a = (BaseAction) actionRecord[idx]; // check if action is branch if (a as IJump!=null) { IJump jump = (IJump) a; int offset = jump.Offset; int sidx = idx; if (offset<0) { // back branch offset+=a.ByteCount; while (offset<0) { sidx--; if (sidx<0) break; BaseAction ac = (BaseAction) actionRecord[sidx]; offset+=ac.ByteCount; } if (!labelList.ContainsKey(sidx)) { this.LabelId ++; labelList[sidx] = this.LabelId; jump.LabelId = this.LabelId; } else { jump.LabelId = (int)labelList[sidx]; } } else { if (offset==0) { sidx = idx+1; if (!labelList.ContainsKey(sidx)) { this.LabelId ++; labelList[sidx] = this.LabelId; jump.LabelId = this.LabelId; } else { jump.LabelId = (int)labelList[sidx]; } } else { // offset>0 do { sidx++; if (sidx>=actionRecord.Count) break; BaseAction ac = (BaseAction) actionRecord[sidx]; offset-=ac.ByteCount; } while (offset>0); sidx++; if (!labelList.ContainsKey(sidx)) { this.LabelId ++; labelList[sidx] = this.LabelId; jump.LabelId = this.LabelId; } else { jump.LabelId = (int)labelList[sidx]; } } } } idx++; } ArrayList lines = new ArrayList(labelList.GetKeyList()); foreach (int line in lines) { int label = (int)labelList[line]; if (line<actionRecord.Count) { BaseAction a = (BaseAction)actionRecord[line]; actionRecord[line] = new ActionContainer( new BaseAction[2] { new ActionLabel(label), a } ); } else { actionRecord.Add(new ActionLabel(label)); } } idx=0; while (idx<actionRecord.Count) { BaseAction a = (BaseAction) actionRecord[idx]; if (a is ActionContainer) { BaseAction[] bl = ((ActionContainer)a).ActionList; actionRecord.RemoveAt(idx); int j=0; while (j<bl.Length) { actionRecord.Insert(idx,bl[j]); j++; idx++; } continue; } idx++; } }
internal void LoadRenderedNamespaces(SortedList nsRenderedList) { foreach (object attr in nsRenderedList.GetKeyList()) { AddRendered((XmlAttribute) attr); } }
private int Save5000GuideAsXML(bool shareReceived, bool showHDTV) { XmlTextWriter writer = new XmlTextWriter(this.guideXMLFile, Encoding.UTF8); writer.Formatting = Formatting.Indented; writer.WriteStartElement("result"); int[] numArray = new int[] { 0, 0 }; FileStream stream = File.OpenRead(this.guideFile); byte[] array = new byte[(int) stream.Length]; stream.Read(array, 0, (int) stream.Length); stream.Close(); bool flag = true; SortedList categoryList = new SortedList(); categoryList = this.Build5000Categories(array); writer.WriteStartElement("category-list"); for (int i = 0; i < categoryList.Count; i++) { writer.WriteStartElement("category"); writer.WriteAttributeString("categoryID", null, categoryList.GetKey(i).ToString()); writer.WriteAttributeString("categoryName", null, categoryList.GetByIndex(i).ToString()); writer.WriteEndElement(); } writer.WriteEndElement(); SortedList list2 = new SortedList(); list2 = this.Build5000Channels(array, categoryList); writer.WriteStartElement("channel-list"); try { int num2 = 0; int length = array.Length; int num4 = length - (840 + (0x2c8 * ReplayHelper.ReplayByteToInt(array, 0x10, 4))); byte[] destinationArray = new byte[num4]; byte[] buffer3 = new byte[0x200]; Array.Copy(array, 840 + (0x2c8 * ReplayHelper.ReplayByteToInt(array, 0x10, 4)), destinationArray, 0, num4); byte[] buffer4 = null; byte[] buffer5 = null; byte[] buffer6 = null; for (int j = 0; (num4 - (0x200 * j)) >= 0x200; j++) { string text5; Array.Copy(destinationArray, 0x200 * j, buffer3, 0, 0x200); DateTime time = new DateTime(0x7b2, 1, 1, 0, 0, 0, 0); long num6 = ReplayHelper.ReplayByteToLong(buffer3, 120, 4); int num7 = 0; if ((num6 & 0x40) > 0) { num7 += 4; } if ((num6 & 0x20) > 0) { num7 += 8; } int num8 = ReplayHelper.ReplayByteToInt(buffer3, 0, 4); int num9 = ReplayHelper.ReplayByteToInt(buffer3, 4, 4); buffer4 = new byte[ReplayHelper.ReplayByteToInt(buffer3, 140, 1) - 1]; buffer5 = new byte[ReplayHelper.ReplayByteToInt(buffer3, 0x8d, 1) - 1]; buffer6 = new byte[ReplayHelper.ReplayByteToInt(buffer3, 0x8e, 1) - 1]; int qualityCode = ReplayHelper.ReplayByteToInt(buffer3, 12, 4); string quality = this.GetQuality(qualityCode); int num11 = ReplayHelper.ReplayByteToInt(buffer3, 0x188, 4); int num12 = num11 / 60; if ((num11 % 60) >= 30) { num12++; } string text2 = num12.ToString(); int num13 = ReplayHelper.ReplayByteToInt(buffer3, 0x7c, 4); int num14 = ReplayHelper.ReplayByteToInt(buffer3, 380, 4); int num15 = ReplayHelper.ReplayByteToInt(buffer3, 0x184, 4); string text3 = time.AddSeconds((double) num13).ToString("yyyy-MM-dd HH:mm:ss.000", DateTimeFormatInfo.InvariantInfo); Array.Copy(buffer3, 0x94 + num7, buffer4, 0, buffer4.Length); Array.Copy(buffer3, ((0x94 + num7) + buffer4.Length) + 1, buffer5, 0, buffer5.Length); Array.Copy(buffer3, ((((0x94 + num7) + buffer4.Length) + 1) + buffer5.Length) + 1, buffer6, 0, buffer6.Length); ReplayChannelGuide guide = (ReplayChannelGuide) list2[num8]; string channelTitle = guide.channelTitle; switch (guide.channelType) { case 1: text5 = "Recurring"; break; case 2: text5 = "Theme"; break; case 3: text5 = "Single"; break; case 4: text5 = "Zone"; break; default: text5 = ""; break; } int channelCategory = guide.channelCategory; string channelCatName = guide.channelCatName; string text7 = ReplayHelper.ReplaceUTF8InString(this.encoding.GetString(buffer4)); string text8 = ReplayHelper.ReplaceUTF8InString(this.encoding.GetString(buffer6)); string text9 = ReplayHelper.ReplaceUTF8InString(this.encoding.GetString(buffer5)); if (shareReceived || ((num14 == 0) && (num15 < 15))) { if (num8 != num2) { if (flag) { flag = false; } else { writer.WriteEndElement(); } writer.WriteStartElement("channel"); writer.WriteAttributeString("title", null, channelTitle); writer.WriteAttributeString("channelID", null, num8.ToString()); writer.WriteAttributeString("channelType", null, text5); writer.WriteAttributeString("categoryID", null, channelCategory.ToString()); writer.WriteAttributeString("categoryName", null, channelCatName); guide.channelDone = true; } writer.WriteStartElement("show"); if (shareReceived && (num14 != 0)) { writer.WriteAttributeString("title", null, text7); } else if (text5.Equals("Single") || text5.Equals("Recurring")) { writer.WriteAttributeString("title", null, channelTitle); } else { writer.WriteAttributeString("title", null, text7); } writer.WriteAttributeString("description", null, text8); if (!showHDTV && text9.StartsWith("(HDTV) ")) { text9 = text9.Remove(0, 7); } if (text9.Equals("")) { if (text8.Equals("")) { writer.WriteAttributeString("episodeTitle", null, text7); } else { if (text8.Length > 0x23) { text8 = text8.Substring(0, 0x20); if (text8.LastIndexOf(" ") >= 0) { text8 = text8.Substring(0, text8.LastIndexOf(" ")) + "..."; } } writer.WriteAttributeString("episodeTitle", null, text8); } } else { writer.WriteAttributeString("episodeTitle", null, text9); } writer.WriteAttributeString("startTimeGMT", null, text3); writer.WriteAttributeString("durationInMinutes", null, text2); writer.WriteAttributeString("quality", null, quality); writer.WriteAttributeString("showID", null, num9.ToString()); writer.WriteEndElement(); } num2 = num8; } if (!flag) { writer.WriteEndElement(); } IList keyList = list2.GetKeyList(); for (int k = 0; k < list2.Count; k++) { string text11; ReplayChannelGuide guide2 = (ReplayChannelGuide) list2[keyList[k]]; string text10 = guide2.channelTitle; switch (guide2.channelType) { case 1: text11 = "Recurring"; break; case 2: text11 = "Theme"; break; case 3: text11 = "Single"; break; case 4: text11 = "Zone"; break; default: text11 = ""; break; } int num18 = guide2.channelCategory; string text12 = guide2.channelCatName; if (!guide2.channelDone) { writer.WriteStartElement("channel"); writer.WriteAttributeString("title", null, text10); writer.WriteAttributeString("channelID", null, keyList[k].ToString()); writer.WriteAttributeString("channelType", null, text11); writer.WriteAttributeString("categoryID", null, num18.ToString()); writer.WriteAttributeString("categoryName", null, text12); writer.WriteEndElement(); } } writer.WriteEndElement(); writer.WriteEndElement(); } catch (Exception exception) { ReplayLogger.Log("Save5000GuideAsXML Exception" + exception.ToString()); if (!flag) { writer.WriteEndElement(); } writer.WriteEndElement(); writer.WriteEndElement(); writer.Flush(); writer.Close(); return -1; } writer.Flush(); writer.Close(); return 1; }
public void WriteHash(HashAlgorithm hash, DocPosition docPos, AncestralNamespaceContextManager anc) { Hashtable nsLocallyDeclared = new Hashtable(); SortedList nsListToRender = new SortedList(new NamespaceSortOrder()); SortedList attrListToRender = new SortedList(new AttributeSortOrder()); UTF8Encoding utf8 = new UTF8Encoding(false); byte[] rgbData; XmlAttributeCollection attrList = this.Attributes; if (attrList != null) { foreach (XmlAttribute attr in attrList) { if (((CanonicalXmlAttribute) attr).IsInNodeSet || Utils.IsNamespaceNode(attr) || Utils.IsXmlNamespaceNode(attr)) { if (Utils.IsNamespaceNode(attr)) { anc.TrackNamespaceNode(attr, nsListToRender, nsLocallyDeclared); } else if (Utils.IsXmlNamespaceNode(attr)) { anc.TrackXmlNamespaceNode(attr, nsListToRender, attrListToRender, nsLocallyDeclared); } else if(IsInNodeSet) { attrListToRender.Add(attr, null); } } } } if (!Utils.IsCommittedNamespace(this, this.Prefix, this.NamespaceURI)) { string name = ((this.Prefix.Length > 0) ? "xmlns" + ":" + this.Prefix : "xmlns"); XmlAttribute nsattrib = (XmlAttribute) this.OwnerDocument.CreateAttribute(name); nsattrib.Value = this.NamespaceURI; anc.TrackNamespaceNode(nsattrib, nsListToRender, nsLocallyDeclared); } if (IsInNodeSet) { anc.GetNamespacesToRender(this, attrListToRender, nsListToRender, nsLocallyDeclared); rgbData = utf8.GetBytes("<" + this.Name); hash.TransformBlock(rgbData, 0, rgbData.Length, rgbData, 0); foreach (object attr in nsListToRender.GetKeyList()) { (attr as CanonicalXmlAttribute).WriteHash(hash, docPos, anc); } foreach (object attr in attrListToRender.GetKeyList()) { (attr as CanonicalXmlAttribute).WriteHash(hash, docPos, anc); } rgbData = utf8.GetBytes(">"); hash.TransformBlock(rgbData, 0, rgbData.Length, rgbData, 0); } anc.EnterElementContext(); anc.LoadUnrenderedNamespaces(nsLocallyDeclared); anc.LoadRenderedNamespaces(nsListToRender); XmlNodeList childNodes = this.ChildNodes; foreach (XmlNode childNode in childNodes) { CanonicalizationDispatcher.WriteHash(childNode, hash, docPos, anc); } anc.ExitElementContext(); if (IsInNodeSet) { rgbData = utf8.GetBytes("</" + this.Name + ">"); hash.TransformBlock(rgbData, 0, rgbData.Length, rgbData, 0); } }