internal virtual SignedToken GetOneNotYetVerifiedToken() { foreach (KeyValuePair <SignedToken, RevocationData> e in revocationInfo.EntrySet()) { if (e.Value == null) { LOG.Info("=== Get token to validate " + e.Key); return(e.Key); } } return(null); }
public virtual void RepositoryWithUninitializedSubmodule() { ObjectId id = ObjectId.FromString("abcd1234abcd1234abcd1234abcd1234abcd1234"); string path = "sub"; DirCache cache = db.LockDirCache(); DirCacheEditor editor = cache.Editor(); editor.Add(new _PathEdit_125(id, path)); editor.Commit(); FileBasedConfig modulesConfig = new FileBasedConfig(new FilePath(db.WorkTree, Constants .DOT_GIT_MODULES), db.FileSystem); modulesConfig.SetString(ConfigConstants.CONFIG_SUBMODULE_SECTION, path, ConfigConstants .CONFIG_KEY_PATH, path); modulesConfig.SetString(ConfigConstants.CONFIG_SUBMODULE_SECTION, path, ConfigConstants .CONFIG_KEY_URL, "git://server/repo.git"); modulesConfig.Save(); SubmoduleStatusCommand command = new SubmoduleStatusCommand(db); IDictionary <string, SubmoduleStatus> statuses = command.Call(); NUnit.Framework.Assert.IsNotNull(statuses); NUnit.Framework.Assert.AreEqual(1, statuses.Count); KeyValuePair <string, SubmoduleStatus> module = statuses.EntrySet().Iterator().Next (); NUnit.Framework.Assert.IsNotNull(module); NUnit.Framework.Assert.AreEqual(path, module.Key); SubmoduleStatus status = module.Value; NUnit.Framework.Assert.IsNotNull(status); NUnit.Framework.Assert.AreEqual(path, status.GetPath()); NUnit.Framework.Assert.AreEqual(id, status.GetIndexId()); NUnit.Framework.Assert.AreEqual(SubmoduleStatusType.UNINITIALIZED, status.GetType ()); }
private string ReplaceUri(string uri, IDictionary <string, string> replacements) { if (replacements.IsEmpty()) { return(uri); } KeyValuePair <string, string>?match = null; foreach (KeyValuePair <string, string> replacement in replacements.EntrySet()) { // Ignore current entry if not longer than previous match if (match != null && match.Value.Key.Length > replacement.Key.Length) { continue; } if (!uri.StartsWith(replacement.Key)) { continue; } match = replacement; } if (match != null) { return(match.Value.Value + Sharpen.Runtime.Substring(uri, match.Value.Key.Length)); } else { return(uri); } }
public virtual void RepositoryWithMissingSubmodule() { ObjectId id = ObjectId.FromString("abcd1234abcd1234abcd1234abcd1234abcd1234"); string path = "sub"; DirCache cache = db.LockDirCache(); DirCacheEditor editor = cache.Editor(); editor.Add(new _PathEdit_93(id, path)); editor.Commit(); SubmoduleStatusCommand command = new SubmoduleStatusCommand(db); IDictionary <string, SubmoduleStatus> statuses = command.Call(); NUnit.Framework.Assert.IsNotNull(statuses); NUnit.Framework.Assert.AreEqual(1, statuses.Count); KeyValuePair <string, SubmoduleStatus> module = statuses.EntrySet().Iterator().Next (); NUnit.Framework.Assert.IsNotNull(module); NUnit.Framework.Assert.AreEqual(path, module.Key); SubmoduleStatus status = module.Value; NUnit.Framework.Assert.IsNotNull(status); NUnit.Framework.Assert.AreEqual(path, status.GetPath()); NUnit.Framework.Assert.AreEqual(id, status.GetIndexId()); NUnit.Framework.Assert.AreEqual(SubmoduleStatusType.MISSING, status.GetType()); }
public WeakValueHashMap(IDictionary <K, V> map) : this() { foreach (KeyValuePair <K, V> entry in map.EntrySet()) { Put(entry.Key, entry.Value); } }
/// <exception cref="NGit.Errors.NoWorkTreeException"></exception> /// <exception cref="System.IO.IOException"></exception> private void Checkout() { ObjectReader r = db.ObjectDatabase.NewReader(); try { foreach (KeyValuePair <string, DirCacheEntry> entry in toBeCheckedOut.EntrySet()) { FilePath f = new FilePath(db.WorkTree, entry.Key); CreateDir(f.GetParentFile()); DirCacheCheckout.CheckoutEntry(db, f, entry.Value, r); modifiedFiles.AddItem(entry.Key); } // Iterate in reverse so that "folder/file" is deleted before // "folder". Otherwise this could result in a failing path because // of a non-empty directory, for which delete() would fail. for (int i = toBeDeleted.Count - 1; i >= 0; i--) { string fileName = toBeDeleted[i]; FilePath f = new FilePath(db.WorkTree, fileName); if (!f.Delete()) { failingPaths.Put(fileName, ResolveMerger.MergeFailureReason.COULD_NOT_DELETE); } modifiedFiles.AddItem(fileName); } } finally { r.Release(); } }
public DirectoryIterator(IDictionary <Type, ICollection <Com.Drew.Metadata.Directory> > map) { _mapIterator = map.EntrySet().Iterator(); if (_mapIterator.HasNext()) { _listIterator = _mapIterator.Next().Value.Iterator(); } }
/// <summary>Generate and write the bundle to the output stream.</summary> /// <remarks> /// Generate and write the bundle to the output stream. /// <p> /// This method can only be called once per BundleWriter instance. /// </remarks> /// <param name="monitor">progress monitor to report bundle writing status to.</param> /// <param name="os"> /// the stream the bundle is written to. The stream should be /// buffered by the caller. The caller is responsible for closing /// the stream. /// </param> /// <exception cref="System.IO.IOException"> /// an error occurred reading a local object's data to include in /// the bundle, or writing compressed object data to the output /// stream. /// </exception> public virtual void WriteBundle(ProgressMonitor monitor, OutputStream os) { PackConfig pc = packConfig; if (pc == null) { pc = new PackConfig(db); } PackWriter packWriter = new PackWriter(pc, db.NewObjectReader()); try { HashSet <ObjectId> inc = new HashSet <ObjectId>(); HashSet <ObjectId> exc = new HashSet <ObjectId>(); Sharpen.Collections.AddAll(inc, include.Values); foreach (RevCommit r in assume) { exc.AddItem(r.Id); } packWriter.SetDeltaBaseAsOffset(true); packWriter.SetThin(exc.Count > 0); packWriter.SetReuseValidatingObjects(false); if (exc.Count == 0) { packWriter.SetTagTargets(tagTargets); } packWriter.PreparePack(monitor, inc, exc); TextWriter w = new OutputStreamWriter(os, Constants.CHARSET); w.Write(NGit.Transport.TransportBundleConstants.V2_BUNDLE_SIGNATURE); w.Write('\n'); char[] tmp = new char[Constants.OBJECT_ID_STRING_LENGTH]; foreach (RevCommit a in assume) { w.Write('-'); a.CopyTo(tmp, w); if (a.RawBuffer != null) { w.Write(' '); w.Write(a.GetShortMessage()); } w.Write('\n'); } foreach (KeyValuePair <string, ObjectId> e in include.EntrySet()) { e.Value.CopyTo(tmp, w); w.Write(' '); w.Write(e.Key); w.Write('\n'); } w.Write('\n'); w.Flush(); packWriter.WritePack(monitor, monitor, os); } finally { packWriter.Release(); } }
public virtual void TestRefKeySameAsName() { IDictionary <string, Ref> allRefs = db.GetAllRefs(); foreach (KeyValuePair <string, Ref> e in allRefs.EntrySet()) { NUnit.Framework.Assert.AreEqual(e.Key, e.Value.GetName()); } }
/// <exception cref="System.IO.IOException"></exception> private void Authorize(HttpURLConnection c) { IDictionary <string, IList <string> > reqHdr = c.GetRequestProperties(); SortedDictionary <string, string> sigHdr = new SortedDictionary <string, string>(); foreach (KeyValuePair <string, IList <string> > entry in reqHdr.EntrySet()) { string hdr = entry.Key; if (IsSignedHeader(hdr)) { sigHdr.Put(StringUtils.ToLowerCase(hdr), ToCleanString(entry.Value)); } } StringBuilder s = new StringBuilder(); s.Append(c.GetRequestMethod()); s.Append('\n'); s.Append(Remove(sigHdr, "content-md5")); s.Append('\n'); s.Append(Remove(sigHdr, "content-type")); s.Append('\n'); s.Append(Remove(sigHdr, "date")); s.Append('\n'); foreach (KeyValuePair <string, string> e in sigHdr.EntrySet()) { s.Append(e.Key); s.Append(':'); s.Append(e.Value); s.Append('\n'); } string host = c.GetURL().GetHost(); s.Append('/'); s.Append(Sharpen.Runtime.Substring(host, 0, host.Length - DOMAIN.Length - 1)); s.Append(c.GetURL().AbsolutePath); string sec; try { Mac m = Mac.GetInstance(HMAC); m.Init(privateKey); sec = Base64.EncodeBytes(m.DoFinal(Sharpen.Runtime.GetBytesForString(s.ToString() , "UTF-8"))); } catch (NoSuchAlgorithmException e_1) { throw new IOException(MessageFormat.Format(JGitText.Get().noHMACsupport, HMAC, e_1 .Message)); } catch (InvalidKeyException e_1) { throw new IOException(MessageFormat.Format(JGitText.Get().invalidKey, e_1.Message )); } c.SetRequestProperty("Authorization", "AWS " + publicKey + ":" + sec); }
public virtual void RepositoryWithSubmodule() { WriteTrashFile("file.txt", "content"); Git git = Git.Wrap(db); git.Add().AddFilepattern("file.txt").Call(); git.Commit().SetMessage("create file").Call(); ObjectId id = ObjectId.FromString("abcd1234abcd1234abcd1234abcd1234abcd1234"); string path = "sub"; DirCache cache = db.LockDirCache(); DirCacheEditor editor = cache.Editor(); editor.Add(new _PathEdit_96(id, path)); editor.Commit(); FileBasedConfig modulesConfig = new FileBasedConfig(new FilePath(db.WorkTree, Constants .DOT_GIT_MODULES), db.FileSystem); modulesConfig.SetString(ConfigConstants.CONFIG_SUBMODULE_SECTION, path, ConfigConstants .CONFIG_KEY_PATH, path); string url = "git://server/repo.git"; modulesConfig.SetString(ConfigConstants.CONFIG_SUBMODULE_SECTION, path, ConfigConstants .CONFIG_KEY_URL, url); modulesConfig.Save(); Repository subRepo = Git.CloneRepository().SetURI(db.Directory.ToURI().ToString() ).SetDirectory(new FilePath(db.WorkTree, path)).Call().GetRepository(); AddRepoToClose(subRepo); NUnit.Framework.Assert.IsNotNull(subRepo); SubmoduleWalk generator = SubmoduleWalk.ForIndex(db); NUnit.Framework.Assert.IsTrue(generator.Next()); NUnit.Framework.Assert.IsNull(generator.GetConfigUrl()); NUnit.Framework.Assert.AreEqual(url, generator.GetModulesUrl()); SubmoduleSyncCommand command = new SubmoduleSyncCommand(db); IDictionary <string, string> synced = command.Call(); NUnit.Framework.Assert.IsNotNull(synced); NUnit.Framework.Assert.AreEqual(1, synced.Count); KeyValuePair <string, string> module = synced.EntrySet().Iterator().Next(); NUnit.Framework.Assert.AreEqual(path, module.Key); NUnit.Framework.Assert.AreEqual(url, module.Value); generator = SubmoduleWalk.ForIndex(db); NUnit.Framework.Assert.IsTrue(generator.Next()); NUnit.Framework.Assert.AreEqual(url, generator.GetConfigUrl()); Repository subModRepository = generator.GetRepository(); AddRepoToClose(subModRepository); StoredConfig submoduleConfig = subModRepository.GetConfig(); NUnit.Framework.Assert.AreEqual(url, submoduleConfig.GetString(ConfigConstants.CONFIG_REMOTE_SECTION , Constants.DEFAULT_REMOTE_NAME, ConfigConstants.CONFIG_KEY_URL)); }
private static string[] ToEnvArray(IDictionary <string, string> env) { string[] envp = new string[env.Count]; int i = 0; foreach (KeyValuePair <string, string> e in env.EntrySet()) { envp[i++] = e.Key + "=" + e.Value; } return(envp); }
/// <summary>Retrieve all the qualifiers for which the corresponding condition evaluate to true. /// </summary> /// <remarks>Retrieve all the qualifiers for which the corresponding condition evaluate to true. /// </remarks> /// <param name="cert"></param> /// <returns></returns> public virtual IList <string> GetQualifiers(CertificateAndContext cert) { IList <string> list = new AList <string>(); foreach (KeyValuePair <string, Condition> e in qualifiersAndConditions.EntrySet()) { if (e.Value.Check(cert)) { list.AddItem(e.Key); } } return(list); }
public virtual void RepositoryWithDifferentRevCheckedOutSubmodule() { ObjectId id = ObjectId.FromString("abcd1234abcd1234abcd1234abcd1234abcd1234"); string path = "sub"; DirCache cache = db.LockDirCache(); DirCacheEditor editor = cache.Editor(); editor.Add(new _PathEdit_317(id, path)); editor.Commit(); string url = "git://server/repo.git"; StoredConfig config = ((FileBasedConfig)db.GetConfig()); config.SetString(ConfigConstants.CONFIG_SUBMODULE_SECTION, path, ConfigConstants. CONFIG_KEY_URL, url); config.Save(); FileBasedConfig modulesConfig = new FileBasedConfig(new FilePath(db.WorkTree, Constants .DOT_GIT_MODULES), db.FileSystem); modulesConfig.SetString(ConfigConstants.CONFIG_SUBMODULE_SECTION, path, ConfigConstants .CONFIG_KEY_PATH, path); modulesConfig.SetString(ConfigConstants.CONFIG_SUBMODULE_SECTION, path, ConfigConstants .CONFIG_KEY_URL, url); modulesConfig.Save(); Repository subRepo = Git.Init().SetBare(false).SetDirectory(new FilePath(db.WorkTree , path)).Call().GetRepository(); NUnit.Framework.Assert.IsNotNull(subRepo); RefUpdate update = subRepo.UpdateRef(Constants.HEAD, true); update.SetNewObjectId(ObjectId.FromString("aaaa0000aaaa0000aaaa0000aaaa0000aaaa0000" )); update.ForceUpdate(); SubmoduleStatusCommand command = new SubmoduleStatusCommand(db); IDictionary <string, SubmoduleStatus> statuses = command.Call(); NUnit.Framework.Assert.IsNotNull(statuses); NUnit.Framework.Assert.AreEqual(1, statuses.Count); KeyValuePair <string, SubmoduleStatus> module = statuses.EntrySet().Iterator().Next (); NUnit.Framework.Assert.IsNotNull(module); NUnit.Framework.Assert.AreEqual(path, module.Key); SubmoduleStatus status = module.Value; NUnit.Framework.Assert.IsNotNull(status); NUnit.Framework.Assert.AreEqual(path, status.GetPath()); NUnit.Framework.Assert.AreEqual(id, status.GetIndexId()); NUnit.Framework.Assert.AreEqual(update.GetNewObjectId(), status.GetHeadId()); NUnit.Framework.Assert.AreEqual(SubmoduleStatusType.REV_CHECKED_OUT, status.GetType ()); }
private static string Format(IDictionary<ObjectId, string> missingCommits) { StringBuilder r = new StringBuilder(); r.Append(JGitText.Get().missingPrerequisiteCommits); foreach (KeyValuePair<ObjectId, string> e in missingCommits.EntrySet()) { r.Append("\n "); r.Append(e.Key.Name); if (e.Value != null) { r.Append(" ").Append(e.Value); } } return r.ToString(); }
private static string Format(IDictionary <ObjectId, string> missingCommits) { StringBuilder r = new StringBuilder(); r.Append(JGitText.Get().missingPrerequisiteCommits); foreach (KeyValuePair <ObjectId, string> e in missingCommits.EntrySet()) { r.Append("\n "); r.Append(e.Key.Name); if (e.Value != null) { r.Append(" ").Append(e.Value); } } return(r.ToString()); }
public Header(IDictionary <string, IList <string> > map) : this() { // initialize fields foreach (KeyValuePair <string, IList <string> > next in map.EntrySet()) { string key = next.Key; IList <string> value = next.Value; List <string> linkedList = new List <string>(); foreach (string element in value) { linkedList.AddItem(element); props.AddItem(key); props.AddItem(element); } keyTable.Put(key, linkedList); } }
/// <exception cref="NGit.Errors.NoWorkTreeException"></exception> /// <exception cref="System.IO.IOException"></exception> private void Checkout() { foreach (KeyValuePair <string, DirCacheEntry> entry in toBeCheckedOut.EntrySet()) { FilePath f = new FilePath(db.WorkTree, entry.Key); if (entry.Value != null) { CreateDir(f.GetParentFile()); DirCacheCheckout.CheckoutEntry(db, f, entry.Value); } else { if (!f.Delete()) { failingPaths.Put(entry.Key, ResolveMerger.MergeFailureReason.COULD_NOT_DELETE); } } modifiedFiles.AddItem(entry.Key); } }
/// <exception cref="System.IO.IOException"></exception> private HttpURLConnection Open(string method, string bucket, string key, IDictionary <string, string> args) { StringBuilder urlstr = new StringBuilder(); urlstr.Append("http://"); urlstr.Append(bucket); urlstr.Append('.'); urlstr.Append(DOMAIN); urlstr.Append('/'); if (key.Length > 0) { HttpSupport.Encode(urlstr, key); } if (!args.IsEmpty()) { Iterator <KeyValuePair <string, string> > i; urlstr.Append('?'); i = args.EntrySet().Iterator(); while (i.HasNext()) { KeyValuePair <string, string> e = i.Next(); urlstr.Append(e.Key); urlstr.Append('='); HttpSupport.Encode(urlstr, e.Value); if (i.HasNext()) { urlstr.Append('&'); } } } Uri url = new Uri(urlstr.ToString()); Proxy proxy = HttpSupport.ProxyFor(proxySelector, url); HttpURLConnection c; c = (HttpURLConnection)url.OpenConnection(proxy); c.SetRequestMethod(method); c.SetRequestProperty("User-Agent", "jgit/1.0"); c.SetRequestProperty("Date", HttpNow()); return(c); }
/// <param name="newHead">the object the head points at after the merge</param> /// <param name="base"> /// the common base which was used to produce a content-merge. May /// be <code>null</code> if the merge-result was produced without /// computing a common base /// </param> /// <param name="mergedCommits">all the commits which have been merged together</param> /// <param name="mergeStatus">the status the merge resulted in</param> /// <param name="mergeStrategy"> /// the used /// <see cref="NGit.Merge.MergeStrategy">NGit.Merge.MergeStrategy</see> /// </param> /// <param name="lowLevelResults"> /// merge results as returned by /// <see cref="NGit.Merge.ResolveMerger.GetMergeResults()">NGit.Merge.ResolveMerger.GetMergeResults() /// </see> /// </param> /// <param name="failingPaths"> /// list of paths causing this merge to fail as returned by /// <see cref="NGit.Merge.ResolveMerger.GetFailingPaths()">NGit.Merge.ResolveMerger.GetFailingPaths() /// </see> /// </param> /// <param name="description">a user friendly description of the merge result</param> public MergeCommandResult(ObjectId newHead, ObjectId @base, ObjectId[] mergedCommits , MergeStatus mergeStatus, MergeStrategy mergeStrategy, IDictionary <string, MergeResult <Sequence> > lowLevelResults, IDictionary <string, ResolveMerger.MergeFailureReason> failingPaths, string description) { this.newHead = newHead; this.mergedCommits = mergedCommits; this.@base = @base; this.mergeStatus = mergeStatus; this.mergeStrategy = mergeStrategy; this.description = description; this.failingPaths = failingPaths; if (lowLevelResults != null) { foreach (KeyValuePair <string, MergeResult <Sequence> > result in lowLevelResults.EntrySet ()) { AddConflict(result.Key, result.Value); } } }
/// <summary>Locate the configuration for a specific host request.</summary> /// <remarks>Locate the configuration for a specific host request.</remarks> /// <param name="hostName"> /// the name the user has supplied to the SSH tool. This may be a /// real host name, or it may just be a "Host" block in the /// configuration file. /// </param> /// <returns>r configuration for the requested name. Never null.</returns> public virtual OpenSshConfig.Host Lookup(string hostName) { IDictionary <string, OpenSshConfig.Host> cache = Refresh(); OpenSshConfig.Host h = cache.Get(hostName); if (h == null) { h = new OpenSshConfig.Host(); } if (h.patternsApplied) { return(h); } foreach (KeyValuePair <string, OpenSshConfig.Host> e in cache.EntrySet()) { if (!IsHostPattern(e.Key)) { continue; } if (!IsHostMatch(e.Key, hostName)) { continue; } h.CopyFrom(e.Value); } if (h.hostName == null) { h.hostName = hostName; } if (h.user == null) { h.user = NGit.Transport.OpenSshConfig.UserName(); } if (h.port == 0) { h.port = NGit.Transport.OpenSshConfig.SSH_PORT; } h.patternsApplied = true; return(h); }
public static object Eval(string source, IDictionary<string, Scriptable> bindings) { Context cx = ContextFactory.GetGlobal().EnterContext(); try { Scriptable scope = cx.InitStandardObjects(); if (bindings != null) { foreach (KeyValuePair<string, Scriptable> entry in bindings.EntrySet()) { Scriptable @object = entry.Value; @object.SetParentScope(scope); scope.Put(entry.Key, scope, @object); } } return cx.EvaluateString(scope, source, "source", 1, null); } finally { Context.Exit(); } }
private IAnnotationValue FindRuleDependencyProperty(Tuple <RuleDependency, IElement> dependency, IAnnotationMirror annotationMirror, RuleDependencyProcessor.RuleDependencyProperty property) { IAnnotationValue recognizerValue = null; IAnnotationValue ruleValue = null; IAnnotationValue versionValue = null; IAnnotationValue dependentsValue = null; IDictionary <IExecutableElement, IAnnotationValue> values = annotationMirror.GetElementValues(); foreach (KeyValuePair <IExecutableElement, IAnnotationValue> value in values.EntrySet()) { IAnnotationValue annotationValue = value.Value; if ("rule()".Equals(value.Key.ToString())) { ruleValue = annotationValue; if (!(annotationValue.GetValue() is int)) { processingEnv.GetMessager().PrintMessage(Diagnostic.Kind.Warning, "Expected int constant for annotation property 'rule()'.", dependency.Item2, annotationMirror, annotationValue); return(null); } if ((int)annotationValue.GetValue() != dependency.Item1.Rule()) { // this is a valid dependency annotation, but not the one we're looking for return(null); } } else { if ("recognizer()".Equals(value.Key.ToString())) { recognizerValue = annotationValue; if (!(annotationValue.GetValue() is ITypeMirror)) { processingEnv.GetMessager().PrintMessage(Diagnostic.Kind.Warning, "Expected Class constant for annotation property 'recognizer()'.", dependency.Item2, annotationMirror, annotationValue); return(null); } ITypeMirror annotationRecognizer = (ITypeMirror)annotationValue.GetValue(); ITypeMirror expectedRecognizer = GetRecognizerType(dependency.Item1); if (!processingEnv.GetTypeUtils().IsSameType(expectedRecognizer, annotationRecognizer)) { // this is a valid dependency annotation, but not the one we're looking for return(null); } } else { if ("version()".Equals(value.Key.ToString())) { versionValue = annotationValue; if (!(annotationValue.GetValue() is int)) { processingEnv.GetMessager().PrintMessage(Diagnostic.Kind.Warning, "Expected int constant for annotation property 'version()'.", dependency.Item2, annotationMirror, annotationValue); return(null); } if ((int)annotationValue.GetValue() != dependency.Item1.Version()) { // this is a valid dependency annotation, but not the one we're looking for return(null); } } } } } if (recognizerValue != null) { if (property == RuleDependencyProcessor.RuleDependencyProperty.Recognizer) { return(recognizerValue); } else { if (ruleValue != null) { if (property == RuleDependencyProcessor.RuleDependencyProperty.Rule) { return(ruleValue); } else { if (versionValue != null) { if (property == RuleDependencyProcessor.RuleDependencyProperty.Version) { return(versionValue); } else { if (property == RuleDependencyProcessor.RuleDependencyProperty.Dependents) { return(dependentsValue); } } } } } } } if (recognizerValue == null) { processingEnv.GetMessager().PrintMessage(Diagnostic.Kind.Warning, "Could not find 'recognizer()' element in annotation.", dependency.Item2, annotationMirror); } if (property == RuleDependencyProcessor.RuleDependencyProperty.Recognizer) { return(null); } if (ruleValue == null) { processingEnv.GetMessager().PrintMessage(Diagnostic.Kind.Warning, "Could not find 'rule()' element in annotation.", dependency.Item2, annotationMirror); } if (property == RuleDependencyProcessor.RuleDependencyProperty.Rule) { return(null); } if (versionValue == null) { processingEnv.GetMessager().PrintMessage(Diagnostic.Kind.Warning, "Could not find 'version()' element in annotation.", dependency.Item2, annotationMirror); } return(null); }
public void ReplaceDatabase(string databaseName, InputStream databaseStream, IDictionary <string, InputStream> attachmentStreams) { ReplaceDatabase(databaseName, databaseStream, attachmentStreams == null ? null : attachmentStreams.EntrySet().GetEnumerator()); }
/// <exception cref="System.IO.IOException"></exception> private HttpURLConnection Open(string method, string bucket, string key, IDictionary <string, string> args) { StringBuilder urlstr = new StringBuilder(); urlstr.Append("http://"); urlstr.Append(bucket); urlstr.Append('.'); urlstr.Append(DOMAIN); urlstr.Append('/'); if (key.Length > 0) { HttpSupport.Encode(urlstr, key); } if (!args.IsEmpty()) { Iterator<KeyValuePair<string, string>> i; urlstr.Append('?'); i = args.EntrySet().Iterator(); while (i.HasNext()) { KeyValuePair<string, string> e = i.Next(); urlstr.Append(e.Key); urlstr.Append('='); HttpSupport.Encode(urlstr, e.Value); if (i.HasNext()) { urlstr.Append('&'); } } } Uri url = new Uri(urlstr.ToString()); Proxy proxy = HttpSupport.ProxyFor(proxySelector, url); HttpURLConnection c; c = (HttpURLConnection)url.OpenConnection(proxy); c.SetRequestMethod(method); c.SetRequestProperty("User-Agent", "jgit/1.0"); c.SetRequestProperty("Date", HttpNow()); return c; }
/// <exception cref="NGit.Errors.TransportException"></exception> private void VerifyPrerequisites() { if (prereqs.IsEmpty()) { return; } RevWalk rw = new RevWalk(transport.local); try { RevFlag PREREQ = rw.NewFlag("PREREQ"); RevFlag SEEN = rw.NewFlag("SEEN"); IDictionary <ObjectId, string> missing = new Dictionary <ObjectId, string>(); IList <RevObject> commits = new AList <RevObject>(); foreach (KeyValuePair <ObjectId, string> e in prereqs.EntrySet()) { ObjectId p = e.Key; try { RevCommit c = rw.ParseCommit(p); if (!c.Has(PREREQ)) { c.Add(PREREQ); commits.AddItem(c); } } catch (MissingObjectException) { missing.Put(p, e.Value); } catch (IOException err) { throw new TransportException(transport.uri, MessageFormat.Format(JGitText.Get().cannotReadCommit , p.Name), err); } } if (!missing.IsEmpty()) { throw new MissingBundlePrerequisiteException(transport.uri, missing); } foreach (Ref r in transport.local.GetAllRefs().Values) { try { rw.MarkStart(rw.ParseCommit(r.GetObjectId())); } catch (IOException) { } } // If we cannot read the value of the ref skip it. int remaining = commits.Count; try { RevCommit c; while ((c = rw.Next()) != null) { if (c.Has(PREREQ)) { c.Add(SEEN); if (--remaining == 0) { break; } } } } catch (IOException err) { throw new TransportException(transport.uri, JGitText.Get().cannotReadObject, err); } if (remaining > 0) { foreach (RevObject o in commits) { if (!o.Has(SEEN)) { missing.Put(o, prereqs.Get(o)); } } throw new MissingBundlePrerequisiteException(transport.uri, missing); } } finally { rw.Release(); } }
private Tuple <IAnnotationMirror, IAnnotationValue> FindRuleDependencyProperty(Tuple <RuleDependency, IElement> dependency, RuleDependencyProcessor.RuleDependencyProperty property) { ITypeElement ruleDependencyTypeElement = processingEnv.GetElementUtils().GetTypeElement(RuleDependencyClassName); ITypeElement ruleDependenciesTypeElement = processingEnv.GetElementUtils().GetTypeElement(RuleDependenciesClassName); IList <IAnnotationMirror> mirrors = dependency.Item2.GetAnnotationMirrors(); foreach (IAnnotationMirror annotationMirror in mirrors) { if (processingEnv.GetTypeUtils().IsSameType(ruleDependencyTypeElement.AsType(), annotationMirror.GetAnnotationType())) { IAnnotationValue element = FindRuleDependencyProperty(dependency, annotationMirror, property); if (element != null) { return(Tuple.Create(annotationMirror, element)); } } else { if (processingEnv.GetTypeUtils().IsSameType(ruleDependenciesTypeElement.AsType(), annotationMirror.GetAnnotationType())) { IDictionary <IExecutableElement, IAnnotationValue> values = annotationMirror.GetElementValues(); foreach (KeyValuePair <IExecutableElement, IAnnotationValue> value in values.EntrySet()) { if ("value()".Equals(value.Key.ToString())) { IAnnotationValue annotationValue = value.Value; if (!(annotationValue.GetValue() is IList)) { processingEnv.GetMessager().PrintMessage(Diagnostic.Kind.Warning, "Expected array of RuleDependency annotations for annotation property 'value()'.", dependency.Item2, annotationMirror, annotationValue); break; } IList <object> annotationValueList = (IList <object>)annotationValue.GetValue(); foreach (object obj in annotationValueList) { if (!(obj is IAnnotationMirror)) { processingEnv.GetMessager().PrintMessage(Diagnostic.Kind.Warning, "Expected RuleDependency annotation mirror for element of property 'value()'.", dependency.Item2, annotationMirror, annotationValue); break; } IAnnotationValue element = FindRuleDependencyProperty(dependency, (IAnnotationMirror)obj, property); if (element != null) { return(Tuple.Create((IAnnotationMirror)obj, element)); } } } else { processingEnv.GetMessager().PrintMessage(Diagnostic.Kind.Error, string.Format("Unexpected annotation property {0}.", value.Key.ToString()), dependency.Item2, annotationMirror, value.Value); } } } } } return(null); }
private string ReplaceUri(string uri, IDictionary<string, string> replacements) { if (replacements.IsEmpty()) { return uri; } KeyValuePair<string, string>? match = null; foreach (KeyValuePair<string, string> replacement in replacements.EntrySet()) { // Ignore current entry if not longer than previous match if (match != null && match.Value.Key.Length > replacement.Key.Length) { continue; } if (!uri.StartsWith(replacement.Key)) { continue; } match = replacement; } if (match != null) { return match.Value.Value + Sharpen.Runtime.Substring(uri, match.Value.Key.Length); } else { return uri; } }
public override ICollection <KeyValuePair <K, V> > EntrySet() { ParseJson(); return(cache.EntrySet()); }
public override void Run() { try { StartingGun.Wait(); for (int i = 0; i < 20; i++) { IList <KeyValuePair <BytesRef, TopDocs> > shuffled = new List <KeyValuePair <BytesRef, TopDocs> >(Answers.EntrySet()); shuffled = CollectionsHelper.Shuffle(shuffled); foreach (KeyValuePair <BytesRef, TopDocs> ent in shuffled) { TopDocs actual = s.Search(new TermQuery(new Term("body", ent.Key)), 100); TopDocs expected = ent.Value; Assert.AreEqual(expected.TotalHits, actual.TotalHits); Assert.AreEqual(expected.ScoreDocs.Length, actual.ScoreDocs.Length, "query=" + ent.Key.Utf8ToString()); for (int hit = 0; hit < expected.ScoreDocs.Length; hit++) { Assert.AreEqual(expected.ScoreDocs[hit].Doc, actual.ScoreDocs[hit].Doc); // Floats really should be identical: Assert.IsTrue(expected.ScoreDocs[hit].Score == actual.ScoreDocs[hit].Score); } } } } catch (Exception e) { throw new Exception(e.Message, e); } }
public Header(IDictionary<string, IList<string>> map) : this() { // initialize fields foreach (KeyValuePair<string, IList<string>> next in map.EntrySet()) { string key = next.Key; IList<string> value = next.Value; List<string> linkedList = new List<string>(); foreach (string element in value) { linkedList.AddItem(element); props.AddItem(key); props.AddItem(element); } keyTable.Put(key, linkedList); } }