示例#1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string tempurl = Utils.GetStaticPageNumbersHtml(2, 100, "showforum", ".aspx", 8);

            
            DbParameter[] prams = 
			{
				DbHelper.MakeInParam("@name", DbType.String, 3,"aabbccdd")
			};
            DbHelper.ExecuteNonQuery(CommandType.Text, "INSERT INTO itca_test(name) VALUES (@name)", prams);
            DbDataReader dr = DbHelper.ExecuteReader(CommandType.Text, "SELECT * FROM wy_articles");
            while (dr.Read())
            {
                Response.Write(dr["title"].ToString()+"<br />"+ dr["content"].ToString());
            }
            if (Request.QueryString["a"] != null)
            {
                Response.Write(Request.QueryString["a"].ToString());
            }

            TinyCache tc = new TinyCache();
            tc.AddObject("test", "bbbbb");


            Response.Write("TinyCache:" + tc.RetrieveObject("test") as string);



            System.Collections.Generic.SortedList<int, object> list = new System.Collections.Generic.SortedList<int, object>();
            list.Add(1, "协会公告");
            list.Add(2, "协会新闻");
            object aaaa = list[1];
        }
示例#2
0
        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;
        }
        public static bool detCursorSelection(Canvas rel, Point relPos, out UIElement result)
        {
            var list = new System.Collections.Generic.SortedList<int, UIElement>();
            foreach (UIElement ue in rel.Children)
            {
                var ta = ue.TransformToAncestor(rel);
                var p = ta.Transform(new Point(0, 0));
                var r = new Rect(p, ue.RenderSize);

                if (r.Contains(relPos))
                    try { list.Add(Canvas.GetZIndex(ue), ue); }
                    catch (Exception) { }
            }
            if (list.Count != 0)
            {
                var pr = list.Keys.Max();
                result = list[pr];
                return true;
            }
            else
            {
                result = null;
                return false;
            }
        }
示例#4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string tempurl = Utils.GetStaticPageNumbersHtml(2, 100, "showforum", ".aspx", 8);


            DbParameter[] prams =
            {
                DbHelper.MakeInParam("@name", DbType.String, 3, "aabbccdd")
            };
            DbHelper.ExecuteNonQuery(CommandType.Text, "INSERT INTO itca_test(name) VALUES (@name)", prams);
            DbDataReader dr = DbHelper.ExecuteReader(CommandType.Text, "SELECT * FROM wy_articles");

            while (dr.Read())
            {
                Response.Write(dr["title"].ToString() + "<br />" + dr["content"].ToString());
            }
            if (Request.QueryString["a"] != null)
            {
                Response.Write(Request.QueryString["a"].ToString());
            }

            TinyCache tc = new TinyCache();

            tc.AddObject("test", "bbbbb");


            Response.Write("TinyCache:" + tc.RetrieveObject("test") as string);



            System.Collections.Generic.SortedList <int, object> list = new System.Collections.Generic.SortedList <int, object>();
            list.Add(1, "协会公告");
            list.Add(2, "协会新闻");
            object aaaa = list[1];
        }
示例#5
0
 internal void ResetChildern()
 {
     Children            = new System.Collections.Generic.SortedList <string, nBrowser.Node>();
     DefaultChildren     = new System.Collections.Generic.SortedList <string, nBrowser.Node>();
     ChildrenKeys        = new System.Collections.Generic.List <string>();
     DefaultChildrenKeys = new System.Collections.Generic.List <string>();
 }
示例#6
0
        public static void Main(string[] args)
        {
            System.IO.StreamReader reader = OpenInput(args);
            int numLines = System.Int32.Parse(reader.ReadLine());

            System.Collections.Generic.SortedList<int, string> longest = new System.Collections.Generic.SortedList<int, string>();
            while (!reader.EndOfStream)
            {
                string line = reader.ReadLine();
                if (line == null)
                    continue;

                if (longest.Count < numLines)
                {
                    longest.Add(line.Length, line);
                }
                else if (line.Length > longest.Keys[0])
                {
                    // We need to add this line and push out the extra that's smallest in our list
                    longest.Add(line.Length, line);
                    longest.RemoveAt(0);
                }
            }

            System.Collections.Generic.IList<int> keys = longest.Keys;
            for (int i = keys.Count - 1; i >= 0; --i)
            {
                System.Console.WriteLine(longest[keys[i]]);
            }
        }
        public CompareBrightnessAction(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 "operation":
                    this.operation = (ComparativeOp)Enum.Parse(typeof(ComparativeOp), property.InnerText);
                    break;

                case "compareVariable":
                    if (property.InnerText != "none")
                    {
                        this.compareVariable = variables[property.InnerText];
                    }
                    break;

                case "compareValue":
                    this.compareValue = System.Convert.ToInt32(property.InnerText);
                    break;

                default:
                    throw new ProjectException("Error el crear la acción");
                }
            }
        }
示例#8
0
        public PauseAction(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 "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;

                default:
                    throw new ProjectException("Error el crear la acción");
                }
            }
        }
