Esempio n. 1
0
        public static NotifyFulfillmentInput CreateFromDictionary(Dictionary<string, object> jsonMap)
        {
            try
            {
                if (jsonMap == null)
                {
                    return null;
                }

                var request = new NotifyFulfillmentInput();

                if(jsonMap.ContainsKey("receiptId"))
                {
                    request.ReceiptId = (string) jsonMap["receiptId"];
                }

                if(jsonMap.ContainsKey("fulfillmentResult"))
                {
                    request.FulfillmentResult = (string) jsonMap["fulfillmentResult"];
                }

                return request;
            }
            catch (System.ApplicationException ex)
            {
                throw new AmazonException("Error encountered while creating Object from dicionary", ex);
            }
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            Hashtable hashtable = new Hashtable();

            for (int i = 0; i < 1000000; i++)
            {
                hashtable[i.ToString("0000000")] = i;

            }
            Stopwatch s1 = Stopwatch.StartNew();
            var r1 = hashtable.ContainsKey("09999");
            var r2 = hashtable.ContainsKey("30000");
            s1.Stop();
            Console.WriteLine("{0}", s1.Elapsed);

            Dictionary<string, int> dictionary = new Dictionary<string, int>();
            for (int i = 0; i < 1000000; i++)
            {
                dictionary.Add(i.ToString("000000"), i);
            }

            Stopwatch s2 = Stopwatch.StartNew();
            var r3 = dictionary.ContainsKey("09999");
            var r4 = dictionary.ContainsKey("30000");
            s2.Stop();
            Console.WriteLine("{0}", s2.Elapsed);
        }
Esempio n. 3
0
        public int[] TwoSum(int[] nums, int target)
        {
            Dictionary<int, int> dictNums = new Dictionary<int, int>();
            int[] returnvalue = new int[2] { 0, 0 };

            for (int i = 0; i < nums.Length; i++)
            {
                if (!dictNums.ContainsKey(nums[i]))
                {
                    dictNums.Add(nums[i], i);
                }
            }

            for (int i = 0; i < nums.Length; i++)
            {
                int Remains = target - nums[i];
                if (dictNums.ContainsKey(Remains))
                {
                    int RemainsIndex = dictNums[Remains];
                    if (i != RemainsIndex)
                    {
                        returnvalue[0] = i + 1;
                        returnvalue[1] = RemainsIndex + 1;
                        break;
                    }
                }
            }

            Array.Sort(returnvalue);
            return returnvalue;
        }
Esempio n. 4
0
    void Start() {
        hoverTrailSet = new HashSet<TrailRenderer>(hoverTrails);
        flightTrailSet = new HashSet<TrailRenderer>(flightTrails);
        stunTrailSet = new HashSet<TrailRenderer>(stunTrails);
        trailTimes = new Dictionary<TrailRenderer, float>();

        foreach (TrailRenderer t in hoverTrails) {
            if (!trailTimes.ContainsKey(t)) {
                trailTimes.Add(t, t.time);
            }
        }

        foreach (TrailRenderer t in flightTrails) {
            if (!trailTimes.ContainsKey(t)) {
                trailTimes.Add(t, t.time);
            }
        }

        foreach (TrailRenderer t in stunTrails) {
            if (!trailTimes.ContainsKey(t)) {
                trailTimes.Add(t, t.time);
            }
        }

        hoverTrails = null;
        flightTrails = null;
        stunTrails = null;

        this.mode = PlayerModeManager.PlayerMode.Stun;
        SetMode(PlayerModeManager.PlayerMode.Hover);
    }
