-
DefaultTargets and InitialTargets
DefaultTargets attribute is a list of targets to execute if no target is specified. The InitialTargets attribute is a list of tarets to be executed before any other targets. In the following example, the i1, i2, t1, t2 will be run in order
<?xml version="1.0" encoding="utf-8" ?> <Project ToolsVersion="3.5" DefaultTargets="t1;t2" InitialTargets="i1;i2" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Target Name="t1"> <Message Text="t1 is running" /> </Target> <Target Name="t2"> <Message Text="t2 is running" /> </Target> <Target Name="i1"> <Message Text="i1 is running" /> </Target> <Target Name="i2"> <Message Text="i2 is running" /> </Target> </Project> -
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);