示例#9
0
        public void GetData(Action<Model.DataItem, Exception> callback)
        {
            // Use this to connect to the actual data service

            var item = new Model.DataItem();

            var sl = new System.Collections.Generic.SortedList<string,string>();

            safeAdd(sl,System.Environment.GetFolderPath(Environment.SpecialFolder.AdminTools));
            safeAdd(sl,System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData));
            safeAdd(sl,System.Environment.GetFolderPath(Environment.SpecialFolder.CDBurning));
            safeAdd(sl,System.Environment.GetFolderPath(Environment.SpecialFolder.CommonAdminTools));
            safeAdd(sl,System.Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData));
            safeAdd(sl,System.Environment.GetFolderPath(Environment.SpecialFolder.CommonDesktopDirectory));
            safeAdd(sl,System.Environment.GetFolderPath(Environment.SpecialFolder.CommonDocuments));
            safeAdd(sl,System.Environment.GetFolderPath(Environment.SpecialFolder.CommonMusic));
            safeAdd(sl,System.Environment.GetFolderPath(Environment.SpecialFolder.CommonOemLinks));
            safeAdd(sl,System.Environment.GetFolderPath(Environment.SpecialFolder.CommonPictures));
            safeAdd(sl,System.Environment.GetFolderPath(Environment.SpecialFolder.CommonProgramFiles));
            safeAdd(sl,System.Environment.GetFolderPath(Environment.SpecialFolder.CommonProgramFilesX86));
            safeAdd(sl,System.Environment.GetFolderPath(Environment.SpecialFolder.CommonPrograms));
            safeAdd(sl,System.Environment.GetFolderPath(Environment.SpecialFolder.CommonStartMenu));
            safeAdd(sl,System.Environment.GetFolderPath(Environment.SpecialFolder.CommonStartup));
            safeAdd(sl,System.Environment.GetFolderPath(Environment.SpecialFolder.CommonTemplates));
            safeAdd(sl,System.Environment.GetFolderPath(Environment.SpecialFolder.CommonVideos));
            safeAdd(sl,System.Environment.GetFolderPath(Environment.SpecialFolder.Cookies));
            safeAdd(sl,System.Environment.GetFolderPath(Environment.SpecialFolder.Desktop));
            safeAdd(sl,System.Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory));
            safeAdd(sl,System.Environment.GetFolderPath(Environment.SpecialFolder.Favorites));
            safeAdd(sl,System.Environment.GetFolderPath(Environment.SpecialFolder.Fonts));
            safeAdd(sl,System.Environment.GetFolderPath(Environment.SpecialFolder.History));
            safeAdd(sl,System.Environment.GetFolderPath(Environment.SpecialFolder.InternetCache));
            safeAdd(sl,System.Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData));
            safeAdd(sl,System.Environment.GetFolderPath(Environment.SpecialFolder.LocalizedResources));
            safeAdd(sl,System.Environment.GetFolderPath(Environment.SpecialFolder.MyComputer));
            safeAdd(sl,System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments));
            safeAdd(sl,System.Environment.GetFolderPath(Environment.SpecialFolder.MyMusic));
            safeAdd(sl,System.Environment.GetFolderPath(Environment.SpecialFolder.MyPictures));
            safeAdd(sl,System.Environment.GetFolderPath(Environment.SpecialFolder.MyVideos));
            safeAdd(sl,System.Environment.GetFolderPath(Environment.SpecialFolder.NetworkShortcuts));
            safeAdd(sl,System.Environment.GetFolderPath(Environment.SpecialFolder.Personal));
            safeAdd(sl,System.Environment.GetFolderPath(Environment.SpecialFolder.PrinterShortcuts));
            safeAdd(sl,System.Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles));
            safeAdd(sl,System.Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86));
            safeAdd(sl,System.Environment.GetFolderPath(Environment.SpecialFolder.Programs));
            safeAdd(sl,System.Environment.GetFolderPath(Environment.SpecialFolder.Recent));
            safeAdd(sl,System.Environment.GetFolderPath(Environment.SpecialFolder.Resources));
            safeAdd(sl,System.Environment.GetFolderPath(Environment.SpecialFolder.SendTo));
            safeAdd(sl,System.Environment.GetFolderPath(Environment.SpecialFolder.StartMenu));
            safeAdd(sl,System.Environment.GetFolderPath(Environment.SpecialFolder.Startup));
            safeAdd(sl,System.Environment.GetFolderPath(Environment.SpecialFolder.System));
            safeAdd(sl,System.Environment.GetFolderPath(Environment.SpecialFolder.SystemX86));
            safeAdd(sl,System.Environment.GetFolderPath(Environment.SpecialFolder.Templates));
            safeAdd(sl,System.Environment.GetFolderPath(Environment.SpecialFolder.UserProfile));
            safeAdd(sl,System.Environment.GetFolderPath(Environment.SpecialFolder.Windows));

            item.SystemFolders = sl.Values;

            callback(item, null);
        }
示例#10
0
        public StopSoundGraphic(string key, XmlElement elementData, System.Collections.Generic.SortedList <string, Variable> variables)
            : base(key)
        {
            this.Surface.Blit(new Surface(StopSound.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 StopSoundAction(key, nodo);
                    break;

                case "previous":
                    break;

                case "next":
                    break;

                default:
                    throw new GraphException("Error al crear GraphStart");
                }
            }
        }
        public AssignLineAction(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 "assignVariable":
                    if (property.InnerText != "none")
                    {
                        this.assignVariable = variables[property.InnerText];
                    }
                    break;

                case "lineSensor":
                    this.lineSensor = (Side)Enum.Parse(typeof(Side), property.InnerText);
                    break;

                default:
                    throw new ProjectException("Error el crear la acción");
                }
            }
        }
        public CompareAccelerometerGraphic(string key, XmlElement elementData, System.Collections.Generic.SortedList <string, Variable> variables)
            : base(key)
        {
            this.needInit = System.Convert.ToBoolean(CompareAccelerometer.NeedInit);
            this.Surface.Blit(new Surface(CompareAccelerometer.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 CompareAccelerometerAction(key, nodo, variables);
                    break;

                case "previous":
                    break;

                case "nextTrue":
                    break;

                case "nextFalse":
                    break;

                default:
                    throw new GraphException("Error al crear GraphStart");
                }
            }
        }
示例#13
0
 protected virtual void DoUPnPIGD()
 {
     try
     {
         // Wait 20 seconds before continue
         int i = 0;
         do
         {
             Thread.Sleep(1 * 1000);
         } while (((Functions.UPnPIGD & Success) != Functions.UPnPIGD) && i++ > 20);
         System.Collections.Generic.SortedList <string, UPnPDevice> tmpDevices = new System.Collections.Generic.SortedList <string, UPnPDevice>(upnp.RootDevices);
         foreach (System.Collections.Generic.KeyValuePair <string, UPnPDevice> devicePair in tmpDevices)
         {
             FlowLib.Events.FmdcEventArgs e = new FlowLib.Events.FmdcEventArgs(Actions.UPnPDeviceDescription, devicePair.Key);
             UpdateBase(this, e);
         }
     }
     finally
     {
         //if ((Functions.UPnPIGD & Success) == Functions.UPnPIGD)
         //{
         Progress = Functions.UPnPExternalRecieveAccess;
         //}
         //else
         //{
         //    Progress = Functions.End;
         //}
     }
 }
示例#14
0
        /// <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 GraphElement GetGraphAction(string key, XmlElement elementData, System.Collections.Generic.SortedList <string, Variable> variables)
 {
     if (this.key != key)
     {
         throw new ActionException("Key is not correct");
     }
     return(new CompareBrightnessGraphic(this.key, elementData, variables));
 }
        static StackObject *Ctor_0(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *__ret = ILIntepreter.Minus(__esp, 0);

            var result_of_this_method = new System.Collections.Generic.SortedList <System.Int32, ILRuntime.Runtime.Intepreter.ILTypeInstance>();

            return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method));
        }
示例#17
0
        public SortedEditableList(System.Collections.Generic.IList <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);
            }
        }
示例#18
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            MySqlConnection con = new MySqlConnection("Server=127.0.0.1;Database=dht;Uid=dht;Pwd=sgv54hnf3ha142s3dfg4ad5sh;");

            con.Open();
            try {
                MySqlCommand cmd = new MySqlCommand("SELECT MAX(id) AS max_id , MIN(id) AS min_id FROM nodes", con);
                IDataReader  r;
                r = cmd.ExecuteReader(CommandBehavior.SingleRow);
                if (!r.Read())
                {
                    return;
                }
                long max = r.GetInt64(0);
                long min = r.GetInt64(1);
                r.Close();
                cmd.CommandText = "SELECT id, endpoint FROM nodes WHERE id >= @id and lastupdate>(subtime(CURRENT_TIMESTAMP,'05:00:00')) order by id LIMIT 0,1";
                cmd.Parameters.Add("@id", MySqlDbType.Int64);
                System.Random rnd = new System.Random();
                System.Collections.Generic.SortedList <long, string> l  = new System.Collections.Generic.SortedList <long, string> ();
                System.Collections.Generic.List <string>             l2 = new System.Collections.Generic.List <string> ();
                int i;
                for (i = 0; i < 10; i++)
                {
                    long id = getrand(rnd, min, max);
                    //Response.Output.WriteLine (id);
                    cmd.Parameters [0].Value = id;
                    r = cmd.ExecuteReader(CommandBehavior.SingleRow);
                    try {
                        if (!r.Read())
                        {
                            continue;
                        }
                        try {
                            l.Add(r.GetInt64(0), r.GetString(1));
                            l2.Add(r.GetString(1));
                        } catch {
                        }
                    } finally {
                        r.Close();
                    }
                }
                //System.Collections.Generic.IList<string > tmp = l.Values;
                for (i = 0; i < l2.Count; i++)
                {
                    Response.Output.WriteLine(l2 [i]);
                }
            } finally {
                con.Close();
            }
        }