Esempio n. 5
0
File: Prefs.cs Progetto: mnisl/OD
		///<summary></summary>
		public static void FillCache(DataTable table){
			//No need to check RemotingRole; no call to db.
			Dictionary<string,Pref> dictPrefs=new Dictionary<string,Pref>();
			Pref pref;
			//PrefName enumpn;
			//Can't use Crud.PrefCrud.TableToList(table) because it will fail the first time someone runs 7.6 before conversion.
			List<string> listDuplicatePrefs=new List<string>();
			for(int i=0;i<table.Rows.Count;i++) {
				pref=new Pref();
				if(table.Columns.Contains("PrefNum")) {
					pref.PrefNum=PIn.Long(table.Rows[i]["PrefNum"].ToString());
				}
				pref.PrefName=PIn.String(table.Rows[i]["PrefName"].ToString());
				pref.ValueString=PIn.String(table.Rows[i]["ValueString"].ToString());
				//no need to load up the comments.  Especially since this will fail when user first runs version 5.8.
				if(dictPrefs.ContainsKey(pref.PrefName)) {
					listDuplicatePrefs.Add(pref.PrefName);//The current preference is a duplicate preference.
				}
				else {
					dictPrefs.Add(pref.PrefName,pref);
				}
			}
			if(listDuplicatePrefs.Count>0 &&																				//Duplicate preferences found, and
				dictPrefs.ContainsKey(PrefName.CorruptedDatabase.ToString()) &&				//CorruptedDatabase preference exists (only v3.4+), and
				dictPrefs[PrefName.CorruptedDatabase.ToString()].ValueString!="0")		//The CorruptedDatabase flag is set.
			{
				throw new ApplicationException(Lans.g("Prefs","Your database is corrupted because an update failed.  Please contact us.  This database is unusable and you will need to restore from a backup."));
			}
			else if(listDuplicatePrefs.Count>0) {//Duplicate preferences, but the CorruptedDatabase flag is not set.
				throw new ApplicationException(Lans.g("Prefs","Duplicate preferences found in database")+": "+String.Join(",",listDuplicatePrefs));
			}
			PrefC.Dict=dictPrefs;
		}
        public void PerformAnalysis(BasicBlocks basicBlocks)
        {
            // Create dictionary of referenced blocks
            Dictionary<BasicBlock, int> referenced = new Dictionary<BasicBlock, int>(basicBlocks.Count);

            // Allocate list of ordered Blocks
            blockOrder = new BasicBlock[basicBlocks.Count];
            int orderBlockCnt = 0;

            // Create sorted worklist
            var workList = new Stack<BasicBlock>();

            foreach (var head in basicBlocks.HeadBlocks)
            {
                workList.Push(head);

                while (workList.Count != 0)
                {
                    var block = workList.Pop();

                    if (!referenced.ContainsKey(block))
                    {
                        referenced.Add(block, 0);
                        blockOrder[orderBlockCnt++] = block;

                        foreach (var successor in block.NextBlocks)
                            if (!referenced.ContainsKey(successor))
                                workList.Push(successor);
                    }
                }
            }
        }
	// We want to mark different elevation zones so that we can draw
	// island-circling roads that divide the areas.
	public void createRoads(Map map) {
		// Oceans and coastal polygons are the lowest contour zone
		// (1). Anything connected to contour level K, if it's below
		// elevation threshold K, or if it's water, gets contour level
		// K.  (2) Anything not assigned a contour level, and connected
		// to contour level K, gets contour level K+1.
		var queue = new Queue<Center> ();
		var elevationThresholds = new float[]{0F, 0.05F, 0.37F, 0.64F};

		var cornerContour = new Dictionary<int, int>();  // corner index -> int contour level
		var centerContour = new Dictionary<int, int>();  // center index -> int contour level
		
		foreach (Center p in map.centers) {
			if (p.coast || p.ocean) {
				centerContour[p.index] = 1;
				queue.Enqueue(p);
			}
		}
		
		while (queue.Count > 0) {
			var p = queue.Dequeue();
			foreach (var r in p.neighbors) {
				var newLevel = centerContour.ContainsKey(p.index)?centerContour[p.index]:0;

				while (newLevel < elevationThresholds.Length && (r.elevation > elevationThresholds[newLevel] && !r.water)) {
					// NOTE: extend the contour line past bodies of water so that roads don't terminate inside lakes.
					newLevel += 1;
				}

				if (centerContour.ContainsKey(r.index)){
					if (newLevel < centerContour[r.index]){
						centerContour[r.index] = newLevel;
						queue.Enqueue(r);
					}
				}
			}
		}
		
		// A corner's contour level is the MIN of its polygons
		foreach (Center p in map.centers) {
			foreach (var q in p.corners) {
				int c1 = cornerContour.ContainsKey(q.index)?cornerContour[q.index]:999;
				int c2 = centerContour.ContainsKey(p.index)?centerContour[p.index]:999;
				cornerContour[q.index] = Mathf.Min(c1,c2);
			}
		}
		
		// Roads go between polygons that have different contour levels
		foreach (Center p in map.centers) {
			foreach (var edge in p.borders) {
				if (edge.v0 != null && edge.v1 !=null && cornerContour[edge.v0.index] != cornerContour[edge.v1.index]) {
					road[edge.index] = Mathf.Min(cornerContour[edge.v0.index], cornerContour[edge.v1.index]);
					if (!roadConnections.ContainsKey(p.index)) {
						roadConnections[p.index] = new List<Edge>();
					}
					roadConnections[p.index].Add(edge);
				}
			}
		}
	}
