internal static RegressionMetrics FromOverallMetrics(IHostEnvironment env, IDataView overallMetrics) { Contracts.AssertValue(env); env.AssertValue(overallMetrics); var metricsEnumerable = overallMetrics.AsEnumerable <SerializationClass>(env, true, ignoreMissingColumns: true); var enumerator = metricsEnumerable.GetEnumerator(); if (!enumerator.MoveNext()) { throw env.Except("The overall RegressionMetrics didn't have any rows."); } SerializationClass metrics = enumerator.Current; if (enumerator.MoveNext()) { throw env.Except("The overall RegressionMetrics contained more than 1 row."); } return(new RegressionMetrics() { L1 = metrics.L1, L2 = metrics.L2, Rms = metrics.Rms, LossFn = metrics.LossFn, RSquared = metrics.RSquared, }); }
public void NewtonsoftJsonToSystemTextJson_SerializedAndDeserializedCorrectly() { // Arrange var initialInstance = new SerializationClass { BooleanStrongTypeNotNull = (BooleanStrongType)true, ByteStrongTypeNotNull = (ByteStrongType)215, DecimalStrongTypeNotNull = (DecimalStrongType)15.55m, DoubleStrongTypeNotNull = (DoubleStrongType)276.1231, GuidStrongTypeNotNull = (GuidStrongType)Guid.NewGuid(), Int16StrongTypeNotNull = (Int16StrongType)(-13264), Int32StrongTypeNotNull = (Int32StrongType)(-13645841), Int64StrongTypeNotNull = (Int64StrongType)12354878548, SByteStrongTypeNotNull = (SByteStrongType)(-100), SingleStrongTypeNotNull = (SingleStrongType)14234.1230, StringStrongTypeNotNull = (StringStrongType)"foo bar", UInt16StrongTypeNotNull = (UInt16StrongType)50146, UInt32StrongTypeNotNull = (UInt32StrongType)3156469123, UInt64StrongTypeNotNull = (UInt64StrongType)17464894014012346145 }; // Act var serialized = Newtonsoft.Json.JsonConvert.SerializeObject(initialInstance); var deserialized = System.Text.Json.JsonSerializer.Deserialize <SerializationClass>(serialized); // Assert initialInstance.Should().BeEquivalentTo(deserialized); }
private void Wczytaj_Sieć(object sender, RoutedEventArgs e) { Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); dlg.Filter = "XML Files (.xml)|*.xml"; Nullable <bool> result = dlg.ShowDialog(); if (result == true) { string fileName = dlg.FileName; try { NeuralNetwork = SerializationClass.ConDeSerializer(NeuralNetwork, fileName); Network randomnet = SerializationClass.ConDeSerializer(NeuralNetwork, fileName); UczenieSieci.IsEnabled = false; } catch (Exception ex) { MessageBox.Show(ex.Message); } } else { MessageBox.Show("Failed to open File"); } }
public void Send(string message, bool isFile) { try { SerializationClass serCl = new SerializationClass(); if (isFile) { serCl.FileName = message.Substring(message.LastIndexOf('\\')+1); serCl.Command = "SendFile"; using (FileStream file = new FileStream(message, FileMode.Open)) { StreamReader sr = new StreamReader(file); string cont = sr.ReadToEnd(); serCl.Content = Encoding.UTF8.GetBytes(cont); } } else { serCl.FileName = message; serCl.Content = Encoding.UTF8.GetBytes(message); serCl.Command = "SendMessage"; } string msg = JsonConvert.SerializeObject(serCl); bytes = Encoding.UTF8.GetBytes(msg); sSender = new Socket(ipAddr.AddressFamily, SocketType.Stream, ProtocolType.Tcp); AsyncCallback acConn = new AsyncCallback(OnConnect); sSender.BeginConnect(ipEnd, acConn, sSender); } catch (Exception exc) { } }
internal static ClassificationMetrics FromMetrics(IHostEnvironment env, IDataView overallMetrics, IDataView confusionMatrix) { Contracts.AssertValue(env); env.AssertValue(overallMetrics); env.AssertValue(confusionMatrix); var metricsEnumerable = overallMetrics.AsEnumerable <SerializationClass>(env, true, ignoreMissingColumns: true); var enumerator = metricsEnumerable.GetEnumerator(); if (!enumerator.MoveNext()) { throw env.Except("The overall RegressionMetrics didn't have any rows."); } SerializationClass metrics = enumerator.Current; if (enumerator.MoveNext()) { throw env.Except("The overall RegressionMetrics contained more than 1 row."); } return(new ClassificationMetrics() { AccuracyMicro = metrics.AccuracyMicro, AccuracyMacro = metrics.AccuracyMacro, LogLoss = metrics.LogLoss, LogLossReduction = metrics.LogLossReduction, TopKAccuracy = metrics.TopKAccuracy, PerClassLogLoss = metrics.PerClassLogLoss, ConfusionMatrix = ConfusionMatrix.Create(env, confusionMatrix) }); }
public void introducingToListTest() { ProductionReport report = new ProductionReport() { Factories = new Factories() { Factory = new Factory() { ProducedCars = new ProducedCars() { Car = new List <Car>() { } } } } }; int count = 1; report.Factories.Factory.ProducedCars.Car.Add(new Car("XXXX", "YYYY", "MMMM")); SerializationClass serialization = new SerializationClass(); List <Car> list = serialization.introducingToList(count, report); Assert.AreEqual(list[0].Model, report.Factories.Factory.ProducedCars.Car[0].Model); Assert.AreEqual(list[0].Vin, report.Factories.Factory.ProducedCars.Car[0].Vin); Assert.AreEqual(list[0].ProductionYear, report.Factories.Factory.ProducedCars.Car[0].ProductionYear); }
/// <summary> /// Constuctor. /// </summary> /// <param name="viewModelStore">The store this view model belongs to.</param> /// <param name="serializationClass">SerializationClass.</param> /// <param name="referencedElement">Element that is referenced by the serialization element. Can be null.</param> protected SerializationClassViewModel(ViewModelStore viewModelStore, SerializationClass serializationClass, ModelElement referencedElement, SerializationClassViewModel parent) : base(viewModelStore, serializationClass, referencedElement) { this.childrenVMs = new ObservableCollection <SerializationElementViewModel>(); this.childrenVMsRO = new ReadOnlyObservableCollection <SerializationElementViewModel>(this.childrenVMs); this.attributesVMs = new ObservableCollection <SerializationAttributeElementViewModel>(); this.attributesVMsRO = new ReadOnlyObservableCollection <SerializationAttributeElementViewModel>(attributesVMs); this.parent = parent; if (this.SerializationElement != null) { // Lazy load the child items, if necessary. if (this.HasLoadedChildren) { this.LoadChildren(); } else if (this.SerializationElement.Children.Count > 0) { this.childrenVMs.Add(DummyChild); } this.LoadAttributes(); /* * // Lazy load the attribute items, if necessary. * if (!this.HasLoadedAttributes) * { * this.LoadAttributes(); * } * else if (this.SerializationElement.Attributes.Count > 0) * this.attributesVMs.Add(DummyAttribute); */ // subscribe this.EventManager.GetEvent <ModelElementPropertyChangedEvent>().Subscribe(this.SerializationElement.Id, new Action <ElementPropertyChangedEventArgs>(OnSerializationClassPropertyChanged)); this.EventManager.GetEvent <ModelElementLinkAddedEvent>().Subscribe(this.Store.DomainDataDirectory.GetDomainRelationship(SerializationClassReferencesChildren.DomainClassId), true, this.SerializationElement.Id, new Action <ElementAddedEventArgs>(OnChildAdded)); this.EventManager.GetEvent <ModelElementLinkDeletedEvent>().Subscribe(this.Store.DomainDataDirectory.GetDomainRelationship(SerializationClassReferencesChildren.DomainClassId), true, this.SerializationElement.Id, new Action <ElementDeletedEventArgs>(OnChildRemoved)); this.EventManager.GetEvent <ModelRolePlayerMovedEvent>().Subscribe(this.Store.DomainDataDirectory.GetDomainRelationship(SerializationClassReferencesChildren.DomainClassId), this.SerializationElement.Id, new Action <RolePlayerOrderChangedEventArgs>(OnChildMoved)); this.EventManager.GetEvent <ModelElementLinkAddedEvent>().Subscribe(this.Store.DomainDataDirectory.GetDomainRelationship(SerializationClassReferencesAttributes.DomainClassId), true, this.SerializationElement.Id, new Action <ElementAddedEventArgs>(OnAttributeAdded)); this.EventManager.GetEvent <ModelElementLinkDeletedEvent>().Subscribe(this.Store.DomainDataDirectory.GetDomainRelationship(SerializationClassReferencesAttributes.DomainClassId), true, this.SerializationElement.Id, new Action <ElementDeletedEventArgs>(OnAttributeRemoved)); this.EventManager.GetEvent <ModelRolePlayerMovedEvent>().Subscribe(this.Store.DomainDataDirectory.GetDomainRelationship(SerializationClassReferencesAttributes.DomainClassId), this.SerializationElement.Id, new Action <RolePlayerOrderChangedEventArgs>(OnAttributeMoved)); } }
/// <summary> /// Constuctor. /// </summary> /// <param name="viewModelStore">The store this view model belongs to.</param> /// <param name="serializationClass">SerializationClass.</param> /// <param name="referencedElement">Element that is referenced by the serialization element. Can be null.</param> protected SerializationClassViewModel(ViewModelStore viewModelStore, SerializationClass serializationClass, ModelElement referencedElement, SerializationClassViewModel parent) : base(viewModelStore, serializationClass, referencedElement) { this.childrenVMs = new ObservableCollection<SerializationElementViewModel>(); this.childrenVMsRO = new ReadOnlyObservableCollection<SerializationElementViewModel>(this.childrenVMs); this.attributesVMs = new ObservableCollection<SerializationAttributeElementViewModel>(); this.attributesVMsRO = new ReadOnlyObservableCollection<SerializationAttributeElementViewModel>(attributesVMs); this.parent = parent; if (this.SerializationElement != null) { // Lazy load the child items, if necessary. if (this.HasLoadedChildren) { this.LoadChildren(); } else if (this.SerializationElement.Children.Count > 0) this.childrenVMs.Add(DummyChild); this.LoadAttributes(); /* // Lazy load the attribute items, if necessary. if (!this.HasLoadedAttributes) { this.LoadAttributes(); } else if (this.SerializationElement.Attributes.Count > 0) this.attributesVMs.Add(DummyAttribute); */ // subscribe this.EventManager.GetEvent<ModelElementPropertyChangedEvent>().Subscribe(this.SerializationElement.Id, new Action<ElementPropertyChangedEventArgs>(OnSerializationClassPropertyChanged)); this.EventManager.GetEvent<ModelElementLinkAddedEvent>().Subscribe(this.Store.DomainDataDirectory.GetDomainRelationship(SerializationClassReferencesChildren.DomainClassId), true, this.SerializationElement.Id, new Action<ElementAddedEventArgs>(OnChildAdded)); this.EventManager.GetEvent<ModelElementLinkDeletedEvent>().Subscribe(this.Store.DomainDataDirectory.GetDomainRelationship(SerializationClassReferencesChildren.DomainClassId), true, this.SerializationElement.Id, new Action<ElementDeletedEventArgs>(OnChildRemoved)); this.EventManager.GetEvent<ModelRolePlayerMovedEvent>().Subscribe(this.Store.DomainDataDirectory.GetDomainRelationship(SerializationClassReferencesChildren.DomainClassId), this.SerializationElement.Id, new Action<RolePlayerOrderChangedEventArgs>(OnChildMoved)); this.EventManager.GetEvent<ModelElementLinkAddedEvent>().Subscribe(this.Store.DomainDataDirectory.GetDomainRelationship(SerializationClassReferencesAttributes.DomainClassId), true, this.SerializationElement.Id, new Action<ElementAddedEventArgs>(OnAttributeAdded)); this.EventManager.GetEvent<ModelElementLinkDeletedEvent>().Subscribe(this.Store.DomainDataDirectory.GetDomainRelationship(SerializationClassReferencesAttributes.DomainClassId), true, this.SerializationElement.Id, new Action<ElementDeletedEventArgs>(OnAttributeRemoved)); this.EventManager.GetEvent<ModelRolePlayerMovedEvent>().Subscribe(this.Store.DomainDataDirectory.GetDomainRelationship(SerializationClassReferencesAttributes.DomainClassId), this.SerializationElement.Id, new Action<RolePlayerOrderChangedEventArgs>(OnAttributeMoved)); } }
/// <summary> /// Deletes a new SerializationClass view model for the given element. /// </summary> /// <param name="element">ModelContext.</param> public void DeleteChild(SerializationClass element) { for (int i = this.allVMs.Count - 1; i >= 0; i--) { if (this.allVMs[i].SerializationElement.Id == element.Id) { this.allVMs[i].Dispose(); this.allVMs.RemoveAt(i); } } OnPropertyChanged("AllVMs"); }
public ActionResult <PixelPlacement> Post(string jsonPlacement) { if (jsonPlacement == null) { return(BadRequest()); } SerializationClass objToSerialize = new SerializationClass(); var placement = objToSerialize.JsonDeserialize(jsonPlacement); //var newPlacement = repository.AddPixelPlacement(placement); return(CreatedAtAction("Get", new { id = placement.PixelPlacementID }, placement)); }
static void Main() { try{ //处理未捕获的异常 Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); //处理UI异常 Application.ThreadException += Application_ThreadException; //处理非UI异常 AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; mav_msg_handler = new MavLinkHandler(); PointConversion = new CoordinateTransformation(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); string procName = System.Diagnostics.Process.GetCurrentProcess().ProcessName; if ((System.Diagnostics.Process.GetProcessesByName(procName)).GetUpperBound(0) > 0) { MessageBox.Show("已经检测到有实例在运行!!!"); return; } SerializationClass serialize = XMLSerializer.DeSerialize <SerializationClass>(System.Windows.Forms.Application.StartupPath + "\\config.txt"); if (serialize != null) { if (serialize.Language == "en") { System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en"); } } Application.Run(new Form1()); }catch (Exception ex) { string str = ""; string strDateInfo = "出现应用程序未处理的异常:" + DateTime.Now.ToString() + "\r\n"; if (ex != null) { str = string.Format(strDateInfo + "异常类型:{0}\r\n异常消息:{1}\r\n异常信息:{2}\r\n", ex.GetType().Name, ex.Message, ex.StackTrace); } else { str = string.Format("应用程序线程错误:{0}", ex); } MessageBox.Show(str); } }
/// <summary> /// Adds a new SerializationClass view model for the given element. /// </summary> /// <param name="element">ModelContext.</param> public void AddChild(SerializationClass element) { if (!(element is SerializedDomainClass)) { return; } SerializedDomainClass dc = element as SerializedDomainClass; /*if (dc.ParentEmbeddedElements.Count > 0) * return;*/ // verify that node hasnt been added yet foreach (SerializedDomainModelViewModel viewModel in this.allVMs) { if (viewModel.SerializationElement.Id == element.Id) { return; } } SerializedDomainModelViewModel vm = new SerializedDomainModelViewModel(this.ViewModelStore, dc); this.allVMs.Add(vm); IOrderedEnumerable <SerializedDomainModelViewModel> items = null; items = this.allVMs.OrderBy <SerializedDomainModelViewModel, string>((x) => (x.DomainElementName)); ObservableCollection <SerializedDomainModelViewModel> temp = new ObservableCollection <SerializedDomainModelViewModel>(); foreach (SerializedDomainModelViewModel item in items) { temp.Add(item); } this.allVMs = temp; OnPropertyChanged("AllVMs"); }
private void SerializeBoW_Click(object sender, RoutedEventArgs e) { Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog(); dlg.Filter = "XML Files (.xml)|*.xml"; Nullable <bool> result = dlg.ShowDialog(); if (result == true) { string fileName = dlg.FileName; try { SerializationClass.ConSerializer(bow, fileName); } catch (Exception ex) { MessageBox.Show(ex.Message); } } else { MessageBox.Show("Failed to save File"); } }
internal static BinaryClassificationMetrics FromMetrics(IHostEnvironment env, IDataView overallMetrics, IDataView confusionMatrix) { Contracts.AssertValue(env); env.AssertValue(overallMetrics); env.AssertValue(confusionMatrix); var metricsEnumerable = overallMetrics.AsEnumerable <SerializationClass>(env, true, ignoreMissingColumns: true); var enumerator = metricsEnumerable.GetEnumerator(); if (!enumerator.MoveNext()) { throw env.Except("The overall RegressionMetrics didn't have any rows."); } SerializationClass metrics = enumerator.Current; if (enumerator.MoveNext()) { throw env.Except("The overall RegressionMetrics contained more than 1 row."); } return(new BinaryClassificationMetrics() { Auc = metrics.Auc, Accuracy = metrics.Accuracy, PositivePrecision = metrics.PositivePrecision, PositiveRecall = metrics.PositiveRecall, NegativePrecision = metrics.NegativePrecision, NegativeRecall = metrics.NegativeRecall, LogLoss = metrics.LogLoss, LogLossReduction = metrics.LogLossReduction, Entropy = metrics.Entropy, F1Score = metrics.F1Score, Auprc = metrics.Auprc, ConfusionMatrix = ConfusionMatrix.Create(env, confusionMatrix), }); }
/// <summary> /// Deletes a new SerializationClass view model for the given element. /// </summary> /// <param name="element">ModelContext.</param> public void DeleteChild(SerializationClass element) { for (int i = this.allVMs.Count - 1; i >= 0; i--) if (this.allVMs[i].SerializationElement.Id == element.Id) { this.allVMs[i].Dispose(); this.allVMs.RemoveAt(i); } OnPropertyChanged("AllVMs"); }
/// <summary> /// Adds a new SerializationClass view model for the given element. /// </summary> /// <param name="element">ModelContext.</param> public void AddChild(SerializationClass element) { if (!(element is SerializedDomainClass)) return; SerializedDomainClass dc = element as SerializedDomainClass; /*if (dc.ParentEmbeddedElements.Count > 0) return;*/ // verify that node hasnt been added yet foreach (SerializedDomainModelViewModel viewModel in this.allVMs) if (viewModel.SerializationElement.Id == element.Id) return; SerializedDomainModelViewModel vm = new SerializedDomainModelViewModel(this.ViewModelStore, dc); this.allVMs.Add(vm); IOrderedEnumerable<SerializedDomainModelViewModel> items = null; items = this.allVMs.OrderBy<SerializedDomainModelViewModel, string>((x) => (x.DomainElementName)); ObservableCollection<SerializedDomainModelViewModel> temp = new ObservableCollection<SerializedDomainModelViewModel>(); foreach (SerializedDomainModelViewModel item in items) temp.Add(item); this.allVMs = temp; OnPropertyChanged("AllVMs"); }