示例#19
0
		protected override void OnLoad (EventArgs e)
		{
			base.OnLoad (e);
			MySqlConnection con = new MySqlConnection ("Server=127.0.0.1;Database=dht;Uid=dht;Pwd=sgv54hnf3ha142s3dfg4ad5sh;");
			con.Open ();
			try {
				MySqlCommand cmd = new MySqlCommand ("SELECT MAX(id) AS max_id , MIN(id) AS min_id FROM nodes", con);
				IDataReader r;
				r = cmd.ExecuteReader (CommandBehavior.SingleRow);
				if (!r.Read ())
					return;
				long max = r.GetInt64 (0);
				long min = r.GetInt64 (1);
				r.Close ();
				cmd.CommandText = "SELECT id, endpoint FROM nodes WHERE id >= @id and lastupdate>(subtime(CURRENT_TIMESTAMP,'05:00:00')) order by id LIMIT 0,1";
				cmd.Parameters.Add ("@id", MySqlDbType.Int64);
				System.Random rnd = new System.Random ();
				System.Collections.Generic.SortedList<long,string > l = new System.Collections.Generic.SortedList<long, string> ();
				System.Collections.Generic.List<string > l2 = new System.Collections.Generic.List<string> ();
				int i;
				for (i=0; i<10; i++) {
					long id = getrand (rnd, min, max);
					//Response.Output.WriteLine (id);
					cmd.Parameters [0].Value = id;
					r = cmd.ExecuteReader (CommandBehavior.SingleRow);
					try {
						if (!r.Read ())
							continue;
						try {
							l.Add (r.GetInt64 (0), r.GetString (1));
							l2.Add (r.GetString (1));
						} catch {
						}
					} finally {
						r.Close ();
					}
				}
				//System.Collections.Generic.IList<string > tmp = l.Values;
				for (i=0; i<l2.Count; i++) {
					Response.Output.WriteLine (l2 [i]);
				}
			} finally {
				con.Close ();
			}
		}
        public void SetZeeOrderOfGroups(Panel panel, out System.Collections.Generic.SortedList <FieldGroupBox, System.Drawing.Point> pointSortedGroups)
        {
            pointSortedGroups = new SortedList <FieldGroupBox, System.Drawing.Point>(new GroupZeeOrderComparer());

            foreach (Control possibleGroupControl in panel.Controls)
            {
                FieldGroupBox groupControl = possibleGroupControl as FieldGroupBox;
                if (groupControl != null)
                {
                    pointSortedGroups.Add(groupControl, ((Control)groupControl).Location);
                }
            }

            foreach (KeyValuePair <FieldGroupBox, System.Drawing.Point> kvp in pointSortedGroups)
            {
                ((Control)kvp.Key).SendToBack();
            }
        }
示例#21
0
        public void MapperPerformsMapOperation()
        {
            var filePath = "file1.txt";
            var fileContent = "whatever am i";
            storage.Store(filePath, fileContent);

            var mapper = new Mapper(filePath, (key, value) =>
            {
                var result = new System.Collections.Generic.SortedList<string, string>();
                foreach (var w in value.Split(' '))
                    result.Add(w, "1");

                return result;
            }, this.storage);

            var mapResult = mapper.PerformMap();

            mapResult.Count().ShouldBe(3);
        }
示例#22
0
    public void Seed(int seed)
    {
        mSeed = seed;
        System.Random random = new System.Random(seed);
        System.Collections.Generic.SortedList<int, byte> list = new System.Collections.Generic.SortedList<int, byte>(256);

        byte u1 = 0;
        do
        {
            list.Add(random.Next(), u1);
            ++u1;
        } while (u1 != 0);

        // Copy into array.
        foreach (System.Collections.Generic.KeyValuePair<int, byte> pair in list)
        {
            perm[u1] = pair.Value;
            perm[u1 + 256] = pair.Value;
            ++u1;
        }
    }
        public TransmissionRfAction(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 "direction":
                    this.direction = System.Convert.ToInt32(property.InnerText);
                    break;

                case "dataVariables":
                    foreach (XmlElement dataVariable in property.ChildNodes)
                    {
                        if (dataVariable.InnerText != "none")
                        {
                            this.dataVariable[System.Convert.ToInt32(dataVariable.Name[4]) - 48] = variables[dataVariable.InnerText];
                        }
                    }
                    break;

                case "dataValues":
                    foreach (XmlElement dataValue in property.ChildNodes)
                    {
                        this.dataValue[System.Convert.ToInt32(dataValue.Name[4]) - 48] = System.Convert.ToInt32(dataValue.InnerText);
                    }
                    break;

                default:
                    throw new ProjectException("Error el crear la acción");
                }
            }
        }
示例#24
0
    public void Seed(int seed)
    {
        mSeed = seed;
        System.Random random = new System.Random(seed);
        System.Collections.Generic.SortedList <int, byte> list = new System.Collections.Generic.SortedList <int, byte>(256);

        byte u1 = 0;

        do
        {
            list.Add(random.Next(), u1);
            ++u1;
        } while (u1 != 0);

        // Copy into array.
        foreach (System.Collections.Generic.KeyValuePair <int, byte> pair in list)
        {
            perm[u1]       = pair.Value;
            perm[u1 + 256] = pair.Value;
            ++u1;
        }
    }
        public CompareAccelerometerAction(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 "axis":
                    this.axis = (AccelerometerAxis)Enum.Parse(typeof(AccelerometerAxis), property.InnerText);
                    break;

                case "operation":
                    this.operation = (ComparativeOp)Enum.Parse(typeof(ComparativeOp), property.InnerText);
                    break;

                case "compareVariable":
                    if (property.InnerText != "none")
                    {
                        this.compareVariable = variables[property.InnerText];
                    }
                    break;

                case "compareValue":
                    this.compareValue = System.Convert.ToDecimal(property.InnerText.Replace(',', '.'), new System.Globalization.CultureInfo("en-GB"));
                    break;

                default:
                    throw new ProjectException("Error el crear la acción");
                }
            }
        }
示例#26
0
        public CallAction(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 "function":
                    this.function = GraphManager.GetFunction(property.InnerText);
                    break;

                default:
                    throw new ProjectException("Error el crear la acción");
                }
            }
        }
示例#27
0
        private void btnLoadCRCList_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter           = "*.txt|*.txt";
            ofd.InitialDirectory = AppDomain.CurrentDomain.BaseDirectory;

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                m_CRCList = new System.Collections.Generic.SortedList <uint, string>();
                System.IO.StreamReader sr = System.IO.File.OpenText(ofd.FileName);

                string line;

                while ((line = sr.ReadLine()) != null)
                {
                    string[] vals = line.Split("	".ToCharArray());
                    m_CRCList.Add(uint.Parse(vals[0]), vals[1]);
                }

                sr.Close();
            }
        }
 /// <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);
 }
