예제 #1
0
        /// <summary>
        /// Example #17.
        /// Delete the file we uploaded from Example #1.
        /// </summary>
        public static void Example17()
        {
            Console.WriteLine("Example #17 - Delete the first file we uploaded.");
            Console.Write("  Deleting... ");

            try
            {
                var deleted = Document1.Delete();

                if (deleted)
                {
                    Console.WriteLine("success :)");
                    Console.WriteLine("  File was deleted.");
                }
                else
                {
                    Console.WriteLine("failed :(");
                }
            }
            catch (BoxViewException e)
            {
                Console.WriteLine("failed :(");
                Console.WriteLine("  Error Code: " + e.Code);
                Console.WriteLine("  Error Message: " + e.Message);
            }

            Console.WriteLine();
        }
예제 #2
0
        /// <summary>
        /// Example #14.
        /// Create a session for the file we uploaded from Example #1 with default options.
        /// </summary>
        public static void Example14()
        {
            Console.WriteLine("Example #14 - Create a session for a file with default options.");
            Console.Write("  Creating... ");

            try
            {
                Session1 = Document1.CreateSession();

                Console.WriteLine("success :)");
                Console.WriteLine("  Session id is " + Session1.Id + ".");
                Console.WriteLine("  Session expires on " + Session1.ExpiresAt + ".");
                Console.WriteLine("  Session view URL is " + Session1.ViewUrl + ".");
                Console.WriteLine("  Session assets URL is " + Session1.AssetsUrl + ".");
                Console.WriteLine("  Session realtime URL is " + Session1.RealtimeUrl + ".");
            }
            catch (BoxViewException e)
            {
                Console.WriteLine("failed :(");
                Console.WriteLine("  Error Code: " + e.Code);
                Console.WriteLine("  Error Message: " + e.Message);
            }

            Console.WriteLine();
        }
예제 #3
0
        /// <summary>
        /// Example #15.
        /// Create a session for the file we uploaded from Example #1 all of the options.
        /// </summary>
        public static void Example15()
        {
            Console.WriteLine("Example #15 - Create a session for a file with more of the options.");
            Console.Write("  Creating... ");

            try
            {
                Session2 = Document1.CreateSession(
                    expiresAt: DateTime.Now.AddMinutes(10),
                    isDownloadable: true,
                    isTextSelectable: false
                    );

                Console.WriteLine("success :)");
                Console.WriteLine("  Session id is " + Session1.Id + ".");
                Console.WriteLine("  Session expires on " + Session1.ExpiresAt + ".");
                Console.WriteLine("  Session view URL is " + Session1.ViewUrl + ".");
                Console.WriteLine("  Session assets URL is " + Session1.AssetsUrl + ".");
                Console.WriteLine("  Session realtime URL is " + Session1.RealtimeUrl + ".");
            }
            catch (BoxViewException e)
            {
                Console.WriteLine("failed :(");
                Console.WriteLine("  Error Code: " + e.Code);
                Console.WriteLine("  Error Message: " + e.Message);
            }

            Console.WriteLine();
        }
예제 #4
0
        /// <summary>
        /// Example #8.
        /// Update the name of the file from Example #1.
        /// </summary>
        public static void Example8()
        {
            Console.WriteLine("Example #8 - Update the name of a file.");
            Console.Write("  Updating... ");

            try
            {
                var updated = Document1.Update(name: "Updated Name");

                if (updated)
                {
                    Console.WriteLine("success :)");
                    Console.WriteLine("  File ID is " + Document1.Id + ".");
                    Console.WriteLine("  File status is " + Document1.Status + ".");
                    Console.WriteLine("  File name is " + Document1.Name + ".");
                    Console.WriteLine("  File was created on " + Document1.CreatedAt + ".");
                }
                else
                {
                    Console.WriteLine("failed :(");
                }
            }
            catch (BoxViewException e)
            {
                Console.WriteLine("failed :(");
                Console.WriteLine("  Error Code: " + e.Code);
                Console.WriteLine("  Error Message: " + e.Message);
            }

            Console.WriteLine();
        }
