/// <summary>
        /// Called by sessions to request a transfer stream from the host application
        /// </summary>
        /// <param name="sessionId">Session Id</param>
        /// <param name="remoteHost">The remote host requesting the transfer</param>
        /// <param name="filename">The filename requested by the remote host</param>
        /// <returns></returns>
        internal async Task <Stream> GetReadStreamAsync(Guid sessionId, IPEndPoint remoteHost, string filename)
        {
            if (GetStream == null)
            {
                LogError("No file system available");
                return(null);
            }

            var eventArgs = new TftpGetStreamEventArgs
            {
                Id         = sessionId,
                Filename   = filename,
                RemoteHost = remoteHost
            };

            Delegate[] invocationList = GetStream.GetInvocationList();
            Task[]     handlerTasks   = new Task[invocationList.Length];

            for (int i = 0; i < invocationList.Length; i++)
            {
                handlerTasks[i] = ((Func <object, TftpGetStreamEventArgs, Task>)invocationList[i])(this, eventArgs);
            }

            await Task.WhenAll(handlerTasks);

            if (eventArgs.Result == null)
            {
                LogError("Unknown file");
                return(null);
            }

            return(eventArgs.Result);
        }
 protected AnnotationFile(string fileName, string contentType, byte[] fileContent)
 {
     FileName    = AnnotationHelper.EnsureValidFileName(fileName);
     MimeType    = contentType;
     FileSize    = new FileSize(fileContent.Length > 0 ? Convert.ToUInt64(fileContent.Length) : 0);
     _annotation = new Lazy <Entity>(() => null, LazyThreadSafetyMode.None);
     _getStream  = () => new MemoryStream(fileContent);
 }
 protected AnnotationFile(HttpPostedFileBase file)
 {
     FileName    = AnnotationHelper.EnsureValidFileName(file.FileName);
     MimeType    = file.ContentType;
     FileSize    = new FileSize(file.ContentLength > 0 ? Convert.ToUInt64(file.ContentLength) : 0);
     _annotation = new Lazy <Entity>(() => null, LazyThreadSafetyMode.None);
     _getStream  = () => file.InputStream;
 }
Beispiel #4
0
        static void Main(string[] args)
        {
            Logolas l0 = new Program().LogolasToFile;
            Logolas l1 = new Logolas(LogolasToConsole);
            Logolas l2 = LogolasToMsgbox;

            Logolas l3 = delegate(string szoveg) { Console.WriteLine("Esemenynaplo: " + szoveg); };
            Logolas l4 = l1 + l2 + l3;
            Logolas l5 = l4 - l1;

            l5 = l5 + l1;

            l1("l1");
            l2("l2");
            l3("l3");
            l4("l4");
            l5("l5");

            Logolas l6 = (Logolas)Delegate.Combine(l4, l5);

            l6("l6");

            Delegate[] logolasok = new Delegate[] { l1, l2, l3 };
            Logolas    l7        = (Logolas)Delegate.Combine(logolasok);

            l7("l7");

            // elore definalt delegate-k
            Action <string> a = LogolasToConsole;

            Func <int, int> duplaz     = delegate(int szam) { return(szam * 2); };
            Func <int, int> triplaz    = szam => szam * 3;
            Func <int, int> negyszerez = x => x * 4;

            Func <int, int, double> osztas = (x, y) => (double)x / y;

            GetStream gs = GetS1;

            gs = GetS2;

            gs = GetS1;
            object o = gs(new FileStream(@"c:\temp\valami.txt", FileMode.Create));

            Console.WriteLine(o.GetType());

            Console.ReadLine();
        }
 public RecoverableEventMessageStream(
     TimeSpan oldStreamCloseTimeout,
     TimeSpan reconnectBackoff,
     int maxReconnectAttempts,
     GetStream getStreamDelegate,
     StreamOpenedAsync openDelegate,
     StreamClosedAsync closeDelegate,
     UnexpectedCloseDelegateAsync unexpectedCloseDelegate)
 {
     this.oldStreamCloseTimeout   = oldStreamCloseTimeout;
     this.reconnectBackoff        = reconnectBackoff;
     this.maxReconnectAttempts    = maxReconnectAttempts;
     this.getStreamDelegate       = getStreamDelegate;
     this.openDelegate            = openDelegate;
     this.closeDelegate           = closeDelegate;
     this.unexpectedCloseDelegate = unexpectedCloseDelegate;
 }
Beispiel #6
0
 StreamRef <Item> On(GetStream _) => stream;
Beispiel #7
0
 StreamRef On(GetStream _) => stream;
Beispiel #8
0
 public object Get(GetStream request)
 {
     return(new MemoryStream(Encoding.UTF8.GetBytes("Welcome to Emby!")));
 }
 protected AnnotationFile()
 {
     _annotation = new Lazy <Entity>(() => null, LazyThreadSafetyMode.None);
     _getStream  = null;
 }