示例#29
0
        /// <summary>
        /// 一个静态构造方法。
        /// </summary>
        static VerifyCode()
        {
            var configSection = GetSection("VerifyCode");

            if (configSection != null)
            {
                if (!string.IsNullOrEmpty(configSection["VerifyCodeEnumerable"]))
                {
                    System.Collections.Generic.List <string> charVerifyCodeEnumerable = new System.Collections.Generic.List <string>();                                 //字符验证码枚举列表。
                    System.Collections.Generic.SortedList <string, string> keyValueVerifyCodeEnumerable = new System.Collections.Generic.SortedList <string, string>(); //键值对(问题和答案)验证码列表。
                    string[] keyValues = configSection["VerifyCodeEnumerable"].Split(',');
                    foreach (var tmp in keyValues)
                    {
                        int eqIndex = tmp.IndexOf('=');
                        if (eqIndex > 0) //如果是键值对验证码。
                        {
                            string key   = tmp.Substring(0, eqIndex);
                            string value = tmp.Substring(eqIndex + 1);
                            if (!keyValueVerifyCodeEnumerable.ContainsKey(key))
                            {
                                keyValueVerifyCodeEnumerable.Add(key, value);
                            }
                        }
                        else if (!charVerifyCodeEnumerable.Contains(tmp)) //如果是字符型验证码。
                        {
                            charVerifyCodeEnumerable.Add(tmp);
                        }
                    }
                    VerifyCode.VerifyCodeEnumerable         = charVerifyCodeEnumerable.ToArray();
                    VerifyCode.KeyValueVerifyCodeEnumerable = keyValueVerifyCodeEnumerable;
                }

                if (!string.IsNullOrEmpty(configSection["Length"]))
                {
                    VerifyCode.Length = System.Convert.ToInt32(configSection["Length"]);
                }

                if (!string.IsNullOrEmpty(configSection["BendingAngle"]))
                {
                    VerifyCode.BendingAngle = System.Convert.ToInt32(configSection["BendingAngle"]);
                }

                if (!string.IsNullOrEmpty(configSection["FontSize"]))
                {
                    VerifyCode.FontSize = System.Convert.ToInt32(configSection["FontSize"]);
                }

                if (!string.IsNullOrEmpty(configSection["Padding"]))
                {
                    VerifyCode.Padding = System.Convert.ToInt32(configSection["Padding"]);
                }

                if (!string.IsNullOrEmpty(configSection["ForeColors"]))
                {
                    System.Collections.Generic.List <System.Drawing.Color> cs = new System.Collections.Generic.List <System.Drawing.Color>();
                    string[] vs = configSection["ForeColors"].Split(',');
                    foreach (var tmp in vs)
                    {
                        cs.Add(System.Drawing.ColorTranslator.FromHtml(tmp));
                    }
                    VerifyCode.ForeColors = cs.ToArray();
                }

                if (!string.IsNullOrEmpty(configSection["Fonts"]))
                {
                    string[] vs = configSection["Fonts"].Split(',');
                    VerifyCode.Fonts = vs;
                }
            }
        }
示例#30
0
 public HTMLAttributeCollection(HTMLElement parent)
 {
     this.parent = parent;
     this.list   = new System.Collections.Generic.SortedList <string, HTMLAttribute>();
 }
示例#31
0
        static private System.Collections.Generic.SortedList <System.UInt64, System.IntPtr> ReadFile(System.IO.BinaryReader binaryReader, AddressLibrary.Header header)
        {
            var offsets = new System.Collections.Generic.SortedList <System.UInt64, System.IntPtr>(header.AddressCount);

            System.UInt64 identifier;
            System.UInt64 offset;

            System.UInt64 previousIdentifier = 0;
            System.UInt64 previousOffset     = 0;

            for (var index = 0; index < header.AddressCount; index++)
            {
                var type           = binaryReader.ReadByte();
                var identifierType = type & 0xF;
                var offsetType     = type >> 4;

                switch ((AddressLibrary.ReadTypes)identifierType)
                {
                case AddressLibrary.ReadTypes.ReadUInt64:
                {
                    identifier = binaryReader.ReadUInt64();

                    break;
                }

                case AddressLibrary.ReadTypes.Add1:
                {
                    identifier = previousIdentifier + 1;

                    break;
                }

                case AddressLibrary.ReadTypes.AddReadByte:
                {
                    identifier = previousIdentifier + binaryReader.ReadByte();

                    break;
                }

                case AddressLibrary.ReadTypes.SubtractReadByte:
                {
                    identifier = previousIdentifier - binaryReader.ReadByte();

                    break;
                }

                case AddressLibrary.ReadTypes.AddReadUInt16:
                {
                    identifier = previousIdentifier + binaryReader.ReadUInt16();

                    break;
                }

                case AddressLibrary.ReadTypes.SubtractReadUInt16:
                {
                    identifier = previousIdentifier - binaryReader.ReadUInt16();

                    break;
                }

                case AddressLibrary.ReadTypes.ReadUInt16:
                {
                    identifier = binaryReader.ReadUInt16();

                    break;
                }

                case AddressLibrary.ReadTypes.ReadUInt32:
                {
                    identifier = binaryReader.ReadUInt32();

                    break;
                }

                default:
                {
                    try
                    {
                        throw new System.InvalidOperationException($"{nameof(AddressLibrary)}: Unexpected {nameof(identifierType)} encountered, {identifierType}.");
                    }
                    catch (System.InvalidOperationException invalidOperationException)
                    {
                        Log.Information($"{invalidOperationException}");

                        throw;
                    }
                }
                }

                var temporaryOffset = (offsetType & 8) != 0 ? previousOffset / (System.UInt64)header.PointerSize : previousOffset;

                switch ((AddressLibrary.ReadTypes)(offsetType & 7))
                {
                case AddressLibrary.ReadTypes.ReadUInt64:
                {
                    offset = binaryReader.ReadUInt64();

                    break;
                }

                case AddressLibrary.ReadTypes.Add1:
                {
                    offset = temporaryOffset + 1;

                    break;
                }

                case AddressLibrary.ReadTypes.AddReadByte:
                {
                    offset = temporaryOffset + binaryReader.ReadByte();

                    break;
                }

                case AddressLibrary.ReadTypes.SubtractReadByte:
                {
                    offset = temporaryOffset - binaryReader.ReadByte();

                    break;
                }

                case AddressLibrary.ReadTypes.AddReadUInt16:
                {
                    offset = temporaryOffset + binaryReader.ReadUInt16();

                    break;
                }

                case AddressLibrary.ReadTypes.SubtractReadUInt16:
                {
                    offset = temporaryOffset - binaryReader.ReadUInt16();

                    break;
                }

                case AddressLibrary.ReadTypes.ReadUInt16:
                {
                    offset = binaryReader.ReadUInt16();

                    break;
                }

                case AddressLibrary.ReadTypes.ReadUInt32:
                {
                    offset = binaryReader.ReadUInt32();

                    break;
                }

                default:
                {
                    try
                    {
                        throw new System.InvalidOperationException($"{nameof(AddressLibrary)}: Unexpected {nameof(offsetType)} encountered, {offsetType}.");
                    }
                    catch (System.InvalidOperationException invalidOperationException)
                    {
                        Log.Information($"{invalidOperationException}");

                        throw;
                    }
                }
                }

                if ((offsetType & 8) != 0)
                {
                    offset *= (System.UInt64)header.PointerSize;
                }

                offsets.Add(identifier, new System.IntPtr((System.Int64)offset));

                previousIdentifier = identifier;
                previousOffset     = offset;
            }

            return(offsets);
        }