Esempio n. 8
0
        public bool CreateIDSpread(string projectPath, Dictionary<string, Dictionary<string, string>> idAllClass, ArrayList textFrameColumnClass)
        {
            _idAllClass = idAllClass;
            _textFrameColumnClass = textFrameColumnClass;
            int noOfTextFrames = textFrameColumnClass.Count;
            const int pageCount = 3;

            if (_idAllClass.ContainsKey("@page") || _idAllClass.ContainsKey("@page:first") || _idAllClass.ContainsKey("@page:left") || _idAllClass.ContainsKey("@page:right"))
            {
                _useMasterGrid = true;
            }
            for (int spread = 1; spread <= pageCount; spread++)
            {
                CreateaFile(projectPath, spread);
                CreateSpread(spread);
                CreateFlattenerPreference(); // Static code
                CreatePage();
                if (spread == 1)
                {
                    CreateTextFrame(noOfTextFrames);
                }
                CloseFile(); // Static code
                GetPagesPerSpread();
            }
            return true;
        }
Esempio n. 9
0
        /// <summary>
        /// Creates a new editor for the supplied node type.
        /// <param name="nodeType">The type of the node to be inspected.</param>
        /// <returns>An editor for the supplied type.</returns>
        /// </summary>
        public static NodeEditor CreateEditor (Type nodeType) {
            // Create type
            if (s_CustomEditors == null) {
                s_CustomEditors = new Dictionary<Type, Type>();

                foreach (Type editorType in EditorTypeUtility.GetDerivedTypes(typeof(NodeEditor))) {
                    var customEditorAttr = AttributeUtility.GetAttribute<CustomNodeEditorAttribute>(editorType, true);
                    if (customEditorAttr != null) {
                        if (s_CustomEditors.ContainsKey(customEditorAttr.inspectedType))
                            s_CustomEditors[customEditorAttr.inspectedType] = editorType;
                        else
                            s_CustomEditors.Add(customEditorAttr.inspectedType, editorType);

                        // Add derived types?
                        if (customEditorAttr.editorForChildClasses) {
                            foreach (var childType in TypeUtility.GetDerivedTypes(customEditorAttr.inspectedType)) {
                                if (!s_CustomEditors.ContainsKey(childType))
                                    s_CustomEditors.Add(childType, editorType);
                            }
                        }
                    }
                }
            }

            // Try get custom nodeeditor attribute
            Type customEditorType = null;
            s_CustomEditors.TryGetValue(nodeType, out customEditorType);
            if (customEditorType != null) {
                var nodeEditor = Activator.CreateInstance(customEditorType) as NodeEditor;
                if (nodeEditor != null)
                    return nodeEditor;
            }

            return new NodeEditor();
        }
Esempio n. 10
0
        public BatArg(Dictionary<string, string> keys)
        {
            Model = (BatModel)(int.Parse(keys["Model"]));
            Hierarchy = (DestHierarchy)(int.Parse(keys["DestHierarchy"]));
            PC = keys.ContainsKey("PC");
            IOS = keys.ContainsKey("IOS");
            AND = keys.ContainsKey("AND");
            if (keys.TryGetValue("SrcFolder", out SrcFolder))	
			{
				SrcFolder = Application.dataPath + SrcFolder;
				SrcFolder.Replace("\\", "/");
			}
            if (keys.TryGetValue("SrcFolderName", out SrcFolderName)) SrcFolderName.Replace("\\", "/");
            SearchLoop = keys.ContainsKey("SearchLoop");
            if (keys.TryGetValue("SearchPrefix", out SearchPrefix))	SearchPrefix.Replace("\\", "/");
            if (keys.TryGetValue("DestFolder", out DestFolderPath))	
			{
				DestFolderPath = Application.dataPath + "/../.." + DestFolderPath;
				DestFolderPath.Replace("\\", "/");
			}
            if (keys.TryGetValue("DestFolderName", out DestFolderName))	DestFolderName.Replace("\\", "/");
			
//			Debug.Log(JsonWriter.Serialize(this));

        }
