PlaceModel.cs CampusAppWP8::Model::GeoDb::PlaceModel CampusAppWP8::Model::GeoDb System::Device::Location System::Text::RegularExpressions //----------------------------------------------------------------------- //<copyrightfile="PlaceModel.cs"company="BTU/IIT"> //Companycopyrighttag. //</copyright> //<author>stubbfel</author> //<sience>08.08.2013</sience> //---------------------------------------------------------------------- namespaceCampusAppWP8.Model.GeoDb { usingSystem; usingSystem.Collections.Generic; usingSystem.Collections.ObjectModel; usingSystem.Device.Location; usingSystem.Globalization; usingSystem.Text.RegularExpressions; usingSystem.Xml.Serialization; usingCampusAppWP8.Resources; usingCampusAppWP8.Utility; publicclassPlaceModel:IEquatable<PlaceModel> { #regionProperty [XmlAttribute("id")] publicstringPlaceId{get;set;} [XmlAttribute("parentId")] publicstringParentId{get;set;} [XmlAttribute("refpoint")] publicstringRefPoint{get;set;} publicGeoCoordinateGeoRefPoint { get { stringrefstring=this.RefPoint; Regexrx=newRegex(Constants.Regex_Coordinate); MatchCollectionmatches=rx.Matches(refstring); if(matches.Count!=1) { returnnull; } string[]values=matches[0].ToString().Split(''); if(values.Length!=2) { returnnull; } //createtheGeoCoordirate try { returnnewGeoCoordinate(double.Parse(values[1],CultureInfo.InvariantCulture),double.Parse(values[0],CultureInfo.InvariantCulture)); } catch(Exceptionex) { Logger.LogException(ex); returnnull; } } } [XmlElement("placeInformation")] publicObservableCollection<PlaceInformation>Informations{get;set;} [XmlElement("placeService")] publicObservableCollection<PlaceService>Services{get;set;} #endregion #regionMethod publicstringToNfcString() { stringnfcStr="{\"pid\":\""+this.PlaceId+"\",\"parent\":\""+this.ParentId+"\"}"; returnnfcStr; } publicboolEquals(PlaceModelother) { if(other.PlaceId.Equals(this.PlaceId)) { returntrue; } returnfalse; } publicvoidAddPlaceInformations(List<PlaceInformation>placeInformations) { foreach(PlaceInformationinfoinplaceInformations) { if(this.Informations.Contains(info)) { intindex=this.Informations.IndexOf(info); this.Informations[index].InformationValue=info.InformationValue; } else { this.Informations.Add(info); } } } publicvoidAddPlaceServices(List<PlaceService>placeServices) { foreach(PlaceServiceserviceinplaceServices) { if(this.Services.Contains(service)) { intindex=this.Services.IndexOf(service); this.Services[index].Request=service.Request; this.Services[index].SAP=service.SAP; } else { this.Services.Add(service); } } } publicboolContainsInformationNames(List<string>names) { foreach(stringnameinnames) { booltmpResult=false; foreach(PlaceInformationinfointhis.Informations) { if(name.Equals(info.InformationName)) { tmpResult=true; break; } } if(!tmpResult) { returntmpResult; } } returntrue; } publicboolContainsServiceNames(List<string>services) { foreach(stringnameinservices) { booltmpResult=false; foreach(PlaceServiceserviceinthis.Services) { if(name.Equals(service.ServiceName)) { tmpResult=true; break; } } if(!tmpResult) { returntmpResult; } } returntrue; } #endregion } }