public MarginPropertyEditor(Dictionary <string, string> kv) : base(kv) { this.Top = int.Parse(kv.get("top", "32")); this.Left = int.Parse(kv.get("left", "32")); this.Right = int.Parse(kv.get("right", "32")); this.Bottom = int.Parse(kv.get("bottom", "32")); }
public PropertyEditor(Dictionary <string, string> kv) { this.Caption = kv.get("caption", "Нет заголовка"); this.Group = kv.get("group", "Прочие"); this.Tooltip = kv.get("tooltip", this.Caption); this.Id = kv["id"]; }
public void runService(string wsdlKey, Dictionary <String, String> args) { switch (wsdlKey) { case "ChannelAdvisor.Admin": //AdminService admin = new AdminService ("ac93793a-4b71-44d4-ad4d-d302c39c238c","Domo123!"); APICredentials creds = new APICredentials() { DeveloperKey = "ac93793a-4b71-44d4-ad4d-d302c39c238c", Password = "******" }; //AdminService admin = AdminService.getInstance ("ac93793a-4b71-44d4-ad4d-d302c39c238c", "Domo123!"); AdminService admin = AdminService.getInstance(args.get("developerKey"), args.get("developerPassword")); admin.APICredentialsValue = creds; var result = admin.GetAuthorizationList(args.get("localId")).ResultData; foreach (AuthorizationResponse resp in result) { Console.WriteLine(resp.AccountID + ":" + resp.LocalID); } break; case "CelsiusToFarenheit": TempConvert converter = new TempConvert(); Console.WriteLine(converter.CelsiusToFahrenheit(args.get("temperature"))); break; case "FarenheitToCelsius": TempConvert converter2 = new TempConvert(); Console.WriteLine(converter2.FahrenheitToCelsius(args.get("temperature"))); break; default: throw new Exception("MagicException:Domo encountered error running service:Unable to map SOAP wsdl"); } }
public void DictionariesExtension_Tests_3() { var d = new Dictionary <string, object> { { "pepe", 3.14m }, { "tronco", "uno que llega" }, }; string tronco = ""; decimal pepe = 0; double doubleNumber = 3; double intNumber = 0; pepe = d.get <decimal>("pepe"); tronco = d.get <string>("tronco"); Assert.AreEqual(3.14m, pepe); Assert.AreEqual(@"uno que llega", tronco); doubleNumber = d.get <double>("notExist"); Assert.AreEqual(0.0, doubleNumber); doubleNumber = d.get <double>("notExist", 34.0); Assert.AreEqual(34.0, doubleNumber); try { intNumber = d.get <int>("tronco", 55); Assert.Fail("It must fail on wrong data type?"); } catch { } }
public EnumPropertyEditor(Dictionary <string, string> kv) : base(kv) { this.CurrentValue = this.DefaultValue = kv.get("default", ""); this.Variants = kv.get("variants", "").Split('¶'); }
public override void Load(Dictionary <string, string> kv) { // this.CurrentValue = kv.get( "value", "" ); this.Top = int.Parse(kv.get("top", "32")); this.Left = int.Parse(kv.get("left", "32")); this.Right = int.Parse(kv.get("right", "32")); this.Bottom = int.Parse(kv.get("bottom", "32")); }
public IntPropertyEditor(Dictionary <string, string> kv) : base(kv) { this.Current = this.Default = int.Parse(kv.get("default", "0")); this.Min = int.Parse(kv.get("min", "0")); this.Max = int.Parse(kv.get("max", "100")); }
public bool Remove(K key) { return(backing.get(key).fold(false, value => { backing.Remove(key); removal(F.kv(key, value)); return true; })); }
public ColorPropertyEditor(Dictionary <string, string> kv) : base(kv) { this.CurrentColor = this.DefaultColor = (Color)ColorConverter.ConvertFromString(kv.get("default", "#ffffffff")); this.Mode = int.Parse(kv.get("mode", "0")); }
public void TestParseWithWildcardLabels() /*throws Exception*/ { TreeWizard wiz = new TreeWizard(adaptor, tokens); CommonTree t = (CommonTree)wiz.Create("(A B C)"); var labels = new Dictionary <string, object>(); bool valid = wiz.Parse(t, "(A %b:. %c:.)", labels); Assert.IsTrue(valid); Assert.AreEqual("B", labels.get("b").ToString()); Assert.AreEqual("C", labels.get("c").ToString()); }
public void TestParseLabelsAndTestText() /*throws Exception*/ { TreeWizard wiz = new TreeWizard(adaptor, tokens); CommonTree t = (CommonTree)wiz.Create("(A B[foo] C)"); var labels = new Dictionary <string, object>(); bool valid = wiz.Parse(t, "(%a:A %b:B[foo] %c:C)", labels); Assert.IsTrue(valid); Assert.AreEqual("A", labels.get("a").ToString()); Assert.AreEqual("foo", labels.get("b").ToString()); Assert.AreEqual("C", labels.get("c").ToString()); }
public void TestParseLabels() /*throws Exception*/ { TreeWizard wiz = new TreeWizard(adaptor, tokens); CommonTree t = (CommonTree)wiz.Create("(A B C)"); IDictionary <string, object> labels = new Dictionary <string, object>(); bool valid = wiz.Parse(t, "(%a:A %b:B %c:C)", labels); assertTrue(valid); assertEquals("A", labels.get("a").ToString()); assertEquals("B", labels.get("b").ToString()); assertEquals("C", labels.get("c").ToString()); }
private void Deserialize(Dictionary <string, object> hash) { this.PurchaseType = hash.getEnum <PurchaseType>("@purchaseType"); this.name = hash.get <string>("name"); this.description = hash.get <string>("description"); this.downloadableContentId = hash.get <string> ("downloadableContentId"); // These localized details will be overwritten when loaded from the app store. // They are set here for testing purposes. this.localizedTitle = name; this.localizedDescription = description; this.priceInLocalCurrency = 1; this.isoCurrencySymbol = "USD"; LocalIds = new Dictionary <BillingPlatform, string>(); platformBundles = new Dictionary <BillingPlatform, Dictionary <string, object> >(); Dictionary <string, object> platforms; if (hash.ContainsKey("platforms")) { platforms = (Dictionary <string, object>)hash ["platforms"]; } else { platforms = new Dictionary <string, object>(); } foreach (BillingPlatform billingPlatform in Enum.GetValues(typeof(BillingPlatform))) { if (platforms.ContainsKey(billingPlatform.ToString())) { Dictionary <string, object> platformData = (Dictionary <string, object>)platforms [billingPlatform.ToString()]; string key = string.Format("{0}.Id", billingPlatform); if (platformData != null && platformData.ContainsKey(key)) { LocalIds.Add(billingPlatform, (string)platformData [key]); } if (platformData != null) { platformBundles [billingPlatform] = platformData; } } if (!LocalIds.ContainsKey(billingPlatform)) { LocalIds [billingPlatform] = Id; } if (!platformBundles.ContainsKey(billingPlatform)) { platformBundles [billingPlatform] = new Dictionary <string, object> (); } } }
public void TestParseLabelsInNestedTree() /*throws Exception*/ { TreeWizard wiz = new TreeWizard(adaptor, tokens); CommonTree t = (CommonTree)wiz.Create("(A (B C) (D E))"); var labels = new Dictionary <string, object>(); bool valid = wiz.Parse(t, "(%a:A (%b:B %c:C) (%d:D %e:E) )", labels); Assert.IsTrue(valid); Assert.AreEqual("A", labels.get("a").ToString()); Assert.AreEqual("B", labels.get("b").ToString()); Assert.AreEqual("C", labels.get("c").ToString()); Assert.AreEqual("D", labels.get("d").ToString()); Assert.AreEqual("E", labels.get("e").ToString()); }
public virtual IRxVal <Option <A> > rxElement(int index) { return(elementRxRefs.get(index).fold( () => { var rxRef = RxRef.a(this.get(index)); // The cast is mono bug. // ArrayTypeMismatchException: Source array type cannot be assigned to destination array type. // (wrapper stelemref) object:stelemref (object,intptr,object) elementRxRefs[index] = rxRef; return rxRef; }, _ => _ )); }
public void selectItem() { if (Inventory.equipped != null && Inventory.equipped.GetComponent <Item> ().CompareTag("Light")) { Destroy(GameObject.Find("Player").GetComponentInChildren <Light>().gameObject); } Inventory.equipped = gameObject; if (item) { //Inventory.hitting = weapon; Inventory.equippedIsForPlacing = true; } else if (weapon) { //Inventory.hitting = weapon; Inventory.equippedIsForPlacing = true; } if (CompareTag("Light")) { GameObject lightPrefab = Dictionary.get("Torch").GetComponentInChildren <Light>().gameObject; GameObject light = (GameObject)GameObject.Instantiate(lightPrefab); light.transform.SetParent(GameObject.Find("Player").transform); light.transform.localPosition = new Vector3(0.1f, 0, -1); light.GetComponent <LightSource>().onPlayer = true; } }
private static Dictionary <Triangle, List <Connection <Triangle> > > CreateSharedEdgesMap( HashSet <IndexConnection> indexConnections, List <Triangle> triangles, LVector3[] vertexVectors) { var connectionMap = new Dictionary <Triangle, List <Connection <Triangle> > >(); foreach (Triangle tri in triangles) { connectionMap.Add(tri, new List <Connection <Triangle> >()); } foreach (IndexConnection indexConnection in indexConnections) { var fromNode = triangles.get(indexConnection.fromTriIndex); var toNode = triangles.get(indexConnection.toTriIndex); var edgeVertexA = vertexVectors[indexConnection.edgeVertexIndex1]; var edgeVertexB = vertexVectors[indexConnection.edgeVertexIndex2]; var edge = new TriangleEdge(fromNode, toNode, edgeVertexA, edgeVertexB); connectionMap.get(fromNode).Add(edge); fromNode.connections.Add(edge); Debug.LogFormat($"Triangle:{fromNode.getIndex()} -->{toNode.getIndex()} {fromNode}-->{toNode}"); } return(connectionMap); }
/** * 修正重复坐标,使坐标相同的下标修改为一致 * <p> * unity的NavMeshData有一些共边的三角形,共边的三角形其实不是连通关系,共边的三角形只是他们共同构成一个凸多边形,并且这种共边的三角形,全部都是扇形排列。 * </p> */ public void amendmentSameVector(int[] indexs, LVector3[] vertices) { if (indexs == null || vertices == null) { return; } Dictionary <LVector3, int> map = new Dictionary <LVector3, int>(); // 检测路径重复点 for (int i = 0; i < vertices.Length; i++) { // 重复出现的坐标 if (map.ContainsKey(vertices[i])) { for (int j = 0; j < indexs.Length; j++) { if (indexs[j] == i) // 修正重复的坐标 // System.out.println(String.format("坐标重复为%s", // indexs[j],i,vertices[i].ToString())); { indexs[j] = map.get(vertices[i]); } } // vertices[i] = null; } else { map.Add(vertices[i], i); } } }
public static void loadPeice(float i, float j, float k) { Vector3 pos = new Vector3(i, j, k); if (Physics2D.OverlapPoint(pos, -1, k - 0.01f, k + 0.01f) != null) { return; } string tile = (string)map[pos]; if (tile != null) { GameObject obj = Dictionary.get(tile); if (!obj.name.Equals("Block(Clone)")) { obj.transform.position = pos; } else { obj = (GameObject)GameObject.Instantiate(obj, pos, Quaternion.identity); obj.transform.SetParent(ground.transform); obj.isStatic = false; } } }
private static List <User> ReadUsers(FileInfo dataDirectory, List <NetflixMovie> movies) { Dictionary <int, List <Preference> > userIDPrefMap = new Dictionary <int, List <Preference> >(104395301, 1.0f); //new HashMap<Integer, List<Preference>>(15485867, 1.0f); int counter = 0; FilenameFilter filenameFilter = new FilenameFilter( delegate(File dir, String filename) { return(filename.startsWith("mv_")); //return filename.startsWith("mv_000"); } ); foreach (FileInfo movieFile in new File(dataDirectory, "training_set").ListFiles(filenameFilter)) { BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(movieFile))); String line = reader.readLine(); if (line == null) { throw new IOException("Can't read first line of file " + movieFile); } int movieID = int.parse(line.substring(0, line.length() - 1)); NetflixMovie movie = movies.get(movieID - 1); if (movie == null) { throw new ArgumentException("No such movie: " + movieID); } while ((line = reader.readLine()) != null) { counter++; if (counter % 100000 == 0) { log.Info("Processed " + counter + " prefs"); } int firstComma = line.indexOf((int)','); Int32 userID = Int32.Parse(line.Substring(0, firstComma)); int secondComma = line.IndexOf((int)',', firstComma + 1); double rating = Double.Parse(line.Substring(firstComma + 1, secondComma)); List <Preference> userPrefs = userIDPrefMap.get(userID); if (userPrefs == null) { userPrefs = new List <Preference>(); userIDPrefMap.Add(userID, userPrefs); } userPrefs.Add(new GenericPreference(null, movie, rating)); } IOUtils.quietClose(reader); } List <User> users = new List <User>(userIDPrefMap.Count); foreach (KeyValuePair <int, List <Preference> > entry in userIDPrefMap) { users.Add(new GenericUser <int>(entry.Key, entry.Value)); } return(users); }
private static Dictionary <Triangle, List <Connection <Triangle> > > CreateIsolatedEdgesMap( Dictionary <Triangle, List <Connection <Triangle> > > connectionMap) { var disconnectionMap = new Dictionary <Triangle, List <Connection <Triangle> > >(); foreach (Triangle tri in connectionMap.Keys) { var connectedEdges = connectionMap.get(tri); var disconnectedEdges = new List <Connection <Triangle> >(); disconnectionMap.Add(tri, disconnectedEdges); if (connectedEdges.Count < 3) { // This triangle does not have all edges connected to other triangles bool ab = true; bool bc = true; bool ca = true; foreach (var item in connectedEdges) { var edge = item as TriangleEdge; if (edge.rightVertex == tri.a && edge.leftVertex == tri.b) { ab = false; } else if (edge.rightVertex == tri.b && edge.leftVertex == tri.c) { bc = false; } else if (edge.rightVertex == tri.c && edge.leftVertex == tri.a) { ca = false; } } if (ab) { disconnectedEdges.Add(new TriangleEdge(tri, null, tri.a, tri.b)); } if (bc) { disconnectedEdges.Add(new TriangleEdge(tri, null, tri.b, tri.c)); } if (ca) { disconnectedEdges.Add(new TriangleEdge(tri, null, tri.c, tri.a)); } } int totalEdges = (connectedEdges.Count + disconnectedEdges.Count); if (totalEdges != 3) { Debug.LogError("Wrong number of edges (" + totalEdges + ") in triangle " + tri.getIndex()); } } return(disconnectionMap); }
public V put(K1 k1, K2 k2, V v) { Dictionary <K2, V> data2 = data.get(k1); V prev = null; if (data2 == null) { data2 = new Dict <K2, V>(); data.put(k1, data2); } else { prev = data2.get(k2); } data2.put(k2, v); return(prev); }
public static IRxVal <A> get(A value) { return(staticCache.get(value).getOrElse(() => { var cached = (IRxVal <A>)RxRef.a(value); staticCache.Add(value, cached); return cached; })); }
public virtual Grammar.LabelElementPair GetTokenLabel(string name) { Grammar.LabelElementPair pair = null; if (tokenLabels != null) { return((Grammar.LabelElementPair)tokenLabels.get(name)); } return(pair); }
public virtual Grammar.LabelElementPair GetRuleListLabel(string name) { Grammar.LabelElementPair pair = null; if (ruleListLabels != null) { return((Grammar.LabelElementPair)ruleListLabels.get(name)); } return(pair); }
public Dictionary <string, List <object> > compileListOclStreams(Dictionary <string, Reader> source, StreamWriter errWriter, Class nodeClass) { resetCounters(); errors.clear(); Dictionary <string, List <object> > result = new Dictionary <string, List <object> >(); // Monitor mon1 = MonitorFactory.start("compile list ocl streams 1"); foreach (KeyValuePair <string, Reader> s in source) { deleteAllConstraintsForSource(s.Key); } // mon1.stop(); foreach (KeyValuePair <string, Reader> s in source) { string sourceName = s.Key; Reader oclExpressionStream = s.Value; // Monitor mon2 = MonitorFactory.start("compile list ocl streams 2"); cstNodes = performSyntaxAnalysis(oclExpressionStream, sourceName, errWriter, nodeClass, errors); result.Add(sourceName, cstNodes); // mon2.stop(); // Monitor mon3 = MonitorFactory.start("compile list ocl streams 3"); if (cstNodes != null) { performSemanticAnalysisPass(sourceName, cstNodes, environment, errWriter, errors, getSemanticAnalyzer(), getPass1CompilerAction()); } // mon3.stop(); } foreach (KeyValuePair <string, Reader> s in source) { string sourceName = s.Key; // Monitor mon4 = MonitorFactory.start("compile list ocl streams 4"); cstNodes = result.get(sourceName); if (cstNodes != null) { performSemanticAnalysisPass(sourceName, cstNodes, environment, errWriter, errors, getSemanticAnalyzer(), getPass2CompilerAction()); } // mon4.stop(); } if (getErrorsCount() == 0) { return(result); } else { return(null); } }
public V get(K1 k1, K2 k2) { Dictionary <K2, V> data2 = data.get(k1); if (data2 == null) { return(null); } return(data2.get(k2)); }
public void register(Command command) { var list = commands.get(command.cmdGroup).getOrElse(() => { var lst = new List <Command>(); commands[command.cmdGroup] = lst; return(lst); }); list.Add(command); }
public static void computePromotion2(HashSet <Character> skuIdSet, Character key, Dictionary <char, int> items) { foreach (char ch in skuIdSet) { String temp = String.valueOf(key) + String.valueOf(ch); if (pt2.containsKey(temp)) { int minimumItems = Math.min(items.get(ch), items.get(key)); totalPrice += (pt2.get(temp) * minimumItems); totalPrice += ((items.get(key) - minimumItems) * currentPrice.get(key)); totalPrice += ((items.get(ch) - minimumItems) * currentPrice.get(ch)); skuIdSet.Remove(ch); skuIdSet.Remove(key); break; } } }
public static IANTLRErrorListener GetErrorListener() { IANTLRErrorListener el = (IANTLRErrorListener)threadToListenerMap.get(Thread.CurrentThread); if (el == null) { return(theDefaultErrorListener); } return(el); }
private static List<User> ReadUsers(FileInfo dataDirectory, List<NetflixMovie> movies) { Dictionary<int, List<Preference>> userIDPrefMap = new Dictionary<int, List<Preference>>(104395301, 1.0f); //new HashMap<Integer, List<Preference>>(15485867, 1.0f); int counter = 0; FilenameFilter filenameFilter = new FilenameFilter( delegate(File dir, String filename) { return filename.startsWith("mv_"); //return filename.startsWith("mv_000"); } ); foreach (FileInfo movieFile in new File(dataDirectory, "training_set").ListFiles(filenameFilter)) { BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(movieFile))); String line = reader.readLine(); if (line == null) { throw new IOException("Can't read first line of file " + movieFile); } int movieID = int.parse(line.substring(0, line.length() - 1)); NetflixMovie movie = movies.get(movieID - 1); if (movie == null) { throw new ArgumentException("No such movie: " + movieID); } while ((line = reader.readLine()) != null) { counter++; if (counter % 100000 == 0) { log.Info("Processed " + counter + " prefs"); } int firstComma = line.indexOf((int) ','); Int32 userID = Int32.Parse(line.Substring(0, firstComma)); int secondComma = line.IndexOf((int) ',', firstComma + 1); double rating = Double.Parse(line.Substring(firstComma + 1, secondComma)); List<Preference> userPrefs = userIDPrefMap.get(userID); if (userPrefs == null) { userPrefs = new List<Preference>(); userIDPrefMap.Add(userID, userPrefs); } userPrefs.Add(new GenericPreference(null, movie, rating)); } IOUtils.quietClose(reader); } List<User> users = new List<User>(userIDPrefMap.Count); foreach (KeyValuePair<int, List<Preference>> entry in userIDPrefMap) { users.Add(new GenericUser<int>(entry.Key, entry.Value)); } return users; }
public void TestParseLabels() { TreeWizard wiz = new TreeWizard( adaptor, tokens ); CommonTree t = (CommonTree)wiz.Create( "(A B C)" ); IDictionary<string, object> labels = new Dictionary<string, object>(); bool valid = wiz.Parse( t, "(%a:A %b:B %c:C)", labels ); assertTrue( valid ); assertEquals( "A", labels.get( "a" ).ToString() ); assertEquals( "B", labels.get( "b" ).ToString() ); assertEquals( "C", labels.get( "c" ).ToString() ); }
protected virtual void IssueRecursionWarnings() { // RECURSION OVERFLOW ICollection<int> dfaStatesWithRecursionProblems = _stateToRecursionOverflowConfigurationsMap.Keys; // now walk truly unique (unaliased) list of dfa states with inf recur // Goal: create a map from alt to map<target,IList<callsites>> // Map<Map<String target, IList<NFAState call sites>> IDictionary<int, IDictionary<string, ICollection<NFAState>>> altToTargetToCallSitesMap = new Dictionary<int, IDictionary<string, ICollection<NFAState>>>(); // track a single problem DFA state for each alt var altToDFAState = new Dictionary<int, DFAState>(); ComputeAltToProblemMaps( dfaStatesWithRecursionProblems, _stateToRecursionOverflowConfigurationsMap, altToTargetToCallSitesMap, // output param altToDFAState ); // output param // walk each alt with recursion overflow problems and generate error ICollection<int> alts = altToTargetToCallSitesMap.Keys; List<int> sortedAlts = new List<int>( alts ); sortedAlts.Sort(); //Collections.sort( sortedAlts ); foreach ( int altI in sortedAlts ) { var targetToCallSiteMap = altToTargetToCallSitesMap.get( altI ); var targetRules = targetToCallSiteMap.Keys; var callSiteStates = targetToCallSiteMap.Values; DFAState sampleBadState = (DFAState)altToDFAState.get( altI ); ErrorManager.RecursionOverflow( this, sampleBadState, altI, targetRules, callSiteStates ); } }
public void TestParseWithWildcardLabels() { TreeWizard wiz = new TreeWizard( adaptor, tokens ); CommonTree t = (CommonTree)wiz.Create( "(A B C)" ); var labels = new Dictionary<string, object>(); bool valid = wiz.Parse( t, "(A %b:. %c:.)", labels ); Assert.IsTrue( valid ); Assert.AreEqual( "B", labels.get( "b" ).ToString() ); Assert.AreEqual( "C", labels.get( "c" ).ToString() ); }
/// <summary> /// This <c>write</c> method will write the key value pairs /// within the provided map to the specified XML node. This will /// write each entry type must contain a key and value so that /// the entry can be deserialized in to the map as a pair. If the /// key or value object is composite it is read as a root object /// so its <c>Root</c> annotation must be present. /// </summary> /// <param name="node"> /// this is the node the map is to be written to /// </param> /// <param name="map"> /// this is the source map that is to be written /// </param> /// <param name="mode"> /// this is the mode that has been inherited /// </param> public void Write(OutputNode node, Dictionary map, Mode mode) { String root = entry.Entry; String name = style.GetElement(root); for(Object index : map.keySet()) { OutputNode next = node.getChild(name); Object item = map.get(index); next.setMode(mode); key.Write(next, index); value.Write(next, item); } }
public void TestParseLabelsAndTestText() { TreeWizard wiz = new TreeWizard( adaptor, tokens ); CommonTree t = (CommonTree)wiz.Create( "(A B[foo] C)" ); var labels = new Dictionary<string, object>(); bool valid = wiz.Parse( t, "(%a:A %b:B[foo] %c:C)", labels ); Assert.IsTrue( valid ); Assert.AreEqual( "A", labels.get( "a" ).ToString() ); Assert.AreEqual( "foo", labels.get( "b" ).ToString() ); Assert.AreEqual( "C", labels.get( "c" ).ToString() ); }
private void readAdvertisedRefsImpl() { var avail = new Dictionary<string, Ref>(); while (true) { string line; try { line = pckIn.ReadString(); } catch (EndOfStreamException) { if (avail.Count == 0) { throw noRepository(); } throw; } if (line == PacketLineIn.END) break; if (avail.Count == 0) { int nul = line.IndexOf('\0'); if (nul >= 0) { // The first line (if any) may contain "hidden" // capability values after a NUL byte. foreach (string c in line.Substring(nul + 1).Split(' ')) remoteCapabilies.Add(c); line = line.Slice(0, nul); } } string name = line.Slice(41, line.Length); if (avail.Count == 0 && name.Equals("capabilities^{}")) { // special line from git-receive-pack to show // capabilities when there are no refs to advertise continue; } ObjectId id = ObjectId.FromString(line.Slice(0, 40)); if (name.Equals(".have")) additionalHaves.Add(id); else if (name.EndsWith("^{}")) { name = name.Slice(0, name.Length - 3); Ref prior = avail.get(name); if (prior == null) throw new PackProtocolException(uri, "advertisement of " + name + "^{} came before " + name); if (prior.PeeledObjectId != null) throw duplicateAdvertisement(name + "^{}"); avail.put(name, new PeeledTag(Storage.Network, name, prior.ObjectId, id)); } else { Ref prior = avail.put(name, new PeeledNonTag(Storage.Network, name, id)); if (prior != null) throw duplicateAdvertisement(name); } } available(avail); }
private Dictionary<string, Host> parse(Stream stream) { var m = new Dictionary<string, Host>(); var sr = new StreamReader(stream); var current = new List<Host>(4); string line; while ((line = sr.ReadLine()) != null) { line = line.Trim(); if (line.Length == 0 || line.StartsWith("#")) continue; var regex = new Regex("[ \t]*[= \t]"); string[] parts = regex.Split(line, 2); string keyword = parts[0].Trim(); string argValue = parts[1].Trim(); var regex2 = new Regex("[ \t]"); if (StringUtils.equalsIgnoreCase("Host", keyword)) { current.Clear(); foreach (string pattern in regex2.Split(argValue)) { string name = dequote(pattern); Host c = m.get(name); if (c == null) { c = new Host(); m.put(name, c); } current.Add(c); } continue; } if (current.isEmpty()) { // We received an option outside of a Host block. We // don't know who this should match against, so skip. // continue; } if (StringUtils.equalsIgnoreCase("HostName", keyword)) { foreach (Host c in current) if (c.hostName == null) c.hostName = dequote(argValue); } else if (StringUtils.equalsIgnoreCase("User", keyword)) { foreach (Host c in current) if (c.user == null) c.user = dequote(argValue); } else if (StringUtils.equalsIgnoreCase("Port", keyword)) { try { int port = int.Parse(dequote(argValue)); foreach (Host c in current) if (c.port == 0) c.port = port; } catch (FormatException) { // Bad port number. Don't set it. } } else if (StringUtils.equalsIgnoreCase("IdentityFile", keyword)) { foreach (Host c in current) if (c.identityFile == null) c.identityFile = toFile(dequote(argValue)); } else if (StringUtils.equalsIgnoreCase("PreferredAuthentications", keyword)) { foreach (Host c in current) if (c.preferredAuthentications == null) c.preferredAuthentications = nows(dequote(argValue)); } else if (StringUtils.equalsIgnoreCase("BatchMode", keyword)) { foreach (Host c in current) if (c.batchMode == null) c.batchMode = yesno(dequote(argValue)); } else if (StringUtils.equalsIgnoreCase("StrictHostKeyChecking", keyword)) { string value = dequote(argValue); foreach (Host c in current) if (c.strictHostKeyChecking == null) c.strictHostKeyChecking = value; } } return m; }
public User(Dictionary<String, String> dict) { this.info = dict.; this.password = dict.get("password"); this.nick = dict.get("nick"); }
public void TestParseLabelsInNestedTree() { TreeWizard wiz = new TreeWizard( adaptor, tokens ); CommonTree t = (CommonTree)wiz.Create( "(A (B C) (D E))" ); var labels = new Dictionary<string, object>(); bool valid = wiz.Parse( t, "(%a:A (%b:B %c:C) (%d:D %e:E) )", labels ); Assert.IsTrue( valid ); Assert.AreEqual( "A", labels.get( "a" ).ToString() ); Assert.AreEqual( "B", labels.get( "b" ).ToString() ); Assert.AreEqual( "C", labels.get( "c" ).ToString() ); Assert.AreEqual( "D", labels.get( "d" ).ToString() ); Assert.AreEqual( "E", labels.get( "e" ).ToString() ); }
public Dictionary<int, int> poll(double timeout) { var readable = read_fds.ToList(); var writeable = write_fds.ToList(); var errors = error_fds.ToList(); Socket.Select(readable, writeable, errors, (int)(timeout * 1000000)); // select in microseconds var events = new Dictionary<int, int>(); foreach(var fd in readable.Select(r => r.fileno())) events[fd] = events.get(fd, 0) | IOLoop.READ; foreach (var fd in writeable.Select(w => w.fileno())) events[fd] = events.get(fd, 0) | IOLoop.WRITE; foreach (var fd in errors.Select(e => e.fileno())) events[fd] = events.get(fd, 0) | IOLoop.ERROR; return events; }
public Application(TupleList<string, CreateRequestHandler, Dictionary<string, object>> handlers_ = null, string default_host_ = "", List<Func<HTTPRequest, OutputTransform>> transforms_ = null, bool wsgi=false, Dictionary<string, object> settings_=null) { if (settings_ == null) settings_ = new Dictionary<string, object>(); if (transforms_ == null) { transforms = new List<Func<HTTPRequest, OutputTransform>>(); if (settings_.get("gzip") != null) transforms.Add(r => new GZipContentEncoding(r)); transforms.Add(r => new ChunkedTransferEncoding(r)); } else transforms = transforms_; handlers = new TupleList<Regex,List<URLSpec>>(); named_handlers = new Dictionary<string, object>(); default_host = default_host_; settings = settings_; //todo implement /*self.ui_modules = {'linkify': _linkify, 'xsrf_form_html': _xsrf_form_html, 'Template': TemplateModule, } self.ui_methods = {}*/ _wsgi = wsgi; /*self._load_ui_modules(settings.get("ui_modules", {})) self._load_ui_methods(settings.get("ui_methods", {}))*/ if (settings.get("static_path") != null) { var path = settings["static_path"] as string; handlers_ = handlers_ ?? new TupleList<string, CreateRequestHandler, Dictionary<string, object>>(); var static_url_prefix = settings.get("static_url_prefix", "/static/"); var static_handler_class = settings.get<CreateRequestHandler>("static_handler_class", (app, rq, args) => new StaticFileHandler(app, rq, args)); var static_handler_args = settings.get("static_handler_args", new Dictionary<string, object>()); static_handler_args["path"] = path; foreach (var pattern in new string[] {Regex.Escape(static_url_prefix) + @"(.*)", @"/(favicon\.ico)", @"/(robots\.txt)"}) { handlers_.Insert(0, Tuple.Create(pattern, static_handler_class, static_handler_args)); } } if (handlers_ != null) add_handlers(".*$", handlers_); // Automatically reload modified modules if (settings.get("debug") != null && !wsgi) { //todo implement //from tornado import autoreload //autoreload.start() } }
public override void OnUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { TLog.d(TAG, "Upgrading database from version {0} to {1}", oldVersion, newVersion); ICursor notesCursor; List<Dictionary<string, string>> db_list = new List<Dictionary<string, string>>(); notesCursor = db.Query(DB_TABLE_NOTES, COLUMNS_VERSION[oldVersion - 1], null, null, null, null, null); notesCursor.MoveToFirst(); if (oldVersion == 1) { // GUID and NOTE_CONTENT are not saved. TLog.d(TAG, "Database version {0} is not supported to update, all old datas will be destroyed", oldVersion); db.ExecSQL("DROP TABLE IF Exists notes"); onCreate(db); return; } // Get old datas from the SQL while(!notesCursor.IsAfterLast) { Dictionary<string, string> row = new Dictionary<string, string>(); for(int i = 0; i < COLUMNS_VERSION[oldVersion - 1].Length; i++) { row.Add (COLUMNS_VERSION[oldVersion - 1][i], notesCursor.GetString(i)); } // create new columns if (oldVersion <= 2) { row.Add(Note.TAGS, ""); } if (oldVersion <= 3) { row.Add(Note.NOTE_CONTENT_PLAIN, stringConverter.encode(Html.FromHtml(row.get(Note.TITLE) + "\n" + row.get(Note.NOTE_CONTENT)).ToString())); } db_list.Add(row); notesCursor.MoveToNext(); } db.ExecSQL("DROP TABLE IF Exists notes"); onCreate(db); // put rows to the database row = new ContentValues(); for(int i = 0; i < db_list.Count; i++) { for(int j = 0; j < COLUMNS_VERSION[newVersion - 1].Length; j++) { row.put(COLUMNS_VERSION[newVersion - 1][j], db_list.get(i).get(COLUMNS_VERSION[newVersion - 1][j])); } db.Insert(DB_TABLE_NOTES, null, row); } }