public void Failed(IExample example, Exception exception) { LastResult = TaskResult.Exception; _server.TaskOutput(CurrentTask, "Failed:", TaskOutputType.STDERR); _server.TaskOutput(CurrentTask, exception.ToString(), TaskOutputType.STDERR); _server.TaskFinished(CurrentTask, exception.ToString(), TaskResult.Exception); }
/// <summary> /// Signal emitted when the pressed animation has completed. /// </summary>The animation source. /// <param name="source">The animation source.</param> /// <param name="e">event</param> private void OnPressedAnimationFinished(object source, EventArgs e) { mPressedAnimation = null; if (mPressedView != null) { string name = mPressedView.Name; this.Deactivate(); object item = Activator.CreateInstance(global::System.Type.GetType("UIControlSample." + name)); if (item is IExample) { this.Deactivate(); global::System.GC.Collect(); global::System.GC.WaitForPendingFinalizers(); currentSample = item as IExample; if (currentSample != null) { currentSample.Activate(); } } else { Log.Error("Example", "FAILED : " + name); } mPressedView = null; } }
private void ExitSample() { currentExample?.Deactivate(); currentExample = null; FullGC(); }
public void Test_08_DefaultImplementation_AbstractClass() { IExample Obj = Types.Instantiate <Example>(false); Assert.IsNotNull(Obj); Assert.AreEqual(9.0, Obj.Eval(3)); }
public static bool TryGetByName <T>(this IExample <T> @this, string name, out T child) { bool success; child = @this.TryGetByName(name, out success); return(success); }
public override void Execute() { bool copyBitmaps = false; for (int i = 0; i < Owner.MaxObjects; i++) { if (Owner.WorldObjects.Host[i].life > 0) { Owner.WorldObjects.Host[i].position += Owner.WorldObjects.Host[i].velocity; float2 pos = Owner.WorldObjects.Host[i].position; float size = Owner.WorldObjects.Host[i].size; if (pos.x < -1 - size || pos.x > 1 + size || pos.y < -1 - size || pos.y > 1 + size) { Owner.WorldObjects.Host[i].life = 0; } else { Owner.WorldObjects.Host[i].life--; } } if (Owner.WorldObjects.Host[i].life <= 0 && m_random.NextDouble() < CreateObjectChance) { MyWorldObject newObject = new MyWorldObject(); newObject.life = (int)(m_random.NextDouble() * MaxLife); newObject.size = (float)m_random.NextDouble() * (MaxSize - MinSize) + MinSize; newObject.position = new float2((float)m_random.NextDouble() * 2 - 1, (float)m_random.NextDouble() * 2 - 1); if (m_random.NextDouble() > StaticObjectChance) { newObject.velocity = new float2((float)m_random.NextDouble() * 2 - 1, (float)m_random.NextDouble() * 2 - 1); float velocitySize = (float)( (m_random.NextDouble() * (MaxVelocity - MinVelocity) + MinVelocity) / Math.Sqrt(newObject.velocity.x * newObject.velocity.x + newObject.velocity.y * newObject.velocity.y) ); newObject.velocity *= velocitySize; } IExample example = m_dataset.GetNext(); Array.Copy(example.Input, 0, Owner.Bitmaps.Host, i * IMG_WIDTH * IMG_WIDTH, IMG_WIDTH * IMG_WIDTH); copyBitmaps = true; CudaDeviceVariable <float> devBitmaps = Owner.Bitmaps.GetDevice(Owner); newObject.bitmap = devBitmaps.DevicePointer + (devBitmaps.TypeSize * i * IMG_WIDTH * IMG_WIDTH); Owner.WorldObjects.Host[i] = newObject; } } Owner.WorldObjects.SafeCopyToDevice(); if (copyBitmaps) { Owner.Bitmaps.SafeCopyToDevice(); } }
public BusinessLogic(ILogger logger, IDataAccess dataAccess, IExample example) { if (!(logger is null || dataAccess is null)) { this.logger = logger; this.dataAccess = dataAccess; }
public void Reads() { string path; float[][] imagesData; int[] labels; const int nExamples = 10; CreateUSPSFile(out path, out imagesData, out labels, nExamples); using (USPSDatasetReader reader = new USPSDatasetReader(path)) { for (int i = 0; i < nExamples; ++i) { Assert.True(reader.HasNext(), "Reader should not be at the end"); IExample refExample = new NormalizedExample(imagesData[i], labels[i]); IExample readExample = reader.ReadNext(); Assert.True(Enumerable.SequenceEqual(refExample.Input, readExample.Input), "Written and read image data should be the same"); Assert.True(refExample.Target == readExample.Target, "Written and read labels should be the same"); } Assert.False(reader.HasNext(), "Reader should be at the end"); } File.Delete(path); }
private void listViewExamples_MouseDoubleClick(object sender, MouseEventArgs e) { try { if (listViewExamples.SelectedItems.Count == 0) { return; } this.Enabled = false; this.Cursor = Cursors.WaitCursor; IExample selectedExample = listViewExamples.SelectedItems[0].Tag as IExample; if (null == selectedExample.Panel) { selectedExample.RunExample(); } else { panelExamples.Controls.Add(selectedExample.Panel); selectedExample.Panel.Dock = DockStyle.Fill; selectedExample.Panel.Visible = true; } } catch (Exception exception) { FormError.Show(this, exception); } finally { this.Enabled = true; this.Cursor = Cursors.Default; } }
private void CreateNewExample() { var exampleFrequecies = _examples.ToDictionary(exampleDef => exampleDef, exampleDef => _currentMonster != null ? _currentMonster.GetExampleFrequencyByMonster(exampleDef) : exampleDef.Frequency); var examplesForMonster = exampleFrequecies.SelectMany(exampleDefPair => Enumerable.Repeat(exampleDefPair.Key, exampleDefPair.Value)); if (!examplesForMonster.Any()) { MessageBox.Show("Vyber si jiného plyšáka. Tomuto už příklady došly."); } else { var random = new Random(); int randomIndex = random.Next(examplesForMonster.Count()); var exampleDef = examplesForMonster.ToArray()[randomIndex]; _currentExample = exampleDef.CreateExample(random); if (_currentMonster != null) { _currentMonster.UpdateExampleByMonster(_currentExample); //callback na potvoru - muze menit example //TODO tato implementace ma za nasledek, ze zmena zvirete po zadani prikladu se uz neprojevi } labelExample.Text = _currentExample.Text; labelX.Visible = _currentExample.IsEquation; labelEquals.Visible = _currentExample.IsEquation; textBox.Text = ""; textBox.Focus(); UpdateLabelMoney(); pictureBoxMonster.ImageLocation = _image1Location; } }
public static int Count <TBase>( this IExample <TBase> repository, ApplicationUser user, Expression <Func <TBase, bool> > predicate) { return(repository.GetAll(user).Count(predicate)); }
private void listBox_SelectedIndexChanged(object sender, EventArgs e) { if (listBox.SelectedItem != null) { switch(listBox.SelectedIndex) { case 0: example = new VertexProgram(); break; case 1: example = new FragmentProgram(); break; case 2: example = new UniformParameter(); break; case 3: example = new VaryingParameter(); break; case 4: example = new TextureSampling(); break; case 5: example = new VertexTwisting(); break; case 6: example = new TwoTextureAccesses(); break; case 7: example = new VertexTransform(); break; case 8: example = new VertexLighting(); break; default: break; } } }
public static IQueryable <TBase> Where <TBase>( this IExample <TBase> repository, ApplicationUser user, Expression <Func <TBase, bool> > predicate) { return(repository.GetAll(user).Where(predicate)); }
internal ExampleViewItem(IExample example, Image icon) { Caption = example.Caption; Description = example.Description; Icon = icon; Item = example; }
public static TBase FirstOrDefault <TBase>( this IExample <TBase> repository, ApplicationUser user, Expression <Func <TBase, bool> > predicate) { return(repository.GetAll(user).FirstOrDefault(predicate)); }
public void Reads() { string[] paths; byte[][] imagesData; int[] labels; const int nFiles = 3; const int nExamplesPerFile = 4; const int nExamples = nFiles * nExamplesPerFile; CreateCIFAR10Files(out paths, out imagesData, out labels, nFiles, nExamplesPerFile); using (CIFAR10DatasetReader reader = new CIFAR10DatasetReader(paths)) { for (int i = 0; i < nExamples; ++i) { Assert.True(reader.HasNext(), "Reader should not be at the end"); IExample refExample = new NormalizedExample(imagesData[i], labels[i]); IExample readExample = reader.ReadNext(); Assert.True(Enumerable.SequenceEqual(refExample.Input, readExample.Input), "Written and read image data should be the same"); Assert.True(refExample.Target == readExample.Target, "Written and read labels should be the same"); } Assert.False(reader.HasNext(), "Reader should be at the end"); } foreach (string path in paths) { File.Delete(path); } }
public void Test_07_DefaultImplementation_Interface() { IExample Obj = Types.Instantiate <IExample>(false); Assert.IsNotNull(Obj); Assert.AreEqual(9.0, Obj.Eval(3)); }
private void LoadDataset() { Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); using (DatasetReader r = m_readerFactory.CreateReader()) { m_nClasses = r.NumClasses; m_nExamplesPerClass = new int[m_nClasses]; m_examples = new List <IExample>(); while (r.HasNext()) { IExample ex = r.ReadNext(); m_examples.Add(ex); m_nExamplesPerClass[ex.Target]++; } } stopWatch.Stop(); MyLog.INFO.WriteLine("Loaded {0} examples in {1} s", m_examples.Count, stopWatch.ElapsedMilliseconds / 1000f); if (m_examples.Count == 0) { throw new FileLoadException("The loaded dataset is empty"); } }
/// <summary> /// Дать ответ /// </summary> /// <param name="answer">Ответ</param> public void TakeAnswer(int answer, bool onTimeEnded = false) { currentExample.UserAnswer = answer; // Устанавливам State: currentExample.SetState(answer == currentExample.UserAnswer ? ExampleState.RightAnswered : ExampleState.WrongAnswered); if (onTimeEnded) { currentExample.SetState(ExampleState.NotAnswered); } processedExample.Add(currentExample); if (exampleSet.Count > 0) { currentExample = exampleSet.Dequeue(); TakeNextExample?.Invoke(this, new ExampleParameters(currentExample.OperandOne, currentExample.OperandTwo, currentExample.Opr)); timer.Stop(); Tick?.Invoke(this, timeToExample); remainingTime = timeToExample; timer.Start(); } else { timer.Stop(); IsStarted = false; TrainingEnded?.Invoke(this, DateTime.Now); } }
private void buttonOptions_Click(object sender, EventArgs e) { try { FormOptions dialog = new FormOptions(_rootDirectory); if (DialogResult.OK == dialog.ShowDialog(this)) { _rootDirectory = dialog.RootDirectory; foreach (ListViewItem item in listViewExamples.Items) { IExample example = item.Tag as IExample; item.Text = example.Caption; item.SubItems[1].Text = example.Description; } Translator.TranslateControls(this, "FormBase.txt", FormOptions.LCID); } } catch (Exception exception) { FormError.Show(this, exception); } }
static void Main(string[] args) { IExample[] examples = new IExample[] { new DFS(), new BFS() }; Console.WriteLine("Select algorithm example:\r\n"); for (int i = 0; i < examples.Length; i++) { Console.WriteLine("[{0}]\t\t{1}", i + 1, examples[i].Name); } int result; if (int.TryParse(Console.ReadLine(), out result)) { IExample example = examples[result - 1]; example.Execute(); } Console.WriteLine("Press any key to exit..."); Console.ReadKey(); }
private void SendExample() { IExample ex = m_dataset.GetNext(); if (Owner.Binarize) { for (int i = 0; i < ex.Input.Length; i++) { Owner.Bitmap.Host[i] = ex.Input[i] >= 0.5 ? 1 : 0; } } else { Array.Copy(ex.Input, Owner.Bitmap.Host, ex.Input.Length); } if (Owner.OneHot) { Array.Clear(Owner.Class.Host, 0, 10); Owner.Class.Host[ex.Target] = 1; } else { Owner.Class.Host[0] = ex.Target; } Owner.Bitmap.SafeCopyToDevice(); Owner.Class.SafeCopyToDevice(); m_hasSentExample = true; }
public ExamplesExecutionContext(IExample example, Action<string> logHandler, Action confirmationRequestHandler) { _example = example; _example.Log = this; _example.Interaction = this; _logHandler = logHandler; _confirmationRequestHandler = confirmationRequestHandler; }
public void SetUp() { var subject = new Data.IoC.IoC(); subject.Register <IExample>(new Example()); _result = subject.For <IExample>(); }
public void TestConfig2() { // do this a second time to ensure that the instantiator works // without regstering the class again. IExample e = Container.Get <IExample>(); Assert.IsNotNull(e); }
public IResponse CheckTheAnswer(IExample example, string answer) { return(new Response { IsCorrect = answer.ToLower().Trim() == example.CorrectAnswer, CorrectAnswer = example.CorrectAnswer }); }
public void InstancePerDependencyTest() { config.Register <IExample, ClassForExample>(); var provider = new DependencyProvider(config); IExample expected = provider.Resolve <IExample>(); IExample actual = provider.Resolve <IExample>(); Assert.AreNotEqual(expected, actual); }
private void ExitSample() { curExample?.Deactivate(); curExample = null; FullGC(); CreateDaliDemo(); }
public void SingletonTest() { config.Register <IExample, ClassForExample>(true); var provider = new DependencyProvider(config); IExample expected = provider.Resolve <IExample>(); IExample actual = provider.Resolve <IExample>(); Assert.AreEqual(expected, actual); }
public static void ShowForm(IWin32Window owner, IExample example) { AreaForm form = new AreaForm(example.Panel); form.Text = example.Caption; form.ShowDialog(owner); form.Controls.Clear(); form.Dispose(); }
public static void Foo() { Console.WriteLine("Covariance example"); var exampleM1 = new BaseExample(); IExample example = exampleM1; CovarianceInterfaces(); CovarianceDelegates(); }
public void Deserialize_WithInterfaceType_ReturnsIdentical(IExample data) { var serialized = Serialize <IExample>(data); _output.WriteLine("Serialized is: {0}", serialized); var deserialized = Deserialize <IExample>(serialized); Assert.Equal(deserialized, data); }
public void TestInterfacedValueTypesAreBoxed() { var e1 = new ExampleStruct2(); IExample e2 = e1; e1.Value++; Assert.AreEqual(1, e1.Value); e1.Value++; Assert.AreEqual(0, e2.Value); }
public void Dispose() { if (_example != null) { _logHandler = null; _confirmationRequestHandler = null; _example.Log = null; _example.Interaction = null; _example.Dispose(); } _example = null; }
public void Pending(IExample example) { LastResult = TaskResult.Skipped; _server.TaskFinished(CurrentTask, "Pending", TaskResult.Skipped); }
private static void RunExample(IExample example) { example.Run().Wait(); }
public void Ignored(IExample example) { _totalCount++; Write(MessageType.Ignored, "I"); _ignored.Add((_ignored.Count + 1) + ") Ignored: " + example.FullName); }
public void Success(IExample example) { _totalCount++; Write(MessageType.Succeeded, "."); _successCount++; }
private string CreateFailureMessage(IExample example, Exception exception) { const string fmt = @"{0}) Failed: {1} {2}"; return string.Format(fmt, _failures.Count + 1, example.FullName, GetExceptionMessage(exception)); }
public void Pending(IExample example) { _listener.InvokeWithReflection("Pending", Translate(example)); }
public void Ignored(IExample example) { Calls.Add("Ignored - " + example.FullName); }
public void Pending(IExample example) { Calls.Add("Pending - " + example.FullName); }
public void Running(IExample example) { }
public void Success(IExample example) { LastResult = TaskResult.Success; _server.TaskFinished(CurrentTask, "" , TaskResult.Success); }
public void Success(IExample example) { _listener.InvokeWithReflection("Success", Translate(example)); }
public void Failed(IExample example, Exception exception) { Calls.Add("Failed - " + example.FullName + " - " + exception.GetType().Name); }
public void Failed(IExample example, Exception exception) { _listener.InvokeWithReflection("Failed", Translate(example), exception); }
//********************************************************************************* /* * TO RUN THE EXAMPLES PRESS : "F5" * This is just a launcher, so you can ignore the code of this class. * The code of the examples are in the "Example_... .cs" CLASSES */ //********************************************************************************* static void Main(string[] args) { Console.Title = "BLUEVIA'S .NET EXAMPLE LAUNCHER"; Console.ForegroundColor = ConsoleColor.DarkCyan; ConsoleKeyInfo enter; bool end = false; //Array to contain an instance of every Bluevia example: IExample[] examples = new IExample[]{ new Example_Advertising(), new Example_Directory(), new Example_Directory_Access(), new Example_Directory_Personal(), new Example_Directory_Profile(), new Example_Directory_Terminal(), new Example_Location(), new Example_MMS_MO(), new Example_MMS_MT(), new Example_MMS_Notifications(), new Example_OAuth(), new Example_Payment(), new Example_SMS_MO(), new Example_SMS_MT(), new Example_SMS_Notifications() }; //IExample Selection: do{ bool requestDone=false; int length = examples.Length; do { Console.Clear(); Console.WriteLine("\t*************************************"); Console.WriteLine("\t** BLUEVIA'S .NET EXAMPLE LAUNCHER **"); Console.WriteLine("\t*************************************"); Console.WriteLine("\n\tSelect an example to make the call:"); Console.WriteLine("\n\tOr Type \"end\" to exit.\n"); //Printing the examples list Console.WriteLine("**********************************************************\n"); for (int i = 0; i < length; i++) { Console.WriteLine(" "+(i+1) + "\t: " + examples[i].GetType()); } Console.WriteLine(" end\t: to exit."); Console.WriteLine("\n**********************************************************\n"); //Capturing the example selection String selection_String = Console.ReadLine(); int selection_int = 0; bool selectionIsNumber = int.TryParse(selection_String, out selection_int); if (selectionIsNumber) { selection_int--; if ((0<= selection_int)&&(selection_int < length)) { requestDone = true; Console.Clear(); Console.WriteLine("\nYou have selected: " + examples[selection_int].GetType().Name + ".\n"); Console.WriteLine("----------------------------------------------------------\n"); Console.WriteLine(examples[selection_int].getDescription()); Console.WriteLine("\n----------------------------------------------------------\n"); Console.WriteLine("Press any key to continue."); enter = Console.ReadKey(); //A valid number has been selected, launching the example: examples[selection_int].call("vw12012654505986", "WpOl66570544", "ad3f0f598ffbc660fbad9035122eae74", "4340b28da39ec36acb4a205d3955a853"); //Console. Console.WriteLine("\nPress any key to continue."); enter = Console.ReadKey(); } else { requestDone = false; Console.WriteLine("\nThe selection must be a number between 1 and " + length); Console.WriteLine("Press any key to retry."); enter = Console.ReadKey(); } } else { if(selection_String.StartsWith("end")){ requestDone = true; end = true; }else{ requestDone = false; Console.WriteLine("The selection must be a number between 1 and " + length); Console.WriteLine("Press any key to retry."); enter = Console.ReadKey(); } } } while (!requestDone); } while (!end); }
private void performExample(IExample example) { UUID uuid = mRichNotificationManager.notify(example.createRichNoti()); Toast.makeTextuniquetempvar.show(); }
protected internal void LoadExample(IExample example) { example.Connect(this); ListViewItem viewItem = listViewExamples.Items.Add(example.Caption); viewItem.SubItems.Add(example.Description); viewItem.ImageIndex = 0; viewItem.Tag = example; _listExamples.Add(example); }
public void Pending(IExample example) { _totalCount++; Write(MessageType.Pending, "P"); _pendings.Add((_pendings.Count + 1) + ") Pending: " + example.FullName); }
/// <summary> /// Loads an example to the instance /// </summary> /// <param name="example">example instance as any</param> protected internal void LoadExample(IExample example) { example.Connect(this); ListViewItem viewItem = listViewExamples.Items.Add(example.Caption); viewItem.BackColor = listViewExamples.Items.Count % 2 != 0 ? Color.White : Color.AliceBlue; viewItem.SubItems.Add(example.Description); viewItem.ImageIndex = 0; viewItem.Tag = example; _listExamples.Add(example); // select first item if nothing selected if (listViewExamples.SelectedItems.Count <= 0) listViewExamples.Items[0].Selected = true; }
public void Failed(IExample example, Exception exception) { _totalCount++; Write(MessageType.Failure, "F"); _failures.Add(CreateFailureMessage(example, exception)); }
private object Translate(IExample example) { return _exampleTranslator.InvokeWithReflection("Translate", example); }
/// <summary> /// Starts a new task for an <see cref="IExample"/> implemetation. /// </summary> /// <param name="example">The example to run.</param> /// <param name="args">An array of arguments. Depending on what is necesarry for an example, /// it may contain multiple variables, such as serverUrl, topic paths etc. Check the example class /// for the description of what is required for this array.</param> public void StartExample( IExample example, params string[] args ) { var task = Task.Run( () => example.Run( cancellationTokenSource.Token, args ) ); runningExamples.Add( task ); }
public void Success(IExample example) { Calls.Add("Success - " + example.FullName); }
public bool IsEquivalentTo(IExample that) { return this.Value == that.Value; }
public void Ignored(IExample example) { LastResult = TaskResult.Skipped; _server.TaskFinished(CurrentTask, "Ignored", TaskResult.Skipped); }