Esempio n. 11
0
        public static GetUserDataResponse CreateFromDictionary(Dictionary<string, object> jsonMap)
        {
            try
            {
                if (jsonMap == null)
                {
                    return null;
                }

                var request = new GetUserDataResponse();

                if(jsonMap.ContainsKey("requestId"))
                {
                    request.RequestId = (string) jsonMap["requestId"];
                }

                if(jsonMap.ContainsKey("amazonUserData"))
                {
                    request.AmazonUserData = AmazonUserData.CreateFromDictionary(jsonMap["amazonUserData"] as Dictionary<string, object>);
                }

                if(jsonMap.ContainsKey("status"))
                {
                    request.Status = (string) jsonMap["status"];
                }

                return request;
            }
            catch (System.ApplicationException ex)
            {
                throw new AmazonException("Error encountered while creating Object from dicionary", ex);
            }
        }
        /// <summary>
        /// Deserializes Company from web api data.
        /// 
        /// IMPORTANT: Only values used for notification list will work at this implementation.
        /// </summary>
        /// <param name="companyDict"></param>
        /// <returns></returns>
        public Company DeserializeCompany(Dictionary<string, object> companyDict)
        {
            Company company = new Company();
            System.Diagnostics.Debug.WriteLine("companyDict created");

            company.id = companyDict["id"].ToString();
            company.id = Hasher.Base64Encode(company.id);

            if (companyDict.ContainsKey("name"))
            {
                company.name = companyDict["name"].ToString();
            }

            if (companyDict.ContainsKey("modified"))
            {
                company.name = companyDict["modified"].ToString();
            }

            if (companyDict.ContainsKey("logo"))
            {
                company.logo = companyDict["logo"].ToString();
            }

            return company;
        } 
Esempio n. 13
0
        public static Ad CreateFromDictionary(Dictionary<string, object> jsonMap) 
        {
            try 
            {
                if (jsonMap == null)
                {
                    return null;
                }

                var request = new Ad();
                
                
                if(jsonMap.ContainsKey("adType")) 
                {
                    request.AdType = (AdType) System.Enum.Parse(typeof(AdType), (string) jsonMap["adType"]);
                }
                
                if(jsonMap.ContainsKey("identifier")) 
                {
                    request.Identifier = (long) jsonMap["identifier"];
                }

                return request;
            } 
            catch (System.ApplicationException ex) 
            {
                throw new AmazonException("Error encountered while creating Object from dicionary", ex);
            }
        }
Esempio n. 14
0
        public static void CsvLoadTripRoutes(string filename, bool lngFirst)
        {
            // load trip routes
            Dictionary<string, LinkedList<Waypoint>> routes = new Dictionary<string, LinkedList<Waypoint>>();
            using (CsvFileReader reader = new CsvFileReader(filename))
            {
                CsvRow row = new CsvRow();
                while (reader.ReadRow(row, ','))
                {
                    string routeID = row[0];
                    double distance = 0;
                    double lat = Convert.ToDouble(lngFirst ? row[2] : row[1]);
                    double lng = Convert.ToDouble(lngFirst ? row[1] : row[2]);
                    if (routes.ContainsKey(routeID))
                        distance = routes[routeID].First.Value.GetDistance(new Location(lat, lng, "null"));
                    Waypoint waypoint = new Waypoint(lat, lng, TimeSpan.Parse(row[3]), distance, row[4].Replace("\"", ""));

                    // Scenario #1
                    if (!routes.ContainsKey(routeID))
                        routes[routeID] = new LinkedList<Waypoint>();
                    routes[routeID].AddLast(waypoint);

                }
            }
            foreach (LinkedList<Waypoint> w in routes.Values)
            {
                Route r = new Route(w.ToArray());
                string key = Route.GetKey(r.start, r.end);
                MapTools.routes.Add(key, r);
            }
        }
