我可以格式化Get-Date
cmdlet没有这样的问题:
$date = Get-Date -format "yyyyMMdd"
Run Code Online (Sandbox Code Playgroud)
但是一旦我在变量中得到了一个日期,我该如何格式化呢?以下声明
$dateStr = $date -format "yyyMMdd"
Run Code Online (Sandbox Code Playgroud)
返回此错误:
"你必须在'-f'运算符的右侧提供一个值表达式"
我正在尝试将文件复制到新位置,维护目录结构.
$source = "c:\some\path\to\a\file.txt"
destination = "c:\a\more\different\path\to\the\file.txt"
Copy-Item $source $destination -Force -Recurse
Run Code Online (Sandbox Code Playgroud)
但我得到一个DirectoryNotFoundException
:
Copy-Item : Could not find a part of the path 'c:\a\more\different\path\to\the\file.txt'
Run Code Online (Sandbox Code Playgroud) 我正在使用xcode和objc创建一个简单的应用程序,我需要从文件加载NSDictionary,但我无法使用NSBundle获取该文件的路径:
NSString *l = [[NSBundle mainBundle] pathForResource:@"LoginStatuses" ofType:@"plist"];
NSLog(@"%@", l);
Run Code Online (Sandbox Code Playgroud)
当我运行此代码时,我得到了这个:
2010-10-16 10:42:42.42样本[5226:a0f](null)
我不知道为什么.
我创建了一个名为Resources的组,在那里我添加了LogingStatuses.plist:
我正在使用Newtonsoft JSON序列化程序,它适用于大多数对象.
不幸的是,JsonSerializationException
当我尝试序列化大型对象时,我得到了一个,其中一个成员抛出一个NullReferenceException
.
反正有没有忽略违规成员并序列化对象的其余部分?
我想也许在JsonSerializerSettings
?
这是我想要做的简化版本:
private class TestExceptionThrowingClass
{
public string Name { get { return "The Name"; } }
public string Address { get { throw new NullReferenceException(); } }
public int Age { get { return 30; } }
}
[Test]
public void CanSerializeAClassWithAnExceptionThrowingMember()
{
// Arrange
var toSerialize = new TestExceptionThrowingClass();
// Act
var serializerSettings = new Newtonsoft.Json.JsonSerializerSettings();
serializerSettings.MaxDepth = 5;
serializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;
serializerSettings.MissingMemberHandling = Newtonsoft.Json.MissingMemberHandling.Ignore;
serializerSettings.NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore; …
Run Code Online (Sandbox Code Playgroud) 我已下载xcode5_GM_seed并安装它,但我找不到组件中的iOS7模拟器.
我在哪里可以找到iOS 7模拟器?
我正在使用linq过滤选择的MessageItems.我编写的方法接受一堆可能为null的参数.如果它们为null,则应忽略该文件的条件.如果它不为null,则使用它来过滤结果.
这是我的理解,当做一个|| operation是C#,如果第一个表达式为true,则不应计算第二个表达式.
例如
if(ExpressionOne() || ExpressionTwo())
{
// only ExpressionOne was evaluated because it was true
}
Run Code Online (Sandbox Code Playgroud)
现在,在linq,我正在尝试这个:
var messages = (from msg in dc.MessageItems
where String.IsNullOrEmpty(fromname) || (!String.IsNullOrEmpty(fromname) && msg.FromName.ToLower().Contains(fromname.ToLower()))
select msg);
Run Code Online (Sandbox Code Playgroud)
我原本以为这会是合理的,因为它String.IsNullOrEmpty(fromname)
等于是真的和||的第二部分 不会跑.
然而它确实运行了,第二部分
msg.FromName.ToLower().Contains(fromname.ToLower()))
Run Code Online (Sandbox Code Playgroud)
抛出一个空引用异常(因为fromname
为null)!! - 我得到一个经典的"对象引用没有设置为对象的实例"异常.
有帮助吗?
编辑:这是一个用C#编写的VS2008应用程序.
所以我的解决方案中有一个名为的文件夹
_lib/
Run Code Online (Sandbox Code Playgroud)
这是我保存我的DLL的地方,以便当我引用它们时,它们会内置到bin/
文件夹中.
现在我的解决方案中有一个新项目.它是一个DLL,但不应该是引用(它是第三方应用程序所必需的).因此,在构建时,我希望将其复制_lib/
到bin/
项目中但未在项目中引用.
我已经_lib/
在我的应用程序中包含了该文件夹,并且我选择的DLL的属性总是复制.这个ALMOST工作,它用文件夹复制文件,所以我的结构如下:
/bin/_lib/thedll.dll
Run Code Online (Sandbox Code Playgroud)
代替
/bin/thedll.dll
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
我有一个看起来像的视图模型.
public class StoreItemViewModel
{
public Guid ItemId { get; set; }
public List<Guid> StoreIds { get; set; }
[Required]
public string Description { get; set; }
//[Required]
//[DataMember(IsRequired = true)]
public int ItemTypeId { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我有一个使用RestSharp的小帮手.
public static IRestResponse Create<T>(object objectToUpdate, string apiEndPoint) where T : new()
{
var client = new RestClient(CreateBaseUrl(null))
{
Authenticator = new HttpBasicAuthenticator("user", "Password1")
};
var request = new RestRequest(apiEndPoint, Method.POST);
//request.JsonSerializer = new JsonSerializer();
// {RequestFormat = DataFormat.Json};
request.AddObject(objectToUpdate);
// …
Run Code Online (Sandbox Code Playgroud) 任何人都知道从SQL Server中的字段中删除标点符号的好方法吗?
我在想
UPDATE tblMyTable SET FieldName = REPLACE(REPLACE(REPLACE(FieldName,',',''),'.',''),'''' ,'')
Run Code Online (Sandbox Code Playgroud)
但是当我打算删除大量不同的字符时,似乎有点单调乏味,例如:!@#$%^&*()<>:"
提前致谢
我想将我的.Net XML文档注释(基于代码标记的文档,由编译器使用/ doc开关自动生成)导入Atlassian Confluence.
我已经使用Doxygen来生成一些看起来很棒的HTML,但我很想拥有一些我可以直接进入Confluence的东西.
有任何想法吗?
.net documentation comments documentation-generation confluence
c# ×4
.net ×2
json.net ×2
powershell ×2
asp.net-mvc ×1
comments ×1
confluence ×1
datetime ×1
ios7 ×1
json ×1
linq ×1
linq-to-sql ×1
nsbundle ×1
null ×1
objective-c ×1
punctuation ×1
replace ×1
restsharp ×1
simulator ×1
sql ×1
sql-server ×1
t-sql ×1
xcode ×1
xcode5 ×1