예제 #5
0
        private void CreateDocument(object sender, RoutedEventArgs e)
        {
            var document = new Document1(); // create document(window)

            document.Owner = this;          // get Owner (.net needed)

            document.Show();

            (Application.Current as App).Documents.Add(document);
        }
예제 #6
0
        IQueryOver <Document1> GetDocument1Query(IUnitOfWork u)
        {
            DocumentJournalNode resultAlias    = null;
            Document1           Document1Alias = null;

            return(u.Session.QueryOver <Document1>(() => Document1Alias)
                   .SelectList(list => list
                               .Select(() => Document1Alias.Id).WithAlias(() => resultAlias.Id)
                               .Select(() => Document1Alias.Date).WithAlias(() => resultAlias.Date)
                               )
                   .OrderBy(x => x.Date).Desc
                   .TransformUsing(Transformers.AliasToBean <DocumentJournalNode <Document1> >()));
        }
예제 #7
0
 public override int GetHashCode()
 {
     unchecked
     {
         int hash = 17;
         hash = hash * 23 + (ChangeNumber == default(int) ? 0 : ChangeNumber.GetHashCode());
         hash = hash * 23 + (Document1 == null ? 0 : Document1.GetHashCode());
         hash = hash * 23 + (DocumentLevel == null ? 0 : DocumentLevel.GetHashCode());
         hash = hash * 23 + (DocumentSummary == null ? 0 : DocumentSummary.GetHashCode());
         hash = hash * 23 + (FileExtension == null ? 0 : FileExtension.GetHashCode());
         hash = hash * 23 + (FileName == null ? 0 : FileName.GetHashCode());
         hash = hash * 23 + (FolderFlag == default(bool) ? 0 : FolderFlag.GetHashCode());
         hash = hash * 23 + (ModifiedDate == default(DateTime) ? 0 : ModifiedDate.GetHashCode());
         hash = hash * 23 + (Owner == default(int) ? 0 : Owner.GetHashCode());
         hash = hash * 23 + (Revision == null ? 0 : Revision.GetHashCode());
         hash = hash * 23 + (Rowguid == default(Guid) ? 0 : Rowguid.GetHashCode());
         hash = hash * 23 + (Status == default(byte) ? 0 : Status.GetHashCode());
         hash = hash * 23 + (Title == null ? 0 : Title.GetHashCode());
         return(hash);
     }
 }
예제 #8
0
        /// <summary>
        /// Example #13.
        /// Download the file we uploaded from Example #1 as a large thumbnail.
        /// </summary>
        public static void Example13()
        {
            Console.WriteLine("Example #13 - Download a large thumbnail from a file.");
            Console.Write("  Downloading... ");

            try
            {
                var contents = Document1.Thumbnail(250, 250);
                var filename = "../../Files/test-thumbnail-large.png";

                File.WriteAllBytes(filename, contents);

                Console.WriteLine("success :)");
                Console.WriteLine("  File was downloaded to " + filename + ".");
            }
            catch (BoxViewException e)
            {
                Console.WriteLine("failed :(");
                Console.WriteLine("  Error Code: " + e.Code);
                Console.WriteLine("  Error Message: " + e.Message);
            }

            Console.WriteLine();
        }
예제 #9
0
        /// <summary>
        /// Example #11.
        /// Download the file we uploaded from Example #1 as a zip file.
        /// </summary>
        public static void Example11()
        {
            Console.WriteLine("Example #11 - Download a file as a zip.");
            Console.Write("  Downloading... ");

            try
            {
                var contents = Document1.Download("zip");
                var filename = "../../Files/test.zip";

                File.WriteAllBytes(filename, contents);

                Console.WriteLine("success :)");
                Console.WriteLine("  File was downloaded to " + filename + ".");
            }
            catch (BoxViewException e)
            {
                Console.WriteLine("failed :(");
                Console.WriteLine("  Error Code: " + e.Code);
                Console.WriteLine("  Error Message: " + e.Message);
            }

            Console.WriteLine();
        }