Esempio n. 15
0
        public static Placement CreateFromDictionary(Dictionary<string, object> jsonMap) 
        {
            try 
            {
                if (jsonMap == null)
                {
                    return null;
                }

                var request = new Placement();
                
                
                if(jsonMap.ContainsKey("dock")) 
                {
                    request.Dock = (Dock) System.Enum.Parse(typeof(Dock), (string) jsonMap["dock"]);
                }
                
                if(jsonMap.ContainsKey("horizontalAlign")) 
                {
                    request.HorizontalAlign = (HorizontalAlign) System.Enum.Parse(typeof(HorizontalAlign), (string) jsonMap["horizontalAlign"]);
                }
                
                if(jsonMap.ContainsKey("adFit")) 
                {
                    request.AdFit = (AdFit) System.Enum.Parse(typeof(AdFit), (string) jsonMap["adFit"]);
                }

                return request;
            } 
            catch (System.ApplicationException ex) 
            {
                throw new AmazonException("Error encountered while creating Object from dicionary", ex);
            }
        }
        public void TraceListenerFilterOnMultipleCollectionsWithCommonElementsDoesNotRepeatElements()
        {
            TraceListenerFilter filter = new TraceListenerFilter();

            TraceListener listener1 = new MockTraceListener();
            TraceListener listener2 = new MockTraceListener();
            IList traceListenersCollection1 = new TraceListener[] { listener1, listener2 };
            TraceListener listener3 = new MockTraceListener();
            TraceListener listener4 = new MockTraceListener();
            IList traceListenersCollection2 = new TraceListener[] { listener2, listener3, listener4 };

            int i = 0;
            Dictionary<TraceListener, int> listeners = new Dictionary<TraceListener, int>();
            foreach (TraceListener listener in filter.GetAvailableTraceListeners(traceListenersCollection1))
            {
                i++;
                listeners[listener] = (listeners.ContainsKey(listener) ? listeners[listener] : 0) + 1;
            }
            foreach (TraceListener listener in filter.GetAvailableTraceListeners(traceListenersCollection2))
            {
                i++;
                listeners[listener] = (listeners.ContainsKey(listener) ? listeners[listener] : 0) + 1;
            }

            Assert.AreEqual(4, i);
            Assert.AreEqual(1, listeners[listener1]);
            Assert.AreEqual(1, listeners[listener2]);
            Assert.AreEqual(1, listeners[listener3]);
            Assert.AreEqual(1, listeners[listener4]);
        }
Esempio n. 17
0
        public static AdPair CreateFromDictionary(Dictionary<string, object> jsonMap) 
        {
            try 
            {
                if (jsonMap == null)
                {
                    return null;
                }

                var request = new AdPair();
                
                
                if(jsonMap.ContainsKey("adOne")) 
                {
                    request.AdOne = Ad.CreateFromDictionary(jsonMap["adOne"] as Dictionary<string, object>); 
                }
                
                if(jsonMap.ContainsKey("adTwo")) 
                {
                    request.AdTwo = Ad.CreateFromDictionary(jsonMap["adTwo"] as Dictionary<string, object>); 
                }

                return request;
            } 
            catch (System.ApplicationException ex) 
            {
                throw new AmazonException("Error encountered while creating Object from dicionary", ex);
            }
        }
Esempio n. 18
0
 public int countPairs(string[] words)
 {
     int i, j, k;
     int len = words.Length;
     int res = 0;
     for (i = 0; i < len; i++)
     {
         for (j = i + 1; j < len; j++)
         {
             if (words[i].Length != words[j].Length) continue;
             Dictionary<char, int> dica = new Dictionary<char, int>();
             Dictionary<char, int> dicb = new Dictionary<char, int>();
             int count = 1;
             for (k = 0; k < words[i].Length; k++)
             {
                 if (dica.ContainsKey(words[i][k]))
                 {
                     if (!dicb.ContainsKey(words[j][k])) break;
                     if (dica[words[i][k]] != dicb[words[j][k]]) break;
                 }
                 else
                 {
                     if (dicb.ContainsKey(words[j][k])) break;
                     dica[words[i][k]] = dicb[words[j][k]] = count++;
                 }
             }
             if (k == words[i].Length)
             {
                 res++;
             }
         }
     }
     return res;
 }
Esempio n. 19
0
        public static AmazonUserData CreateFromDictionary(Dictionary<string, object> jsonMap)
        {
            try
            {
                if (jsonMap == null)
                {
                    return null;
                }

                var request = new AmazonUserData();

                if(jsonMap.ContainsKey("userId"))
                {
                    request.UserId = (string) jsonMap["userId"];
                }

                if(jsonMap.ContainsKey("marketplace"))
                {
                    request.Marketplace = (string) jsonMap["marketplace"];
                }

                return request;
            }
            catch (System.ApplicationException ex)
            {
                throw new AmazonException("Error encountered while creating Object from dicionary", ex);
            }
        }
