We can configure WCF services with Multiple EndPoints. To return Json, the following steps are needed: (1) Change OperationContract using WebGet, Json and UriTemplate --- note that input can only be string [WebGet(ResponseFormat=WebMessageFormat.Json, UriTemplate="Data/{value}")] [OperationContract] ListGetData(string value); (2) App.Config ==> Edit WCF config ==> Add webHttpBinding with Binding Behavior wedHttp <services> <service name="WcfServiceLibrary1.Service1"> ... <endpoint address="jsonTest" behaviorConfiguration="NewBehavior0" binding="webHttpBinding" bindingConfiguration="" contract="WcfServiceLibrary1.IService1" /> ... <behaviors> <endpointBehaviors> <behavior name="NewBehavior0"> <webHttp /> </behavior> </endpointBehaviors> (3) Publish to AppFabric Site/App considering the following details: (3.1) Make sure WebDeploy (MSDeploy,VS2010SP1) update installed so that AppFabric has deploy menu and VS2010 WCF App has Package/publish tab (3.2) Note that We are using WCF Lib not app so publish to AppFabric rather than using package. (3.3) Edit binding to default WebSite to have net.tcp binding infor 808:* and net.pipe etc and create an App "mb" with "http,net.tcp,net.pipe" as enabled protocols. (3.4) Browse the app to get base address like http://localhost/mb/WcfServiceLibrary1.Service1.svc test http://[baseAddress]/jsonTest/Data/0 should get to Json Data (save to disk) (3.5) make sure net.tcp port and address match 808:* and uses App "mb" and use a WPF client to add Service Reference for testing. and we should see client config has all protocols.
Sunday, June 3, 2012
AppFabric 1.1 host WCF multi-binding and Json Data
Saturday, June 2, 2012
Style Trigger and DataTrigger
To style a simple Lisbox, we can trigger change of property by either looking at other property or data loaded <Style TargetType="{x:Type ListBoxItem}" > <Style.Triggers> <Trigger Property="IsSelected" Value="true"> <Setter Property="Foreground" Value="Red" /> </Trigger> <DataTrigger Binding="{Binding Path=Name}" Value="User 3"> <Setter Property="BorderBrush" Value="Black" /> <Setter Property="BorderThickness" Value="1" /> ... list.Add(new User(){ Name="User 1"}); list.Add(new User() { Name = "User 2" }); listBox1.ItemsSource = list;
Thursday, May 31, 2012
Monday, May 28, 2012
WPF 3 D Coordinate System with A Camera: Example
Then we can map 2D Texture to 3D using MeshGeometry3D <Viewport3D> <Viewport3D.Camera> <PerspectiveCamera Position="-20,46,0" UpDirection="0,0,1" LookDirection="4,-10,0" NearPlaneDistance="0"/> ...... <GeometryModel3D.Geometry> <MeshGeometry3D Positions="-10,-10,-10 10,-10,-10 10,10,-10 -10,10,-10 -10,-10,10 -10,10,10" TriangleIndices="0 2 3 0 1 2 0 4 3 4 5 3" TextureCoordinates="0,0 0,1 1,1 1,0" />
Saturday, May 26, 2012
Future Pricing and MR factor model
MATLAB code [hist_date, hist_high, hist_low, hist_open, hist_close, hist_vol] =get_hist_stock_data('SPX','2006'); Data=hist_close; [n,nn] = size(Data); R_dollar=hist_close(2:end)-hist_close(1:end-1); R_pct=R_dollar./hist_close(1:end-1); [b_int,nn,nn,nn,stats] = regress(R_pct,[ones(n-1,1),Data(1:(n-1),1)]); intercept = b_int(1); slope = b_int(2); if (slope > 0) error('Cannot use geometric mean reversion: pct chg=k*(mu-s)+sigma*dW requiring k>0)'); end sigma = sqrt(stats(4)); k = -slope; mu = -intercept/slope; days=20; dT = 1; St=zeros(days,1); St(1)=hist_close(end); for i=1:1:days St(i+1)=St(i)+(k*(mu-St(i))+sigma*normrnd(0,1))*St(i); end % future price dS/S = dLn(F(t))/dt *dt + signma*dW or % Ft-1=Ft*exp(-dS/S+signma*dW) Ft=zeros(days,1); Ft(end)=St(end); for i=days:-1:2 chg =(St(i+1)-St(i))/St(i); Ft(i-1)=Ft(i)*exp(-chg+sigma*normrnd(0,1)); end f1=figure(1); set(f1,'name','%-Return Mean Reversion Factor Model'); p=plot(0:days,St); set(p,'color','red'); hold on; p=plot(1:days,Ft); hold off;

Friday, May 25, 2012
Subscribe to:
Posts (Atom)