我正在尝试使用SOLID原理学习更好的编程实践.在这里,我正在研究Shapes的示例应用程序.我只是想知道,我在任何地方都违反了原则.下面是类及其代码.
1.基类 - 形状
public abstract class Shape
{
public abstract double Area();
public virtual double Volume()
{
throw new NotImplementedException("You cannot determine volume from here...Method not implemented.");
}
}
Run Code Online (Sandbox Code Playgroud)
2.实现基类Shape的矩形,三角形等形状的类.
public class Circle : Shape
{
public int Radius { get; set; }
public override double Area() { return 3.14 * Radius * Radius; }
}
public class Triangle : Shape
{
public int Height { get; set; }
public int Base { get; set; }
public override double …Run Code Online (Sandbox Code Playgroud) 我试图在pandas数据帧上使用过滤器来过滤掉与重复值匹配的所有行(当存在重复时需要删除所有行,而不仅仅是第一个或最后一个).
这就是我在编辑器中的作用:
df = df.groupby("student_id").filter(lambda x: x.count() == 1)
Run Code Online (Sandbox Code Playgroud)
但是,当我使用此代码运行我的脚本时,我收到错误:
TypeError:filter函数返回一个Series,但是期望一个标量bool
我在尝试应用过滤器之前,通过连接另外两个帧来创建数据帧.
有没有办法找到杀死这份Hadoop工作的用户的名字?
我在群集Hadoop 2.6.0节点上没有root访问权限,因此我只能使用Hadoop命令行工具并仔细检查日志.
我检查了日志并尝试使用mapred job -history [jhist file]但找不到用户名.
我已经有一个使用的网站MVC 5,它使用表单身份验证SQL Server.
现在我可以绕过Forms Authentication已经在办公室网络上的用户.此外,我想跟踪用户并应用类似的规则Forms Authentication.谢谢.
c# asp.net windows-authentication form-authentication asp.net-mvc-5
在.Net 4.X,这个扩展方法是在System.Xml.XPath.
但是,我想知道如何在.Net Core中找到/使用它?我有一个类库.
移植工具没有显示任何内容XPathSelectElement.
或者.Net核心中的任何替代品?
非常感谢!
我试图了解类方法.根据我的阅读,我们必须在定义时将cls作为第一个参数传递给类方法(类似于我们将self作为第一个参数传递的实例方法).但是我看到即使我将self作为类方法的第一个参数传递它也能工作.谁能解释一下这是如何工作的?
我已经看到他们将类定义为类方法的一些用法,但他们仍然将self作为第一个参数而不是cls.我想了解用法.
#!/usr/bin/python
class A(object):
def foo(self,x):
print "executing foo(%s,%s)"%(self,x)
@classmethod
def class_foo(self,x):
print "executing class_foo(%s,%s)"%(self,x)
>>> A.class_foo(2)
executing class_foo(<class '__main__.A'>,2)
>>>
Run Code Online (Sandbox Code Playgroud) 我的Utilities.CS文件App_Code夹中有以下文件作为我的MVC4应用程序中使用的"帮助器"方法(构建操作设置为编译)
如图所示,代码中有一个断点......
应用程序编译(Ctrl-Shift-B)没有错误但是当我运行应用程序时,我在断点之后的CS0122: 'Settings' is inaccessible due to its protection level后续return语句中得到一个.
该AdminGroup设置public在"设置设计器"中定义
突破点一线从来没有被击中,可能是由于运行时编译错误......但如果我编译它,它为什么重新编译后在运行时?
(对不起,我是MVC的新手,所以不确定发生了什么)
namespace MyApplication
{
public class Utilities
{
public static string UserID
{
get
{
return Regex.Replace(WindowsIdentity.GetCurrent().Name, @".+\\", "").ToUpper();
}
}
public static bool IsAdmin
{
get
{
System.Diagnostics.Debug.WriteLine("Break point on this line");
return (HttpContext.Current.User.IsInRole(Properties.Settings.Default.AdminGroup));
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
UPDATE
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
// …Run Code Online (Sandbox Code Playgroud) 使用ASP.NETIdentity时,我希望在用户登录我的网站时尽可能长时间地保留登录信息,这样用户在重新打开浏览器时就不需要再次登录了(就像github.com和stackoverflow.com一样) ).当我登录github时,它会持续很多天我的信息,所以我不需要每天都重新登录.是否有任何方法可以使用ASP.NETIdentity 实现此功能?
我想从内部获取方法名称.这可以使用reflection如下所示完成.但是,我想在不使用的情况下得到它reflection
System.Reflection.MethodBase.GetCurrentMethod().Name
Run Code Online (Sandbox Code Playgroud)
示例代码
public void myMethod()
{
string methodName = // I want to get "myMethod" to here without using reflection.
}
Run Code Online (Sandbox Code Playgroud)