Esempio n. 20
0
    public int countBananaSplits(string[] ingredients)
    {
        Dictionary<string, int> dict = new Dictionary<string, int>();
        for (int i = 0; i < ingredients.Length; i++)
        {
            if (dict.ContainsKey(ingredients[i]))
            {
                dict[ingredients[i]]++;
            }
            else
            {
                dict.Add(ingredients[i], 1);
            }
        }

        if (!dict.ContainsKey("ice cream"))
        {
            return 0;
        }
        if (!dict.ContainsKey("banana"))
        {
            return 0;
        }

        int ret = 1;
        Dictionary<string, int>.Enumerator e = dict.GetEnumerator();
        while (e.MoveNext())
        {
            if (e.Current.Key != "ice cream" && e.Current.Key != "banana")
                ret *= (e.Current.Value + 1);
        }

        return dict["ice cream"]*dict["banana"]*(ret - 1);
    }
Esempio n. 21
0
	public GooglePurchase( Dictionary<string,object> dict )
	{
		if( dict.ContainsKey( "packageName" ) )
			packageName = dict["packageName"].ToString();

		if( dict.ContainsKey( "orderId" ) )
			orderId = dict["orderId"].ToString();

		if( dict.ContainsKey( "productId" ) )
			productId = dict["productId"].ToString();

		if( dict.ContainsKey( "developerPayload" ) )
			developerPayload = dict["developerPayload"].ToString();
		
		if( dict.ContainsKey( "type" ) )
			type = dict["type"] as string;

		if( dict.ContainsKey( "purchaseTime" ) )
			purchaseTime = long.Parse( dict["purchaseTime"].ToString() );

		if( dict.ContainsKey( "purchaseState" ) )
			purchaseState = (GooglePurchaseState)int.Parse( dict["purchaseState"].ToString() );

		if( dict.ContainsKey( "purchaseToken" ) )
			purchaseToken = dict["purchaseToken"].ToString();

		if( dict.ContainsKey( "signature" ) )
			signature = dict["signature"].ToString();

		if( dict.ContainsKey( "originalJson" ) )
			originalJson = dict["originalJson"].ToString();
	}
Esempio n. 22
0
        public static Stream ListToHtmlTable(object list, Dictionary<string, string> titles, bool IsExportAllCol)
        {
            var sBuilder = new StringBuilder();
            sBuilder.Append("<table cellspacing=\"0\" rules=\"all\" border=\"1\" style=\"border-collapse:collapse;\">");
            sBuilder.Append("<tr>");
            EachHelper.EachListHeader(list, (index, name, type) => 
            {
                if (IsExportAllCol || titles.ContainsKey(name))
                    sBuilder.Append(string.Format("<td>{0}</td>", titles[name]??name));
            });
            sBuilder.Append("</tr>");
            EachHelper.EachListRow(list, (index, row) =>
            {
                sBuilder.Append("<tr>");
                EachHelper.EachObjectProperty(row, (cellIndex, name, value) => {
                    if (IsExportAllCol || titles.ContainsKey(name))
                        sBuilder.Append(string.Format("<td>{0}</td>", value ?? string.Empty));
                });
                sBuilder.Append("</tr>");
            });
            sBuilder.Append("</table");

            byte[] byteArray = Encoding.Default.GetBytes(sBuilder.ToString());
            var stream = new MemoryStream(byteArray);
            return stream;
        }
 private void ApplySettings(ArrayList toolStripSettingsToApply)
 {
     if (toolStripSettingsToApply.Count != 0)
     {
         this.SuspendAllLayout(this.form);
         Dictionary<string, ToolStrip> itemLocationHash = this.BuildItemOriginationHash();
         Dictionary<object, List<SettingsStub>> dictionary2 = new Dictionary<object, List<SettingsStub>>();
         foreach (SettingsStub stub in toolStripSettingsToApply)
         {
             object key = !string.IsNullOrEmpty(stub.ToolStripPanelName) ? stub.ToolStripPanelName : null;
             if (key == null)
             {
                 if (!string.IsNullOrEmpty(stub.Name))
                 {
                     ToolStrip toolStrip = ToolStripManager.FindToolStrip(this.form, stub.Name);
                     this.ApplyToolStripSettings(toolStrip, stub, itemLocationHash);
                 }
             }
             else
             {
                 if (!dictionary2.ContainsKey(key))
                 {
                     dictionary2[key] = new List<SettingsStub>();
                 }
                 dictionary2[key].Add(stub);
             }
         }
         foreach (ToolStripPanel panel in this.FindToolStripPanels(true, this.form.Controls))
         {
             foreach (Control control in panel.Controls)
             {
                 control.Visible = false;
             }
             string name = panel.Name;
             if ((string.IsNullOrEmpty(name) && (panel.Parent is ToolStripContainer)) && !string.IsNullOrEmpty(panel.Parent.Name))
             {
                 name = panel.Parent.Name + "." + panel.Dock.ToString();
             }
             panel.BeginInit();
             if (dictionary2.ContainsKey(name))
             {
                 List<SettingsStub> list2 = dictionary2[name];
                 if (list2 != null)
                 {
                     foreach (SettingsStub stub2 in list2)
                     {
                         if (!string.IsNullOrEmpty(stub2.Name))
                         {
                             ToolStrip strip2 = ToolStripManager.FindToolStrip(this.form, stub2.Name);
                             this.ApplyToolStripSettings(strip2, stub2, itemLocationHash);
                             panel.Join(strip2, stub2.Location);
                         }
                     }
                 }
             }
             panel.EndInit();
         }
         this.ResumeAllLayout(this.form, true);
     }
 }
