Exemple #1
0
        static public T Read <T>(this StreamSystem item, string path, Operation <T, Stream> operation, long milliseconds = StreamSystem.DEFAULT_WAIT)
        {
            T output;

            item.AttemptRead <T>(path, operation, out output, milliseconds);
            return(output);
        }
Exemple #2
0
        static public AttemptResult AttemptRead <T>(this StreamSystem item, string path, Operation <T, Stream> operation, out T output, long milliseconds = StreamSystem.DEFAULT_WAIT)
        {
            return(item.AttemptRead(path, delegate(Stream stream, out T inner) {
                inner = operation(stream);

                return true;
            }, out output, milliseconds));
        }
Exemple #3
0
        static public AttemptResult AttemptRead(this StreamSystem item, string path, Process <Stream> process, long milliseconds = StreamSystem.DEFAULT_WAIT)
        {
            return(item.AttemptRead(path, delegate(Stream stream) {
                process(stream);

                return true;
            }, milliseconds));
        }
Exemple #4
0
        static public AttemptResult AttemptRead <T>(this StreamSystem item, string path, TryOperation <T, Stream> operation, out T output, long milliseconds = StreamSystem.DEFAULT_WAIT)
        {
            T temp = default(T);

            AttemptResult result = item.AttemptRead(path, delegate(Stream stream) {
                return(operation(stream, out temp));
            }, milliseconds);

            output = temp;
            return(result);
        }
Exemple #5
0
        static public AttemptResult AttemptReadObject(this StreamSystem item, string path, out object obj, long milliseconds = StreamSystem.DEFAULT_WAIT)
        {
            return(item.AttemptRead(path, delegate(Stream stream, out object inner) {
                if (stream.Length > 0)
                {
                    return stream.TryReadObject(out inner);
                }

                inner = null;
                return false;
            }, out obj, milliseconds));
        }
Exemple #6
0
 static public AttemptResult AttemptReadText(this StreamSystem item, string path, out string text, long milliseconds = StreamSystem.DEFAULT_WAIT)
 {
     return(item.AttemptRead(path, delegate(Stream stream) {
         return stream.ReadText();
     }, out text, milliseconds));
 }
Exemple #7
0
 static public AttemptResult AttemptReadLines(this StreamSystem item, string path, Process <IEnumerable <string> > process, long milliseconds = StreamSystem.DEFAULT_WAIT)
 {
     return(item.AttemptRead(path, delegate(Stream stream) {
         process(stream.ReadTextLines());
     }, milliseconds));
 }
Exemple #8
0
 static public AttemptResult AttemptReadRandomLine(this StreamSystem item, string path, Process <string> process, RandIntSource source, long milliseconds = StreamSystem.DEFAULT_WAIT)
 {
     return(item.AttemptRead(path, delegate(Stream stream) {
         process(stream.ReadTextRandomLine(source));
     }, milliseconds));
 }
Exemple #9
0
 static public AttemptResult AttemptReadIntoStream(this StreamSystem item, string path, Stream destination, long milliseconds = StreamSystem.DEFAULT_WAIT)
 {
     return(item.AttemptRead(path, delegate(Stream file_stream) {
         destination.WriteStream(file_stream);
     }, milliseconds));
 }
Exemple #10
0
 static public AttemptResult AttemptReadBytes(this StreamSystem item, string path, out byte[] bytes, long milliseconds = StreamSystem.DEFAULT_WAIT)
 {
     return(item.AttemptRead(path, delegate(Stream stream) {
         return stream.ReadBytes();
     }, out bytes, milliseconds));
 }