예제 #10
0
        /// <summary>
        /// Example #9.
        /// Download the file we uploaded from Example #1 in its original file format.
        /// </summary>
        public static void Example9()
        {
            Console.WriteLine("Example #9 - Download a file in its original file" + " format.");
            Console.Write("  Downloading... ");

            try
            {
                var contents = Document1.Download();
                var filename = "../../Files/test-original.doc";

                File.WriteAllBytes(filename, contents);

                Console.WriteLine("success :)");
                Console.WriteLine("  File was downloaded to " + filename + ".");
            }
            catch (BoxViewException e)
            {
                Console.WriteLine("failed :(");
                Console.WriteLine("  Error Code: " + e.Code);
                Console.WriteLine("  Error Message: " + e.Message);
            }

            Console.WriteLine();
        }
예제 #11
0
        /// <inheritdoc/>
        public override IDock CreateLayout()
        {
            // Documents

            var document1 = new Document1
            {
                Id     = "Document1",
                Width  = double.NaN,
                Height = double.NaN,
                Title  = "Document1"
            };

            var document2 = new Document2
            {
                Id     = "Document2",
                Width  = double.NaN,
                Height = double.NaN,
                Title  = "Document2"
            };

            var document3 = new Document3
            {
                Id     = "Document3",
                Width  = double.NaN,
                Height = double.NaN,
                Title  = "Document3"
            };

            // Left / Top

            var leftTopTool1 = new LeftTopTool1
            {
                Id     = "LeftTop1",
                Width  = double.NaN,
                Height = double.NaN,
                Title  = "LeftTop1"
            };

            var leftTopTool2 = new LeftTopTool2
            {
                Id     = "LeftTop2",
                Width  = 200,
                Height = 200,
                Title  = "LeftTop2"
            };

            var leftTopTool3 = new LeftTopTool3
            {
                Id     = "LeftTop3",
                Width  = double.NaN,
                Height = double.NaN,
                Title  = "LeftTop3"
            };

            // Left / Bottom

            var leftBottomTool1 = new LeftBottomTool1
            {
                Id     = "LeftBottom1",
                Width  = double.NaN,
                Height = double.NaN,
                Title  = "LeftBottom1"
            };

            var leftBottomTool2 = new LeftBottomTool2
            {
                Id     = "LeftBottom2",
                Width  = double.NaN,
                Height = double.NaN,
                Title  = "LeftBottom2"
            };

            var leftBottomTool3 = new LeftBottomTool3
            {
                Id     = "LeftBottom3",
                Width  = double.NaN,
                Height = double.NaN,
                Title  = "LeftBottom3"
            };

            // Right / Top

            var rightTopTool1 = new RightTopTool1
            {
                Id     = "RightTop1",
                Width  = double.NaN,
                Height = double.NaN,
                Title  = "RightTop1"
            };

            var rightTopTool2 = new RightTopTool2
            {
                Id     = "RightTop2",
                Width  = double.NaN,
                Height = double.NaN,
                Title  = "RightTop2"
            };

            var rightTopTool3 = new RightTopTool3
            {
                Id     = "RightTop3",
                Width  = double.NaN,
                Height = double.NaN,
                Title  = "RightTop3"
            };

            // Right / Bottom

            var rightBottomTool1 = new RightBottomTool1
            {
                Id     = "RightBottom1",
                Width  = double.NaN,
                Height = double.NaN,
                Title  = "RightBottom1"
            };

            var rightBottomTool2 = new RightBottomTool2
            {
                Id     = "RightBottom2",
                Width  = double.NaN,
                Height = double.NaN,
                Title  = "RightBottom2"
            };

            var rightBottomTool3 = new RightBottomTool3
            {
                Id     = "RightBottom3",
                Width  = double.NaN,
                Height = double.NaN,
                Title  = "RightBottom3"
            };

            // Left Pane

            var leftPane = new LayoutDock
            {
                Id          = "LeftPane",
                Dock        = "Left",
                Width       = 200,
                Height      = double.NaN,
                Title       = "LeftPane",
                CurrentView = null,
                Views       = CreateList <IView>
                              (
                    new ToolDock
                {
                    Id          = "LeftPaneTop",
                    Dock        = "Top",
                    Width       = double.NaN,
                    Height      = 340,
                    Title       = "LeftPaneTop",
                    CurrentView = leftTopTool1,
                    Views       = CreateList <IView>
                                  (
                        leftTopTool1,
                        leftTopTool2,
                        leftTopTool3
                                  )
                },
                    new SplitterDock()
                {
                    Id    = "LeftPaneTopSplitter",
                    Dock  = "Top",
                    Title = "LeftPaneTopSplitter"
                },
                    new ToolDock
                {
                    Id          = "LeftPaneBottom",
                    Dock        = "Bottom",
                    Width       = double.NaN,
                    Height      = double.NaN,
                    Title       = "LeftPaneBottom",
                    CurrentView = leftBottomTool1,
                    Views       = CreateList <IView>
                                  (
                        leftBottomTool1,
                        leftBottomTool2,
                        leftBottomTool3
                                  )
                }
                              )
            };

            // Right Pane

            var rightPane = new LayoutDock
            {
                Id          = "RightPane",
                Dock        = "Right",
                Width       = 240,
                Height      = double.NaN,
                Title       = "RightPane",
                CurrentView = null,
                Views       = CreateList <IView>
                              (
                    new ToolDock
                {
                    Id          = "RightPaneTop",
                    Dock        = "Top",
                    Width       = double.NaN,
                    Height      = 340,
                    Title       = "RightPaneTop",
                    CurrentView = rightTopTool1,
                    Views       = CreateList <IView>
                                  (
                        rightTopTool1,
                        rightTopTool2,
                        rightTopTool3
                                  )
                },
                    new SplitterDock()
                {
                    Id    = "RightPaneTopSplitter",
                    Dock  = "Top",
                    Title = "RightPaneTopSplitter"
                },
                    new ToolDock
                {
                    Id          = "RightPaneBottom",
                    Dock        = "Bottom",
                    Width       = double.NaN,
                    Height      = double.NaN,
                    Title       = "RightPaneBottom",
                    CurrentView = rightBottomTool1,
                    Views       = CreateList <IView>
                                  (
                        rightBottomTool1,
                        rightBottomTool2,
                        rightBottomTool3
                                  )
                }
                              )
            };

            // Documents

            var documentsPane = new DocumentDock
            {
                Id          = "DocumentsPane",
                Dock        = "",
                Width       = double.NaN,
                Height      = double.NaN,
                Title       = "DocumentsPane",
                CurrentView = document1,
                Views       = CreateList <IView>
                              (
                    document1,
                    document2,
                    document3
                              )
            };

            // Main

            var mainLayout = new LayoutDock
            {
                Id          = "MainLayout",
                Dock        = "",
                Width       = double.NaN,
                Height      = double.NaN,
                Title       = "MainLayout",
                CurrentView = null,
                Views       = CreateList <IView>
                              (
                    leftPane,
                    new SplitterDock()
                {
                    Id    = "LeftSplitter",
                    Dock  = "Left",
                    Title = "LeftSplitter"
                },
                    rightPane,
                    new SplitterDock()
                {
                    Id    = "RightSplitter",
                    Dock  = "Right",
                    Title = "RightSplitter"
                },
                    documentsPane
                              )
            };

            var mainView = new MainView
            {
                Id          = "Main",
                Width       = double.NaN,
                Height      = double.NaN,
                Title       = "Main",
                CurrentView = mainLayout,
                Views       = CreateList <IView>
                              (
                    mainLayout
                              )
            };

            // Home

            var homeView = new HomeView
            {
                Id     = "Home",
                Width  = double.NaN,
                Height = double.NaN,
                Title  = "Home"
            };

            // Root

            var root = new RootDock
            {
                Id          = "Root",
                Width       = double.NaN,
                Height      = double.NaN,
                Title       = "Root",
                CurrentView = homeView,
                DefaultView = homeView,
                Views       = CreateList <IView>(homeView, mainView)
            };

            return(root);
        }
        private async Task SetupCodeControlAsync()
        {
            var w = new AdhocWorkspace(Host);

#if false
            foreach (var fieldInfo in w.GetType().GetFields(BindingFlags.FlattenHierarchy | BindingFlags.Instance | BindingFlags.NonPublic))
            {
                var v = fieldInfo.GetValue(w);
                Debug.WriteLine($"{fieldInfo.Name}: {v}");
            }

            var langSvc = w.Services.GetLanguageServices(LanguageNames.CSharp);
            var method  = langSvc.GetType().GetMethod("GetService", BindingFlags.Instance | BindingFlags.Public);

            List <object> services = new List <object>();
            foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
            {
                try
                {
                    foreach (var type in assembly.GetTypes())
                    {
                        if (typeof(ILanguageService).IsAssignableFrom(type))
                        {
                            try
                            {
                                if (!type.ContainsGenericParameters)
                                {
                                    var m      = method.MakeGenericMethod(new[] { type });
                                    var result = m.Invoke(langSvc, new object[] { });
                                    if (result != null)
                                    {
                                        Debug.WriteLine(result);
                                        services.Add(result);
                                    }
                                }
                            }
                            catch
                            {
                            }

                            if (type.IsPublic)
                            {
                                Debug.WriteLine(String.Format("{0:G5}", type.IsPublic.ToString()) + " " +
                                                type.FullName);
                            }
                        }
                    }
                }
                catch
                {
                }
            }
            foreach (object service in services)
            {
                foreach (var methodInfo in service.GetType().GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic))
                {
                    Debug.WriteLine((methodInfo.ReturnType?.FullName ?? "") + " " + service.GetType().FullName + "." + methodInfo.Name + "( " +
                                    string.Join(", ", methodInfo.GetParameters().Select(p => (p.IsOptional ? " optional " : "") + p.ParameterType + " " + p.Name)) + ")");
                }

                if (service.GetType().Name == "CSharpCodeCleanupService")
                {
                }
            }

            // w.Services.FindLanguageServices<IFormattingService>(metadata =>
            // {
            // foreach (var (key, value) in metadata)
            // {

            // Debug.WriteLine($"{key} = {value}");
            // }

            // Debug.WriteLine("");

            // return false;
            // });
