-
property and item in msbuild
In msbuild, there are two way to save variable information, they are property and item. Here is an example how to define properties and items.
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>pdbonly</DebugType> <Optimize>true</Optimize> <OutputPath>bin\Release\</OutputPath> <DefineConstants>TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet> </PropertyGroup> <!--reference items--> <ItemGroup> <Reference Include="System" /> <Reference Include="System.Core"> <RequiredTargetFramework>3.5</RequiredTargetFramework> </Reference> <Reference Include="System.Xml.Linq"> <RequiredTargetFramework>3.5</RequiredTargetFramework> </Reference> <Reference Include="System.Data.DataSetExtensions"> <RequiredTargetFramework>3.5</RequiredTargetFramework> </Reference> <Reference Include="System.Data" /> <Reference Include="System.Xml" /> </ItemGroup>
-
Application Type in silverlgiht
When you create an silverlight app, by default a App.xaml file is created, and by default the class behind is the class or EntryPointType. This information is saved in the AppManifest.xml, so that when the xap file is downloaded, silverlight runtime will create an instance of that class. This class should derive from Application class. After the the application class is instantiated by the runtime, the most important job need to do in the constructor is to set the RootVisual property. You can do in code, or you can do it by loading a a xaml file. Visual studio use the second approach. And here is the pattern. The xaml file automatically create some code behind, which run the following code.
public partial class App1 : Application { private bool _contentLoaded;
-
XAML is faster than code in silverlight
Parsing XAML is faster than intantiating objects from code, because XAML parser does not create the API objects you use to interact with elements, but instead only create an internal representation. After you start interacting with elements from code, silverlight creates api objects that will slow down your application.
-
an another way to do setInterval
In window object, there is a function setInterval which allows your to run a task repeatedly at an interval.
setInterval(doSomething; 100);
However, if the method last longer than the preset interval, it is not so efficient. We can use the follow function to make it more predictable.
loopTask(doSomething, 100);
-
notes of regular expression in javascript
The simplest way to tell whether a regular expression is find in source string is to use the "test" method.
var reg = /a/; var found = reg.test("abc"); console.log(found);
In lots of occasion, we use regular expression to test user's input, for example to test if a input is in date format. You need the "^" and "$" character to wrap the regular expression pattern.
To do a simple search in string, we can use string.match(regex) syntax. This is useful when we do want to whether a match or how many matchs can be found. If you just care about a first match, you will use non global regular expression. In this case, f a match is found, an array object will be return, the first element of the array is the entire match, the 1 to (length -1)th members of the array is the sub matches which are generated by the round bracket "()". The array or match object also has property "index" and "input". When a regular expression search is perform, the RegExp object also get updated.
var src = "Please send mail to george@contoso.com and someone@example.com. Thanks!";