从这篇文章.这是代码:
float InvSqrt(float x){ // line 0
float xhalf = 0.5f * x;
int i = *(int*)&x; // store floating-point bits in integer
i = 0x5f3759d5 - (i >> 1); // initial guess for Newton's method
x = *(float*)&i; // convert new bits into float
x = x*(1.5f - xhalf*x*x); // One round of Newton's method
return x;
}
Run Code Online (Sandbox Code Playgroud)
......我甚至不知道那是C还是C++.[好吧显然它是C,谢谢]有人可以为我翻译成Java吗?它(只是,我希望)第2和第4行令我感到困惑.
我正在使用Visual Studio 2010,尝试创建一个MEF应用程序.这需要.NET 4.0还是我可以定位.NET 2.0?
我必须创建一个应用程序,它将从数据库中读取一些信息,处理数据,将更改写回数据库,然后将包含这些更改的电子邮件发送给某些用户或组.我将在c#中编写此代码,此过程必须在特定时间每周运行一次.这将在Windows 2008 Server上运行.
在过去,我总是会使用计时器创建一个Windows服务的路径,并设置它在app.config文件中运行的时间/日期,以便可以更改它,只需重新启动即可捕获更新.
不过,最近,我看过博客帖子等,建议编写一个控制台应用程序,然后使用计划任务来执行它.
我已经阅读了很多关于这个问题的帖子,但是没有看到关于哪个过程更好的明确答案.
你们有什么想法?
谢谢你的任何想法.
我有2个字符串数组,如果_authRole数组中存在任何数组,我想返回.怎么做的?
string[] _userRoles = userdata.Split(',');
string[] _authRoles = AuthRoles.Split(',');
bool isAuthorized = _authRoles.Any(_userRoles ??);
Run Code Online (Sandbox Code Playgroud)
/ M
我想比较给定类型的元素列表,以查看哪个列表 "更大".
new BuiltInComparer<IEnumerable<int>>().Compare(
new[] {3,2,3},
new[] {1,2,3})
Run Code Online (Sandbox Code Playgroud)
...将返回1
new BuiltInComparer<IEnumerable<int>>().Compare(
new[] {1,2,3},
new[] {1,2,4})
Run Code Online (Sandbox Code Playgroud)
......会返回-1等
有没有这样的内置比较器?
有没有办法设置日历扩展器,以便在文本框收到焦点时显示日历,何时单击带有"PopupButtonID"的元素?使用我当前的设置,它似乎是一个或另一个.
维基百科中有一个C++ XMLRPC实现列表:
我想知道人们最常使用这些库中的哪一个.你有这些图书馆的经验吗?
我的团队正在维护一个巨大的Client Server win32 Delphi应用程序.它是一个客户端/服务器应用程序(胖客户端),它使用DevArt(SDAC)组件连接到SQL Server.
业务逻辑经常"被困"在Component的事件处理程序中,无论如何,通过一定程度的重构,可以将业务逻辑移动到公共单元中(这项工作的很大一部分已经在重构期间完成了......维护遗留应用程序的人别写的非常令人沮丧,但这是一项非常普遍的工作).
现在有一个Web界面的请求,当然我有几个选项,在这个问题中我想关注VCL for web(intraweb)选项.
我们的想法是为客户端/服务器应用程序和Web应用程序使用公共代码(相同的pas文件).我听说很多人将遗留应用程序从delphi迁移到intraweb,但在这里我也试图保留Thick客户端.
这个想法是使用通用代码,可能会用一些编译器指令来编写特定的代码:
{$IFDEF CLIENTSERVER}
{here goes the thick client specific code}
{$ELSE}
{here goes the Intraweb specific code}
{$ENDIF}
Run Code Online (Sandbox Code Playgroud)
然后另一个问题是"迁移计划",假设我有300个功能,在第一个版本中,我将只在Web应用程序中提供50个.如何跟踪它?我在想(ab)使用Delphi接口来处理这个问题.例如,对于用户身份验证,我可以在过程中移动所有相关代码并声明如下界面:
type
IUserAuthentication= interface['{0D57624C-CDDE-458B-A36C-436AE465B477}']
procedure UserAuthentication;
end;
Run Code Online (Sandbox Code Playgroud)
通过这种方式,当我在两个应用程序(胖客户端和Intraweb)中实现IUserAuthentication接口时,我知道该功能已被"移植"到Web上.无论如何,我不知道这种方法是否有意义.我制作了一个原型来模拟整个过程.它适用于"Hello world"应用程序,但我想知道它是否对大型应用程序有意义,或者这种接口的想法只会适得其反并且会适得其反.
我的问题是:这种方法有意义吗?(接口的想法只是一个额外的想法,它不像上面描述的通用代码部分那么重要)它是一个可行的选择吗?
据我所知,这取决于很多类型的应用程序,无论如何我是CRM/Accounting域中的通用,并且单个安装上的并发用户数通常小于20,峰值为50.
额外评论(更新):我问这个问题是因为我没有n层应用程序,所以我认为Intraweb是拥有一个与胖客户端有共同代码的Web应用程序的唯一选择.在我的特定情况下,从Delphi代码开发Web服务是没有意义的,所以我可以选择使用ASP.NET编写Web界面(复制业务逻辑),但在这种情况下我无法利用公共代码.简单的方法.是的我可以使用dll,但我的代码不适合.
我有一个活动清单.我创建了一个每日重复的新项目(开始时间:2010年1月5日上午12:00和结束时间:2010年5月30日12:00 AM).我想删除具有开始时间的项目:5/12/2010 12:00 AM但我的应用程序抛出了异常.
我的代码如下:
DateTime eventDate = DateTime.Parse(list.Fields.GetFieldByInternalName("EventDate").GetFieldValueAsHtml(DateTime.Parse(this.DateTimeOfItem).ToUniversalTime()));
SPQuery pQuery = new SPQuery();
pQuery.ExpandRecurrence = true;
pQuery.CalendarDate = eventDate.AddDays(-1);
pQuery.Query = string.Format("<OrderBy><FieldRef Name=\"EventDate\"/></OrderBy><Where><And><DateRangesOverlap><FieldRef Name=\"EventDate\" /><FieldRef Name=\"EndDate\" /><FieldRef Name=\"RecurrenceID\" /><Value Type=\"DateTime\"><Week /></Value></DateRangesOverlap><Eq><FieldRef Name=\"ID\" /><Value Type=\"Counter\">{0}</Value></Eq></And></Where>", this.ID);
SPListItemCollection itemColl = list.GetItems(pQuery);
int index = 0;
while (index < itemColl.Count)
{
SPListItem item = itemColl[index];
if (DateTime.Parse(item["EventDate"].ToString()).CompareTo(eventDate) == 0)
{
web.AllowUnsafeUpdates = true;
item["UID"] = Guid.NewGuid().ToString();
item["EventType"] = 3;
item["RecurrenceID"] = eventDate;
item["MasterSeriesItemID"] = this.ID;
item["XMLTZone"] = null;
item["RecurrenceData"] = "Every 1 …Run Code Online (Sandbox Code Playgroud) 我有一个Linq-2-XML查询,如果我创建的谷歌站点地图的urlset元素填充了属性,但如果没有属性存在则可以正常工作.
无法查询:
<?xml version="1.0" encoding="utf-8"?>
<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>http://www.foo.com/index.htm</loc>
<lastmod>2010-05-11</lastmod>
<changefreq>monthly</changefreq>
<priority>1.0</priority>
</url>
<url>
<loc>http://www.foo.com/about.htm</loc>
<lastmod>2010-05-11</lastmod>
<changefreq>monthly</changefreq>
<priority>1.0</priority>
</url>
</urlset>
Run Code Online (Sandbox Code Playgroud)
可以查询:
<?xml version="1.0" encoding="utf-8"?>
<urlset>
<url>
<loc>http://www.foo.com/index.htm</loc>
<lastmod>2010-05-11</lastmod>
<changefreq>monthly</changefreq>
<priority>1.0</priority>
</url>
<url>
<loc>http://www.foo.com/about.htm</loc>
<lastmod>2010-05-11</lastmod>
<changefreq>monthly</changefreq>
<priority>1.0</priority>
</url>
</urlset>
Run Code Online (Sandbox Code Playgroud)
查询:
XDocument xDoc = XDocument.Load(@"C:\Test\sitemap.xml");
var sitemapUrls = (from l in xDoc.Descendants("url")
select l.Element("loc").Value);
foreach (var item in sitemapUrls)
{
Console.WriteLine(item.ToString());
}
Run Code Online (Sandbox Code Playgroud)
这是什么原因?
c# ×5
.net ×3
.net-3.5 ×1
2-tier ×1
ajax ×1
asp.net ×1
c ×1
c++ ×1
calendar ×1
comparator ×1
delphi ×1
devart ×1
intraweb ×1
java ×1
linq ×1
linq-to-xml ×1
mef ×1
recurrence ×1
sharepoint ×1
sql-server ×1
translation ×1
xml-rpc ×1