private static void CompileJumpTarget(KeyValuePair<int, ProxyRule>[] rules, ProxyRule rule) { if (rule.Action == MatchAction.GotoName) { rule.Action = MatchAction.Goto; rule._jumpTarget = ((rules.Select((e, i) => new { Index = i, Item = e }).FirstOrDefault(x => x.Item.Value.Name == rule.ActionString)?.Index) ?? rules.Length - 1); } else if (rule.Action == MatchAction.Goto) { int number; if (!int.TryParse(rule.ActionString, out number)) number = int.MaxValue; rule._jumpTarget = rules.Select((e, i) => new { Index = i, Item = e }).First(x => x.Item.Key >= number).Index; } }
public IServiceResult PackageSolution(string solutionPath, string buildConfiguration, KeyValuePair<string, string>[] buildProperties) { if (string.IsNullOrWhiteSpace(solutionPath)) { return new FailureResult(Resources.SolutionPackagingService.ErrorSolutionPathParameterCannotBeEmpty); } if (string.IsNullOrWhiteSpace(buildConfiguration)) { return new FailureResult(Resources.SolutionPackagingService.ErrorBuildConfigurationParameterCannotBeEmpty); } if (buildProperties == null) { return new FailureResult(Resources.SolutionPackagingService.ErrorBuildPropertiesParameterCannotBeNull); } // Build the solution IServiceResult buildResult = this.solutionBuilder.Build(solutionPath, buildConfiguration, buildProperties); if (buildResult.Status == ServiceResultType.Failure) { return new FailureResult( Resources.SolutionPackagingService.BuildFailedMessageTemplate, solutionPath, buildConfiguration, string.Join(",", buildProperties.Select(p => p.Key + "=" + p.Value))) { InnerResult = buildResult }; } // pre-packaging IServiceResult prepackagingResult = this.prepackagingService.Prepackage(this.buildFolder); if (prepackagingResult.Status == ServiceResultType.Failure) { return new FailureResult(Resources.SolutionPackagingService.PrepackagingFailedMessageTemplate, solutionPath) { InnerResult = prepackagingResult }; } // packaging IServiceResult packageResult = this.packagingService.Package(); if (packageResult.Status == ServiceResultType.Failure) { return new FailureResult(Resources.SolutionPackagingService.PackagingFailedMessageTemplate, solutionPath) { InnerResult = packageResult }; } string packagePath = packageResult.ResultArtefact; return new SuccessResult( Resources.SolutionPackagingService.PackagingSucceededMessageTemplate, solutionPath, buildConfiguration, string.Join(",", buildProperties.Select(p => p.Key + "=" + p.Value)), packagePath) { ResultArtefact = packagePath }; }
public void KeyCollection(JaggedDictionary<int, string> sut, KeyValuePair<JaggedIndex4<int>, string>[] values) { foreach (var kvp in values) sut[kvp.Key] = kvp.Value; var debugView = new JaggedDictionaryKeyCollectionDebugView<int, string>(sut.Keys); var items = debugView.Items; Assert.Equal(values.Select(kvp => kvp.Key).Distinct().Count(), items.Length); }
public NormalizedGraphSearchTest() { store = new Store(@"..\..\..\Databases\int based\"); store.ClearAll(); //Performance.ComputeTime(() => store.ReloadFrom(Config.Source_data_folder_path + "10M.ttl"), "load 10 млн ", true); store.ReloadFrom(@"C:\deployed\triples.ttl"); store.NodeGenerator.TryGetUri(new OV_iri("http://fogid.net/o/collection-item"), out collectionItempredicate); var triplesCount = store.GetTriplesCount(); store.NodeGenerator.TryGetUri(new OV_iri("http://fogid.net/o/in-collection"), out inCollectionPredicate); edges = (from triple in store.GetTriplesWithPredicate(collectionItempredicate) from item in store.GetTriplesWithSubjectPredicate(triple.Subject, inCollectionPredicate) select new KeyValuePair<int, int>((int)item.WritableValue, (int)triple.Object.WritableValue)).ToArray(); vertexes = edges.Select(pair => pair.Key).Concat(edges.Select(pair => pair.Value)).Distinct(); normalizedGraph4Search = new NormalizedGraph4Search(@"..\..\..\Databases\int based\tree\"); normalizedGraph4Search.ReCreate(edges); var allSubTree = normalizedGraph4Search.GetAllSubTree(edges[0].Key); }
public static void RunCmdlet(this PSCmdlet cmdlet, string parameterSet, KeyValuePair<string, object[]>[] incomingValues) { var cmdletType = cmdlet.GetType(); parameterSetFieldInfo.SetValue(cmdlet, parameterSet); beginProcessingMethodInfo.Invoke(cmdlet, emptyParameters); var parameterProperties = incomingValues.Select(x => new Tuple<PropertyInfo, object[]>( cmdletType.GetProperty(x.Key), x.Value)).ToArray(); for (int i = 0; i < incomingValues[0].Value.Length; i++) { foreach (var parameter in parameterProperties) { parameter.Item1.SetValue(cmdlet, parameter.Item2[i], null); } processRecordMethodInfo.Invoke(cmdlet, emptyParameters); } endProcessingMethodInfo.Invoke(cmdlet, emptyParameters); }
/// <summary> /// Gets an image control with mouse events required to rotate the image cycle on mouse over. Returns null if /// no image is available. /// </summary> /// <param name="deviceURL"></param> /// <param name="images"></param> /// <returns></returns> internal static System.Web.UI.WebControls.WebControl GetDeviceImageRotater(KeyValuePair<string, Uri>[] images, string deviceURL) { HyperLink deviceLink = new HyperLink(); deviceLink.NavigateUrl = deviceURL; if (images != null) { System.Web.UI.WebControls.Image deviceImage = new System.Web.UI.WebControls.Image(); if (images.Length > 0) { deviceImage.ImageUrl = images[0].Value.ToString(); // Hover events are only useful if there are extra images to cycle to if (images.Length > 1) { string[] imageUrls = images.Select(i => String.Format("'{0}'", i.Value)).ToArray(); // Create onmouseover event. It creates an array of url strings that should be cycled in order string mouseOver = String.Format("ImageHovered(this, new Array({0}))", String.Join(",", imageUrls) ); // Create onmouseout event. It is passed a single url string that should be loaded when the cursor leaves the image string mouseOff = String.Format("ImageUnHovered(this, '{0}')", images[0].Value.ToString()); deviceImage.Attributes.Add("onmouseover", mouseOver.Replace("\\", "\\\\")); deviceImage.Attributes.Add("onmouseout", mouseOff.Replace("\\", "\\\\")); } } else // there are no images availble, so use the unknown one deviceImage.ImageUrl = UNKNOWN_IMAGE_URL; deviceImage.Height = Unit.Pixel(128); deviceImage.Width = Unit.Pixel(128); deviceLink.Controls.Add(deviceImage); return deviceLink; } else return null; }
public void ShouldPutMultiple() { _db = _txn.OpenDatabase(configuration: new DatabaseConfiguration { Flags = DatabaseOpenFlags.DuplicatesFixed | DatabaseOpenFlags.Create }); var values = new[] { 1, 2, 3, 4, 5 }.Select(BitConverter.GetBytes).ToArray(); using (var cur = _txn.CreateCursor(_db)) cur.PutMultiple(UTF8.GetBytes("TestKey"), values); var pairs = new KeyValuePair<byte[], byte[]>[values.Length]; using (var cur = _txn.CreateCursor(_db)) { for (var i = 0; i < values.Length; i++) { cur.MoveNextDuplicate(); pairs[i] = cur.Current; } } Assert.Equal(values, pairs.Select(x => x.Value).ToArray()); }
public Scatter(KeyValuePair<double, double>[] Points) { points = Points.Select(i => new PointF((float)i.Key, ToFloat(i.Value))).ToArray(); }
public void CopyTo_should_copy_values() { var dict = CreateTwoItemDictionary(); var copy = new KeyValuePair<int, string>[2]; dict.CopyTo(copy, 0); Assert.That(copy.Select(v => v.Value).ToArray(), Is.EquivalentTo(new[] { "35A", "35B"})); }
private void AddFunction(PrimitiveTypeKind returnType, string functionName, KeyValuePair<string, PrimitiveTypeKind>[] parameterDefinitions) { FunctionParameter returnParameter = CreateReturnParameter(returnType); FunctionParameter[] parameters = parameterDefinitions.Select(paramDef => CreateParameter(paramDef.Value, paramDef.Key)).ToArray(); EdmFunction function = new EdmFunction(functionName, EdmConstants.EdmNamespace, DataSpace.CSpace, new EdmFunctionPayload { IsBuiltIn = true, ReturnParameters = new FunctionParameter[] {returnParameter}, Parameters = parameters, IsFromProviderManifest = true, }); function.SetReadOnly(); this.functions.Add(function); }
public static void GetSetTest(ListDictionary ld, KeyValuePair<string, string>[] data) { DictionaryEntry[] translated = data.Select(kv => new DictionaryEntry(kv.Key, kv.Value)).ToArray(); foreach (KeyValuePair<string, string> kv in data) { Assert.Equal(kv.Value, ld[kv.Key]); } for (int i = 0; i < data.Length / 2; i++) { object temp = ld[data[i].Key]; ld[data[i].Key] = ld[data[data.Length - i - 1].Key]; ld[data[data.Length - i - 1].Key] = temp; } for (int i = 0; i < data.Length; i++) { Assert.Equal(data[data.Length - i - 1].Value, ld[data[i].Key]); } }
public void StreamPropertyNoMetadataAtomTest() { IEnumerable<PayloadReaderTestDescriptor> testDescriptors = new PayloadReaderTestDescriptor[] { #region only href // read link with only href. new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.Entity().StreamProperty("StreamProperty", "http://odata.org/readlink", null, null, null), }, // edit-link with only href. new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.Entity().StreamProperty("StreamProperty", null, "http://odata.org/editlink", null, null), }, // read link with only href. - two links - case sensitive difference. new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.Entity() .StreamProperty("StreamProperty", "http://odata.org/readlink", null, null, null) .StreamProperty("StreampRoperty", "http://odata.org/readlink2", null, null, null), }, // edit-link with only href. - two links - case sensitive difference. new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.Entity() .StreamProperty("StreamProperty", null, "http://odata.org/editlink", null, null) .StreamProperty("sTreamProperty", null, "http://odata.org/editlink2", null, null), }, #endregion #region missing content type // read link with missing content type. new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.Entity().StreamProperty("StreamProperty", "http://odata.org/readlink", null, null, null), }, // edit-link with missing content type. new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.Entity().StreamProperty("StreamProperty", null, "http://odata.org/editlink", null, null), }, // edit-link with content type in different namespace. new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.Entity().StreamProperty("StreamProperty", null, "http://odata.org/editlink", null, null) .XmlRepresentation(@"<entry xmlns:foo='http://www.w3.org/SomeNamespace'> <link rel='http://docs.oasis-open.org/odata/ns/edit-media/StreamProperty' href='http://odata.org/editlink' foo:type='application/atom+xml' /> </entry>"), }, #endregion #region content type on both // both read and edit link with the same content type, read link first new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.Entity().StreamProperty("StreamProperty", "http://odata.org/readlink", "http://odata.org/editlink", "mime/type") .XmlRepresentation(@"<entry> <link rel='http://docs.oasis-open.org/odata/ns/mediaresource/StreamProperty' href='http://odata.org/readlink' type='mime/type'/> <link rel='http://docs.oasis-open.org/odata/ns/edit-media/StreamProperty' href='http://odata.org/editlink' type='mime/type'/> </entry>"), }, // both read and edit link with the same content type, edit link first new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.Entity().StreamProperty("StreamProperty", "http://odata.org/readlink", "http://odata.org/editlink", "mime/type") .XmlRepresentation(@"<entry> <link rel='http://docs.oasis-open.org/odata/ns/edit-media/StreamProperty' href='http://odata.org/editlink' type='mime/type'/> <link rel='http://docs.oasis-open.org/odata/ns/mediaresource/StreamProperty' href='http://odata.org/readlink' type='mime/type'/> </entry>"), }, #endregion #region etag // verify that read link discards etag. new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.Entity().StreamProperty("StreamProperty", "http://odata.org/readlink", null, null, null) .XmlRepresentation(@"<entry> <link rel='http://docs.oasis-open.org/odata/ns/mediaresource/StreamProperty' href='http://odata.org/readlink' m:etag='someetag'/> </entry>"), }, #endregion etag #region all possible valid attributes // edit-link with href, content type and etag. new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.Entity().StreamProperty("StreamProperty", null, "http://odata.org/editlink", "application/atom+xml", "some_etag"), }, // read link with href and content type. new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.Entity().StreamProperty("StreamProperty", "http://odata.org/readlink", null, "application/atom+xml", null), }, #endregion #region extra attributes // extra attributes in the read link. new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.Entity().StreamProperty("StreamProperty", "http://odata.org/readlink") .XmlRepresentation(@"<entry> <link rel='http://docs.oasis-open.org/odata/ns/mediaresource/StreamProperty' foo1='bar1' href='http://odata.org/readlink' foo='bar'/> </entry>"), }, // extra attributes in the edit-link. new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.Entity().StreamProperty("StreamProperty",null, "http://odata.org/editlink") .XmlRepresentation(@"<entry> <link rel='http://docs.oasis-open.org/odata/ns/edit-media/StreamProperty' foo1='bar1' href='http://odata.org/editlink' foo='bar'/> </entry>"), }, #endregion #region missing rel // missing rel new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.Entity() .XmlRepresentation(@"<entry> <link href='http://odata.org/editlink' type='application/atom+xml'/> </entry>"), }, // rel attribute in different namespace new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.Entity() .XmlRepresentation(@"<entry xmlns:foo='http://www.w3.org/SomeNamespace'> <link href='http://odata.org/editlink' type='application/atom+xml' foo:rel='http://docs.oasis-open.org/odata/ns/edit-media/StreamProperty'/> </entry>"), }, #endregion missing rel #region name prefix // verify that invalid stream name prefix is discarded. new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.Entity() .XmlRepresentation(@"<entry> <link rel='http://docs.oasis-open.org/odata/ns/data/somename/StreamProperty' href='http://odata.org/readlink' /> </entry>"), }, // verify that stream name prefix is case-sensitive. new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.Entity() .XmlRepresentation(@"<entry> <link rel='http://docs.oasis-open.org/odata/ns/Mediaresource/StreamProperty' href='http://odata.org/readlink' type='application/atom+xml'/> </entry>"), }, // verify that incomplete rel is not recognized as stream property (missing the last slash in read link) new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.Entity() .XmlRepresentation(@"<entry> <link rel='http://docs.oasis-open.org/odata/ns/mediaresource' href='http://odata.org/readlink' /> </entry>"), }, // verify that incomplete rel is not recognized as stream property (missing the last slash in edit link) new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.Entity() .XmlRepresentation(@"<entry> <link rel='http://docs.oasis-open.org/odata/ns/edit-media' href='http://odata.org/editlink' /> </entry>"), }, #endregion #region order of the attributes and link // edit link first. new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.Entity() .StreamProperty("StreamProperty1", null, "http://odata.org/editlink", null, null) .StreamProperty("StreamProperty2", "http://odata.org/readlink", null, null, null), }, // read link first. new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.Entity() .StreamProperty("StreamProperty1", "http://odata.org/readlink", null, null, null) .StreamProperty("StreamProperty2", null, "http://odata.org/editlink", null, null), }, // rel after etag, href and type. new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.Entity().StreamProperty("StreamProperty", null, "http://odata.org/editlink", "application/atom+xml", "some_etag") .XmlRepresentation(@"<entry> <link m:etag='some_etag' href='http://odata.org/editlink' type='application/atom+xml' rel='http://docs.oasis-open.org/odata/ns/edit-media/StreamProperty'/> </entry>"), }, #endregion order of the attributes and link #region content inside link element // verify that all contents inside link element are skipped. new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.Entity() .StreamProperty("StreamProperty", null, "http://odata.org/editlink", "application/atom+xml", null) .XmlRepresentation(@"<entry> <link href='http://odata.org/editlink' type='application/atom+xml' rel='http://docs.oasis-open.org/odata/ns/edit-media/StreamProperty'> <m:unknown>some text</m:unknown> <!-- Some comments --> <d:unknown/> <ns:someelement xmlns:ns='somenamespace'/> <![CDATA[cdata]]> </link> </entry>"), }, #endregion content inside link element }; #region empty or missing etag KeyValuePair<string, string>[] etags = new KeyValuePair<string, string>[] { new KeyValuePair<string, string>(string.Empty, "m:etag=''"), // empty etag new KeyValuePair<string, string>("some_etag", "m:etag='some_etag'"), // valid etag new KeyValuePair<string, string>(null, "foo:etag='some_etag'"), // etag in a different namespace }; testDescriptors = testDescriptors.Concat(etags.Select(etag => new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.Entity().StreamProperty("StreamProperty", null, "http://odata.org/editlink", null, etag.Key) .XmlRepresentation(string.Format(@"<entry xmlns:foo='http://www.w3.org/SomeNamespace'> <link rel='http://docs.oasis-open.org/odata/ns/edit-media/StreamProperty' href='http://odata.org/editlink' {0} /> </entry>", etag.Value)), })); #endregion empty or missing etag // WCF DS client, server and default ODataLib show the same behavior for stream properties. this.CombinatorialEngineProvider.RunCombinations( TestReaderUtils.ODataBehaviorKinds, testDescriptors, this.ReaderTestConfigurationProvider.AtomFormatConfigurations, (behaviorKind, testDescriptor, testConfiguration) => { if (testConfiguration.IsRequest) { testDescriptor = new PayloadReaderTestDescriptor(testDescriptor) { ExpectedException = null, ExpectedResultPayloadElement = tc => RemoveStreamPropertyPayloadElementNormalizer.Normalize(testDescriptor.PayloadElement.DeepCopy()) }; } testDescriptor.RunTest(testConfiguration.CloneAndApplyBehavior(behaviorKind)); }); }
public static void Message_Tranfer_Arbol_Union(MarkovNet arboldeunion, KeyValuePair<BayesianNode, int>[] evidence = null) { //absorber evidence if (evidence != null && evidence.Length > 0) { arboldeunion.BayesianNet.Evidence = evidence.Select(x => x.Value).ToArray(); } if (arboldeunion.Count() > ParalellStartNumber) { #region ParalellAlgorithm arboldeunion.Debug = true; var taskarr = new Task[arboldeunion.Count]; for (int i = 0; i < arboldeunion.Count; i++) { taskarr[i] = new Task(o => { var node = o as BayesianNode; if (node != null) lock (node) { do { arboldeunion.Work(node); } while (!node.Finished); } }, arboldeunion[i]); taskarr[i].Start(); } for (int i = 0; i < arboldeunion.Count*8; i++) { System.Threading.Thread.Sleep(300); Increment(); } Task.WaitAll(taskarr); arboldeunion.Debug = false; #endregion } else #region DeterministicAlgorithm while (!arboldeunion.AllConditionalProbabilitiesComputed()) { foreach (var item in arboldeunion) { arboldeunion.Work(item); } Increment(); } #endregion foreach (var node in arboldeunion.BayesianNet) arboldeunion.Marginalize_X(node); }
public void RedisStorageStoresAndRemovesObjectsInBulks() { KeyValuePair<string, string>[] objectsToStore = new KeyValuePair<string, string>[100]; for (int i = 0; i < objectsToStore.Length; i++) { objectsToStore[i] = new KeyValuePair<string, string>(Guid.NewGuid().ToString(), "jack checked chicken"); } using (var storage = new RedisStorage(RedisStorageTests.Host)) { storage.BulkStore(objectsToStore); storage.BulkRemove(objectsToStore.Select(o => o.Key).ToArray()); foreach (var @object in objectsToStore) { Assert.That(() => storage.Retrieve<string>(@object.Key), Throws.InstanceOf<ArgumentOutOfRangeException>()); } } }
public void RedisStorageStoresAndRetrievesComplexObjectsInBulks() { var objectToStore = new ComplexParameter() { SomeProperty = "this is string", AnotherProperty = 47 }; KeyValuePair<string, ComplexParameter>[] objectsToStore = new KeyValuePair<string, ComplexParameter>[100]; for (int i = 0; i < objectsToStore.Length; i++) { objectsToStore[i] = new KeyValuePair<string, ComplexParameter>(Guid.NewGuid().ToString(), objectToStore); } using (var storage = new RedisStorage(RedisStorageTests.Host)) { storage.BulkStore(objectsToStore); var retrievedObjects = storage.BulkRetrieve<ComplexParameter>(objectsToStore.Select(o => o.Key).ToArray()); foreach (var retrievedObject in retrievedObjects) { retrievedObject.SomeProperty.ShouldBe(objectToStore.SomeProperty); retrievedObject.AnotherProperty.ShouldBe(objectToStore.AnotherProperty); } } }
private static string InsertStatement(string tableName, KeyValuePair<string, string>[] keysAndValues) { return string.Format("{0} ({1}) VALUES ({2}); ", tableName, string.Join<string>(", ", keysAndValues.Select(x => x.Key)), string.Join<string>(", ", keysAndValues.Select(x => x.Value))); }
public static Texture2D FromLabels(KeyValuePair<string, Color>[] labels, SpriteFont font, Size size, GraphicsDevice device) { RenderTarget2D target = new RenderTarget2D(device, size.Width, size.Height); SpriteBatch sb = new SpriteBatch(device); device.SetRenderTarget(target); device.Clear(Color.Transparent); sb.Begin(); for (int i = 0; i < labels.Length; i++) { string prevString = string.Join(" ", labels.Select(l => l.Key).ToArray(), 0, i); if (i > 0) prevString += " "; float x = 1 + font.MeasureString(prevString).X; sb.DrawString(font, labels[i].Key, new Vector2(x, 1), labels[i].Value, 0f, Vector2.Zero, Vector2.One, SpriteEffects.None, 0f); } sb.End(); device.SetRenderTarget(null); Texture2D texture = new Texture2D(device, size.Width, size.Height); Color[] colorData = target.GetColorData(); texture.SetData(colorData); target.Dispose(); return texture; }
public static void CopyToTest(ListDictionary ld, KeyValuePair<string, string>[] data) { DictionaryEntry[] translated = data.Select(kv => new DictionaryEntry(kv.Key, kv.Value)).ToArray(); DictionaryEntry[] full = new DictionaryEntry[data.Length]; ld.CopyTo(full, 0); Assert.Equal(translated, full); DictionaryEntry[] large = new DictionaryEntry[data.Length * 2]; ld.CopyTo(large, data.Length / 2); for (int i = 0; i < large.Length; i++) { if (i < data.Length / 2 || i >= data.Length + data.Length / 2) { Assert.Equal(new DictionaryEntry(), large[i]); Assert.Null(large[i].Key); Assert.Null(large[i].Value); } else { Assert.Equal(translated[i - data.Length / 2], large[i]); } } }
private static void Vote(string host, KeyValuePair<User, int[]>[] voters, Guid id, PublicKey publicKey) { log.Info("Voting in parallel..."); var candidateTasks = voters.Select(kvp => ElectroClient.VoteAsync(host, Program.PORT, kvp.Key.Cookies, id, HomoCrypto.EncryptVector(kvp.Value, publicKey))).ToArray(); try { Task.WaitAll(); log.InfoFormat("Voted by {0} users", voters.Length); } catch(Exception e) { throw new ServiceException(ExitCode.DOWN, string.Format("Failed to vote by {0} users in parallel: {1}", candidateTasks.Length, e)); } }
public void InitTaskRemote(string taskName, KeyValuePair<string, byte[]>[] mainFileList, KeyValuePair<string, byte[]>[] extraFileList) { if(_tasks.ContainsKey(taskName)) throw new Exception("Такая задача уже была ранее проинициализирована"); Directory.CreateDirectory(taskName); foreach (var f in mainFileList) File.WriteAllBytes(f.Key, f.Value); if(extraFileList != null) foreach (var f in extraFileList) File.WriteAllBytes(f.Key, f.Value); var t = new TaskScheduler(taskName, taskName, mainFileList.Select(p => p.Key).ToArray(), _finder, _connection); if (_isStarted) t.Start(); _tasks.Add(taskName, t); }
private static string GetUrl(KeyValuePair<string, object>[] parameters) { return "{0}?{1}".AsFormat( Target, string.Join("&", parameters.Select(p => "{0}={1}".AsFormat(p.Key, p.Value)))); }