#endif
            w.AddSolution(SolutionInfo.Create(SolutionId.CreateNewId(), VersionStamp.Create()));
            var projectInfo = ProjectInfo.Create(ProjectId.CreateNewId(), VersionStamp.Create(),
                                                 "Code Project", "code", LanguageNames.CSharp);
            var w2 = w.CurrentSolution.AddProject(projectInfo);
            w.TryApplyChanges(w2);

            DocumentInfo documentInfo;
            var          filename = Filename;
            if (filename != null)
            {
                documentInfo = DocumentInfo.Create(DocumentId.CreateNewId(projectInfo.Id), "Default",
                                                   null, SourceCodeKind.Regular, new FileTextLoader(filename, Encoding.UTF8), filename);
            }
            else
            {
                documentInfo = DocumentInfo.Create(DocumentId.CreateNewId(projectInfo.Id), "Default",
                                                   null, SourceCodeKind.Regular);
            }

            w2 = w.CurrentSolution.AddDocument(documentInfo);
            w.TryApplyChanges(w2);

            Project1  = w.CurrentSolution.GetProject(projectInfo.Id);
            Document1 = w.CurrentSolution.GetDocument(documentInfo.Id);


            var qui       = w.Services.GetLanguageServices(LanguageNames.CSharp).GetService <QuickInfoService>();
            var textAsync = await Document1.GetTextAsync();

            if (false)
            {
                for (var i = 0; i < textAsync.Length; i++)
                {
                    var re = await qui.GetQuickInfoAsync(Document1, i);

                    if (re != null)
                    {
                        Debug.WriteLine(re.Span.ToString());
                        Debug.WriteLine("tags = " + string.Join(";", re.Tags));
                        foreach (var reRelatedSpan in re.RelatedSpans)
                        {
                            Debug.WriteLine("relatedspan " + reRelatedSpan.ToString());
                        }

                        foreach (var quickInfoSection in re.Sections)
                        {
                            Debug.WriteLine("" + i + " Text(" + quickInfoSection.Text + ") Kind(" + quickInfoSection.Kind + ") TaggedParts(" +
                                            String.Join(", ", quickInfoSection.TaggedParts) + ")");
                        }
                    }
                }
            }

            CodeControl.DebugLevel = 2;
            CodeControl.JTF2       = JTF2;
            CodeControl.Document   = Document1;
            var tree = await Document1.GetSyntaxTreeAsync();

            CodeControl.SyntaxTree = tree;
            var model = await Document1.GetSemanticModelAsync();

            CodeControl.SemanticModel = model;
            CodeControl.Compilation   = model.Compilation;

            // CodeControl.AddHandler(RoslynCodeControl.ContentChangedEvent, new RoslynCodeControl.ContentChangedRoutedEventHandler(CodeControlContentChanged));
            CodeControl.AddHandler(RoslynCodeBase.RenderStartEvent, new RoutedEventHandler((sender, args) =>
            {
                // StartTime = DateTime.Now;
                Debug.WriteLine("render start");
            }));
            CodeControl.AddHandler(RoslynCodeBase.RenderCompleteEvent, new RoutedEventHandler((sender, args) =>
            {
                // var span = DateTime.Now - StartTime;
                Debug.WriteLine("render complete ");
            }));

            await CodeControl.UpdateFormattedTextAsync();
        }