示例#32
0
文件: Type.cs 项目: Rype69/utilities
        /// <summary>
        /// Find all non-abstract classes derived from the specified class.
        /// </summary>
        /// <param name="baseType">
        /// The topmost class in the class hierarchy.
        /// </param>
        /// <returns>
        /// All non-abstract classes derived from the baseType with a default constructor.
        /// </returns>
        public static System.Collections.Generic.List <System.Type> GetDerivedClasses(System.Type baseType)
        {
            var result = new System.Collections.Generic.List <System.Type>();

            // try
            // {
            // Loop through each loaded assembly and each exported type
            // looking for non-abstract types that derive from our property//s type
            foreach (var t in from a in System.AppDomain.CurrentDomain.GetAssemblies()
                     from t in a.GetTypes()
                     where (!t.IsAbstract) && t.IsSubclassOf(baseType)
                     where (t.GetConstructor(System.Type.EmptyTypes) != null)
                     where result.IndexOf(t) == -1
                     select t)
            {
                result.Add(t);
            }

            // }

            // catch (System.Exception)
            // {
            // This exception should only happen in a Design environment in which the
            // controls that use this method are being changed and recompiled.
            //
            // This is because of a charming //feature// that Visual Studio has while
            // you stay in a single Visual Studio session. (If you exit and re-enter Visual Studio,
            // this problem goes away.)

            // When a project is compiled, its dll is placed in a temp directory and used
            // by web pages in the solution. When it is re-compiled, the new dll is placed in a
            // new temp directory, but the pre-existing usages of the control still point - by default -
            // to the old temp directory.

            // This has an unpleasant side effect (among many others!) of causing multiple versions of the
            // same class definition to appear in the list of loaded dll assemblies. This can cause
            // a duplication error.
            // }
            var sortedList = new System.Collections.Generic.SortedList <string, System.Type>(result.Capacity);

            foreach (var t in result)
            {
                // try
                // {
                sortedList.Add($"{t.Name}::{t.FullName}::{t.GUID}", t);

                // }

                // catch (System.Exception)
                // {
                //  Ditto on the reason for an exception here.
                // }
            }

            var sortedResult = new System.Collections.Generic.List <System.Type> {
                Capacity = sortedList.Count
            };

            for (var i = 0; i <= (sortedList.Count - 1); i++)
            {
                sortedResult.Add(result[result.IndexOf(sortedList.Values[i])]);
            }

            return(sortedResult);
        }
示例#33
0
 protected virtual void DoUPnPIGD()
 {
     try
     {
         // Wait 20 seconds before continue
         int i = 0;
         do
         {
             Thread.Sleep(1 * 1000);
         } while (((Functions.UPnPIGD & Success) != Functions.UPnPIGD) && i++ > 20);
         System.Collections.Generic.SortedList<string, UPnPDevice> tmpDevices = new System.Collections.Generic.SortedList<string, UPnPDevice>(upnp.RootDevices);
         foreach (System.Collections.Generic.KeyValuePair<string, UPnPDevice> devicePair in tmpDevices)
         {
             FlowLib.Events.FmdcEventArgs e = new FlowLib.Events.FmdcEventArgs(Actions.UPnPDeviceDescription, devicePair.Key);
             UpdateBase(this, e);
         }
     }
     finally
     {
         //if ((Functions.UPnPIGD & Success) == Functions.UPnPIGD)
         //{
             Progress = Functions.UPnPExternalRecieveAccess;
         //}
         //else
         //{
         //    Progress = Functions.End;
         //}
     }
 }
示例#34
0
文件: BAMSort.cs 项目: cpatmoore/bio
        /// <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;
        }