Esempio n. 24
0
        public static Dictionary<string, object> Dictionary(string[] keys, object[] values)
        {
            var table = new Dictionary<string, object>();
            values = (object[]) values[0];

            for (int i = 0; i < keys.Length; i++)
            {
                string name = keys[i].ToLowerInvariant();
                object entry = i < values.Length ? values[i] : null;

                if (entry == null)
                {
                    if (table.ContainsKey(name))
                        table.Remove(name);
                }
                else
                {
                    if (table.ContainsKey(name))
                        table[name] = entry;
                    else
                        table.Add(name, entry);
                }
            }

            return table;
        }
Esempio n. 25
0
        /// <summary>
        /// Adds a list of violations to the task provider.
        /// </summary>
        /// <param name="violations">The list of violations to add.</param>
        public void AddResults(List<ViolationInfo> violations)
        {
            Param.AssertNotNull(violations, "violations");
            StyleCopTrace.In(violations);

            this.SuspendRefresh();
            
            var hierarchyItems = new Dictionary<string, IVsHierarchy>();

            for (int index = 0; index < violations.Count; index++)
            {
                ViolationInfo violation = violations[index];
                IVsHierarchy hierarchyItem = hierarchyItems.ContainsKey(violation.File) ? hierarchyItems[violation.File] : null;

                var task = new ViolationTask(this.serviceProvider, violation, hierarchyItem);
                
                hierarchyItem = task.HierarchyItem;

                if (!hierarchyItems.ContainsKey(violation.File))
                {
                    hierarchyItems.Add(violation.File, hierarchyItem);
                }

                this.Tasks.Add(task);
            }

            this.ResumeRefresh();

            StyleCopTrace.Out();
        }
Esempio n. 26
0
        //This method determines how many incomplete and complete passes each player had.
        public static Dictionary<string, double[]> passCompletion(List<action> actionList)
        {
            var passes = new Dictionary<string, double[]>();//First index of double[] array is incomplete passes, second index is completed passes

            foreach (action a in actionList)
            {
                Console.WriteLine(a.passer + " -> " + a.receiver + " by " + a.type);

                if (a.receiver != null && (a.type.Equals("air") || a.type.Equals("ground")))
                {
                    if (passes.ContainsKey(a.passer))
                        passes[a.passer][1]++;
                    else
                        passes.Add(a.passer, (new double[2] {0,1}) );
                }

                if (a.receiver == null && (a.type.Equals("air") || a.type.Equals("ground")))
                {
                    if (passes.ContainsKey(a.passer))
                        passes[a.passer][0]++;
                    else
                        passes.Add(a.passer, (new double[2] { 1, 0 }));
                }
            }

            foreach (var player in passes)
                Console.WriteLine(player.Key + "-> Missed: " + player.Value[0] + ", Completed: "+ player.Value[1]);//Prints list of all players and their pass %

            return passes;
        }
            internal MethodInfoOperationSelector(ContractDescription description, MessageDirection directionThatRequiresClientOpSelection)
            {
                operationMap = new Dictionary<object, string>();

                for (int i = 0; i < description.Operations.Count; i++)
                {
                    OperationDescription operation = description.Operations[i];
                    if (operation.Messages[0].Direction == directionThatRequiresClientOpSelection)
                    {
                        if (operation.SyncMethod != null)
                        {
                            if (!operationMap.ContainsKey(operation.SyncMethod.MethodHandle))
                                operationMap.Add(operation.SyncMethod.MethodHandle, operation.Name);
                        }
    
                        if (operation.BeginMethod != null)
                        {
                            if (!operationMap.ContainsKey(operation.BeginMethod.MethodHandle))
                            {
                                operationMap.Add(operation.BeginMethod.MethodHandle, operation.Name);
                                operationMap.Add(operation.EndMethod.MethodHandle, operation.Name);                    
                            }
                        }

                        if (operation.TaskMethod != null)
                        {
                            if (!operationMap.ContainsKey(operation.TaskMethod.MethodHandle))
                            {
                                operationMap.Add(operation.TaskMethod.MethodHandle, operation.Name);
                            }
                        }
                    }
                }
            }
