首页
\
问答
\
无法从docker container runngin ubuntu 14.04访问互联网(can't access internet from the docker container runngin ubuntu 14.04)
无法从docker container runngin ubuntu 14.04访问互联网(can't access internet from the docker container runngin ubuntu 14.04)
我在Docker容器中配置sentrifugo。 我无法从我的docker容器访问互联网。 我是Docker的新手。 我的主机正在运行Ubuntu 14.04。 有什么建议么?
I am configuring sentrifugo in a Docker container. I can't access the internet from my docker container. I am new to Docker. My host machine is running Ubuntu 14.04. Any suggestions?
原文:https://stackoverflow.com/questions/33166713
更新时间:2023-04-09 13:04
最满意答案
由于
GetValue
返回Object
您需要实现IComparable
的非泛型版本。void Main() { var custList = new List<Customer>() { new Customer(){ Country = new Country(){ Name = "Sweden" } }, new Customer(){ Country = new Country(){ Name = "Denmark" } }, }; var itemProp = typeof(Customer).GetProperty("Country"); custList = custList.OrderBy(cust => itemProp.GetValue(cust, null)).ToList(); custList.Dump(); } public class Country : IComparable<Country>, IComparable { public string Name {get;set;} public int CompareTo(Country other) { return string.Compare(this.Name, other.Name); } public int CompareTo(object other) { var o = other as Country; if(o == null) return 0; //Or how you want to handle it return CompareTo(o); } } public class Customer { public Country Country{get;set;} }
Since
GetValue
returnsObject
you need to implement the non generic version ofIComparable
.void Main() { var custList = new List<Customer>() { new Customer(){ Country = new Country(){ Name = "Sweden" } }, new Customer(){ Country = new Country(){ Name = "Denmark" } }, }; var itemProp = typeof(Customer).GetProperty("Country"); custList = custList.OrderBy(cust => itemProp.GetValue(cust, null)).ToList(); custList.Dump(); } public class Country : IComparable<Country>, IComparable { public string Name {get;set;} public int CompareTo(Country other) { return string.Compare(this.Name, other.Name); } public int CompareTo(object other) { var o = other as Country; if(o == null) return 0; //Or how you want to handle it return CompareTo(o); } } public class Customer { public Country Country{get;set;} }
相关问答
更多-
使用prop.GetValue(result)获取属性值。 Use prop.GetValue(result) to get the property value.
-
NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"thisIsTheNameOfYourDateProperty" ascending:NO]; NSArray *orderedArray = [arrayOfCustomObjects sortedArrayUsingDescriptors:[NSArray arrayWithObject:sortDescriptor]]; NSSortDescripto ...
-
实体框架DbEntityEntry.Property方法是否使用反射?(Does the Entity Framework DbEntityEntry.Property method use reflection?)[2023-12-16]
它不使用反射(反射是在创建元数据模型时完成的),但是一次是从编译的动态表达式构建和缓存的委托。 执行实际属性集的代码在这里 : internal static void SetValue(EdmProperty property, object target, object value) { var setter = GetSetterDelegateForProperty(property); setter(target, value); } 并构建表达式并编译委托就在这 ... -
这种方法怎么样: Func
sort1 = r => GetProperty(r, "City"); Func sort2 = r => GetProperty(r, "State"); Func sort3 = r => GetProperty(r, "Address"); Func filterPredicate = p => GetProperty(p, "City").ToS ... -
首先,我以前曾试图像这样重新发明这种轮子,但它永远不会像你想的那样真正起作用。 如果你需要那种动态的灵活性,那么可能已经有一个库在某处, 或者你也可以实际手动制作SQL或其他东西(它很糟糕,但有时它是唯一的实用方法)..除此之外.. 。 我认为你的问题实际上与SQLite有关 - 由于拼写错误或版本不相同,我无法让SQLite的东西工作(例如,SQLite的默认nuget包有一个SQLiteConnectionStringBuilder而不是一个SqliteConnectionStringBuilder , ...
-
实体框架DbSet反射(Entity Framework DbSet Reflection)[2021-12-07]
您应该使用ChangeTracker。 .... foreach( var entry in context.ChangeTracker.Entries()) { if(entry.State!=EntityState.Unchanged) { TrackedEntity entity = entry.Entity; entity.Modified = DateTime.UtcNow; entity.Modifie ... -
您可以使用Dynamic LINQ。 这是blog post关于Scott Gu的blog post 。 You could use Dynamic LINQ. Here's a blog post about it from Scott Gu.
-
LINQ - 实体框架代码优先 - 将结果分组到自定义类(LINQ - Entity framework code first - Grouped results to custom class)[2023-10-20]
您可以使用此linq查询: var myObjects = (from m in db.MyObjects group m by m.Name into grouped select new MyObjectWithCount() { MyObject = grouped.FirstOrDefault(), ... -
由于GetValue返回Object您需要实现IComparable的非泛型版本。 void Main() { var custList = new List
() { new Customer(){ Country = new Country(){ Name = "Sweden" } }, new Customer(){ Country = new Country(){ Name = "Denmark" } }, }; ... -
如何使用反射来确定属性上是否存在属性?(How can reflection be used to determine if an attribute exists on a property?)[2022-07-12]
以下代码有效: using System.Web.Script.Serialization; public class TestAttribute { [ScriptIgnore] public string SomeProperty1 { get; set; } public string SomeProperty2 { get; set; } public string SomeProperty3 { get; set; } [ScriptIgnore] public st ...