好的,所以我有一个 .NET 控制台应用程序,它的 Main 方法包含在 Program 类中。你知道,通常的:
class Program
{
static void Main(string[] args)
{
// Do something spectactular
}
}
Run Code Online (Sandbox Code Playgroud)
自从我开始如此严格地使用 StyleCop 和 FxCop 以来,我对确保所有内容都正确记录变得有点挑剔。
然后它击中了我。我完全不知道如何正确记录 Program 和 Program.Main。
我想,从长远来看,您可以采用以下方法:
/// <summary>
/// Encapsulates the application's main entry point.
/// </summary>
class Program
{
/// <summary>
/// The application's main entry point.
/// </summary>
static void Main(string[] args)
{
// Do something spectactular
}
}
Run Code Online (Sandbox Code Playgroud)
但这似乎严重不足(尽管我的 Main 例程总是委托给其他类来完成这项工作)。
你们是如何记录这些事情的?有推荐或标准吗?
我有一个结构数组包含字段作为不同长度的结构数组.例如:
's'是一个结构'data'是's'中的一个字段,也是一个结构数组本身和
length(s(n).data) ~= length(s(m).data)
Run Code Online (Sandbox Code Playgroud)
我想预先分配一个数组,该数组从每个字段s.data.timestamp中获取一个时间戳.有没有办法在不使用for循环两次的情况下执行此操作?这是我到目前为止:
% find the total length
count=0;
for x=1:length(s)
count=count+length(s(x).data);
end
% preallocate timestamp array
timestamp=zeros(1,count);
% populate timestamp array
index=1;
for x=1:length(s)
for y=1:length(s(x).data)
timestamp(index)=s(x).data(y).timestamp;
index=index+1;
end
end
Run Code Online (Sandbox Code Playgroud)
我想过根据's'的长度和'数据'的平均长度过高估计我需要的长度,但每个'数据'字段/子结构的实际长度变化很大.我是否会更好地过高估计它的结果并在之后修剪得到的数组?使用我正在使用的数据集时,零时间戳是不可能的,所以这应该不是问题.
我有以下模型,我已经创建并使用nHibernate进行映射.使用延迟加载,所以我不需要在开始时获得经销商的车辆.
Public class Dealer
{
public virtual string Name { get;set;}
public virtual IList<Vehicles> Vehicles { get;set;}
}
Run Code Online (Sandbox Code Playgroud)
现在让我们假设经销商拥有数千辆汽车.
如果我这样做,Dealer.Vehicles.Count那么NH将选择并提取所有数据.
简单计算的最佳方法是什么?有没有什么方法可以让我在经销商类别中声明一个新的房地产经纪人数量?
此外,Hibernate还有一个功能,我相信它将在更新版本的NH中实现,称为Extra Lazy Loading.这会解决问题吗?
我看到LIKE运算符可以在我切换PRAGMA case_sensitive_like = ON时优化查询.我测量,它确实有效,查询"LIKE someth%"在分区大的二进制索引表上变快十倍.但问题是我的库作为我的应用程序的附加组件实现,它维护自己的表与它连接的任何数据库.所以问题是
在SQL Server中执行递归自联接的最简单方法是什么?我有这样一张桌子:
PersonID | Initials | ParentID
1 CJ NULL
2 EB 1
3 MB 1
4 SW 2
5 YT NULL
6 IS 5
Run Code Online (Sandbox Code Playgroud)
而且我希望能够获得仅与特定人员开始的层次结构相关的记录.所以,如果我通过PersonID = 1请求CJ的层次结构,我会得到:
PersonID | Initials | ParentID
1 CJ NULL
2 EB 1
3 MB 1
4 SW 2
Run Code Online (Sandbox Code Playgroud)
对于EB,我会得到:
PersonID | Initials | ParentID
2 EB 1
4 SW 2
Run Code Online (Sandbox Code Playgroud)
我有点卡住这个可以想不出怎么做除了基于一堆连接的固定深度响应.这会发生,因为我们不会有很多级别,但我想做得恰到好处.
谢谢!克里斯.
我正在使用Scala 2.8.0并尝试读取管道分隔文件,如下面的代码剪切:
object Main {
def main(args: Array[String]) :Unit = {
if (args.length > 0) {
val lines = scala.io.Source.fromPath("QUICK!LRU-2009-11-15.psv")
for (line <-lines)
print(line)
}
}
}
Run Code Online (Sandbox Code Playgroud)
这是错误:
线程"main"中的异常java.nio.charset.UnmappableCharacterException:在sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:)的java.nio.charset.CoderResult.throwException(CoderResult.java:261)输入长度= 1. 319)at.nio.cs.StreamDecoder.read(StreamDecoder.java:158)at java.io.InputStreamReader.read(InputStreamReader.java:167)at java.io.BufferedReader.fill(BufferedReader.java:136)at at java.io.BufferedReader.read(BufferedReader.java:157)at scala.io.BufferedSource $$ anonfun $ 1 $$ anonfun $ apply $ 1.apply(BufferedSource.scala:29)at scala.io.BufferedSource $$ anonfun $ 1 $ $ anonfun $在scala.io.Codec.wrap(Codec.scala:65)的scala.io.BufferedSource $$ anonfun $ 1.apply(BufferedSource.scala:29)scala上应用$ 1.apply(BufferedSource.scala:29) .io.BufferedSource $$ anonfun $ 1.apply(BufferedSource.scala:29)at scala.collection.Iterator $$ anon $ 14.next(Iterator.scala:149)at scala.collection.Iterator $$ anon $ 2.next(Iterator .scala:745)scala.collection.Iterator $$ anon $ 2.head(Iterator.scala:732)at …
当我使用内部Web服务器(而不是IIS)从Visual Studio 2008 SP1运行Web应用程序时,我收到上述错误.
完整错误(源文件Default.aspx.cs):
编译器错误消息:CS0433:类型'WebApplication3.Site1'存在于'c:\ Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\aa563bcf\59deedc0\App_Web_site1.master.cdcab7d2中. muczzy9v.dll'和'c:\ Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\aa563bcf\59deedc0\assembly\dl3\44c3a3cf\80dd34ed_6968ca01\WebApplication3.DLL'
前面的完整警告:
警告:CS0436:'c:\ Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\aa563bcf\59deedc0\App_Web_default.aspx.cdcab7d2._tlkwdos.0中的类型'WebApplication3._Default'. cs'与'c:\ Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\aa563bcf\59deedc0\assembly\dl3\44c3a3cf\e096e61c_6568ca01\WebApplication3中的导入类型'WebApplication3._Default'发生冲突.DLL".使用'c:\ Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\aa563bcf\59deedc0\App_Web_default.aspx.cdcab7d2._tlkwdos.0.cs'中定义的类型.
警告源指向中间文件App_Web_default.aspx.cdcab7d2._tlkwdos.0.cs:
Line 162:
Line 163: [System.Runtime.CompilerServices.CompilerGlobalScopeAttribute()]
Line 164: public class default_aspx : global::WebApplication3._Default, System.Web.IHttpHandler {
Line 165:
Line 166: private static bool @__initialized;
Run Code Online (Sandbox Code Playgroud)
我的问题:这是从哪里来的?
webapp(不是网站!)有一个Default.aspx和一个Site1.Master,没有依赖项.它们几乎是空的,asp:Label页面上有一个.以前,这个webapp运行良好.当我将Default.aspx.cs中的任何引用删除到master时,一切顺利.主人只有一些代码.
它实际上是许多小小的"即发即弃"测试webapps中的一个,所以我不在乎.但我之前没有看过这个,现在我很好奇该做什么,然后将代码复制到一个新项目中(清洁解决方案没有帮助).
注意:我已阅读此帖和其他一些内容,但不适用.
我有一个用Grizzly制作的REST服务器,它使用HTTPS并与Firefox完美配合.这是代码:
//Build a new Servlet Adapter.
ServletAdapter adapter=new ServletAdapter();
adapter.addInitParameter("com.sun.jersey.config.property.packages", "My.services");
adapter.addInitParameter(ResourceConfig.PROPERTY_CONTAINER_REQUEST_FILTERS, SecurityFilter.class.getName());
adapter.setContextPath("/");
adapter.setServletInstance(new ServletContainer());
//Configure SSL (See instructions at the top of this file on how these files are generated.)
SSLConfig ssl=new SSLConfig();
String keystoreFile=Main.class.getResource("resources/keystore_server.jks").toURI().getPath();
System.out.printf("Using keystore at: %s.",keystoreFile);
ssl.setKeyStoreFile(keystoreFile);
ssl.setKeyStorePass("asdfgh");
//Build the web server.
GrizzlyWebServer webServer=new GrizzlyWebServer(getPort(9999),".",true);
//Add the servlet.
webServer.addGrizzlyAdapter(adapter, new String[]{"/"});
//Set SSL
webServer.setSSLConfig(ssl);
//Start it up.
System.out.println(String.format("Jersey app started with WADL available at "
+ "%sapplication.wadl\n",
"https://localhost:9999/"));
webServer.start();
Run Code Online (Sandbox Code Playgroud)
现在,我尝试用Java实现它:
SSLContext ctx=null;
try {
ctx …Run Code Online (Sandbox Code Playgroud) IronPython中的相同之处是什么?它只是一个尝试 - 最后块?
using (var something = new ClassThatImplementsIDisposable())
{
// stuff happens here
}
Run Code Online (Sandbox Code Playgroud) 请原谅我,因为我是Objective C的新手.
我从/ Date(xxxxxxxxxxxxx-xxxx)/格式的.NET Web服务中获取日期.我正在寻找一些关于如何最好地将其解析为NSDate对象的方向.我已经尝试过对它使用dateWithTimeIntervalSince1970,但它在1969年的日期回来了,我所知道的日期是在2006年.
寻找处理JSON日期的正确方法的一些方向.
提前致谢!
arrays ×1
asp.net ×1
c# ×1
coding-style ×1
collections ×1
datetime ×1
exception ×1
idisposable ×1
iphone ×1
ironpython ×1
java ×1
json ×1
lazy-loading ×1
master-pages ×1
matlab ×1
nhibernate ×1
objective-c ×1
optimization ×1
recursion ×1
rest ×1
scala ×1
self-join ×1
sql ×1
sql-like ×1
sql-server ×1
sqlite ×1
ssl ×1
x509 ×1