本文整理汇总了C#中City类的典型用法代码示例。如果您正苦于以下问题:C# City类的具体用法?C# City怎么用?C# City使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
City类属于命名空间,在下文中一共展示了City类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Insert
public int Insert(City city)
{
hotelContext.Cities.Add(city);
Save();
return city.ID;
}
开发者ID:sabdiel,项目名称:DataAccess,代码行数:7,代码来源:CityRepository.cs
示例2: GetMinDistance
private static int GetMinDistance(Map map, City currentCity, Stack<City> visited)
{
int? minDistance = null;
var currentDistance = 0;
if (currentCity != null && visited.Any())
{
currentDistance = visited.Peek().Roads.Single(x => x.City.Name == currentCity.Name).Distance;
}
var unvisited = map.Cities.Except(visited).Where(x => !Equals(x, currentCity));
if (currentCity != null)
{
visited.Push(currentCity);
unvisited = unvisited.Intersect(currentCity.Roads.Select(x => x.City));
}
foreach (var city in unvisited)
{
int distance = GetMinDistance(map, city, visited);
if (minDistance == null || distance < minDistance)
{
minDistance = distance;
}
}
if (currentCity != null)
{
visited.Pop();
}
currentDistance += minDistance ?? 0;
return currentDistance;
}
开发者ID:navoznov,项目名称:AdventOfCode,代码行数:31,代码来源:Program.cs
示例3: Algorithm
// Main constructor that initializes everything except window
public Algorithm(CitiesLocations _citiesLocations, CitiesConnections _citiesConnectios,
City _startCity, City _finalCity, Alg_Speed _algSpeed, Heuristic _algHeuristic,
ref GraphLayoutCity _graphLayout, ref TextBox _textBoxLog,
ResourceDictionary _resourceDictionary, GraphManager _graphManager)
{
citiesLocations = _citiesLocations;
citiesConnecitons = _citiesConnectios;
StartCity = _startCity;
FinalCity = _finalCity;
AlgSpeed = _algSpeed;
AlgHeuristic = _algHeuristic;
graphLayout = _graphLayout;
textBoxLog = _textBoxLog;
resourceDictionary = _resourceDictionary;
IsRunning = false;
Window = null;
CanContinue = false;
graphManager = _graphManager;
}
开发者ID:NikolaiSamteladze,项目名称:PathFinder,代码行数:27,代码来源:Algorithm.General.cs
示例4: Car
public Car(int xPos, int yPos, City city, Passenger passenger)
{
XPos = xPos;
YPos = yPos;
City = city;
Passenger = passenger;
}
开发者ID:2pointb,项目名称:ApplicationProj,代码行数:7,代码来源:Car.cs
示例5: MakeNodeList
public static void MakeNodeList(Node root,int DummyCount)
{
AllNodesButRoot.Clear();
foreach (City c in cities)
{
if (c != null && c.id != 0 && c.id != root.id&& c.isLarge==true )
{
AllNodesButRoot.Add(c);
}
}
foreach (Resort r in resorts)
{
if (r != null)
{
AllNodesButRoot.Add(r);
}
}
for(int i = 1; i <= DummyCount; i++)
{
City dummy = new City();
// dummy.id = AllNodesButRoot.Count + 1+i;
dummy.id = root.id ;
dummy.name = root.name;
dummy.isDummy = true;
AllNodesButRoot.Add(dummy);
}
return;
}
开发者ID:lovcavil,项目名称:travel,代码行数:29,代码来源:Program.cs
示例6: CalculateDistance_with_a_valid_route_should_return_the_distance
public void CalculateDistance_with_a_valid_route_should_return_the_distance()
{
RoutesCalculator routesCalculator = new RoutesCalculator();
City A = new City('A');
City B = new City('B');
City C = new City('C');
City D = new City('D');
City E = new City('E');
A.Connections.Add(B, 5);
B.Connections.Add(C, 4);
C.Connections.Add(D, 8);
D.Connections.Add(C, 8);
D.Connections.Add(E, 6);
A.Connections.Add(D, 5);
C.Connections.Add(E, 2);
E.Connections.Add(B, 3);
A.Connections.Add(E, 7);
Assert.IsTrue(9 == routesCalculator.CalculateDistance(A, B, C));
Assert.IsTrue(5 == routesCalculator.CalculateDistance(A, D));
Assert.IsTrue(13 == routesCalculator.CalculateDistance(A, D, C));
Assert.IsTrue(22 == routesCalculator.CalculateDistance(A, E, B, C, D));
}
开发者ID:acazsouza,项目名称:trains,代码行数:25,代码来源:RoutesCalculatorTests.cs
示例7: WriteToFile
public void WriteToFile(String fileName, City from, City to, List<Link> links)
{
Application app = new Application();
Workbook wb = app.Workbooks.Add();
Worksheet ws = wb.Worksheets.Add();
ws.Range["A1"].Value = "From";
ws.Range["B1"].Value = "To";
ws.Range["C1"].Value = "Distance";
ws.Range["D1"].Value = "Transport Mode";
Range formatRange;
formatRange = ws.Range["A1", "D1"];
formatRange.EntireRow.Font.Bold = true;
formatRange.EntireRow.Font.Size = 14;
formatRange.BorderAround2(XlLineStyle.xlContinuous, XlBorderWeight.xlThin);
int row = 2;
links.ForEach( l => {
int localRow = row;
ws.Range["A" + localRow].Value = l.FromCity.Name;
ws.Range["B" + localRow].Value = l.ToCity.Name;
ws.Range["C" + localRow].Value = l.Distance;
ws.Range["D" + localRow].Value = l.TransportMode;
});
wb.SaveAs(fileName, XlFileFormat.xlOpenXMLWorkbook);
wb.Close();
}
开发者ID:Lesrac,项目名称:ecnf_labor,代码行数:29,代码来源:ExcelExchange.cs
示例8: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
if (Request.IsSecureConnection)
{
string serverName = HttpUtility.UrlEncode(Request.ServerVariables["SERVER_NAME"]);
string filePath = Request.FilePath;
Response.Redirect("http://" + serverName + filePath);
}
if (!TerritorySite.BL.Linq.Territory.IsCurrentTerritoryAssigned())
{
if (!Page.IsPostBack)
{
DoDataBind();
City thisCity = new City(CurrentUser.CurrentAccount.CityId);
this.address.Value = thisCity.Description + ", " + thisCity.StateProvince.Description;
LiteralHiddenId.Text = HiddenFieldMemory.ClientID;
LiteralHiddenCenterId.Text = HiddenFieldCenterMemory.ClientID;
this.ButtonDone.Attributes.Add("onmousedown", "javascript:savePoints();");
}
this.LiteralKey.Text = System.Web.Configuration.WebConfigurationManager.AppSettings["GMAPKEY"];
this.Form.Attributes.Add("onload", "LoadMap()");
ShowScript = true;
}
else
{
LabelMessage.Text = "You cannot modify the map while the territory is assigned";
tableContent.Visible = false;
ShowScript = false;
}
}
开发者ID:hondoslack,项目名称:territorysite,代码行数:34,代码来源:TerritoryDesigner.aspx.cs
示例9: GetCitiesFromPageHtml
IEnumerable<City> GetCitiesFromPageHtml(String html)
{
var startRegionMarker = "<select id=\"filterAddressTown\"";
var endRegionMarker = "</select>";
var startIndex = html.IndexOf(startRegionMarker);
var endIndex = html.IndexOf(endRegionMarker, startIndex) + endRegionMarker.Length;
var citiesXml = html.Substring(startIndex, endIndex - startIndex);
var cities = new List<City>();
var parsed = XDocument.Parse(citiesXml);
foreach (var elem in parsed.Elements().First().Elements())
{
var city = new City()
{
Id = elem.Attribute("value").Value.Trim(),
Name = elem.Value.Trim()
};
if (city.Id == "0")
continue;
cities.Add(city);
}
return cities;
}
开发者ID:alpospb,项目名称:Mining,代码行数:29,代码来源:SparExpressMiner.cs
示例10: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
DBConnection bindComboBox = new DBConnection();
City cities = new City();
DataTable DT = new DataTable();
DT = bindComboBox.BindDropdown(cities.SearchCities(), "City_Name", "City_Number");
CityDDL.DataSource = DT;
CityDDL.DataValueField = "City_Number";
CityDDL.DataTextField = "City_Name";
CityDDL.DataBind();
GenderDDL.Items.Add("Male");
GenderDDL.Items.Add("Female");
//EmployeeType
EmployeeType empType = new EmployeeType();
DT = bindComboBox.BindDropdown(empType.SearchEmployeeTypes(), "Employee_Type_Name", "Employee_Type_Number");
EmployeeTypeDDL.DataSource = DT;
EmployeeTypeDDL.DataValueField = "Employee_Type_Name";
EmployeeTypeDDL.DataTextField = "Employee_Type_Number";
EmployeeTypeDDL.DataBind();
}
开发者ID:Davidsobey,项目名称:Tweek-Performance,代码行数:25,代码来源:Add_Employee.aspx.cs
示例11: Load
public IList<City> Load()
{
using (MySqlConnection conn = new MySqlConnection("server = localhost; user id = root; password = ; database = test"))
{
conn.Open();
var cmd = conn.CreateCommand();
cmd.CommandText = "set character set 'utf8'";
cmd.ExecuteNonQuery();
var cmdText = @"select * from dol_city";
cmd = conn.CreateCommand();
cmd.CommandText = cmdText;
var reader = cmd.ExecuteReader();
var cityList = new List<City>();
while (reader.Read())
{
var city = new City()
{
ID = reader.GetInt32("id"),
Name = reader.GetString("city_name"),
X = reader.GetFloat("x"),
Y = reader.GetFloat("y")
};
cityList.Add(city);
}
reader.Close();
return cityList;
}
}
开发者ID:hefangshi,项目名称:dolmap-data,代码行数:28,代码来源:CityDM.cs
示例12: WriteToFile
public void WriteToFile(String fileName, City from, City to, List<Link> links)
{
var excel = new Excel.Application();
excel.DisplayAlerts = false;
excel.Workbooks.Add();
excel.Range["A1", "D1"].Borders.LineStyle = Excel.XlLineStyle.xlContinuous;
excel.Range["A1", "D1"].Font.Size = 14;
excel.Range["A1", "D1"].Font.Bold = true;
excel.Range["A1"].Value = "From";
excel.Range["B1"].Value = "To";
excel.Range["C1"].Value = "Distance";
excel.Range["D1"].Value = "Transport Mode";
int row = 2;
foreach (var l in links)
{
excel.Range["A" + row.ToString()].Value = l.FromCity.Name;
excel.Range["B" + row.ToString()].Value = l.ToCity.Name;
excel.Range["C" + row.ToString()].Value = l.Distance;
excel.Range["D" + row.ToString()].Value = l.TransportMode.ToString();
row++;
}
excel.Columns.AutoFit();
Excel._Workbook doc = excel.ActiveWorkbook;
doc.SaveAs(fileName);
doc.Close();
}
开发者ID:platzhersh,项目名称:FHNW-Java-Projekte,代码行数:31,代码来源:ExcelExchange.cs
示例13: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
if (Request.QueryString["Action"] == "delete")
{
string x = Request.QueryString["x"].ToString();
string y = Request.QueryString["y"].ToString();
var db = new TerritorySite.BL.Linq.TerritoryDBDataContext();
var addressToDelete = (from deleteAddress in db.Addresses
where deleteAddress.TerritoryId == TerritoryId
& deleteAddress.Long.Contains(x)
& deleteAddress.Lat.Contains(y)
select deleteAddress).FirstOrDefault();
if (addressToDelete != null)
{
Address.Delete(addressToDelete.AddressId);
}
}
DoDataBind();
City thisCity = new City(CurrentUser.CurrentAccount.CityId);
}
this.LiteralKey.Text = System.Web.Configuration.WebConfigurationManager.AppSettings["GMAPKEY"];
}
开发者ID:hondoslack,项目名称:territorysite,代码行数:28,代码来源:TerritoryPrint.aspx.cs
示例14: GuardCaptain
public GuardCaptain(City city) : base(AIType.AI_Vendor, FightMode.None, 10, 1, 0.2, 0.4)
{
City = city;
Female = Utility.RandomDouble() > 0.75;
Blessed = true;
Name = Female ? NameList.RandomName("female") : NameList.RandomName("male");
Title = "the guard captain";
Body = Female ? 0x191 : 0x190;
HairItemID = Race.RandomHair(Female);
FacialHairItemID = Race.RandomFacialHair(Female);
HairHue = Race.RandomHairHue();
Hue = Race.RandomSkinHue();
SetStr(150);
SetInt(50);
SetDex(150);
SetWearable(new ShortPants(1508));
if (Female)
SetWearable(new FemaleStuddedChest());
else
SetWearable(new PlateChest());
SetWearable(new BodySash(1326));
SetWearable(new Halberd());
CantWalk = true;
}
开发者ID:Ravenwolfe,项目名称:ServUO,代码行数:31,代码来源:GuardCaptain.cs
示例15: CreateCity
public bool CreateCity(string name)
{
if (!String.IsNullOrEmpty(name)){
if (name.Length > 50)
{
return false;
}
City city = this.CityRepository.Get(s => s.Name == name).FirstOrDefault();
if (city == null)
{
City newCity = new City();
newCity.Name = name;
newCity.IsDeleted = false;
this.CityRepository.Insert(newCity);
this.Save();
return true;
}
else if (city.IsDeleted == true)
{
city.IsDeleted = false;
this.CityRepository.Update(city);
this.Save();
return true;
}
else
{
return false;
}
}
return false;
}
开发者ID:taihdse60630,项目名称:JSS_Final,代码行数:35,代码来源:CommonListUnitOfWork.cs
示例16: WriteToFile
public string WriteToFile(String fileName, City from, City to, List<Link> links)
{
object misValue = System.Reflection.Missing.Value;
Application excelApplication = new Application();
Workbook excelWorkBook = excelApplication.Workbooks.Add(misValue);
Worksheet excelWorkSheet = excelWorkBook.Worksheets.get_Item(1);
excelWorkSheet.Cells[1, 1] = "From";
excelWorkSheet.Cells[1, 2] = "To";
excelWorkSheet.Cells[1, 3] = "Distance";
excelWorkSheet.Cells[1, 4] = "Transport Mode";
Range _range;
_range = excelWorkSheet.get_Range("A1", "D1");
_range.Font.Size = 14;
_range.Font.Bold = true;
Borders borders = _range.Borders;
borders.LineStyle = XlLineStyle.xlContinuous;
borders.Weight = 2d;
int j = 2;
foreach (var l in links)
{
excelWorkSheet.Cells[j, 1] = l.FromCity.Name + " (" + l.FromCity.Country + ")";
excelWorkSheet.Cells[j, 2] = l.ToCity.Name + " (" + l.ToCity.Country + ")";
excelWorkSheet.Cells[j, 3] = l.Distance;
excelWorkSheet.Cells[j, 4] = l.TransportMode.ToString();
++j;
}
excelWorkBook.SaveAs(fileName);
excelWorkBook.Close();
return "Ok";
}
开发者ID:mjenny,项目名称:ECNF,代码行数:33,代码来源:ExcelExchange.cs
示例17: WriteToFile
public void WriteToFile(String fileName, City from, City to, List<Link> links)
{
var workbook = _excelApp.Workbooks.Add();
var worksheet = workbook.Worksheets[1];
worksheet.Cells[1, 1] = "From";
worksheet.Cells[1, 2] = "To";
worksheet.Cells[1, 3] = "Distance";
worksheet.Cells[1, 4] = "Transport Mode";
Range range;
range = worksheet.get_Range("A1", "D1");
range.Font.Size = 14;
range.Font.Bold = true;
range.BorderAround2(XlLineStyle.xlContinuous, XlBorderWeight.xlThin);
int row = 2;
foreach (var l in links)
{
worksheet.Cells[row, 1] = l.FromCity.Name;
worksheet.Cells[row, 2] = l.ToCity.Name;
worksheet.Cells[row, 3] = l.Distance;
worksheet.Cells[row, 4] = l.TransportMode;
++row;
}
workbook.SaveAs(fileName, XlFileFormat.xlOpenXMLWorkbook);
workbook.Close();
return ;
}
开发者ID:mp66,项目名称:FallStudie14,代码行数:30,代码来源:ExcelExchange.cs
示例18: uploadMiasta_Click
protected void uploadMiasta_Click(object sender, EventArgs e)
{
if(fileMiasta.HasFile)
{
MemoryStream stream = new MemoryStream(fileMiasta.FileBytes);
XmlReaderSettings settings = new XmlReaderSettings();
int i = 0;
Repository<City, Guid> cityrep = new Repository<City, Guid>();
using (XmlReader r = XmlReader.Create(stream, settings))
{
XPathDocument xpathDoc = new XPathDocument(r);
XPathNavigator xpathNav = xpathDoc.CreateNavigator();
string xpathQuery = "/teryt/catalog/row/col[attribute::name='NAZWA']";
XPathExpression xpathExpr = xpathNav.Compile(xpathQuery);
XPathNodeIterator xpathIter = xpathNav.Select(xpathExpr);
while (xpathIter.MoveNext())
{
City city = new City();
city.Name = xpathIter.Current.Value;
cityrep.SaveOrUpdate(city);
if (i % 500 == 0)
HBManager.Instance.GetSession().Flush();
i++;
//AddressManager.InsertCity(new City { Name = xpathIter.Current.Value });
}
}
HBManager.Instance.GetSession().Flush();
}
}
开发者ID:tsubik,项目名称:SFASystem,代码行数:35,代码来源:PanstwaMiasta.aspx.cs
示例19: btnSave_Click
protected void btnSave_Click(object sender, EventArgs e)
{
bool canContinue = false;
try
{
double.Parse(TextBoxHeight.Text);
double.Parse(TextBoxWidth.Text);
LabelSizeError.Visible = false;
canContinue = true;
}
catch
{
LabelSizeError.Visible = true;
}
if (canContinue)
{
if (int.Parse(DropDownListLanguages.SelectedValue) > 509)
{
Account newAccount = CurrentUser.CurrentAccount;
bool isEditing = !newAccount.IsNew;
newAccount.Description = TextBoxDescription.Text;
newAccount.CountryId = int.Parse(DropDownCountry.SelectedValue);
newAccount.LanguageId = int.Parse(DropDownListLanguages.SelectedValue);
newAccount.CityId = int.Parse(DropDownListCityList.SelectedValue);
newAccount.TrackNames = CheckBoxNames.Checked;
newAccount.TrackPhoneNumbers = CheckBoxPhoneNumbers.Checked;
newAccount.PrintHeight = double.Parse(TextBoxHeight.Text);
newAccount.PrintUnit = DropDownListUnit.SelectedValue;
newAccount.PrintWidth = double.Parse(TextBoxWidth.Text);
newAccount.IsForeignLanguage = CheckBoxIsForeignLanguage.Checked;
newAccount.Save();
CurrentUser.SetAccountCookie(newAccount);
if (!isEditing)
{
if (AccountUserMap.GetForCurrentUser() == null)
{
AccountUserMap newMap = new AccountUserMap();
newMap.AccountId = newAccount.AccountId;
newMap.UserId = CurrentUser.UserName;
newMap.Save();
}
Language defaultLanguage = new Language(509);
defaultLanguage.AddLanguageToCurrentAccount();
defaultLanguage = new Language(int.Parse(DropDownListLanguages.SelectedValue));
defaultLanguage.AddLanguageToCurrentAccount();
City selectedCity = new City(int.Parse(this.DropDownListCityList.SelectedValue));
selectedCity.AssociateWithCurrentAccount();
}
LabelMessage.Text = "Saved.";
Saved();
CurrentUser.Refresh();
}
else
{
LabelMessage.Text = "Please select a valid language";
}
}
}
开发者ID:hondoslack,项目名称:territorysite,代码行数:60,代码来源:AccountData.ascx.cs
示例20: Cities_Inserting
partial void Cities_Inserting(City entity)
{
entity.InsertDate = DateTime.Now;
entity.InsertUser = Application.User.Name;
entity.UpdateDate = DateTime.Now;
entity.UpdateUser = Application.User.Name;
}
开发者ID:karthikeyan51,项目名称:EMS,代码行数:7,代码来源:EMSDataService.cs
注:本文中的City类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论