我正在使用ASP.NET成员资格提供程序的包装器,以便我可以使用更多松散耦合的库.我想使用StructureMap来提供真正的IoC,但是我在使用User-to-Profile工厂对象进行配置时遇到了麻烦,我正在使用它来在用户的上下文中实例化配置文件.这是相关的细节,首先是库中的接口和包装器:
// From ASP.Net MVC Membership Starter Kit
public interface IProfileService
{
object this[string propertyName] { get; set; }
void SetPropertyValue(string propertyName, object propertyValue);
object GetPropertyValue(string propertyName);
void Save();
}
public class AspNetProfileBaseWrapper : IProfileService
{
public AspNetProfileBaseWrapper(string email) {}
// ...
}
Run Code Online (Sandbox Code Playgroud)
接下来,用于与配置文件数据中的特定属性进行交互的存储库:
class UserDataRepository : IUserDataRepository
{
Func<MembershipUser, IProfileService> _profileServiceFactory;
// takes the factory as a ctor param
// to configure it to the context of the given user
public UserDataRepository(
Func<MembershipUser, IProfileService> profileServiceFactory) …
Run Code Online (Sandbox Code Playgroud) 我正在使用Microsoft的说明将MVC3应用程序升级到MVC4 .一切都进行得相当顺利 - 除了我的几个日期模型属性现在渲染方式不同.例如,其中一个属性在viewmodel中定义如下:
[Required(ErrorMessage = "Required")]
[DataType(DataType.Date)]
[RegularExpression(@"([1-9]|0[1-9]|1[012])...",
ErrorMessage = "Format is mm/dd/yyyy")]
[FormatHint("mm/dd/yyyy")]
[InputSize("small")]
public string Date { get; set; }
Run Code Online (Sandbox Code Playgroud)
在升级到MVC4之前,这将通过调用来呈现,@Html.EditorFor(m => m.Date)
这将使用自定义的EditorTemplate - String.cshtml
模板(因为它是一个字符串!).我有一些格式化html的自定义数据注释,因此它在客户端使用了字段布局,jQueryUI和twitter Bootstrap.验证是通过jquery验证完成的,不引人注目.无论如何,这是它以前呈现的方式:
现在我正在使用MVC4,String.cshtml
不再为此属性调用编辑器模板.它呈现如下(在Chrome中使用HTML5编辑器的东西,我假设):
该input
元素看起来几乎相同 - 所有的jQuery验证位都在那里 - 唯一的区别似乎是type
属性现在type="date"
,之前的位置type="text"
.
我想继续使用String.cshtml
EditorTemplate来获取此数据类型.我想可能有一个数据注释,我可以放在ViewModel属性上为其提供TemplateHint @Html.EditorFor(...)
.如果不是这样,我想知道我可以编写的自定义EditorTemplate来劫持MVC4的格式(我已经尝试过了DateTime.cshtml
- 它也没有被调用).如果不是其中任何一个,那么我愿意接受如何获得我以前的属性渲染的建议.
当使用char*str作为第一个参数(不是分隔符字符串)时,strtok将无法正常工作.
它是否与在该表示法中分配字符串的区域有关?(据我所知,这是一个只读区域).
提前致谢
例:
//char* str ="- This, a sample string."; // <---doesn't work
char str[] ="- This, a sample string."; // <---works
char delims[] = " ";
char * pch;
printf ("Splitting string \"%s\" into tokens:\n",str);
pch = strtok (str,delims);
while (pch != NULL)
{
printf ("%s\n",pch);
pch = strtok (NULL, delims);
}
return 0;
Run Code Online (Sandbox Code Playgroud) 我需要实现一个具有密集数学计算的算法.java中是否已经支持此了?或者是否有任何第三方供应商提供此支持?
谢谢极客!!!
我有一个正在调用其他几个脚本的主脚本,我需要将其他脚本中的变量加载到主脚本中,以便可以将它们转储到html文件中。我尝试点调用我正在调用的脚本,但是那没有用,或者我做错了。任何帮助,将不胜感激。
脚本的示例部分:
.\get-cluster.ps1
$MyReport += Get-CustomHeader "Clusters not in compliance : $($CapacityInfo.count) ($MyReport += Get-HTMLTable $capacityinfo
$MyReport += Get-CustomHeaderClose
Run Code Online (Sandbox Code Playgroud)
变量$capacityinfo
存在于get-cluster.ps1
脚本中
while (true)
{
//read in the file
StreamReader convert = new StreamReader("../../convert.txt");
//define variables
string line = convert.ReadLine();
double conversion;
int numberIn;
double conversionFactor;
//ask for the conversion information
Console.WriteLine("Enter the conversion in the form (Amount, Convert from, Convert to)");
String inputMeasurement = Console.ReadLine();
string[] inputMeasurementArray = inputMeasurement.Split(',');
//loop through the lines looking for a match
while (line != null)
{
string[] fileMeasurementArray = line.Split(',');
if (fileMeasurementArray[0] == inputMeasurementArray[1])
{
if (fileMeasurementArray[1] == inputMeasurementArray[2])
{
Console.WriteLine("The conversion factor for {0} …
Run Code Online (Sandbox Code Playgroud) 我写了下面的代码:
1. MyClass[] origArr=new MyClass[3];
2. MyClass[] arr1;
3. // filled the array with objects and did some work on it .
4. dgv_1.DataSource=origArr;
5.
6. // Here is the problem :
7. arr1=origArr;
8. // do some work on arr1 ...
9. dgv_2.DataSource=arr1;
Run Code Online (Sandbox Code Playgroud)
出于某种原因,当'arr1'中的数据发生变化时,'origArr'中的数据发生了变化......
我认为这可能是因为'origArr'和'arr1'是指向同一个对象的指针,所以我将第7行更改为:
7. origArr.CopyTo(arr1,0);
Run Code Online (Sandbox Code Playgroud)
但它不起作用......我该怎么做才能使指针指向不同的对象?
以下if语句.
emptyFields = false;
$(".ClassNanme").each(function() {
if(($.trim($(this).val()) == "") && ($(this).css('display') != 'none' ) {
emptyFields = true;
return false; // break out of the each-loop
}
});
Run Code Online (Sandbox Code Playgroud)
但是不起作用,我不知道如何使用jquery检查css属性显示是否设置为none.
当其中一个对象为空或其css属性显示未设置为none时,应选择此if语句.
检查值是否为空是有效的,我所坚持的是检查对象是否隐藏(或显示:无).
谢谢.
塞萨尔.
c# ×4
.net ×1
asp.net-mvc ×1
c ×1
class ×1
css ×1
java ×1
java-api ×1
jquery ×1
powershell ×1
string ×1
strtok ×1
structuremap ×1
winforms ×1
wpf ×1