示例#35
0
        static void Main(string[] args)
        {
            ArrayList <string> list = new ArrayList <string>()
            {
                "A", "B", "C", "D", "E", "F", "J", "H", "I", "G", "K", "L"
            };

            // перебор значений
            foreach (object o in list)
            {
                Console.Write($"{o} ");
            }

            //количество элементов
            Console.WriteLine($"\nколичество элементов: {list.Count}");

            Console.WriteLine($"\n - заносим в список элемент 'FF' ");
            list.Add("FF"); // заносим в список строковый массив

            // перебор значений
            foreach (object o in list)
            {
                Console.Write($"{o} ");
            }

            // удаляем первый элемент
            Console.WriteLine($"\n{list[0]} - удаляем первый элемент");
            list.RemoveAt(0);

            // перебор значений
            for (int i = 0; i < list.Count; i++)
            {
                Console.Write($"{list[i]} ");
            }

            // получение элемента по индексу
            Console.WriteLine($"\n{list[0]} - получение элемента по индексу [0]");

            //поиск в коллекции значения
            if (list.Contains("E"))
            {
                // перебор значений
                foreach (object o in list)
                {
                    if (o == "E")
                    {
                        Console.Write($"\n{o} - 'E' поиск успешен");
                    }
                    else
                    {
                        Console.Write($"\n{o} - не 'E' ");
                    }
                }
            }
            Console.WriteLine($"\n");

            var hs = new System.Collections.Generic.HashSet <long>();

            for (long i = 0; i < 10; i++)
            {
                hs.Add(i);
            }

            foreach (var item in hs)
            {
                Console.Write($" {item}");
            }
            Console.WriteLine();

            for (int i = 0; i < hs.Count; i++)
            {
                hs.Remove(i + 1);
            }

            foreach (var item in hs)
            {
                Console.Write($" {item}");
            }
            Console.WriteLine("\n");

            var sl = new System.Collections.Generic.SortedList <long, string>();

            foreach (var item in hs)
            {
                sl.Add(item, "Book");
            }

            foreach (var item in sl)
            {
                Console.Write($" {item}");
            }
            Console.WriteLine("\n");

            foreach (var item in sl)
            {
                if (item.Key == 9)
                {
                    Console.WriteLine($"Совпадение по запросу: 9 - найдено! ({item.Key})");
                }
                else
                {
                    Console.WriteLine($"Совпадение по запросу: 9 - не найдено!!! ({item.Key})");
                }
            }
            Console.WriteLine("\n");

            var CrocoSortedList = new System.Collections.Generic.SortedList <float, Crocodile <string> >();

            CrocoSortedList.Add(0, new Crocodile <string>("Crocodile1", 4));
            CrocoSortedList.Add(1, new Crocodile <string>("Crocodile2", 3));
            CrocoSortedList.Add(2, new Crocodile <string>("Crocodile3", 2));
            CrocoSortedList.Add(3, new Crocodile <string>("Crocodile4", 5));
            CrocoSortedList.Add(4, new Crocodile <string>("Crocodile5", 7));
            CrocoSortedList.Add(5, new Crocodile <string>("Crocodile6", 6));
            CrocoSortedList.Add(6, new Crocodile <string>("Crocodile7", 9));
            CrocoSortedList.Add(7, new Crocodile <string>("Crocodile8", 8));
            CrocoSortedList.Add(8, new Crocodile <string>("Crocodile9", 2));
            CrocoSortedList.Add(9, new Crocodile <string>("Crocodile10", 1));

            // Вывод значения полей объектов на консоль. Используется перегруженный метод ToString() класса Crocodile<T> .
            foreach (object o in CrocoSortedList)
            {
                Console.Write($"\n{o} ");
            }
            Console.WriteLine("\n");

            //поиск в коллекции значения
            foreach (var item in CrocoSortedList)
            {
                if (item.Value == CrocoSortedList[3])
                {
                    Console.WriteLine($"Совпадение по запросу: Crocodile4 - найдено! ({item.Key})");
                }
                else
                {
                    Console.WriteLine($"Совпадение по запросу: Crocodile4 - не найдено!!! ({item.Key})");
                }
            }
            Console.WriteLine("\n");

            var CrocoHashSet = new System.Collections.Generic.HashSet <Crocodile <string> >();

            foreach (var item in CrocoSortedList)
            {
                CrocoHashSet.Add(item.Value);
            }

            // Вывод значения полей объектов на консоль. Используется перегруженный метод ToString() класса Crocodile<T> .
            foreach (object o in CrocoHashSet)
            {
                Console.Write($"\n{o} ");
            }
            Console.WriteLine("\n");

            // Удаляем элемент с идентификационным номером 3. Компаратор будет сравнивать объекты именно по идентификационному номеру соответствие имени объекта не учитывается.
            Console.WriteLine("\nУдаляем элемент с идентификатором(\"3\")");
            CrocoHashSet.Remove(new Crocodile <string>("Crocodile4", 5));

            // Вывод значения полей объектов на консоль. Используется перегруженный метод ToString() класса Crocodile<T> .
            foreach (object o in CrocoHashSet)
            {
                Console.Write($"\n{o} ");
            }
            Console.WriteLine("\n");


            //-------------------------------------------------------------------------------------------------------

            ObservableCollection <Crocodile <string> > crocodiles = new ObservableCollection <Crocodile <string> >
            {
                new Crocodile <string>("Crocodile4", 5),
                new Crocodile <string>("Crocodile11", 6),
                new Crocodile <string>("Crocodile12", 7)
            };

            crocodiles.CollectionChanged += Users_CollectionChanged;

            crocodiles.Add(new Crocodile <string>("Crocodile13", 5));
            crocodiles.RemoveAt(1);
            crocodiles[0] = new Crocodile <string>("Crocodile14", 6);

            foreach (Crocodile <string> crocodile in crocodiles)
            {
                Console.WriteLine(crocodile.Name);
            }

            Console.ReadLine();
        }
示例#36
0
        private Node InitializeTree()
        {
            Node root = new Node();

            //Custom Sorted List, to allow where Multple files in Diff directorys might have the same
            //filename. So still to some degree first come first serve but might be close enough
            //to how microsoft System to match much more closely.
            System.Collections.Generic.SortedList <string, System.Collections.Generic.List <nBrowser.File> > list;
            list = new System.Collections.Generic.SortedList <string, System.Collections.Generic.List <nBrowser.File> >();

            for (int i = 0; i <= Browserfiles.Count - 1; i++)
            {
                if (list.ContainsKey(nbrowserfiles[i].FileName) == false)
                {
                    System.Collections.Generic.List <nBrowser.File> l;
                    l = new System.Collections.Generic.List <nBrowser.File>();
                    list.Add(nbrowserfiles[i].FileName, l);
                }
                list[nbrowserfiles[i].FileName].Add(nbrowserfiles[i]);
            }
            nBrowser.File[] files = new nBrowser.File[Browserfiles.Count];

            int count = 0;

            for (int i = 0; i <= list.Count - 1; i++)
            {
                System.Collections.Generic.List <nBrowser.File> l = list[list.Keys[i]];
                for (int b = 0; b <= l.Count - 1; b++)
                {
                    files[count] = l[b];
                    count++;
                }
            }

            #region Connect Nodes
            for (int i = 0; i <= Browserfiles.Count - 1; i++)
            {
                for (int a = 0; a <= files[i].Keys.Length - 1; a++)
                {
                    Node child  = files[i].GetNode(files[i].Keys[a]);
                    Node parent = null;
                    if (child.ParentId.Length > 0)
                    {
                        parent = this.GetNode(child.ParentId);
                        if (parent == null)
                        {
                            throw new nBrowser.Exception(String.Format("Parent not found with id = {0}", child.ParentId));
                        }
                    }
                    if (parent == null)
                    {
                        parent = root;
                    }
                    parent.AddChild(child);
                }
            }
            #endregion

            #region Inject DefaultBrowser Nodes
            for (int i = 0; i <= Browserfiles.Count - 1; i++)
            {
                for (int a = 0; a <= files[i].DefaultKeys.Length - 1; a++)
                {
                    Node defaultNode = files[i].GetDefaultNode(files[i].DefaultKeys[a]);
                    Node node        = this.GetNode(defaultNode.Id);
                    if (node == defaultNode)
                    {
                        // there is no regular node so the defaultNode is already at
                        // the correct spot in the tree.
                        continue;
                    }
                    Node parentNode = this.GetNode(node.ParentId);
                    if (parentNode == null)
                    {
                        parentNode = root;
                    }
                    // insert the default node between the regular node and it's parent.
                    parentNode.RemoveChild(node);
                    defaultNode.AddChild(node);
                    parentNode.AddChild(defaultNode);
                }
            }
            #endregion

            #region Merge Ref Nodes
            for (int i = 0; i <= Browserfiles.Count - 1; i++)
            {
                foreach (Node refNode in files[i].RefNodes)
                {
                    GetNode(refNode.RefId).MergeFrom(refNode);
                }
            }
            #endregion

            return(root);
        }
        static StackObject *get_Item_1(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 2);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            System.Int32 @key = ptr_of_this_method->Value;

            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            System.Collections.Generic.SortedList <System.Int32, ILRuntime.Runtime.Intepreter.ILTypeInstance> instance_of_this_method = (System.Collections.Generic.SortedList <System.Int32, ILRuntime.Runtime.Intepreter.ILTypeInstance>) typeof(System.Collections.Generic.SortedList <System.Int32, ILRuntime.Runtime.Intepreter.ILTypeInstance>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            var result_of_this_method = instance_of_this_method[key];

            return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method));
        }
