public TransmissionRfGraphic(string key, XmlElement elementData, System.Collections.Generic.SortedList <string, Variable> variables) : base(key) { this.Surface.Blit(new Surface(TransmissionRf.GraphicIcon)); foreach (XmlElement nodo in elementData) { switch (nodo.Name) { case "position": this.Center = new Point(System.Convert.ToInt32(nodo.ChildNodes[0].InnerText), System.Convert.ToInt32(nodo.ChildNodes[1].InnerText)); break; case "properties": this.element = new TransmissionRfAction(key, nodo, variables); break; case "previous": break; case "nextTrue": break; case "nextFalse": break; default: throw new GraphException("Error al crear GraphStart"); } } }
/// <summary> /// Creates an object that translates the parameters used for external methods to parameters for internal methods. /// </summary> public DestroyParameterMatrix(TableSchema tableSchema) { // Initialize the object. this.ExternalParameterItems = new SortedList <string, ExternalParameterItem>(); // Every set of update parameters requires a unique key to identify the record that is to be updated. UniqueConstraintParameterItem primaryKeyParameterItem = new UniqueConstraintParameterItem(); primaryKeyParameterItem.ActualDataType = typeof(System.Object[]); primaryKeyParameterItem.DeclaredDataType = typeof(System.Object[]); primaryKeyParameterItem.Description = string.Format("The required key for the {0} table.", tableSchema.Name); primaryKeyParameterItem.FieldDirection = FieldDirection.In; primaryKeyParameterItem.Name = string.Format("{0}Key", CommonConversion.ToCamelCase(tableSchema.Name)); this.ExternalParameterItems.Add(primaryKeyParameterItem.Name, primaryKeyParameterItem); // This will create an interface for the 'Destroy' method. foreach (KeyValuePair <string, ColumnSchema> columnPair in tableSchema.Columns) { // This column is turned into a simple parameter. ColumnSchema columnSchema = columnPair.Value; // The row version is required for the optimistic concurrency checking that is part of all update operations. if (columnSchema.IsRowVersion) { SimpleParameterItem simpleParameterItem = new SimpleParameterItem(); simpleParameterItem.ActualDataType = columnSchema.DataType; simpleParameterItem.ColumnSchema = columnSchema; simpleParameterItem.DeclaredDataType = columnSchema.DataType; simpleParameterItem.Description = string.Format("The required value for the {0} column.", CommonConversion.ToCamelCase(columnSchema.Name)); simpleParameterItem.FieldDirection = FieldDirection.In; simpleParameterItem.Name = CommonConversion.ToCamelCase(columnSchema.Name); this.ExternalParameterItems.Add(simpleParameterItem.Name, simpleParameterItem); } } }
/// <summary> /// ''' List the devices of a given device type that are registered in the Profile store /// ''' </summary> /// ''' <param name="DeviceType">Type of devices to list</param> /// ''' <returns>An ArrayList of installed devices and associated device descriptions</returns> /// ''' <exception cref="Exceptions.InvalidValueException">Throw if the supplied DeviceType is empty string or /// ''' null value.</exception> /// ''' <remarks> /// ''' Use this to find all the registered devices of a given type that are in the Profile store /// ''' <para>If a DeviceType is supplied, where no device of that type has been registered before on this system, /// ''' an empty list will be returned</para> /// ''' </remarks> public ArrayList RegisteredDevices(string DeviceType) { System.Collections.Generic.SortedList <string, string> RegDevs = null; ArrayList RetVal = new ArrayList(); if (string.IsNullOrEmpty(DeviceType)) { TL.LogMessage("RegisteredDevices", "Empty string or Nothing supplied as DeviceType"); throw new Exceptions.InvalidValueException("Empty string or Nothing supplied as DeviceType"); } try { RegDevs = ProfileStore.EnumKeys(DeviceType + " Drivers"); // Get Key-Class pairs } catch (NullReferenceException ex) { TL.LogMessage("RegisteredDevices", "WARNING: there are no devices of type: \"" + DeviceType + "\" registered on this system"); RegDevs = new System.Collections.Generic.SortedList <string, string>(); }// Return an empty list TL.LogMessage("RegisteredDevices", "Device type: " + DeviceType + " - found " + RegDevs.Count + " devices"); foreach (System.Collections.Generic.KeyValuePair <string, string> kvp in RegDevs) { TL.LogMessage("RegisteredDevices", " " + kvp.Key + " - " + kvp.Value); RetVal.Add(new KeyValuePair(kvp.Key, kvp.Value)); } return(RetVal); }
internal NetworkHost(IPAddress ipAddress) { this.ipAddress = ipAddress; this.macAddress = null; this.recentMacAdresses = new PopularityList <string, PhysicalAddress>(255); this.ttlCount = new SortedList <byte, int>(); this.ttlDistanceCount = new SortedList <byte, int>(); this.operatingSystemCounterList = new SortedList <string, SortedList <string, double> >(); this.hostNameList = new List <string>(); this.domainNameList = new List <string>(); this.openTcpPortList = new List <ushort>(); this.networkServiceMetadataList = new SortedList <ushort, NetworkServiceMetadata>(); this.sentPackets = new NetworkPacketList(); this.receivedPackets = new NetworkPacketList(); this.incomingSessionList = new List <NetworkTcpSession>(); this.outgoingSessionList = new List <NetworkTcpSession>(); this.queriedIpList = new List <IPAddress>(); this.queriedNetBiosNameList = new List <string>(); this.queriedDnsNameList = new List <string>(); this.httpUserAgentBannerList = new List <string>(); this.httpServerBannerList = new List <string>(); this.ftpServerBannerList = new List <string>(); this.dhcpVendorCodeList = new List <string>(); this.extraDetailsList = new SortedList <string, string>(); this.universalPlugAndPlayFieldList = null;//I could just as well set this to null 'cause it is not often used. I'll initialize it when it is needed. this.acceptedSmbDialectsList = null; this.preferredSmbDialect = null; }
/// <summary> /// Sort the index of SequenceAlignmentMap by RName then by Pos. /// Fill the index (sorted by RName then by Pos) into a list, when the list size reaches /// the maximum limit, write the list to file and clear the list. /// </summary> private SortedDictionary <string, IList <string> > SortByChromosomeCoordinates() { SortedDictionary <string, IList <string> > sortedFiles = new SortedDictionary <string, IList <string> >(); IList <string> files = null; var groups = new System.Collections.Generic.SortedList <string, System.Collections.Generic.SortedList <object, string> >(); System.Collections.Generic.SortedList <object, string> sortedList = null; for (int index = 0; index < sequenceAlignMap.QuerySequences.Count; index++) { SAMAlignedSequence alignedSeq = sequenceAlignMap.QuerySequences[index]; if (!groups.TryGetValue(alignedSeq.RName, out sortedList)) { sortedList = new System.Collections.Generic.SortedList <object, string>(); groups.Add(alignedSeq.RName, sortedList); } string indices = string.Empty; if (!sortedList.TryGetValue(alignedSeq.Pos, out indices)) { sortedList.Add(alignedSeq.Pos, index.ToString(CultureInfo.InvariantCulture)); } else { indices = string.Format(CultureInfo.InvariantCulture, "{0},{1}", indices, index.ToString(CultureInfo.InvariantCulture)); sortedList[alignedSeq.Pos] = indices; } if (sortedList.Count >= SortedListMaxCount) { if (!sortedFiles.TryGetValue(alignedSeq.RName, out files)) { files = new List <string>(); sortedFiles.Add(alignedSeq.RName, files); } files.Add(WriteToFile(sortedList)); sortedList.Clear(); } } foreach (KeyValuePair <string, System.Collections.Generic.SortedList <object, string> > group in groups) { if (group.Value.Count > 0) { if (!sortedFiles.TryGetValue(group.Key, out files)) { files = new List <string>(); sortedFiles.Add(group.Key, files); } files.Add(WriteToFile(group.Value)); group.Value.Clear(); } } return(sortedFiles); }
public static void DumpOpcodes() { var files = System.IO.Directory.GetFiles(@"E:\HFS\WOWDEV\SNIFFS_CLEAN\", "*.sqlite", System.IO.SearchOption.AllDirectories).OrderBy(t => t); var versionOpcodeList = new System.Collections.Generic.SortedList<uint, ClientBuildCache>(); foreach (var file in files) { uint clientBuild = 0; using (var con = new System.Data.SQLite.SQLiteConnection("Data Source=" + file)) { con.Open(); using (var sqlcommand = con.CreateCommand()) { sqlcommand.CommandText = "select key, value from header where key = 'clientBuild'"; var reader = sqlcommand.ExecuteReader(); while (reader.Read()) { clientBuild = (uint)reader.GetInt32(1); break; } } if (!versionOpcodeList.ContainsKey(clientBuild)) { versionOpcodeList.Add(clientBuild, new ClientBuildCache() { ClientBuild = clientBuild, OpcodeList = new List<OpcodeCache>() }); } var clientBuildOpcodes = versionOpcodeList[clientBuild]; using (var sqlcommand = con.CreateCommand()) { sqlcommand.CommandText = "select distinct opcode, direction from packets order by opcode , direction"; var reader = sqlcommand.ExecuteReader(); while (reader.Read()) { var opcode = (uint)reader.GetInt32(0); var direction = (byte)reader.GetInt32(1); if (!clientBuildOpcodes.OpcodeList.Exists(t => t.Opcode == opcode && t.Direction == direction)) clientBuildOpcodes.OpcodeList.Add(new OpcodeCache() { Direction = direction, Opcode = opcode }); } } con.Close(); } } var clientBuildOpcodeList = versionOpcodeList.Select(t => t.Value).ToList(); clientBuildOpcodeList.SaveObject("clientBuildOpcodeList.xml"); }
public SortedViewableList(IEditableList <T> list, Func <T, TKey> keySelector) : base(list) { FSortedList = new System.Collections.Generic.SortedList <TKey, T>(); FKeySelector = keySelector; foreach (var item in list) { FSortedList.Add(FKeySelector(item), item); } }
public static string LargestNumberFromArray(int[] vs) { var sl = new System.Collections.Generic.SortedList <string, int>(new LargestComparer()); foreach (var v in vs) { sl.Add(v.ToString(), v); } return(String.Join("", sl.Values.Select(v => v.ToString()))); }
public PopularityList(int minPoolSize, int maxPoolSize, ListCanExpand listCanExpandDelegate) { this.minPoolSize = minPoolSize; this.maxPoolSize = maxPoolSize; this.currentPoolSize = this.minPoolSize; this.listCanExpandDelegate = listCanExpandDelegate; this.sortedList = new SortedList <TKey, LinkedListNode <KeyValuePair <TKey, TValue> > >(); //this.sortedList = new Dictionary<TKey, LinkedListNode<KeyValuePair<TKey, TValue>>>(); this.linkedList = new LinkedList <KeyValuePair <TKey, TValue> >(); }
public void listen(object stateInfo) { myTimer.Change(System.Threading.Timeout.Infinite, System.Threading.Timeout.Infinite); try { if (!isEnabled | !runFlag) { return; } if (readSmtp) { GlobalShared.Log.Log((int)LogClass.logType.Info, "Checking for SMTP messages", false); System.Collections.Generic.SortedList <string, Rfc822Message> messages = getSmtpMessages(); if ((messages != null)) { if (messages.Count > 0) { GlobalShared.Log.Log((int)LogClass.logType.Info, "About to process messages", false); foreach (KeyValuePair <string, Rfc822Message> msg in messages) { if (!string.IsNullOrEmpty(UtilFunctions.findIssueTag(msg.Value))) { processMessage(msg); } if (!runFlag | !isEnabled) { break; // TODO: might not be correct. Was : Exit For } } } } else { GlobalShared.Log.Log((int)LogClass.logType.Info, "No SMTP messages found", false); } } else { GlobalShared.Log.Log((int)LogClass.logType.Info, "readSmtp=" + readSmtp, false); } if (readOutlook) { GlobalShared.Log.Log((int)LogClass.logType.Info, "Checking for Outlook messages", false); getOutlookMessages(); } } catch (System.IO.FileNotFoundException ex) { GlobalShared.Log.Log((int)LogClass.logType.ErrorCondition, ex.Message, false); } catch (System.IO.IOException ex) { GlobalShared.Log.Log((int)LogClass.logType.ErrorCondition, ex.Message, false); } catch (System.Exception ex) { GlobalShared.Log.Log((int)LogClass.logType.ErrorCondition, ex.Message, false); } myTimer.Change(RETRIEVE_MAIL_INTERVAL, RETRIEVE_MAIL_INTERVAL); }
/// <summary> /// Looks for a key in the array of key/values of the parameter string. If not found, return the specified default value /// </summary> /// <param name="items">The list to look in</param> /// <param name="key">The key to find</param> /// <param name="defValue">The default value to return if the key is not found</param> /// <returns>The value corresponding to the specified key, or the default value if not found.</returns> static internal string FindKey(System.Collections.Generic.SortedList <string, string> items, string key, string defValue) { string ret; if (items.TryGetValue(key, out ret)) { return(ret); } return(defValue); }
internal TcpDataStream(uint initialTcpSequenceNumber, ushort sourcePort, ushort destinationPort, NetworkTcpSession session) { this.initialTcpSequenceNumber = initialTcpSequenceNumber; this.expectedTcpSequenceNumber = initialTcpSequenceNumber; this.sourcePort = sourcePort; this.destinationPort = destinationPort; this.dataList = new SortedList <uint, byte[]>(); this.dataListMaxSize = 64;//i hope I shouldn't need more than 64 packets in the list. It depends on how late a misordered packet might get received. Smaller number gives better performance, larger number gives better tolerance to reordered packets this.totalByteCount = 0; this.virtualTcpData = null; this.session = session; }
/// <summary> /// Creates an object that translates the parameters used for external methods to parameters for internal methods. /// </summary> public UpdateParameterMatrix(TableSchema tableSchema) { // Initialize the object. this.ExternalParameterItems = new SortedList <string, ExternalParameterItem>(); // Every set of update parameters requires a unique key to identify the record that is to be updated. UniqueConstraintParameterItem primaryKeyParameterItem = new UniqueConstraintParameterItem(); primaryKeyParameterItem.ActualDataType = typeof(System.Object[]); primaryKeyParameterItem.DeclaredDataType = typeof(System.Object[]); primaryKeyParameterItem.Description = string.Format("The required key for the {0} table.", tableSchema.Name); primaryKeyParameterItem.FieldDirection = FieldDirection.In; primaryKeyParameterItem.Name = string.Format("{0}Key", CommonConversion.ToCamelCase(tableSchema.Name)); this.ExternalParameterItems.Add(primaryKeyParameterItem.Name, primaryKeyParameterItem); // This will create an interface for the 'Update' method. foreach (KeyValuePair <string, ColumnSchema> columnPair in tableSchema.Columns) { // This column is turned into a simple parameter. ColumnSchema columnSchema = columnPair.Value; // If a column requires special processing, it is not handled with the rest of the parameters. bool isOrdinaryColumn = true; // The row version is required for the optimistic concurrency checking that is part of all update operations. if (columnSchema.IsRowVersion) { isOrdinaryColumn = false; SimpleParameterItem simpleParameterItem = new SimpleParameterItem(); simpleParameterItem.ActualDataType = columnSchema.DataType; simpleParameterItem.ColumnSchema = columnSchema; simpleParameterItem.DeclaredDataType = columnSchema.DataType; simpleParameterItem.Description = string.Format("The required value for the {0} column.", CommonConversion.ToCamelCase(columnSchema.Name)); simpleParameterItem.FieldDirection = FieldDirection.In; simpleParameterItem.Name = CommonConversion.ToCamelCase(columnSchema.Name); this.ExternalParameterItems.Add(simpleParameterItem.Name, simpleParameterItem); } // Ordinary parameters are passed from the external caller to the internal methods without modification or // interpretation. if (isOrdinaryColumn) { SimpleParameterItem simpleParameterItem = new SimpleParameterItem(); simpleParameterItem.ActualDataType = columnSchema.DataType; simpleParameterItem.ColumnSchema = columnSchema; simpleParameterItem.DeclaredDataType = typeof(System.Object); simpleParameterItem.Description = string.Format("The optional value for the {0} column.", CommonConversion.ToCamelCase(columnSchema.Name)); simpleParameterItem.FieldDirection = FieldDirection.In; simpleParameterItem.Name = CommonConversion.ToCamelCase(columnSchema.Name); this.ExternalParameterItems.Add(simpleParameterItem.Name, simpleParameterItem); } } }
static void Sort(string inputdir = "", string outputdir = ".\\output") { Console.WriteLine("Hashing " + inputdir); System.Timers.Timer t = new System.Timers.Timer(5000); t.Elapsed += T_Elapsed; DateTime start = DateTime.Now; t.Start(); (ConcurrentDictionary <string, Digest> gilePathsToHashes, ConcurrentDictionary <Digest, HashSet <string> > hashesToFiles) = GetHashes( dirPath: inputdir, searchPattern: "*.png"); t.Stop(); DateTime stop = DateTime.Now; Console.WriteLine("Hashed " + hashesToFiles.Count + "images in " + (start.Ticks - stop.Ticks) / 1000 + "s."); Console.WriteLine("Sorting " + inputdir); t.Elapsed -= T_Elapsed; t.Elapsed += T_Elapsed1; t.Start(); start = DateTime.Now; SortedList <string, Digest> sortedPaths = new System.Collections.Generic.SortedList <string, Digest>(gilePathsToHashes.Count); foreach (var item in gilePathsToHashes) { sortedPaths.Add(item.Key.ToString(), item.Value); } stop = DateTime.Now; t.Stop(); Console.WriteLine("Sorted " + sortedPaths.Count + "images in " + (start.Ticks - stop.Ticks) / 1000 + "s."); Console.WriteLine("Writing output files " + inputdir); t.Elapsed -= T_Elapsed1; t.Elapsed += T_Elapsed2; t.Start(); start = DateTime.Now; int i = 1; foreach (var item in sortedPaths) { if (File.Exists(outputdir + "\\" + i + ".png")) { File.Delete(outputdir + "\\" + i + ".png"); } File.Copy(item.Key, outputdir + "\\" + i++ + ".png"); } stop = DateTime.Now; t.Stop(); Console.WriteLine("Copied " + sortedPaths.Count + "images in " + (start.Ticks - stop.Ticks) / 1000 + "s."); }
private SortedList <string, Rfc822Message> getOutlookMessages() { System.Collections.Generic.SortedList <string, Rfc822Message> messages = new System.Collections.Generic.SortedList <string, Rfc822Message>(); //Dim tempApp As Outlook.Application //Dim tempInbox As Outlook.MAPIFolder //Dim InboxItems As Outlook.Items //Dim tempMail As Object = Nothing //Dim objattachments, objAttach RDOSession session = null; //object inbox = null; try { //tempApp = New Outlook.Application session = (RDOSession)Interaction.CreateObject("Redemption.RDOSession"); session.Logon(); } catch (System.Exception ex) { GlobalShared.Log.Log((int)LogClass.logType.ErrorCondition, "Unable to create Outlook object: " + ex.Message, false); return(null); } //tempInbox = tempApp.GetNamespace("Mapi").GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox) RDOFolder inbox = session.GetDefaultFolder(rdoDefaultFolders.olFolderInbox); //InboxItems = tempInbox.Items //Dim msg As Outlook.MailItem foreach (MailItem msg in inbox.Items) { //For Each msg In InboxItems if (!string.IsNullOrEmpty(UtilFunctions.findIssueTag((Rfc822Message)msg).Trim())) { if (!UtilFunctions.searchUID(msg.EntryID)) { // No. Add to list messages.Add(msg.EntryID, (Rfc822Message)msg); } } if (!runFlag | !isEnabled) { break; // TODO: might not be correct. Was : Exit For } } session.Logoff(); string cnt = messages.Count.ToString(); cnt += " Outlook messages were found"; GlobalShared.Log.Log((int)LogClass.logType.Info, cnt, false); return(messages); }
internal SmbSession(System.Net.IPAddress serverIP, ushort serverTcpPort, System.Net.IPAddress clientIP, ushort clientTcpPort) { this.serverIP = serverIP; this.serverTcpPort = serverTcpPort; this.clientIP = clientIP; this.clientTcpPort = clientTcpPort; this.lastReferencedFileIdPerTreeMux = new SortedList <uint, ushort>(); this.lastReferencedFileIdPerPidMux = new SortedList <uint, ushort>(); this.fileIdAssemblerList = new PopularityList <ushort, FileTransfer.FileStreamAssembler>(100); }
/// <summary> /// Temp: turn context1:value1,context2:value2,... into a dict /// </summary> static void AddColumnColonToDictionary(System.Collections.Generic.SortedList <string, string> facts, string input) { string[] pairs = input.Split(','); foreach (string p in pairs) { string[] kv = p.Split(':'); if (kv.Length >= 2) { facts.Add(kv[0], kv[1]); } } }
public async Task <System.Collections.Generic.SortedList <string, string> > GetHeaderAsync() { return(await Task.Run(() => { var list = new System.Collections.Generic.SortedList <string, string>(); list.Add("appkey", _AppKey); list.Add("apptoken", AppToken); list.Add("noncestr", Guid.NewGuid().ToString("N")); list.Add("usertoken", _UserToken); var sign = GetSign(list); list.Add("sign", sign); return list; })); }
public PlaySoundAction(string key, XmlElement properties, System.Collections.Generic.SortedList <string, Variable> variables) { this.key = key; if (properties.Name != "properties") { throw new ActionException("Can't create the action"); } foreach (XmlElement property in properties.ChildNodes) { switch (property.Name) { case "version": break; case "frequencyVariable": if (property.InnerText != "none") { this.frequencyVariable = variables[property.InnerText]; } break; case "frecuencyValue": this.frecuencyValue = System.Convert.ToDecimal(property.InnerText.Replace(',', '.'), new System.Globalization.CultureInfo("en-GB")); break; case "flowchartControl": this.flowchartControl = (FlowchartControl)Enum.Parse(typeof(FlowchartControl), property.InnerText); break; case "timeVariable": if (property.InnerText != "none") { this.timeVariable = variables[property.InnerText]; } break; case "timeValue": this.timeValue = System.Convert.ToDecimal(property.InnerText.Replace(',', '.'), new System.Globalization.CultureInfo("en-GB")); break; case "waitFinish": this.waitFinish = System.Convert.ToBoolean(property.InnerText); break; default: throw new ProjectException("Error el crear la acción"); } } }
/// <summary> /// Creates an object that translates the parameters used for external methods to parameters for internal methods. /// </summary> public CreateParameterMatrix(TableSchema tableSchema) { // Initialize the object. this.ExternalParameterItems = new SortedList <string, ExternalParameterItem>(); // This will create an interface for the 'Create' method. foreach (KeyValuePair <string, ColumnSchema> columnPair in tableSchema.Columns) { // This column is turned into a simple parameter. ColumnSchema columnSchema = columnPair.Value; // If a column requires special processing, it is not handled with the rest of the parameters. bool isOrdinaryColumn = true; // The row version is not used in the set of Create parameters. if (columnSchema.IsRowVersion) { isOrdinaryColumn = false; } // AutoIncremented columns can only be specified as output parameters. if (columnSchema.IsAutoIncrement) { isOrdinaryColumn = false; SimpleParameterItem simpleParameterItem = new SimpleParameterItem(); simpleParameterItem.ActualDataType = columnSchema.DataType; simpleParameterItem.ColumnSchema = columnSchema; simpleParameterItem.DeclaredDataType = columnSchema.DataType; simpleParameterItem.Description = string.Format("The generated value for the {0} column.", columnSchema.Name); simpleParameterItem.FieldDirection = FieldDirection.Out; simpleParameterItem.Name = CommonConversion.ToCamelCase(columnSchema.Name); this.ExternalParameterItems.Add(simpleParameterItem.Name, simpleParameterItem); } // The only complication for ordinary parameters is whether the data type can accept a default or not. if (isOrdinaryColumn) { SimpleParameterItem simpleParameterItem = new SimpleParameterItem(); bool isOptional = columnSchema.IsNullable || columnSchema.DefaultValue != DBNull.Value; simpleParameterItem.ActualDataType = columnSchema.DataType; simpleParameterItem.ColumnSchema = columnSchema; simpleParameterItem.DeclaredDataType = isOptional ? typeof(System.Object) : columnSchema.DataType; simpleParameterItem.Description = string.Format("The {0} value for the {1} column.", isOptional ? "optional" : "required", columnSchema.Name); simpleParameterItem.FieldDirection = FieldDirection.In; simpleParameterItem.Name = CommonConversion.ToCamelCase(columnSchema.Name); this.ExternalParameterItems.Add(simpleParameterItem.Name, simpleParameterItem); } } }
public TcpDataStream(uint initialTcpSequenceNumber, bool streamIsClientToServer, NetworkTcpSession session) { this.initialTcpSequenceNumber = initialTcpSequenceNumber; this.expectedTcpSequenceNumber = initialTcpSequenceNumber; //this.sourcePort=sourcePort; //this.destinationPort=destinationPort; this.dataList = new SortedList <uint, byte[]>(); //this.dataListMaxSize=64;//i hope I shouldn't need more than 64 packets in the list. It depends on how late a misordered packet might get received. Smaller number gives better performance, larger number gives better tolerance to reordered packets this.dataListMaxSize = 256;//allows data packets to be out-of-order up to 256 packets apart from each other in the same unidirectional stream //this.totalByteCount=0; this.virtualTcpData = null; this.session = session; this.networkFlow = session.Flow; //this.protocolFinder = session.protocolFinder; this.streamIsClientToServer = streamIsClientToServer; }
/// <summary> /// Constructs a schema from the contents of an XML specification. /// </summary> /// <param name="fileContents">The contents of a file that specifies the schema in XML.</param> public DataModelSchema(string fileContents) { // Initialize the object this.itemList = new List <ObjectSchema>(); this.relationList = new SortedList <string, RelationSchema>(); this.tableList = new SortedList <string, TableSchema>(); // Compile the schema to resolve all the types and qualified names. XmlSchemaSet xmlSchemaSet = new XmlSchemaSet(); XmlTextReader xmlTextReader = new XmlTextReader(new StringReader(fileContents)); XmlSchema primarySchema = XmlSchema.Read(xmlTextReader, new ValidationEventHandler(ValidationCallback)); xmlSchemaSet.Add(primarySchema); xmlSchemaSet.Compile(); // The namespace Teraque.DataModelGenerator is used to create qualified names from the XPath specifications. These are most useful in // following the key schemas back to the relevant table schemas. this.xmlNamespaceManager = new XmlNamespaceManager(new NameTable()); foreach (XmlSchema xmlSchema in xmlSchemaSet.Schemas()) { foreach (XmlQualifiedName xmlQualifiedName in xmlSchema.Namespaces.ToArray()) { this.xmlNamespaceManager.AddNamespace(xmlQualifiedName.Name, xmlQualifiedName.Namespace); } } // Initialize the data structures from primary schema in the set. foreach (XmlSchema xmlSchema in xmlSchemaSet.Schemas(primarySchema.TargetNamespace)) { this.name = xmlSchema.Id; this.targetNamespace = xmlSchema.TargetNamespace; this.version = Convert.ToDecimal(xmlSchema.Version); foreach (XmlSchemaObject xmlSchemaObject in xmlSchema.Items) { if (xmlSchemaObject is XmlSchemaAnnotation) { this.itemList.Add(new AnnotationSchema(this, xmlSchemaObject as XmlSchemaAnnotation)); } } } // The schema is parsed in two passes. The first evaluates the tables, keys and unique constraints. The second // evaluates the foreign keys and associates them with the parent and child tables. FirstPass(xmlSchemaSet); SecondPass(xmlSchemaSet); }
private void InitFieldAndProperty() { if (_cfgSystem != null) { _routineBaseDirectory = _cfgSystem.RoutineDirectory; } RoutineName = null; RoutineDirectorySelected = null; IsNewCommand = false; IsEditCommand = false; IsLoadCommand = false; IsDeleteCommand = false; IsClearCommand = false; IsExitCommand = false; _routineNamesAndDirectories = new SortedList <string, string>(); }
/// <summary> /// 在后台线程中异步调用 获取数据的方法。 /// </summary> public AsynLoadDataHelper(MB.WinBase.IFace.IAsynClientQueryRule asynRule, bool isTotalPageDisplayed, bool isQueryAll) { _IsTotalPageDisplayed = isTotalPageDisplayed; _IsQueryAll = isQueryAll; _DataList = new SortedList <int, byte[]>(); _WorkThread = new MB.Util.AsynWorkThread(); _AsynQueryRule = asynRule; _AsynQueryRule.GetBufferByIndexCompleted += new EventHandler <MB.WinBase.Common.GetBufferByIndexCompletedEventArgs>(_AsynQueryRule_GetBufferByIndexCompleted); _WaitDialog = new WaitDialogForm(this); _WaitDialog.ClickCanceled += new EventHandler(_WaitDialog_ClickCanceled); _WaitProcessState = new MB.WinBase.Common.WorkWaitDialogArgs(); iniAsynWorkThread(); }
static void Main(string[] args) { List <string> listTest = new List <string>(); for (int i = 1; i <= 500000; i++)//50_0000 { listTest.Add(i.ToString().PadLeft(10, '0')); } Stopwatch stopMatch = new Stopwatch(); stopMatch.Start(); List <string> listOrder = listTest.OrderByDescending(c => c).ToList <string>(); stopMatch.Stop(); Console.WriteLine("Linq排序耗时:\t{0}毫秒", stopMatch.ElapsedMilliseconds.ToString()); stopMatch.Reset(); stopMatch.Start(); var sortedList = new System.Collections.Generic.SortedList <string, string>(); foreach (var item in listTest) { sortedList.Add(item, item); } Console.WriteLine("SortedList排序耗时:\t{0}毫秒", stopMatch.ElapsedMilliseconds.ToString()); stopMatch.Stop(); string[] arrTest = listOrder.ToArray(); stopMatch.Reset(); stopMatch.Start(); QuickSort(arrTest, 0, arrTest.Length - 1); stopMatch.Stop(); Console.WriteLine("二分法排序耗时:\t{0}毫秒", stopMatch.ElapsedMilliseconds.ToString()); Console.Read(); }
public StopCameraAction(string key, XmlElement properties, System.Collections.Generic.SortedList <string, Variable> variables) { this.key = key; if (properties.Name != "properties") { throw new ActionException("Can't create the action"); } foreach (XmlElement property in properties.ChildNodes) { switch (property.Name) { case "version": break; default: throw new ProjectException("Error el crear la acción"); } } }
internal SmbSession(System.Net.IPAddress serverIP, ushort serverTcpPort, System.Net.IPAddress clientIP, ushort clientTcpPort) { this.serverIP = serverIP; this.serverTcpPort = serverTcpPort; this.clientIP = clientIP; this.clientTcpPort = clientTcpPort; this.lastReferencedFileIdPerTreeMux = new SortedList <uint, ushort>(); this.lastReferencedFileIdPerPidMux = new SortedList <uint, ushort>(); this.fileIdAssemblerList = new PopularityList <ushort, FileTransfer.FileStreamAssembler>(100); this.fileIdAssemblerList.PopularityLost += FileIdAssemblerList_PopularityLost; this.fileIdSegmentAssemblerList = new PopularityList <ushort, FileTransfer.FileSegmentAssembler>(100); this.fileIdSegmentAssemblerList.PopularityLost += FileIdSegmentAssemblerList_PopularityLost; this.lastTreeConnectAndXRequestPathPerUserMux = new PopularityList <int, string>(100); this.treePathList = new PopularityList <ushort, string>(100); }
string GetSign(System.Collections.Generic.SortedList <string, string> reqParams) { var sb = new StringBuilder(); foreach (string key in reqParams.Keys) { if (reqParams[key] != null && !string.IsNullOrWhiteSpace(reqParams[key].ToString())) { if (sb.Length > 0) { sb.Append("&"); } sb.Append(key + "=" + reqParams[key].ToString()); } } string sign = XuHos.Common.StringEncrypt.GetMD5_32(sb.ToString()).ToUpper(); return(sign); }
/// <summary> /// Create a table schema from the XML Schema specification. /// </summary> /// <param name="dataModelSchema">The data model to which this table belongs.</param> /// <param name="xmlSchemaElement">The root of the XmlSchema element that describes the table.</param> public TableSchema(DataModelSchema dataModelSchema, XmlSchemaElement xmlSchemaElement) : base(dataModelSchema, xmlSchemaElement) { // Initialize the object. this.dataModelSchema = dataModelSchema; this.isPersistent = GetPersistentIndicator(xmlSchemaElement); this.name = xmlSchemaElement.Name; this.columnList = new SortedList <string, ColumnSchema>(); this.constraintList = new SortedList <string, ConstraintSchema>(); this.childRelationList = new SortedList <string, RelationSchema>(); this.parentRelationList = new SortedList <string, RelationSchema>(); // Every table has a row version column which tracks the history of changes to the row. ColumnSchema rowVersionSchema = new ColumnSchema(this, "RowVersion", typeof(Int64), false, true, DBNull.Value, Int32.MaxValue); this.columnList.Add(rowVersionSchema.Name, rowVersionSchema); // Initialize the columns of the table. Initialize(xmlSchemaElement); }
/// <summary> /// Creates a file in Temp folder. /// Write the data in SortedList to a file. /// Returns the filename /// </summary> /// <param name="sortedList">List to be written to file.</param> /// <returns>File name.</returns> private static string WriteToFile(System.Collections.Generic.SortedList <object, string> sortedList) { string[] indices; string fileName = Path.GetTempFileName(); using (StreamWriter writer = new StreamWriter(fileName)) { foreach (KeyValuePair <object, string> entry in sortedList) { indices = entry.Value.Split(','); for (int count = 0; count < indices.Length; count++) { writer.WriteLine(string.Format(CultureInfo.InvariantCulture, "{0},{1}", entry.Key, indices[count])); } } writer.Flush(); } return(fileName); }
/// <summary> /// Sort the index of SequenceAlignmentMap by QName. /// Fill the index (sorted by QName) into a list, when the list size reaches /// the maximum limit, write the list to file and clear the list. /// </summary> private IList <string> SortByReadNames() { IList <string> files = new List <string>(); var sortedList = new System.Collections.Generic.SortedList <object, string>(); for (int index = 0; index < sequenceAlignMap.QuerySequences.Count; index++) { SAMAlignedSequence alignedSeq = sequenceAlignMap.QuerySequences[index]; string indices = string.Empty; if (!sortedList.TryGetValue(alignedSeq.QName, out indices)) { sortedList.Add(alignedSeq.QName, index.ToString(CultureInfo.InvariantCulture)); } else { indices = string.Format(CultureInfo.InvariantCulture, "{0},{1}", indices, index.ToString(CultureInfo.InvariantCulture)); sortedList[alignedSeq.QName] = indices; } if (sortedList.Count >= SortedListMaxCount) { if (files == null) { files = new List <string>(); } files.Add(WriteToFile(sortedList)); sortedList.Clear(); } } if (sortedList.Count > 0) { files.Add(WriteToFile(sortedList)); sortedList.Clear(); } return(files); }
public static System.Collections.Generic.SortedList<int, eJobStatus> GetStatusesOfJobs(int[] jobIDs) { System.Collections.Generic.SortedList<int, eJobStatus> jobStatusesList = new System.Collections.Generic.SortedList<int, eJobStatus>(); DataTable dtResults = null; DataAccess objADO = new DataAccess(); ArrayList colParameters = new ArrayList(); System.Data.SqlClient.SqlParameter[] arrParameters = null; DataAccess.ArrayListParameter objParameter = null; string strStoredProcedure = "selStatusesForWMSourceIDs"; objADO = Domain.GetADOInstance(); objParameter = new DataAccess.ArrayListParameter("WMSourceIDs", jobIDs); dtResults = objADO.GetDataSet(strStoredProcedure, objParameter, arrParameters).Tables[0]; objADO = null; if (dtResults.Rows.Count > 0) { foreach (DataRow drJobStatusInfo in dtResults.Rows) { jobStatusesList.Add(int.Parse(drJobStatusInfo["WMSourceID"].ToString()), (eJobStatus)Enum.Parse(typeof(eJobStatus),drJobStatusInfo["JobStatus"].ToString())); } } return jobStatusesList; }
/// <summary> /// Sort the index of SequenceAlignmentMap by RName then by Pos. /// Fill the index (sorted by RName then by Pos) into a list, when the list size reaches /// the maximum limit, write the list to file and clear the list. /// </summary> private SortedDictionary<string, IList<string>> SortByChromosomeCoordinates() { SortedDictionary<string, IList<string>> sortedFiles = new SortedDictionary<string, IList<string>>(); IList<string> files = null; var groups = new System.Collections.Generic.SortedList<string, System.Collections.Generic.SortedList<object, string>>(); System.Collections.Generic.SortedList<object, string> sortedList = null; for (int index = 0; index < sequenceAlignMap.QuerySequences.Count; index++) { SAMAlignedSequence alignedSeq = sequenceAlignMap.QuerySequences[index]; if (!groups.TryGetValue(alignedSeq.RName, out sortedList)) { sortedList = new System.Collections.Generic.SortedList<object, string>(); groups.Add(alignedSeq.RName, sortedList); } string indices = string.Empty; if (!sortedList.TryGetValue(alignedSeq.Pos, out indices)) { sortedList.Add(alignedSeq.Pos, index.ToString(CultureInfo.InvariantCulture)); } else { indices = string.Format(CultureInfo.InvariantCulture, "{0},{1}", indices, index.ToString(CultureInfo.InvariantCulture)); sortedList[alignedSeq.Pos] = indices; } if (sortedList.Count >= SortedListMaxCount) { if (!sortedFiles.TryGetValue(alignedSeq.RName, out files)) { files = new List<string>(); sortedFiles.Add(alignedSeq.RName, files); } files.Add(WriteToFile(sortedList)); sortedList.Clear(); } } foreach (KeyValuePair<string, System.Collections.Generic.SortedList<object, string>> group in groups) { if (group.Value.Count > 0) { if (!sortedFiles.TryGetValue(group.Key, out files)) { files = new List<string>(); sortedFiles.Add(group.Key, files); } files.Add(WriteToFile(group.Value)); group.Value.Clear(); } } return sortedFiles; }
public Competencia() { praticas = new SortedList<int, Pratica>(); competenciaID = -1; }
private void FindUrls() { try { var typers = new Collection<Type>(); var isrc = new System.Collections.Generic.SortedList<TypedDataSourceAttributeComparer, DataSourceAttribute>(); KnownTypes.ItemsSource = isrc; foreach (var item in AppDomain.CurrentDomain.GetAssemblies()) { foreach (var itype in item.GetTypes()) { foreach (var cat in itype.GetCustomAttributes(typeof(DataSourceAttribute), false)) { var xcat = (cat as DataSourceAttribute); if (xcat.IgnoreClones) { foreach (var cloneposs in typers) { if (cloneposs == itype) { goto noadd; } } } isrc.Add(new TypedDataSourceAttributeComparer { DataSourceAttribute = xcat, Type = itype }, xcat); typers.Add(itype); noadd: continue; } } } } catch (Exception ex) { ErrorDialog.PrcException(new Exception("Error searching for Sources. This is most likely caused by a missing dependency. Is SlimDX installed?", ex)); } }
public Competencia(FamiliaCompetencias fam) { praticas = new SortedList<int, Pratica>(); familia = fam; competenciaID = -1; }
/// <summary> /// Creates a collection cloned from another <see cref="AscendingIntegerCollection" />. /// </summary> /// <param name="from"></param> public AscendingIntegerCollection(AscendingIntegerCollection from) { _list = new System.Collections.Generic.SortedList<int, object>(from._list); }
/// <summary> /// Sort the index of SequenceAlignmentMap by QName. /// Fill the index (sorted by QName) into a list, when the list size reaches /// the maximum limit, write the list to file and clear the list. /// </summary> private IList<string> SortByReadNames() { IList<string> files = new List<string>(); var sortedList = new System.Collections.Generic.SortedList<object,string>(); for (int index = 0; index < sequenceAlignMap.QuerySequences.Count; index++) { SAMAlignedSequence alignedSeq = sequenceAlignMap.QuerySequences[index]; string indices = string.Empty; if (!sortedList.TryGetValue(alignedSeq.QName, out indices)) { sortedList.Add(alignedSeq.QName, index.ToString(CultureInfo.InvariantCulture)); } else { indices = string.Format(CultureInfo.InvariantCulture, "{0},{1}", indices, index.ToString(CultureInfo.InvariantCulture)); sortedList[alignedSeq.QName] = indices; } if (sortedList.Count >= SortedListMaxCount) { if (files == null) { files = new List<string>(); } files.Add(WriteToFile(sortedList)); sortedList.Clear(); } } if (sortedList.Count > 0) { files.Add(WriteToFile(sortedList)); sortedList.Clear(); } return files; }