Ejemplo n.º 1
0
        public ChildEntriesRequestNetworkCommand(string entryFullPath,
                                                 Func <Task <WebSocket> > transport,
                                                 JsonSerializer serializer,
                                                 NetworkClientCollection root)
        {
            EntryFullPath = entryFullPath;
            Transport     = transport;
            Serializer    = serializer;
            Root          = root;

            Result     = null;
            FileSystem = null;
        }
Ejemplo n.º 2
0
        public NetworkSelectionResult(SelectionResult selectionResult)
        {
            SelectionResultType = selectionResult.ResultType;
            Collection          = new NetworkClientCollection(selectionResult.Collection);

            if (SelectionResultType == SelectionResultType.FoundDocument)
            {
                Document = new NetworkClientDocument(selectionResult.Document);
            }
            else
            {
                Document = null;
            }

            if (SelectionResultType == SelectionResultType.MissingCollection || SelectionResultType == SelectionResultType.MissingDocumentOrCollection)
            {
                MissingNames = selectionResult.MissingNames.ToArray();
            }
            else
            {
                MissingNames = new string[0];
            }
        }
Ejemplo n.º 3
0
        //public IEnumerable<IFlowControl> ExecuteOnClient() {
        //    ReceiveString rs = new ReceiveString(new ReceiveBytes(Transport));
        //    yield return rs;
        //    string ser = rs.Result;

        //    using(StringReader sr = new StringReader(ser)) {
        //        using(JsonReader jr = new JsonTextReader(sr)) {
        //            Result = Serializer.Deserialize<T>(jr);
        //        }
        //    }
        //}

        public async Task ExecuteOnServer()
        {
            ICollection root = (await FileSystem.SelectAsync(ParentPath, CancellationToken.None))
                               .Collection;

            IEntry toSend;

            if (typeof(IDocument).IsAssignableFrom(typeof(T)))
            {
                toSend = new NetworkClientDocument(await root.CreateDocumentAsync(DocumentName, CancellationToken.None));
            }
            else
            {
                toSend = new NetworkClientCollection(await root.CreateCollectionAsync(DocumentName, CancellationToken.None));
            }

            using (StringWriter sw = new StringWriter()) {
                using (JsonWriter jw = new JsonTextWriter(sw)) {
                    Serializer.Serialize(jw, toSend);
                    await(new SendString(sw.ToString(), new SendBytes(Transport))).AwaitFlowControl();
                }
            }
        }
Ejemplo n.º 4
0
        public async Task ExecuteOnClient()
        {
            ReceiveString rs  = new ReceiveString(new ReceiveBytes(Transport));
            string        ser = await rs.AwaitFlowResult();

            IEnumerable <NetworkClientEntry> entries;

            using (StringReader sr = new StringReader(ser)) {
                using (JsonReader jr = new JsonTextReader(sr)) {
                    entries = Serializer.Deserialize <NetworkClientEntry[]>(jr).Where(x => x != null);
                }
            }

            NetworkClientCollection ncc = Root as NetworkClientCollection;

            //Parallel.ForEach(entries, nce => {
            //    nce.ParentSetup(ncc);
            //});
            foreach (var nce in entries)
            {
                nce.ParentSetup(ncc);
            }
            Result = entries.ToArray();
        }