Sends for the fellow dear visitors:
Welcome to DongPad!
在Silverlight4中,默认应用程序存储配额是1MB=1024KB=1048576Bytes,可以在SL程序的右键菜单点击查看,如下图1:
如果要申请配额,可以在构造里检查存储配额然后执行一下代码,但要考虑到用户可能阻止该请求:
using (var store = IsolatedStorageFile.GetUserStoreForApplication()) { Int64 IsoQuota = store.Quota; //单位为bytes Int64 requestIsoQuota = 1000; if (store.IncreaseQuotaTo(IsoQuota +requestIsoQuota )) //增加到指定大小 { //…… } }
执行上述代码将自动提示用户"是否要增加可用存储",结果如下图2:
为了保持默认的1MB默认存储,我们选择“否”以便于后面的测试,如果选择了“是”也没关系,我们可以在应用程序存储选项页中选择该程序删除网站对应的存储使其重新初始化到1MB。在上述代码中,我们请求增加的配额为1000bytes,但是提示请求的大小依然是默认的配额1MB,这里Silverlight是如何显示申请存储配额时请求的大小的呢?
经测试发现,Silverlight对请求的大小采用了小数点保留一位四舍五入的策略,上图的请求的大小实际上就是上述代码中(IsoQuota +requestIsoQuota)除以(1MB*1024*1024)四舍五入保留一位小数的结果。在默认配额情况下,如果请求的配额requestIsoQuota 小于0.05MB=52428.8bytes=52429时,提示请求到的存储大小的小数位将被忽略,但这并不影响实际的存储配额,提示请求的大小依然是1.0MB,如果requestIsoQuota大于或等于0.05MB=52428.8bytes(requestIsoQuota类型为Int64,即requestIsoQuota最小为52429时提示请求大小为1.1MB)将提示请求大小为1.1MB。这里我们可以来验证一下,将requestIsoQuota的值更改为52428,提示请求的大小为1.0M,选择“是”对其进行增加可用存储,然后将requestIsoQuota的值更改为1,这时候的提示是请求的大小为1.1M,这也就从侧面反映了显示出来的请求的大小并不影响实际的存储配额,虽然他们可能是不一致的。
Tags: DongPad
DataContext is a general (dependency) property of all descendants of FrameworkElement. Is is inherited through the logical tree from parent to children and can be used as an implicit source for DataBinding. It does not do anything by itself, you must basically databind to it.
查看全部...
F#有强大的类型推理(type inference),所以在F#中不需要我们显示指定参数类型。如 let add p1 p2 = p1+p2;; 这样我们就定义了接收两个int类型参数返回int类型的一个add函数:val add : int -> int –> int,这个推理过程是由f#编译器完成的。
因为F#不使用隐式类型转换,所以如果我们对add传入float类型参数,如:add 100.0 200.0,编译将产生如下错误:
stdin(46,5): error FS0001: This expression has type float but is here used with type int
因此这里需要显示指定参数的类型,方式如:let add2 (p1:float) p2 = p1+p2;; 这样编译器推理出add2函数接受两个float类型参数并返回float类型:val add2 : float -> float -> float。虽然在这里没有显示指定add2的p2参数类型,但是因为显示指定了F#的第一个参数为float类型,p2自然也就被推理为float类型了。因此如果有不同类型的参数,应该为这些参数都显示指定类型,add3接受一个float和一个int类型参数,并返回两个参数的连接形式string:let add3 (p1:float) (p2:int)=(string p1)+(string p2),编译器编译结果为:val add3 : float -> int -> string,在这里要注意的就是(string p1),它的意思是对p1进行强制转换。
积硅步以至千里。
Tags: DongPad F#
打印函数主要有三个:printf、printfn和sprintf。
printf将参数打印到控制台窗口中。printfn将参数打印输出并且换行。
打印函数可以使用下面这些格式指示符:
%O格式指示符会将对象进行装箱操作,并调用Object.ToString函数。%A的运作方式相同,但是在调用Object.ToString之前会检查[]属性指定的任何特殊打印选项。 PS: 紧接着的是来自官方的解释,从侧面说明了 printfn "%O" false (结果为False)与 printfn "%A" false(结果为false)的区别 %O 设置通过将对象装箱并使用其 ToString 方法来打印的任何值的格式。 %A 设置使用默认布局设置打印的任何值的格式。
%O格式指示符会将对象进行装箱操作,并调用Object.ToString函数。%A的运作方式相同,但是在调用Object.ToString之前会检查[]属性指定的任何特殊打印选项。
PS: 紧接着的是来自官方的解释,从侧面说明了 printfn "%O" false (结果为False)与 printfn "%A" false(结果为false)的区别
%O 设置通过将对象装箱并使用其 ToString 方法来打印的任何值的格式。
%A 设置使用默认布局设置打印的任何值的格式。
sprintf用于输出的目标为一个字符串的情况。
节选自:CC682,更多格式请参考官方Core.Printf的%[flags][width][.precision][type]详解
Tags: DongPad F# 占位符
1.Foundations of F#
If youre already familiar with FP, youll find F# the language youve always dreamed of. And all .NET programmers will find F# an exciting real-world alternative to C# and Visual Basic. This book is likely to have many imitators, but few true competitors. Written by F# evangelist Rob Pickering, and tech reviewed by F#s main designer, Don Syme, this is an elegant, comprehensive introduction to all aspects of the language and an incisive guide to using F# for real-world professional development. F# is the future of programming (not just on .NET), and the future is now.
这本书09年夏就开始在看了,后来一度荒废,继而直到上周参加盛大创新院赞助首届.NET技术交流会听了老赵的《F#语言对异步程序设计的支持》,才又激起我对F#探索的兴趣来。也希望籍此机会,好好的熟悉一下F#。
本文主要介绍了VS2010特性之Sequence Diagram Reverse Engineering对LINQ和Lambdas的扩展
The Sequence Diagram Reverse Engineering feature available in Visual Studio 2010 allows you to create a UML 2.1 “like” diagram that represents your source code. I say “like” in the previous sentence because we use all the notation prescribed by the UML standard, but there are a few instances where we add some notation that is not found in the standard. Support for LINQ and Lambda expressions are examples of where we have extended the Combined Fragment notation to include what we have dubbed a “Deferred Call”.
Here’s a simple console application that I’ll use to show what I mean.
@CLR via C#2.0 P32 1.工作目录
2.编译器本身目录(PS:根据全局CSC.rsp文件的配置)
3./lib开关指定的目录
4.Lib环境变量指向的工作目录
现在,我们来做了一下尝试,在非编译器目录创建如下两个测试类,并对C1编译:
//C1.cs @cmd prompt: csc /t:library C1.cs
public class C1 { public string Name{get;set;} public int Age{get;set;} }
//Program.cs @cmd prompt: csc /r:C1.dll Program.cs
using System; public class Program { static void Main() { C1 c1 = new C1{Name="Jack"}; Console.WriteLine(string.Format("c1's name is {0}",c1.Name)); Console.ReadKey(); } }
1.编译Program时,由于我们指定的非绝对路径,所以搜索到Program的当前工作目录即结束,我们亦可尝试将C1.Dll剪切到其他工作目录,并指定完整路径进行编译。
2.将C1.dll剪切到csc工作目录C:\Windows\Microsoft.NET\Framework\v3.5(视具体环境而定),编译不通过,what r u doing?
from Tyl2008
Powered By DongPad CopyRight 2008-2009, xhtml | css
Processed in 0.046 seconds(s) , 沪ICP备08111450号