From c36bdcc5a4b6fcbf107d90d0f5eb4f741ec6c366 Mon Sep 17 00:00:00 2001 From: "Gun.io Whitespace Robot" Date: Fri, 16 Dec 2011 09:40:37 -0500 Subject: [PATCH] Remove whitespace [Gun.io WhitespaceBot] --- FSharpTutorials/Kombinaattorit.fs | 8 +++---- .../CSharpExamples/Properties/AssemblyInfo.cs | 10 ++++---- .../CSharpExamples/PresisDemo/Script.fsx | 2 +- .../CSharpExamples/PresisDemo/SlideDemo.fs | 4 ++-- .../UnitTests/Properties/AssemblyInfo.cs | 10 ++++---- LegacyCode.cs | 14 +++++------ NewCode.cs | 4 ++-- Stocks.fs | 12 +++++----- StocksApplication/README | 4 ++-- .../Properties/AssemblyInfo.cs | 10 ++++---- .../StocksApplicationSLTestPage.aspx | 4 ++-- .../StocksApplicationSLTestPage.html | 4 ++-- .../StocksService.svc.cs | 2 +- .../StocksService.svc.fs | 2 +- .../htmlclient/scripts.js | 8 +++---- .../StocksApplicationSL/App.xaml.cs | 6 ++--- .../StocksApplicationSL/MainPage.xaml | 2 +- .../Properties/AssemblyInfo.cs | 10 ++++---- .../ClientLogics.fs | 24 +++++++++---------- .../MainViewModel.fs | 22 ++++++++--------- .../StocksApplicationViewModel/Script.fsx | 2 +- .../StocksServiceLogics/Script.fsx | 2 +- .../StocksServiceLogics/Stocks.fs | 14 +++++------ UnitTest1.cs | 6 ++--- XmlProjectParsing/Program.fs | 10 ++++---- XmlProjectParsing/README | 8 +++---- 26 files changed, 102 insertions(+), 102 deletions(-) diff --git a/FSharpTutorials/Kombinaattorit.fs b/FSharpTutorials/Kombinaattorit.fs index 339587f..33db997 100644 --- a/FSharpTutorials/Kombinaattorit.fs +++ b/FSharpTutorials/Kombinaattorit.fs @@ -3,7 +3,7 @@ //Sulutus ei ole pakollista: let f(x,y) = x+y let g x y = x+y - + //Funktion tyyppi: let I x = x // x: a @@ -37,15 +37,15 @@ let moi = vakioMoi 123 //function composition let yhdistä1 f g x = g(f x) let yhdistä2 f g x = (f >> g) x - + //val yhdistä1 : ('a -> 'b) -> ('b -> 'c) -> 'a -> 'c //val yhdistä2 : ('a -> 'b) -> ('b -> 'c) -> 'a -> 'c let yhdistä3 f g = (f >> g) - + //käytännön esimerkki: //let käsittele = (tallenna >> validoi >> lähetä) - + diff --git a/FunctionalTutorial/CSharpExamples/CSharpExamples/Properties/AssemblyInfo.cs b/FunctionalTutorial/CSharpExamples/CSharpExamples/Properties/AssemblyInfo.cs index 98a774f..06784fe 100644 --- a/FunctionalTutorial/CSharpExamples/CSharpExamples/Properties/AssemblyInfo.cs +++ b/FunctionalTutorial/CSharpExamples/CSharpExamples/Properties/AssemblyInfo.cs @@ -2,7 +2,7 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following +// General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("CSharpExamples")] @@ -14,8 +14,8 @@ [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] @@ -25,11 +25,11 @@ // Version information for an assembly consists of the following four values: // // Major Version -// Minor Version +// Minor Version // Build Number // Revision // -// You can specify all the values or you can default the Build and Revision Numbers +// You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] diff --git a/FunctionalTutorial/CSharpExamples/PresisDemo/Script.fsx b/FunctionalTutorial/CSharpExamples/PresisDemo/Script.fsx index 14f391b..3c5d4c1 100644 --- a/FunctionalTutorial/CSharpExamples/PresisDemo/Script.fsx +++ b/FunctionalTutorial/CSharpExamples/PresisDemo/Script.fsx @@ -1,4 +1,4 @@ -// This file is a script that can be executed with the F# Interactive. +// This file is a script that can be executed with the F# Interactive. // It can be used to explore and test the library project. // Note that script files will not be part of the project build. diff --git a/FunctionalTutorial/CSharpExamples/PresisDemo/SlideDemo.fs b/FunctionalTutorial/CSharpExamples/PresisDemo/SlideDemo.fs index 9273d81..6cfef7d 100644 --- a/FunctionalTutorial/CSharpExamples/PresisDemo/SlideDemo.fs +++ b/FunctionalTutorial/CSharpExamples/PresisDemo/SlideDemo.fs @@ -2,7 +2,7 @@ open System; -type PresentationKeeper(name: string, employer : string) = +type PresentationKeeper(name: string, employer : string) = member lollis.name = name member fuulis.employer = employer override this.ToString() = name + ", " + employer @@ -18,7 +18,7 @@ let topics = [ (2, "Functional programming from c# perspective, Linq principles" let formatTopic topic keeper = String.Format ("{0} ({1})", topic, keeper.ToString()) -let pimpTheList = topics |> Seq.sortBy (fun (prio,_,_) -> prio) +let pimpTheList = topics |> Seq.sortBy (fun (prio,_,_) -> prio) |> Seq.map (fun (_, a, b) -> a,b) |> Seq.map (fun x -> (formatTopic (fst x) (snd x))) diff --git a/FunctionalTutorial/UnitTests/UnitTests/Properties/AssemblyInfo.cs b/FunctionalTutorial/UnitTests/UnitTests/Properties/AssemblyInfo.cs index bde569f..39ac6ca 100644 --- a/FunctionalTutorial/UnitTests/UnitTests/Properties/AssemblyInfo.cs +++ b/FunctionalTutorial/UnitTests/UnitTests/Properties/AssemblyInfo.cs @@ -2,7 +2,7 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following +// General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("UnitTests")] @@ -14,8 +14,8 @@ [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] @@ -25,11 +25,11 @@ // Version information for an assembly consists of the following four values: // // Major Version -// Minor Version +// Minor Version // Build Number // Revision // -// You can specify all the values or you can default the Build and Revision Numbers +// You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/LegacyCode.cs b/LegacyCode.cs index 5e4740a..ac66a2c 100644 --- a/LegacyCode.cs +++ b/LegacyCode.cs @@ -31,7 +31,7 @@ private List> Decompose(string data) { char mark = '\n'; char mark2 = ','; - + List> result = new List>(); foreach (string datedata in data.Split(mark)) @@ -51,21 +51,21 @@ private List> Decompose(string data) private List> ReFormat(List> list) { - + list.RemoveAt(0); - + List> result = new List>(); - + foreach(var sublist in list){ - + string date = sublist[0]; string rate = sublist[4]; DateTime parseDate = DateTime.ParseExact(date, "yyyy-mm-dd", CultureInfo.InvariantCulture); double parseRate = Double.Parse(rate, CultureInfo.GetCultureInfo("en-US")); - + result.Add(new Tuple(parseDate, parseRate)); - + } return result; diff --git a/NewCode.cs b/NewCode.cs index b03d421..fe33248 100644 --- a/NewCode.cs +++ b/NewCode.cs @@ -44,7 +44,7 @@ private IEnumerable> Decompose(string data) private IEnumerable> ReFormat(IEnumerable> list) { - Func parseDate = + Func parseDate = dt => DateTime.ParseExact(dt, "yyyy-mm-dd", CultureInfo.InvariantCulture); Func parseRate = rt => Double.Parse(rt, CultureInfo.GetCultureInfo("en-US")); @@ -52,7 +52,7 @@ private IEnumerable> ReFormat(IEnumerable (parseDate(sublist.ElementAt(0)), parseRate(sublist.ElementAt(4))); - + return result; } diff --git a/Stocks.fs b/Stocks.fs index f8e9275..649d88c 100644 --- a/Stocks.fs +++ b/Stocks.fs @@ -4,30 +4,30 @@ open System.Collections.Generic open System.Globalization open System.IO open System.Net -let public MakeUrl symbol (dfrom:DateTime) (dto:DateTime) = +let public MakeUrl symbol (dfrom:DateTime) (dto:DateTime) = new Uri("http://ichart.finance.yahoo.com/table.csv?s=" + symbol + "&e=" + dto.Day.ToString() + "&d=" + dto.Month.ToString() + "&f=" + dto.Year.ToString() + "&g=d&b=" + dfrom.Day.ToString() + "&a=" + dfrom.Month.ToString() + "&c=" + dfrom.Year.ToString() + "&ignore=.csv") -let internal fetch (url : Uri) = +let internal fetch (url : Uri) = let req = WebRequest.Create (url) :?> HttpWebRequest use stream = req.GetResponse().GetResponseStream() use reader = new StreamReader(stream) reader.ReadToEnd() -let internal decompose (response:string) = +let internal decompose (response:string) = let split (mark:char) (data:string) = data.Split(mark) |> Array.toList response |> split '\n' |> List.filter (fun f -> f<>"") - |> List.map (split ',') + |> List.map (split ',') let internal reformat (sel) = let parseDate d = DateTime.ParseExact(d, "yyyy-mm-dd", CultureInfo.InvariantCulture) let parseRate r = Double.Parse(r, CultureInfo.GetCultureInfo("en-US")) - let focus (l:string list) = + let focus (l:string list) = (parseDate l.[0], parseRate l.[4]) Seq.skip 1 sel |> Seq.map focus @@ -35,5 +35,5 @@ let public GetResult url = (fetch >> decompose >> reformat) url let DateMaxClose list = Seq.maxBy snd list -//let req = MakeUrl "MSFT" (new DateTime(2010, 2, 20)) (new DateTime(2010, 3, 25)) +//let req = MakeUrl "MSFT" (new DateTime(2010, 2, 20)) (new DateTime(2010, 3, 25)) //let AvgClose = (GetResult >> Seq.map snd >> Seq.average) req diff --git a/StocksApplication/README b/StocksApplication/README index 059202d..e0e579f 100644 --- a/StocksApplication/README +++ b/StocksApplication/README @@ -1,5 +1,5 @@ -This is technical demo to apply F-Sharp (F#) language in real world application. +This is technical demo to apply F-Sharp (F#) language in real world application. This application is close to real world enterprise application (with very optimal solutions, at least in 2011). The function of this application is to get Stock Quote Data and Historical Stock Prices from Yahoo Finance @@ -7,7 +7,7 @@ The function of this application is to get Stock Quote Data and Historical Stock Architecture visaul presentation: Architecture.pptx -There are two web user interfaces: +There are two web user interfaces: 1. Silverlight 5.0 MVVM made with Expression Blend - Silverlight F# 2.0 ViewModel and client logics dll 2. HTML 5.0 + jQuery 1.6.1 + Javascript (Ajax) diff --git a/StocksApplication/StocksApplication.Web/Properties/AssemblyInfo.cs b/StocksApplication/StocksApplication.Web/Properties/AssemblyInfo.cs index 36483a2..968997b 100644 --- a/StocksApplication/StocksApplication.Web/Properties/AssemblyInfo.cs +++ b/StocksApplication/StocksApplication.Web/Properties/AssemblyInfo.cs @@ -3,7 +3,7 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following +// General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("StocksApplication.Web")] @@ -15,8 +15,8 @@ [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] @@ -26,11 +26,11 @@ // Version information for an assembly consists of the following four values: // // Major Version -// Minor Version +// Minor Version // Build Number // Revision // -// You can specify all the values or you can default the Revision and Build Numbers +// You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/StocksApplication/StocksApplication.Web/StocksApplicationSLTestPage.aspx b/StocksApplication/StocksApplication.Web/StocksApplicationSLTestPage.aspx index b0cd5fe..a4ba415 100644 --- a/StocksApplication/StocksApplication.Web/StocksApplicationSLTestPage.aspx +++ b/StocksApplication/StocksApplication.Web/StocksApplicationSLTestPage.aspx @@ -25,7 +25,7 @@ if (sender != null && sender != 0) { appSource = sender.getHost().Source; } - + var errorType = args.ErrorType; var iErrorCode = args.ErrorCode; @@ -44,7 +44,7 @@ errMsg += "Line: " + args.lineNumber + " \n"; errMsg += "Position: " + args.charPosition + " \n"; } - else if (errorType == "RuntimeError") { + else if (errorType == "RuntimeError") { if (args.lineNumber != 0) { errMsg += "Line: " + args.lineNumber + " \n"; errMsg += "Position: " + args.charPosition + " \n"; diff --git a/StocksApplication/StocksApplication.Web/StocksApplicationSLTestPage.html b/StocksApplication/StocksApplication.Web/StocksApplicationSLTestPage.html index 5c9d525..5fa3190 100644 --- a/StocksApplication/StocksApplication.Web/StocksApplicationSLTestPage.html +++ b/StocksApplication/StocksApplication.Web/StocksApplicationSLTestPage.html @@ -24,7 +24,7 @@ if (sender != null && sender != 0) { appSource = sender.getHost().Source; } - + var errorType = args.ErrorType; var iErrorCode = args.ErrorCode; @@ -43,7 +43,7 @@ errMsg += "Line: " + args.lineNumber + " \n"; errMsg += "Position: " + args.charPosition + " \n"; } - else if (errorType == "RuntimeError") { + else if (errorType == "RuntimeError") { if (args.lineNumber != 0) { errMsg += "Line: " + args.lineNumber + " \n"; errMsg += "Position: " + args.charPosition + " \n"; diff --git a/StocksApplication/StocksApplication.Web/StocksService.svc.cs b/StocksApplication/StocksApplication.Web/StocksService.svc.cs index 0bacb6d..81fc059 100644 --- a/StocksApplication/StocksApplication.Web/StocksService.svc.cs +++ b/StocksApplication/StocksApplication.Web/StocksService.svc.cs @@ -25,7 +25,7 @@ public class StocksService var uri = Stocks.MakeUrl(quote, fromdate, todate); - try { + try { return Stocks.GetResult(uri); }catch(System.Net.WebException){ //throw; diff --git a/StocksApplication/StocksApplication.Web/StocksService.svc.fs b/StocksApplication/StocksApplication.Web/StocksService.svc.fs index ac75bb6..765e03d 100644 --- a/StocksApplication/StocksApplication.Web/StocksService.svc.fs +++ b/StocksApplication/StocksApplication.Web/StocksService.svc.fs @@ -36,6 +36,6 @@ type StocksService = //failwith("GetResult returned error"); let tmp = { Date = todate; Rate = -1.0 } List.toSeq [tmp] - + // example: http://localhost:49624/StocksService.svc/Symbol/MSFT/20100905/20100910 diff --git a/StocksApplication/StocksApplication.Web/htmlclient/scripts.js b/StocksApplication/StocksApplication.Web/htmlclient/scripts.js index 50a198f..8ba06b8 100644 --- a/StocksApplication/StocksApplication.Web/htmlclient/scripts.js +++ b/StocksApplication/StocksApplication.Web/htmlclient/scripts.js @@ -1,4 +1,4 @@ -$(document).ready(function() +$(document).ready(function() { //Debug: function concatObject(obj) { @@ -12,10 +12,10 @@ $(document).ready(function() Date.prototype.formatDDMMYYYYPlus = function(){ - return this.getDate() + "." + (this.getMonth()+1) + "." + this.getFullYear(); + return this.getDate() + "." + (this.getMonth()+1) + "." + this.getFullYear(); } Date.prototype.formatDDMMYYYYMinus = function(){ - return this.getDate() + "." + (this.getMonth()-1) + "." + this.getFullYear(); + return this.getDate() + "." + (this.getMonth()-1) + "." + this.getFullYear(); } function toyyyymmdd(str){ @@ -23,7 +23,7 @@ $(document).ready(function() function prezero(num){ if(num.length<2)return "0"+num; else return num; - } + } return nums[2] + prezero(nums[1]) + prezero(nums[0]); }; diff --git a/StocksApplication/StocksApplicationSL/App.xaml.cs b/StocksApplication/StocksApplicationSL/App.xaml.cs index 3d1b143..4033ece 100644 --- a/StocksApplication/StocksApplicationSL/App.xaml.cs +++ b/StocksApplication/StocksApplicationSL/App.xaml.cs @@ -35,14 +35,14 @@ private void Application_Exit(object sender, EventArgs e) private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e) { // If the app is running outside of the debugger then report the exception using - // the browser's exception mechanism. On IE this will display as a yellow alert + // the browser's exception mechanism. On IE this will display as a yellow alert // icon in the status bar and Firefox will display a script error. if (!System.Diagnostics.Debugger.IsAttached) { // NOTE: This will allow the application to continue running after an exception has been thrown - // but not handled. - // For production applications this error handling should be replaced with something that will + // but not handled. + // For production applications this error handling should be replaced with something that will // report the error to the website and stop the application. e.Handled = true; Deployment.Current.Dispatcher.BeginInvoke(delegate { ReportErrorToDOM(e); }); diff --git a/StocksApplication/StocksApplicationSL/MainPage.xaml b/StocksApplication/StocksApplicationSL/MainPage.xaml index 42f6133..f189147 100644 --- a/StocksApplication/StocksApplicationSL/MainPage.xaml +++ b/StocksApplication/StocksApplicationSL/MainPage.xaml @@ -54,7 +54,7 @@ - diff --git a/StocksApplication/StocksApplicationSL/Properties/AssemblyInfo.cs b/StocksApplication/StocksApplicationSL/Properties/AssemblyInfo.cs index 1f018bb..b2c99b7 100644 --- a/StocksApplication/StocksApplicationSL/Properties/AssemblyInfo.cs +++ b/StocksApplication/StocksApplicationSL/Properties/AssemblyInfo.cs @@ -3,7 +3,7 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following +// General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("StocksApplicationSL")] @@ -15,8 +15,8 @@ [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] @@ -26,11 +26,11 @@ // Version information for an assembly consists of the following four values: // // Major Version -// Minor Version +// Minor Version // Build Number // Revision // -// You can specify all the values or you can default the Revision and Build Numbers +// You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] diff --git a/StocksApplication/StocksApplicationViewModel/ClientLogics.fs b/StocksApplication/StocksApplicationViewModel/ClientLogics.fs index ed9b7f1..ceb19f4 100644 --- a/StocksApplication/StocksApplicationViewModel/ClientLogics.fs +++ b/StocksApplication/StocksApplicationViewModel/ClientLogics.fs @@ -7,9 +7,9 @@ open System.Net open System.IO [] -type StockQuote = { +type StockQuote = { [] mutable Date : DateTime - [] mutable Rate : double + [] mutable Rate : double } let byRate (s:StockQuote) = s.Rate @@ -17,30 +17,30 @@ let byRate (s:StockQuote) = s.Rate let DateMaxClose list = Seq.maxBy byRate list let AvgClose list = Seq.averageBy byRate list -/// Object from Json -let internal unjson<'t> (jsonString:string) : 't = - use ms = new System.IO.MemoryStream(System.Text.Encoding.BigEndianUnicode.GetBytes(jsonString)) - let obj = (new DataContractJsonSerializer(typeof<'t>)).ReadObject(ms) +/// Object from Json +let internal unjson<'t> (jsonString:string) : 't = + use ms = new System.IO.MemoryStream(System.Text.Encoding.BigEndianUnicode.GetBytes(jsonString)) + let obj = (new DataContractJsonSerializer(typeof<'t>)).ReadObject(ms) obj :?> 't - + let mutable callresult = Seq.empty -let internal fetchAsync (url : Uri) trigger = +let internal fetchAsync (url : Uri) trigger = let req = WebRequest.CreateHttp url req.CookieContainer <- new CookieContainer() let asynccall = async{ try - let! res = req.AsyncGetResponse() + let! res = req.AsyncGetResponse() use stream = res.GetResponseStream() use reader = new StreamReader(stream) - let! rdata = reader.AsyncReadToEnd() + let! rdata = reader.AsyncReadToEnd() callresult <- unjson> rdata trigger "" |> ignore with | _ as ex -> //for debug - failwith(ex.ToString()) + failwith(ex.ToString()) } asynccall |> Async.StartImmediate - + diff --git a/StocksApplication/StocksApplicationViewModel/MainViewModel.fs b/StocksApplication/StocksApplicationViewModel/MainViewModel.fs index 1d04e4a..094a231 100644 --- a/StocksApplication/StocksApplicationViewModel/MainViewModel.fs +++ b/StocksApplication/StocksApplicationViewModel/MainViewModel.fs @@ -13,37 +13,37 @@ type MainViewModel() = let mutable maxDate = DateTime.Now let mutable maxRate = 0.00 let mutable avgClose = 0.00 - + //Silverlight databinding interface let event = new Event<_,_>() interface INotifyPropertyChanged with [] member x.PropertyChanged = event.Publish - + member x.TriggerPropertyChanged(name)= event.Trigger(x, new PropertyChangedEventArgs(name)) - - member x.FromDate + + member x.FromDate with get() = fromDate - and set t = + and set t = fromDate <- t x.TriggerPropertyChanged "FromDate" - member x.ToDate + member x.ToDate with get() = toDate - and set t = + and set t = toDate <- t x.TriggerPropertyChanged "ToDate" member x.Symbol with get() = symbol - and set t = + and set t = symbol <- t x.TriggerPropertyChanged "Symbol" member x.Rates with get() = rates - and set t = + and set t = rates <- t let trigger p = x.TriggerPropertyChanged p maxRate <- ClientLogics.DateMaxClose(rates).Rate @@ -54,11 +54,11 @@ type MainViewModel() = member x.UpdateData (_:Object) (_:EventArgs) = //Service path let server = "http://localhost:49624/StocksService.svc" - let service = new Uri(server + "/Symbol/" + x.Symbol + "/" + + let service = new Uri(server + "/Symbol/" + x.Symbol + "/" + x.FromDate.ToString("yyyyMMdd") + "/" + x.ToDate.ToString("yyyyMMdd"), UriKind.Absolute) //UI-thread syncronization - let trigger _ = + let trigger _ = let update _ = x.Rates <- ClientLogics.callresult System.Windows.Deployment.Current.Dispatcher.BeginInvoke(new Action(update)) |> ignore ClientLogics.fetchAsync service trigger diff --git a/StocksApplication/StocksApplicationViewModel/Script.fsx b/StocksApplication/StocksApplicationViewModel/Script.fsx index e67d287..7270b16 100644 --- a/StocksApplication/StocksApplicationViewModel/Script.fsx +++ b/StocksApplication/StocksApplicationViewModel/Script.fsx @@ -1,4 +1,4 @@ -// This file is a script that can be executed with the F# Interactive. +// This file is a script that can be executed with the F# Interactive. // It can be used to explore and test the library project. // Note that script files will not be part of the project build. diff --git a/StocksApplication/StocksServiceLogics/Script.fsx b/StocksApplication/StocksServiceLogics/Script.fsx index d4e7e2a..55f5c49 100644 --- a/StocksApplication/StocksServiceLogics/Script.fsx +++ b/StocksApplication/StocksServiceLogics/Script.fsx @@ -1,4 +1,4 @@ -// This file is a script that can be executed with the F# Interactive. +// This file is a script that can be executed with the F# Interactive. // It can be used to explore and test the library project. // Note that script files will not be part of the project build. diff --git a/StocksApplication/StocksServiceLogics/Stocks.fs b/StocksApplication/StocksServiceLogics/Stocks.fs index 1b34fab..73cd99f 100644 --- a/StocksApplication/StocksServiceLogics/Stocks.fs +++ b/StocksApplication/StocksServiceLogics/Stocks.fs @@ -7,30 +7,30 @@ open System.Runtime.Serialization open System.Net [] -type StockQuote = { +type StockQuote = { [] mutable Date : DateTime - [] mutable Rate : double + [] mutable Rate : double } -let public MakeUrl symbol (dfrom:DateTime) (dto:DateTime) = +let public MakeUrl symbol (dfrom:DateTime) (dto:DateTime) = let monthfix (d:DateTime)= (d.Month-1).ToString() new Uri("http://ichart.finance.yahoo.com/table.csv?s=" + symbol + "&e=" + dto.Day.ToString() + "&d=" + monthfix(dto) + "&f=" + dto.Year.ToString() + "&g=d&b=" + dfrom.Day.ToString() + "&a=" + monthfix(dfrom) + "&c=" + dfrom.Year.ToString() + "&ignore=.csv") -let internal fetch (url : Uri) = +let internal fetch (url : Uri) = let req:HttpWebRequest = downcast WebRequest.Create (url) use stream = req.GetResponse().GetResponseStream() use reader = new StreamReader(stream) reader.ReadToEnd() -let internal decompose (response:string) = +let internal decompose (response:string) = let split (mark:char) (data:string) = data.Split(mark) |> Array.toList response |> split '\n' |> List.filter (fun f -> f<>"") - |> List.map (split ',') + |> List.map (split ',') let internal reformat (sel) = let parseDate d = DateTime.ParseExact(d, "yyyy-MM-dd", CultureInfo.InvariantCulture) @@ -39,4 +39,4 @@ let internal reformat (sel) = Seq.skip 1 sel |> Seq.map focus let public GetResult url = (fetch >> decompose >> reformat) url -//let req = MakeUrl "MSFT" (new DateTime(2010, 2, 20)) (new DateTime(2010, 3, 25)) +//let req = MakeUrl "MSFT" (new DateTime(2010, 2, 20)) (new DateTime(2010, 3, 25)) diff --git a/UnitTest1.cs b/UnitTest1.cs index 0954c69..1fec211 100644 --- a/UnitTest1.cs +++ b/UnitTest1.cs @@ -46,7 +46,7 @@ public void TestMethodNewCode() public void TestMethodLegacyCode() { var l = new LegacyCode(); - var url = LegacyCode.MakeUrl("MSFT", + var url = LegacyCode.MakeUrl("MSFT", new DateTime(2000,9,15), new DateTime(2000,10,18) ); @@ -54,8 +54,8 @@ public void TestMethodLegacyCode() var closerate = l.DateMaxClose(res); Assert.IsTrue(closerate.Item2 > 20); - + } - + } } diff --git a/XmlProjectParsing/Program.fs b/XmlProjectParsing/Program.fs index ceb8ee2..ab6d61c 100644 --- a/XmlProjectParsing/Program.fs +++ b/XmlProjectParsing/Program.fs @@ -6,14 +6,14 @@ open System.IO let getFiles = Directory.GetFiles(@"c:\projects", "*.csproj", SearchOption.AllDirectories) |> Array.toSeq - -let getProjectInfo (fname:string) = + +let getProjectInfo (fname:string) = let xn ns s = XName.Get(s,ns) let xml = XDocument.Load fname let xns = xn (xml.Root.Attribute(XName.Get("xmlns")).Value) let isSilverligthAssembly = xml.Descendants(xns "TargetFrameworkIdentifier") - |> (Seq.filter (fun p -> p.Value = "Silverlight") + |> (Seq.filter (fun p -> p.Value = "Silverlight") >> Seq.isEmpty >> not) let outputPaths = xml.Descendants(xns "OutputPath") |> Seq.map(fun x -> x.Value) @@ -23,8 +23,8 @@ let getProjectInfo (fname:string) = let showInfo projInfo = let name,sl,(outs:string seq) = projInfo match sl with - | false -> Console.WriteLine("Assembly " + name + " outputs:") - | true -> Console.WriteLine("SL-assembly " + name + " outputs:") + | false -> Console.WriteLine("Assembly " + name + " outputs:") + | true -> Console.WriteLine("SL-assembly " + name + " outputs:") outs |> Seq.iter(Console.WriteLine) let test = getFiles |> Seq.map (getProjectInfo) |> Seq.iter(showInfo) diff --git a/XmlProjectParsing/README b/XmlProjectParsing/README index 0b3b3de..1d10a15 100644 --- a/XmlProjectParsing/README +++ b/XmlProjectParsing/README @@ -12,16 +12,16 @@ The functionality is: 3. Show info to console Both Python and F# was pretty good: -When developing this (with Visual Studio 2010) they had Interactive (REPL-loop) -mode to run functions partially. C# doesn't so I have to go to separate -unit test files to test the program. So, this was much faster to make with +When developing this (with Visual Studio 2010) they had Interactive (REPL-loop) +mode to run functions partially. C# doesn't so I have to go to separate +unit test files to test the program. So, this was much faster to make with F# and Python than C#. However, I think that Python did have minor problems: - Python didn't have monadic bind (F# ">>") out-of-the-box. - Also I think Python syntax with list operations is somehow weird and un-natural: -I described the steps (1, 2, 3) but in Python I have to code them as (3, 2, 1). +I described the steps (1, 2, 3) but in Python I have to code them as (3, 2, 1). C#: GetFiles().Select(GetProjectInfo).ToList().ForEach(ShowInfo);