예제 #13
0
        public override IDock CreateLayout()
        {
            var document1 = new Document1
            {
                Id    = "Document1",
                Title = "Document1"
            };

            var document2 = new Document2
            {
                Id    = "Document2",
                Title = "Document2"
            };

            var document3 = new Document3
            {
                Id    = "Document3",
                Title = "Document3"
            };

            var leftTopTool1 = new LeftTopTool1
            {
                Id    = "LeftTop1",
                Title = "LeftTop1"
            };

            var leftTopTool2 = new LeftTopTool2
            {
                Id    = "LeftTop2",
                Title = "LeftTop2"
            };

            var leftTopTool3 = new LeftTopTool3
            {
                Id    = "LeftTop3",
                Title = "LeftTop3"
            };

            var leftBottomTool1 = new LeftBottomTool1
            {
                Id    = "LeftBottom1",
                Title = "LeftBottom1"
            };

            var leftBottomTool2 = new LeftBottomTool2
            {
                Id    = "LeftBottom2",
                Title = "LeftBottom2"
            };

            var leftBottomTool3 = new LeftBottomTool3
            {
                Id    = "LeftBottom3",
                Title = "LeftBottom3"
            };

            var rightTopTool1 = new RightTopTool1
            {
                Id    = "RightTop1",
                Title = "RightTop1"
            };

            var rightTopTool2 = new RightTopTool2
            {
                Id    = "RightTop2",
                Title = "RightTop2"
            };

            var rightTopTool3 = new RightTopTool3
            {
                Id    = "RightTop3",
                Title = "RightTop3"
            };

            var rightBottomTool1 = new RightBottomTool1
            {
                Id    = "RightBottom1",
                Title = "RightBottom1"
            };

            var rightBottomTool2 = new RightBottomTool2
            {
                Id    = "RightBottom2",
                Title = "RightBottom2"
            };

            var rightBottomTool3 = new RightBottomTool3
            {
                Id    = "RightBottom3",
                Title = "RightBottom3"
            };

            var mainLayout = new LayoutDock
            {
                Id          = "MainLayout",
                Title       = "MainLayout",
                Proportion  = double.NaN,
                Orientation = Orientation.Horizontal,
                CurrentView = null,
                Views       = CreateList <IView>
                              (
                    new LayoutDock
                {
                    Id          = "LeftPane",
                    Title       = "LeftPane",
                    Proportion  = double.NaN,
                    Orientation = Orientation.Vertical,
                    CurrentView = null,
                    Views       = CreateList <IView>
                                  (
                        new ToolDock
                    {
                        Id          = "LeftPaneTop",
                        Title       = "LeftPaneTop",
                        Proportion  = double.NaN,
                        CurrentView = leftTopTool1,
                        Views       = CreateList <IView>
                                      (
                            leftTopTool1,
                            leftTopTool2,
                            leftTopTool3
                                      )
                    },
                        new SplitterDock()
                    {
                        Id    = "LeftPaneTopSplitter",
                        Title = "LeftPaneTopSplitter"
                    },
                        new ToolDock
                    {
                        Id          = "LeftPaneBottom",
                        Title       = "LeftPaneBottom",
                        Proportion  = double.NaN,
                        CurrentView = leftBottomTool1,
                        Views       = CreateList <IView>
                                      (
                            leftBottomTool1,
                            leftBottomTool2,
                            leftBottomTool3
                                      )
                    }
                                  )
                },
                    new SplitterDock()
                {
                    Id    = "LeftSplitter",
                    Title = "LeftSplitter"
                },
                    new DocumentDock
                {
                    Id          = "DocumentsPane",
                    Title       = "DocumentsPane",
                    Proportion  = double.NaN,
                    CurrentView = document1,
                    Views       = CreateList <IView>
                                  (
                        document1,
                        document2,
                        document3
                                  )
                },
                    new SplitterDock()
                {
                    Id    = "RightSplitter",
                    Title = "RightSplitter"
                },
                    new LayoutDock
                {
                    Id          = "RightPane",
                    Title       = "RightPane",
                    Proportion  = double.NaN,
                    Orientation = Orientation.Vertical,
                    CurrentView = null,
                    Views       = CreateList <IView>
                                  (
                        new ToolDock
                    {
                        Id          = "RightPaneTop",
                        Title       = "RightPaneTop",
                        Proportion  = double.NaN,
                        CurrentView = rightTopTool1,
                        Views       = CreateList <IView>
                                      (
                            rightTopTool1,
                            rightTopTool2,
                            rightTopTool3
                                      )
                    },
                        new SplitterDock()
                    {
                        Id    = "RightPaneTopSplitter",
                        Title = "RightPaneTopSplitter"
                    },
                        new ToolDock
                    {
                        Id          = "RightPaneBottom",
                        Title       = "RightPaneBottom",
                        Proportion  = double.NaN,
                        CurrentView = rightBottomTool1,
                        Views       = CreateList <IView>
                                      (
                            rightBottomTool1,
                            rightBottomTool2,
                            rightBottomTool3
                                      )
                    }
                                  )
                }
                              )
            };

            var mainView = new MainView
            {
                Id          = "Main",
                Title       = "Main",
                CurrentView = mainLayout,
                Views       = CreateList <IView>(mainLayout)
            };

            var homeView = new HomeView
            {
                Id    = "Home",
                Title = "Home"
            };

            var root = CreateRootDock();

            root.Id               = "Root";
            root.Title            = "Root";
            root.CurrentView      = homeView;
            root.DefaultView      = homeView;
            root.Views            = CreateList <IView>(homeView, mainView);
            root.Top              = CreatePinDock();
            root.Top.Alignment    = Alignment.Top;
            root.Bottom           = CreatePinDock();
            root.Bottom.Alignment = Alignment.Bottom;
            root.Left             = CreatePinDock();
            root.Left.Alignment   = Alignment.Left;
            root.Right            = CreatePinDock();
            root.Right.Alignment  = Alignment.Right;

            return(root);
        }
        public async void TestDocumentOperations()
        {
            var store = await StartNebula(dbAccess => new DocumentStore(dbAccess));

            var docA = new Document1 {
                Id = Guid.NewGuid()
            };
            var docB = new Document1 {
                Id = Guid.NewGuid()
            };

            await store.CreateDocument1(docA);

            var docAResult1 = await store.GetDocument1(docA.Id);

            Assert.NotNull(docAResult1);
            Assert.Equal(docA.Id, docAResult1.Document.Id);

            var docBResult1 = await store.GetDocument1(docB.Id);

            Assert.Null(docBResult1);

            await Task.Delay(1000);

            await store.UpdateDocument1(docA);

            var docAResult2 = await store.GetDocument1(docA.Id);

            Assert.NotNull(docAResult2);
            Assert.True(docAResult2.Metadata.CreatedTime == docAResult1.Metadata.CreatedTime);
            Assert.True(docAResult2.Metadata.ModifiedTime > docAResult1.Metadata.ModifiedTime);

            await Assert.ThrowsAsync <NebulaStoreException>(() => store.UpdateDocument1(docB));

            var docBResult2 = await store.GetDocument1(docB.Id);

            Assert.Null(docBResult2);

            await store.UpsertDocument1(docB);

            var docBResult3 = await store.GetDocument1(docB.Id);

            Assert.NotNull(docBResult3);
            Assert.Equal(docB.Id, docBResult3.Document.Id);

            await Task.Delay(1000);

            await store.UpsertDocument1(docA);

            var docAResult3 = await store.GetDocument1(docA.Id);

            Assert.NotNull(docAResult3);
            Assert.True(docAResult3.Metadata.CreatedTime == docAResult2.Metadata.CreatedTime);
            Assert.True(docAResult3.Metadata.ModifiedTime > docAResult2.Metadata.ModifiedTime);

            var allDocs = await store.GetAllDocuments1();

            Assert.Equal(2, allDocs.Count);
            Assert.NotNull(allDocs.SingleOrDefault(x => x.Document.Id == docA.Id));
            Assert.NotNull(allDocs.SingleOrDefault(x => x.Document.Id == docB.Id));

            var batchResult = await store.GetDocument1(new[] { docA.Id });

            Assert.Equal(1, batchResult.Loaded.Count);
            Assert.NotNull(batchResult.Loaded.SingleOrDefault(x => x.Document.Id == docA.Id));

            var queryResult1 = await store.GetDocument1("true");

            Assert.Equal(2, queryResult1.Loaded.Count);

            var queryResult2 = await store.GetDocument1($"[x].Id = '{docB.Id}'");

            Assert.Equal(1, queryResult2.Loaded.Count);
            Assert.NotNull(queryResult2.Loaded.SingleOrDefault(x => x.Document.Id == docB.Id));

            // Set ttl on DocB.
            await store.UpsertDocument1(docB, new OperationOptions { Ttl = 1 });

            await Task.Delay(2000);

            var docBResult4 = await store.GetDocument1(docB.Id);

            Assert.Null(docBResult4);

            await store.DeleteDocument1(docA.Id);

            var docAResult4 = await store.GetDocument1(docA.Id);

            Assert.Null(docAResult4);
        }
 public async Task UpsertDocument1(Document1 document, OperationOptions options = null)
 {
     await StoreClient.UpsertDocumentAsync(document, _documentMapping, options);
 }
 public async Task UpdateDocument1(Document1 document)
 {
     await StoreClient.UpdateDocumentAsync(document, _documentMapping, null);
 }