Esempio n. 28
0
        public Dictionary<string, object> Fill(WebInterface webInterface, string filename, OSHttpRequest httpRequest,
            OSHttpResponse httpResponse, Dictionary<string, object> requestParameters, ITranslator translator, out string response)
        {
            response = null;
            var vars = new Dictionary<string, object>();
            
            if (requestParameters.ContainsKey("ResetMenu"))
            {
                PagesMigrator.ResetToDefaults();
                response = translator.GetTranslatedString("ChangesSavedSuccessfully");
                return null;
            }
            if (requestParameters.ContainsKey("ResetSettings"))
            {
                SettingsMigrator.ResetToDefaults();
                response = translator.GetTranslatedString("ChangesSavedSuccessfully");
                return null;
            }

            vars.Add("FactoryReset", translator.GetTranslatedString("FactoryReset"));
            vars.Add("ResetMenuText", translator.GetTranslatedString("ResetMenuText"));
            vars.Add("ResetSettingsText", translator.GetTranslatedString("ResetSettingsText"));
            vars.Add("ResetMenuInfoText", translator.GetTranslatedString("ResetMenuText"));
            vars.Add("ResetSettingsInfoText", translator.GetTranslatedString("ResetSettingsInfoText"));
            vars.Add("Reset", translator.GetTranslatedString("Reset"));

            return vars;
        }
Esempio n. 29
0
 public void Then_The_Items_Are_Added()
 {
     IDictionary<string, string> hash = new Dictionary<string, string>();
     hash.Add(id => "goose", @class => "chicken");
     Assert.That(hash.Count, Is.EqualTo(2));
     Assert.That(hash.ContainsKey("id"), Is.True);
     Assert.That(hash.ContainsKey("class"), Is.True);
 }
Esempio n. 30
0
    public long countVotes(string[] votes, string website)
    {
        int len = votes.Length;
        int i, j, k;
        long[] point = new long[len];
        for (i = 0; i < point.Length; i++) point[i] = 1;
        Dictionary<string, int> name = new Dictionary<string, int>();
        for (i = 0; i < point.Length; i++)
        {
            string[] st = votes[i].Split(' ');
            name[st[0]] = i;
        }
        bool[,] loop = new bool[len, len];
        bool[,] connect = new bool[len, len];
        for (i = 0; i < point.Length; i++)
        {
            point[i] = 1;
            string[] st = votes[i].Split(' ');
            for (j = 1; j < st.Length; j++)
            {
                if (name.ContainsKey(st[j]))
                {
                    loop[i, name[st[j]]] = true;
                    connect[i, name[st[j]]] = true;
                }
                else point[i]++;
            }
        }
        for (k = 0; k < len; k++)
        {
            for (i = 0; i < len; i++)
            {
                for (j = 0; j < len; j++)
                {
                    loop[i, j] |= loop[i, k] & loop[k, j];
                }
            }
        }
        long[] newpoint = new long[len];
        for (i = 0; i < len; i++) newpoint[i] = point[i];

        for (k = 0; k <= len; k++)
        {
            for (i = 0; i < len; i++)
            {
                newpoint[i] = point[i];
                for (j = 0; j < len; j++)
                {
                    if (loop[i, j] && !loop[j, i] && connect[i, j])
                    {
                        newpoint[i] += newpoint[j];
                    }
                }
            }
        }
        if (name.ContainsKey(website)) return newpoint[name[website]];
        else return 1;
    }