@@ -628,27 +628,6 @@ module Eventually =
628628 let force e = Option.get ( forceWhile ( fun () -> true ) e)
629629
630630 /// Keep running the computation bit by bit until a time limit is reached.
631- #if FX_ NO_ SYSTEM_ DIAGNOSTICS_ STOPWATCH
632- // There is no Stopwatch on Silverlight, so use DateTime.Now. I'm not sure of the pros and cons of this.
633- // An alternative is just to always force the computation all the way to the end.
634- //let repeatedlyProgressUntilDoneOrTimeShareOver _timeShareInMilliseconds runner e =
635- // Done (runner (fun () -> force e))
636- let repeatedlyProgressUntilDoneOrTimeShareOver ( timeShareInMilliseconds : int64 ) runner e =
637- let rec runTimeShare e =
638- runner ( fun () ->
639- let sw = System.DateTime.Now
640- let rec loop e =
641- match e with
642- | Done _ -> e
643- | NotYetDone ( work) ->
644- let ts = System.DateTime.Now - sw
645- if ts.TotalMilliseconds > float timeShareInMilliseconds then
646- NotYetDone( fun () -> runTimeShare e)
647- else
648- loop( work())
649- loop e)
650- runTimeShare e
651- #else
652631 /// The runner gets called each time the computation is restarted
653632 let repeatedlyProgressUntilDoneOrTimeShareOver timeShareInMilliseconds runner e =
654633 let sw = new System.Diagnostics.Stopwatch()
@@ -667,7 +646,6 @@ module Eventually =
667646 loop( work())
668647 loop( e))
669648 runTimeShare e
670- #endif
671649
672650 let rec bind k e =
673651 match e with
@@ -990,81 +968,6 @@ module Shim =
990968 abstract AssemblyLoadFrom: fileName : string -> System.Reflection.Assembly
991969 abstract AssemblyLoad: assemblyName : System.Reflection.AssemblyName -> System.Reflection.Assembly
992970
993- #if FX_ FILE_ SYSTEM_ USES_ ISOLATED_ STORAGE
994- open System.IO .IsolatedStorage
995- open System.Windows
996- open System
997-
998- type DefaultFileSystem () =
999- interface IFileSystem with
1000- member this.ReadAllBytesShim ( fileName : string ) =
1001- use stream = this.FileStreamReadShim fileName
1002- let len = stream.Length
1003- let buf = Array.zeroCreate< byte> ( int len)
1004- stream.Read( buf, 0 , ( int len)) |> ignore
1005- buf
1006-
1007-
1008- member this.AssemblyLoadFrom ( fileName : string ) =
1009- let load () =
1010- let assemblyPart = System.Windows.AssemblyPart()
1011- let assemblyStream = this.FileStreamReadShim( fileName)
1012- assemblyPart.Load( assemblyStream)
1013- if System.Windows.Deployment.Current.Dispatcher.CheckAccess() then
1014- load()
1015- else
1016- let resultTask = System.Threading.Tasks.TaskCompletionSource< System.Reflection.Assembly>()
1017- System.Windows.Deployment.Current.Dispatcher.BeginInvoke( Action( fun () -> resultTask.SetResult ( load()))) |> ignore
1018- resultTask.Task.Result
1019-
1020- member this.AssemblyLoad ( assemblyName : System.Reflection.AssemblyName ) =
1021- try
1022- System.Reflection.Assembly.Load( assemblyName.FullName)
1023- with e ->
1024- this.AssemblyLoadFrom( assemblyName.Name + " .dll" )
1025-
1026- member __.FileStreamReadShim ( fileName : string ) =
1027- match Application.GetResourceStream( System.Uri( fileName, System.UriKind.Relative)) with
1028- | null -> IsolatedStorageFile.GetUserStoreForApplication() .OpenFile( fileName, System.IO.FileMode.Open) :> System.IO.Stream
1029- | resStream -> resStream.Stream
1030-
1031- member __.FileStreamCreateShim ( fileName : string ) =
1032- System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication() .CreateFile( fileName) :> Stream
1033-
1034- member __.FileStreamWriteExistingShim ( fileName : string ) =
1035- let isf = System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication()
1036- new System.IO.IsolatedStorage.IsolatedStorageFileStream( fileName, FileMode.Open, FileAccess.Write, isf) :> Stream
1037-
1038- member __.GetFullPathShim ( fileName : string ) = fileName
1039- member __.IsPathRootedShim ( pathName : string ) = true
1040-
1041- member __.IsInvalidPathShim ( path : string ) =
1042- let isInvalidPath ( p : string ) =
1043- String.IsNullOrEmpty( p) || p.IndexOfAny( System.IO.Path.GetInvalidPathChars()) <> - 1
1044-
1045- let isInvalidDirectory ( d : string ) =
1046- d= null || d.IndexOfAny( Path.GetInvalidPathChars()) <> - 1
1047-
1048- isInvalidPath ( path) ||
1049- let directory = Path.GetDirectoryName( path)
1050- let filename = Path.GetFileName( path)
1051- isInvalidDirectory( directory) || isInvalidPath( filename)
1052-
1053- member __.GetTempPathShim () = " ."
1054-
1055- member __.GetLastWriteTimeShim ( fileName : string ) =
1056- match Application.GetResourceStream( System.Uri( fileName, System.UriKind.Relative)) with
1057- | null -> IsolatedStorageFile.GetUserStoreForApplication() .GetLastAccessTime( fileName) .LocalDateTime
1058- | _ resStream -> System.DateTime.Today.Date
1059- member __.SafeExists ( fileName : string ) =
1060- match Application.GetResourceStream( System.Uri( fileName, System.UriKind.Relative)) with
1061- | null -> IsolatedStorageFile.GetUserStoreForApplication() .FileExists fileName
1062- | resStream -> resStream.Stream <> null
1063- member __.FileDelete ( fileName : string ) =
1064- match Application.GetResourceStream( System.Uri( fileName, System.UriKind.Relative)) with
1065- | null -> IsolatedStorageFile.GetUserStoreForApplication() .DeleteFile fileName
1066- | _ resStream -> ()
1067- #else
1068971
1069972 type DefaultFileSystem () =
1070973 interface IFileSystem with
@@ -1104,14 +1007,9 @@ module Shim =
11041007 member __.GetLastWriteTimeShim ( fileName : string ) = File.GetLastWriteTime fileName
11051008 member __.SafeExists ( fileName : string ) = System.IO.File.Exists fileName
11061009 member __.FileDelete ( fileName : string ) = System.IO.File.Delete fileName
1107- #endif
11081010
11091011 type System.Text.Encoding with
11101012 static member GetEncodingShim ( n : int ) =
1111- #if FX_ NO_ GET_ ENCODING_ BY_ INTEGER
1112- System.Text.Encoding.GetEncoding( n.ToString())
1113- #else
11141013 System.Text.Encoding.GetEncoding( n)
1115- #endif
11161014
11171015 let mutable FileSystem = DefaultFileSystem() :> IFileSystem
0 commit comments