示例#38
0
文件: Build.cs 项目: nlhepler/mono
		private Node InitializeTree()
		{
			Node root = new Node();
			//Custom Sorted List, to allow where Multple files in Diff directorys might have the same
			//filename. So still to some degree first come first serve but might be close enough
			//to how microsoft System to match much more closely.
			System.Collections.Generic.SortedList<string, System.Collections.Generic.List<nBrowser.File>> list;
			list = new System.Collections.Generic.SortedList<string, System.Collections.Generic.List<nBrowser.File>>();

			for (int i = 0;i <= Browserfiles.Count - 1;i++)
			{
				if (list.ContainsKey(nbrowserfiles[i].FileName) == false)
				{
					System.Collections.Generic.List<nBrowser.File> l;
					l = new System.Collections.Generic.List<nBrowser.File>();
					list.Add(nbrowserfiles[i].FileName, l);
				}
				list[nbrowserfiles[i].FileName].Add(nbrowserfiles[i]);
			}
			nBrowser.File[] files = new nBrowser.File[Browserfiles.Count];

			int count = 0;
			for (int i = 0;i <= list.Count - 1;i++)
			{
				System.Collections.Generic.List<nBrowser.File> l = list[list.Keys[i]];
				for (int b = 0;b <= l.Count - 1;b++)
				{
					files[count] = l[b];
					count++;
				}
			}

			#region Connect Nodes
			for (int i = 0;i <= Browserfiles.Count - 1;i++)
			{
				for (int a = 0;a <= files[i].Keys.Length - 1;a++)
				{
					Node child = files[i].GetNode(files[i].Keys[a]);
					Node parent = null;
					if (child.ParentId.Length > 0)
					{
						parent = this.GetNode(child.ParentId);
						if (parent == null)
							throw new nBrowser.Exception(String.Format("Parent not found with id = {0}", child.ParentId));
					}
					if (parent == null)
						parent = root;
					parent.AddChild(child);
				}
			}
			#endregion
			
			#region Inject DefaultBrowser Nodes
			for (int i = 0;i <= Browserfiles.Count - 1;i++)
			{
				for (int a = 0;a <= files[i].DefaultKeys.Length - 1;a++)
				{
					Node defaultNode = files[i].GetDefaultNode(files[i].DefaultKeys[a]);
					Node node = this.GetNode(defaultNode.Id);
					if (node == defaultNode) 
					{
						// there is no regular node so the defaultNode is already at
						// the correct spot in the tree.
						continue;
					}
					Node parentNode = this.GetNode(node.ParentId);
					if (parentNode == null)
						parentNode = root;
					// insert the default node between the regular node and it's parent.
					parentNode.RemoveChild(node);
					defaultNode.AddChild(node);
					parentNode.AddChild(defaultNode);
				}
			}
			#endregion

			#region Merge Ref Nodes
			for (int i = 0;i <= Browserfiles.Count - 1;i++)
			{
				foreach (Node refNode in files[i].RefNodes) {
					GetNode(refNode.RefId).MergeFrom(refNode);
				}
			}
			#endregion

			return root;
		}
