示例#1
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];
            }
        }
示例#2
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();
                }
            }
        }