示例#39
0
        /// <summary>
        /// 获取托盘图标详细信息。
        /// </summary>
        /// <returns></returns>
        public static TrayItemData[] GetTrayWndDetail()
        {
            System.Collections.Generic.SortedList <string, TrayItemData> stlTrayItems = new System.Collections.Generic.SortedList <string, TrayItemData>();
            try
            {
                Thinksea.Windows.Win32API.TBBUTTON tbButtonInfo = new Thinksea.Windows.Win32API.TBBUTTON();
                System.IntPtr hTrayWnd          = System.IntPtr.Zero;
                System.IntPtr hTrayProcess      = System.IntPtr.Zero;
                int           iTrayProcessID    = 0;
                int           iAllocBaseAddress = 0;
                int           iRet           = 0;
                int           iTrayItemCount = 0;

                hTrayWnd = GetTrayWnd();
                Thinksea.Windows.Win32API.User32.GetWindowThreadProcessId(hTrayWnd, ref iTrayProcessID);
                //hTrayProcess = Thinksea.Windows.Win32API.Kernel32.OpenProcess(
                //(uint)Thinksea.Windows.Win32API.ProcessAccessFlags.PROCESS_ALL_ACCESS |
                //(uint)Thinksea.Windows.Win32API.ProcessAccessFlags.PROCESS_VM_OPERATION |
                //(uint)Thinksea.Windows.Win32API.ProcessAccessFlags.PROCESS_VM_READ |
                //(uint)Thinksea.Windows.Win32API.ProcessAccessFlags.PROCESS_VM_WRITE, 0, (uint)iTrayProcessID);
                hTrayProcess = Thinksea.Windows.Win32API.Kernel32.OpenProcess(
                    Thinksea.Windows.Win32API.ProcessAccessFlags.PROCESS_ALL_ACCESS |
                    Thinksea.Windows.Win32API.ProcessAccessFlags.PROCESS_VM_OPERATION |
                    Thinksea.Windows.Win32API.ProcessAccessFlags.PROCESS_VM_READ |
                    Thinksea.Windows.Win32API.ProcessAccessFlags.PROCESS_VM_WRITE, false, (uint)iTrayProcessID);


                iAllocBaseAddress = Thinksea.Windows.Win32API.Kernel32.VirtualAllocEx(hTrayProcess, 0, System.Runtime.InteropServices.Marshal.SizeOf(tbButtonInfo), (int)Thinksea.Windows.Win32API.WindowsNumber.MEM_COMMIT, (int)Thinksea.Windows.Win32API.WindowsNumber.PAGE_READWRITE);
                iTrayItemCount    = Thinksea.Windows.Win32API.User32.SendMessage(hTrayWnd, (int)Thinksea.Windows.Win32API.WindowsNumber.TB_BUTTONCOUNT, 0, 0);

                for (int i = 0; i < iTrayItemCount; i++)
                {
                    try
                    {
                        TrayItemData trayItem = new TrayItemData();
                        Thinksea.Windows.Win32API.TRAYDATA trayData = new Thinksea.Windows.Win32API.TRAYDATA();
                        int           iOut           = 0;
                        int           dwProcessID    = 0;
                        System.IntPtr hRelProcess    = System.IntPtr.Zero;
                        string        strTrayToolTip = string.Empty;

                        iRet = Thinksea.Windows.Win32API.User32.SendMessage(hTrayWnd, (int)Thinksea.Windows.Win32API.WindowsNumber.TB_GETBUTTON, i, iAllocBaseAddress);
                        System.IntPtr hButtonInfo = System.Runtime.InteropServices.Marshal.AllocHGlobal(System.Runtime.InteropServices.Marshal.SizeOf(tbButtonInfo));
                        System.IntPtr hTrayData   = System.Runtime.InteropServices.Marshal.AllocHGlobal(System.Runtime.InteropServices.Marshal.SizeOf(trayData));

                        iRet = Thinksea.Windows.Win32API.Kernel32.ReadProcessMemory(hTrayProcess, iAllocBaseAddress, hButtonInfo, System.Runtime.InteropServices.Marshal.SizeOf(tbButtonInfo), out iOut);
                        System.Runtime.InteropServices.Marshal.PtrToStructure(hButtonInfo, tbButtonInfo);

                        iRet = Thinksea.Windows.Win32API.Kernel32.ReadProcessMemory(hTrayProcess, tbButtonInfo.dwData, hTrayData, System.Runtime.InteropServices.Marshal.SizeOf(trayData), out iOut);
                        System.Runtime.InteropServices.Marshal.PtrToStructure(hTrayData, trayData);

                        byte[] bytTextData = new byte[1024];
                        iRet           = Thinksea.Windows.Win32API.Kernel32.ReadProcessMemory(hTrayProcess, tbButtonInfo.iString, bytTextData, 1024, out iOut);
                        strTrayToolTip = System.Text.Encoding.Unicode.GetString(bytTextData);
                        if (!string.IsNullOrEmpty(strTrayToolTip))
                        {
                            int iNullIndex = strTrayToolTip.IndexOf('\0');
                            strTrayToolTip = strTrayToolTip.Substring(0, iNullIndex);
                        }

                        Thinksea.Windows.Win32API.User32.GetWindowThreadProcessId(trayData.hwnd, ref dwProcessID);
                        //hRelProcess = Thinksea.Windows.Win32API.Kernel32.OpenProcess((uint)Thinksea.Windows.Win32API.ProcessAccessFlags.PROCESS_QUERY_INFORMATION, 0, (uint)dwProcessID);
                        hRelProcess = Thinksea.Windows.Win32API.Kernel32.OpenProcess(Thinksea.Windows.Win32API.ProcessAccessFlags.PROCESS_QUERY_INFORMATION, false, (uint)dwProcessID);
                        System.Text.StringBuilder sbProcImagePath = new System.Text.StringBuilder(256);
                        if (hRelProcess != System.IntPtr.Zero)
                        {
                            Thinksea.Windows.Win32API.Kernel32.GetProcessImageFileName(hRelProcess, sbProcImagePath, sbProcImagePath.Capacity);
                        }

                        string strImageFilePath = string.Empty;
                        if (sbProcImagePath.Length > 0)
                        {
                            int    iDeviceIndex  = sbProcImagePath.ToString().IndexOf("\\", "\\Device\\HarddiskVolume".Length);
                            string strDevicePath = sbProcImagePath.ToString().Substring(0, iDeviceIndex);
                            int    iStartDisk    = (int)'A';
                            while (iStartDisk <= (int)'Z')
                            {
                                System.Text.StringBuilder sbWindowImagePath = new System.Text.StringBuilder(256);
                                iRet = Thinksea.Windows.Win32API.Kernel32.QueryDosDevice(((char)iStartDisk).ToString() + ":", sbWindowImagePath, sbWindowImagePath.Capacity);
                                if (iRet != 0)
                                {
                                    if (sbWindowImagePath.ToString() == strDevicePath)
                                    {
                                        strImageFilePath = ((char)iStartDisk).ToString() + ":" + sbProcImagePath.ToString().Replace(strDevicePath, "");
                                        break;
                                    }
                                }
                                iStartDisk++;
                            }
                        }

                        trayItem.dwProcessID     = dwProcessID;
                        trayItem.fsState         = tbButtonInfo.fsState;
                        trayItem.fsStyle         = tbButtonInfo.fsStyle;
                        trayItem.hIcon           = trayData.hIcon;
                        trayItem.hProcess        = hRelProcess;
                        trayItem.hWnd            = trayData.hwnd;
                        trayItem.idBitmap        = tbButtonInfo.iBitmap;
                        trayItem.idCommand       = tbButtonInfo.idCommand;
                        trayItem.lpProcImagePath = strImageFilePath;
                        trayItem.lpTrayToolTip   = strTrayToolTip;
                        stlTrayItems[string.Format("{0:d8}", tbButtonInfo.idCommand)] = trayItem;
                    }
                    catch { continue; }
                }

                Thinksea.Windows.Win32API.Kernel32.VirtualFreeEx(hTrayProcess, iAllocBaseAddress, System.Runtime.InteropServices.Marshal.SizeOf(tbButtonInfo), (int)Thinksea.Windows.Win32API.WindowsNumber.MEM_RELEASE);
                Thinksea.Windows.Win32API.Kernel32.CloseHandle(hTrayProcess);

                TrayItemData[] trayItems = new TrayItemData[stlTrayItems.Count];
                stlTrayItems.Values.CopyTo(trayItems, 0);
                return(trayItems);
            }
            catch (System.Runtime.InteropServices.SEHException ex)
            {
                throw ex;
            }
            catch (System.Exception ex)
            {
                throw ex;
            }
        }
        static StackObject *Add_2(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 3);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            ILRuntime.Runtime.Intepreter.ILTypeInstance @value = (ILRuntime.Runtime.Intepreter.ILTypeInstance) typeof(ILRuntime.Runtime.Intepreter.ILTypeInstance).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            System.Int32 @key = ptr_of_this_method->Value;

            ptr_of_this_method = ILIntepreter.Minus(__esp, 3);
            System.Collections.Generic.SortedList <System.Int32, ILRuntime.Runtime.Intepreter.ILTypeInstance> instance_of_this_method = (System.Collections.Generic.SortedList <System.Int32, ILRuntime.Runtime.Intepreter.ILTypeInstance>) typeof(System.Collections.Generic.SortedList <System.Int32, ILRuntime.Runtime.Intepreter.ILTypeInstance>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            instance_of_this_method.Add(@key, @value);

            return(__ret);
        }
示例#41
0
		internal void ResetChildern()
		{
			Children = new System.Collections.Generic.SortedList<string, nBrowser.Node>();
			DefaultChildren = new System.Collections.Generic.SortedList<string, nBrowser.Node>();
			ChildrenKeys = new System.Collections.Generic.List<string>();
			DefaultChildrenKeys = new System.Collections.Generic.List<string>();
		}
示例#42
0
文件: parse.cs 项目: paladin74/Dapple
        /// <summary>
        /// Parse the list stylesheet response.
        /// </summary>
        /// <param name="hDocument">The GeosoftXML response</param>
        /// <param name="oStylesheets">The list of stylesheets</param>
        public void ListStylesheets(System.Xml.XmlDocument hDocument, out System.Collections.Generic.SortedList<string, string> oStylesheets)
        {
            System.Xml.XmlNodeList hItemList;
            System.Xml.XmlNode hNode;

            oStylesheets = new System.Collections.Generic.SortedList<string,string>();

            try
            {
                // --- find all the item elements located anywhere in the document ---

                hItemList = hDocument.SelectNodes("//" + Constant.Tag.STYLESHEET_TAG);

                if (hItemList == null) throw new DapException("No stylesheets found");

                // --- loop through all the datasets adding them to the list ---

                for (int i = 0; i < hItemList.Count; i++)
                {
                    System.Xml.XmlNode hAttr;
                    string strName = string.Empty;
                    string strEdition = string.Empty;

                    hNode = hItemList[i];
                    hAttr = hNode.Attributes.GetNamedItem(Constant.Attribute.NAME_ATTR);
                    if (hAttr != null && hAttr.Value != null)
                        strName = hAttr.Value;

                    hAttr = hNode.Attributes.GetNamedItem(Constant.Attribute.EDITION_ATTR);
                    if (hAttr != null && hAttr.Value != null)
                        strEdition = hAttr.Value;

                    if (!string.IsNullOrEmpty(strName) && !oStylesheets.ContainsKey(strName))
                        oStylesheets.Add(strName, strEdition);
                }
            }
            catch (Exception e)
            {
                throw new DapException("Error compiling list of stylesheets", e);
            }
        }
 /// <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);
 }