Exemplo n.º 1
0
        /// <summary>
        /// Adds a new Navigation Path.
        /// </summary>
        /// <param name="nspace">The target namespace (<c>null</c> for the root).</param>
        /// <param name="name">The Name.</param>
        /// <param name="pages">The Pages.</param>
        /// <param name="provider">The Provider to use for the new Navigation Path, or <c>null</c> for the default provider.</param>
        /// <returns>True if the Path is added successfully.</returns>
        public static bool AddNavigationPath(NamespaceInfo nspace, string name, List <PageInfo> pages, IPagesStorageProviderV30 provider)
        {
            var namespaceName = nspace != null ? nspace.Name : null;
            var fullName      = NameTools.GetFullName(namespaceName, name);

            if (Exists(fullName))
            {
                return(false);
            }

            if (provider == null)
            {
                provider = Collectors.PagesProviderCollector.GetProvider(Settings.DefaultPagesProvider);
            }

            NavigationPath newPath = provider.AddNavigationPath(namespaceName, name, pages.ToArray());

            if (newPath != null)
            {
                Log.LogEntry("Navigation Path " + fullName + " added", EntryType.General, Log.SystemUsername);
            }
            else
            {
                Log.LogEntry("Creation failed for Navigation Path " + fullName, EntryType.Error, Log.SystemUsername);
            }
            return(newPath != null);
        }
Exemplo n.º 2
0
 public override void OnSelected(ref MotionSynthesizer synthesizer)
 {
     using (NavigationPath navPath = GetDebugObject <NavigationPath>())
     {
         navPath.DrawPath();
     }
 }
Exemplo n.º 3
0
    void FixedUpdate()
    {
        if (next_navigation != null)
        {
            if (Time.timeSinceLevelLoad > next_navigation.start_time)
            {
                if (next_navigation != current_navigation)
                {
                    current_navigation = next_navigation;
                    next_navigation    = null;
                }
            }
        }
        if (current_navigation != null)
        {
            horizontal_position = current_navigation.transform.position.x +
                                  current_navigation.x_path.Evaluate(Time.timeSinceLevelLoad - current_navigation.start_time);
            vertical_position = current_navigation.transform.position.y +
                                current_navigation.y_path.Evaluate(Time.timeSinceLevelLoad - current_navigation.start_time);

            angle = current_navigation.angle.Evaluate(Time.timeSinceLevelLoad - current_navigation.start_time);
        }

        transform.position    = new Vector3(horizontal_position, vertical_position, 0f);
        transform.eulerAngles = new Vector3(0, 0, angle);

        //this.transform.position = new Vector3(horizontal_position, vertical_position, 0);

        // Player exists on an AnimationCurve.
        // When Player colides with ConstructedSite, follow a new AnimationCurve when position.x is greater than site's threshold
        // Customizable thresholds would almost always be site.transform.position.x - site.transform.scale.x/2
    }
Exemplo n.º 4
0
 private void OnCollisionStay(Collision collision)
 {
     if (collision.gameObject.layer == LayerMask.NameToLayer("Hazard"))
     {
         List <SoundStruct> temporary_list = new List <SoundStruct>()
         {
             parameter_test
         };
         SoundFactory.DeleteSound(ref temporary_list, "event:/enginetest");
         Application.LoadLevel(Application.loadedLevel + 2);
     }
     else if (collision.gameObject.layer == LayerMask.NameToLayer("Goal"))
     {
         List <SoundStruct> temporary_list = new List <SoundStruct>()
         {
             parameter_test
         };
         SoundFactory.DeleteSound(ref temporary_list, "event:/enginetest");
         Application.LoadLevel(Application.loadedLevel + 1);
     }
     else if (collision.gameObject.layer == LayerMask.NameToLayer("Navigation"))
     {
         NavigationPath pathfinding = collision.gameObject.GetComponent <NavigationPath>();
         if (pathfinding != null)
         {
             next_navigation = pathfinding;
         }
     }
 }
Exemplo n.º 5
0
        public void NavigatePath(NavigationPath navigationPath)
        {
            switch (navigationPath)
            {
            case NavigationPath.Home:
                Title = "Dashboard";
                _navigationService.Navigate <HomeViewModel>();
                break;

            case NavigationPath.Balances:
                Title = "Balances";
                _navigationService.Navigate <BalancesViewModel>();
                break;

            case NavigationPath.Transactions:
                Title = "Transactions";
                _navigationService.Navigate <TransactionsViewModel>();
                break;

            case NavigationPath.SendReceive:
                Title = "Send or Receive";
                _navigationService.Navigate <SendReceiveViewModel>();
                break;

            case NavigationPath.History:
                Title = "History";
                _navigationService.Navigate <HistoryViewModel>();
                break;

            case NavigationPath.Settings:
                Title = "Settings";
                _navigationService.Navigate <SettingsViewModel>();
                break;
            }
        }
Exemplo n.º 6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:NavigationPathRow" /> class.
 /// </summary>
 /// <param name="path">The original navigation path.</param>
 /// <param name="canSelect">A value indicating whether the path can be selected.</param>
 /// <param name="selected">A value indicating whether the navigation path is selected.</param>
 public NavigationPathRow(NavigationPath path, bool canSelect, bool selected)
 {
     fullName        = path.FullName;
     pages           = path.Pages.Length.ToString();
     provider        = path.Provider.Information.Name;
     this.canSelect  = canSelect;
     additionalClass = selected ? " selected" : "";
 }
Exemplo n.º 7
0
 public PatrolState(EnemyAgent agent, Quaternion originalRotation, NavigationPath patrolPath = null) : base(agent)
 {
     if (patrolPath != null)
     {
         _path       = patrolPath.Path;
         _currentPos = new Vector2(_agent.Parent.position.x, _agent.Parent.position.z);
     }
     _originalRotation = originalRotation;
 }
Exemplo n.º 8
0
 private void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
     else if (Instance != this)
     {
         Destroy(gameObject);
     }
 }
Exemplo n.º 9
0
 /*
  * Builds a path from the start node to the goal node. The recursion goes
  * backwards through node parents until the parent is null (the start node),
  * and a list is created using that node as the first. This partial path is
  * then returned up the recursion, and each node adds its own state until the goal
  * state is reached.
  */
 public NavigationPath extractPath()
 {
     if (parent == null){
         NavigationPath partialPath = new NavigationPath(this.state);
         return partialPath;
     } else {
         NavigationPath partialPath = parent.extractPath();
         partialPath.addWaypoint(this.state);
         return partialPath;
     }
 }
Exemplo n.º 10
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.name.Contains("Intersection"))
        {
            if (other.name.Contains("Start"))
            {
                arrived = false;
            }
            IntersectionProperties temp = other.gameObject.GetComponent <IntersectionProperties>();

            if (nextID == temp.intersectionID)
            {
                nextPath = temp.nextPath;
                nextID   = temp.nextID;
                if (nextPath != null)
                {
                    nextTurnSign      = temp.nextTurnSign;
                    currentIndication = temp.nextTurnSign;
                    if (currentIndication == 's')
                    {
                        naviRenderer.material = arrowStraight;
                    }
                    else if (currentIndication == 'r')
                    {
                        naviRenderer.material = arrowRight;
                    }
                    else if (currentIndication == 'l')
                    {
                        naviRenderer.material = arrowLeft;
                    }
                    else
                    {
                        naviRenderer.material = transparent;
                        currentIndication     = 't';
                    }
                    mySyncScript.RpcUpdateChar(myDirectionTag, currentIndication);

                    changePath = true;
                }
                else
                {
                    nextTurnSign      = '\0';
                    currentIndication = 'z';

                    naviRenderer.material = transparent;
                }
            }
            else if (nextID == -1)
            {
                nextID  = 0;
                arrived = true;
            }
        }
    }
Exemplo n.º 11
0
        /// <summary>
        /// Sets the navigation paths label.
        /// </summary>
        private void SetupNavigationPaths()
        {
            string[] paths = NavigationPaths.PathsPerPage(currentPage);

            string currentPath = Request["NavPath"];

            if (!string.IsNullOrEmpty(currentPath))
            {
                currentPath = currentPath.ToLowerInvariant();
            }

            if (!discussMode && !viewCodeMode && paths.Length > 0)
            {
                StringBuilder sb = new StringBuilder(500);
                sb.Append(Properties.Messages.Paths);
                sb.Append(": ");
                for (int i = 0; i < paths.Length; i++)
                {
                    NavigationPath path = NavigationPaths.Find(paths[i]);
                    if (path != null)
                    {
                        if (currentPath != null && paths[i].ToLowerInvariant().Equals(currentPath))
                        {
                            sb.Append("<b>");
                        }

                        sb.Append(@"<a href=""");
                        sb.Append(UrlTools.BuildUrl("Default.aspx?Page=", Tools.UrlEncode(currentPage.FullName), "&amp;NavPath=", Tools.UrlEncode(paths[i])));
                        sb.Append(@""" title=""");
                        sb.Append(NameTools.GetLocalName(path.FullName));
                        sb.Append(@""">");
                        sb.Append(NameTools.GetLocalName(path.FullName));
                        sb.Append("</a>");

                        if (currentPath != null && paths[i].ToLowerInvariant().Equals(currentPath))
                        {
                            sb.Append("</b>");
                        }

                        if (i != paths.Length - 1)
                        {
                            sb.Append(", ");
                        }
                    }
                }

                lblNavigationPaths.Text = sb.ToString();
            }
            else
            {
                lblNavigationPaths.Visible = false;
            }
        }
Exemplo n.º 12
0
 public override void TreeTraversal(ADecisionNode p_sourceNode)
 {
     using (NavigationGraphAlgorithm.CalculatePathRequest l_calculationRequest = NavigationGraphAlgorithm.CalculatePathRequest.CalculatePathRequestPool.popOrCreate())
     {
         NavigationGraphAlgorithm.CalculatePathRequest.prepareForCalculation(
             l_calculationRequest,
             NavigationGraphContainer.UniqueNavigationGraph,
             SourceNavigationNode,
             TargetNavigationNode,
             PathCalculationParameters.build(2.0f));
         NavigationGraphAlgorithm.CalculatePath(l_calculationRequest);
         ref NavigationPath l_calculatedNavigationPath = ref l_calculationRequest.ResultPath;
         NavigationPath = new List <NavigationNode>(l_calculatedNavigationPath.NavigationNodes);
         PathCost       = l_calculatedNavigationPath.PathCost;
     }
    void OnEnable()
    {
        EditorApplication.update += Update;

        t = (NavigationPath)target;
        if (t == null)
        {
            return;
        }


        SetupEditorVariables();
        GetVariableProperties();
        SetupReorderableList();
    }
Exemplo n.º 14
0
    void InstantiateZombie()
    {
        float random      = Random.Range(0, 100);
        int   zombieIndex = 0;

        if (random < 50)
        {
            zombieIndex = 1;
        }
        NavigationPath newPath = Instantiate(path, path.transform.position, Quaternion.identity);
        GameObject     zombie  = Instantiate(zombies[zombieIndex], path.transform.position, Quaternion.identity);

        zombie.GetComponent <FollowPath>().path        = newPath;
        zombie.GetComponent <EnemyAttack>().MinDamage  = zombiesKilled;
        zombie.GetComponent <EnemyAttack>().MaxDamage  = zombiesToKill;
        zombie.GetComponent <EnemyDamage>().DropPickup = true;
        zombie.GetComponent <EnemyDamage>().PickupType = PickupsType.Ammo;
    }
Exemplo n.º 15
0
        public bool GetPathBetweenAIFaces(
            int startingFace,
            int endingFace,
            Vec2 startingPosition,
            Vec2 endingPosition,
            float agentRadius,
            NavigationPath path)
        {
            int length = path.PathPoints.Length;

            if (EngineApplicationInterface.IScene.GetPathBetweenAIFaceIndices(this.Pointer, startingFace, endingFace, startingPosition, endingPosition, agentRadius, path.PathPoints, ref length))
            {
                path.Size = length;
                return(true);
            }
            path.Size = 0;
            return(false);
        }
Exemplo n.º 16
0
        /// <summary>
        /// Modifies a Navigation Path.
        /// </summary>
        /// <param name="fullName">The full name of the path to modify.</param>
        /// <param name="pages">The list of Pages.</param>
        /// <returns><c>true</c> if the path is modified, <c>false</c> otherwise.</returns>
        public static bool ModifyNavigationPath(string fullName, List <PageInfo> pages)
        {
            NavigationPath path = Find(fullName);

            if (path == null)
            {
                return(false);
            }

            NavigationPath newPath = path.Provider.ModifyNavigationPath(path, pages.ToArray());

            if (newPath != null)
            {
                Log.LogEntry("Navigation Path " + fullName + " modified", EntryType.General, Log.SystemUsername);
            }
            else
            {
                Log.LogEntry("Modification failed for Navigation Path " + fullName, EntryType.Error, Log.SystemUsername);
            }
            return(newPath != null);
        }
Exemplo n.º 17
0
        /// <summary>
        /// Removes a Navigation Path.
        /// </summary>
        /// <param name="fullName">The full name of the path to remove.</param>
        /// <returns><c>true</c> if the path is removed, <c>false</c> otherwise.</returns>
        public static bool RemoveNavigationPath(string fullName)
        {
            NavigationPath path = Find(fullName);

            if (path == null)
            {
                return(false);
            }

            var done = path.Provider.RemoveNavigationPath(path);

            if (done)
            {
                Log.LogEntry("Navigation Path " + fullName + " removed", EntryType.General, Log.SystemUsername);
            }
            else
            {
                Log.LogEntry("Deletion failed for Navigation Path " + fullName, EntryType.Error, Log.SystemUsername);
            }
            return(done);
        }
Exemplo n.º 18
0
        protected void rptNavPaths_ItemCommand(object sender, CommandEventArgs e)
        {
            txtCurrentNavPath.Value = e.CommandArgument as string;

            if (e.CommandName == "Select")
            {
                if (!CanManagePagesInCurrentNamespace())
                {
                    return;
                }

                string currentWiki = DetectWiki();

                txtName.Text    = txtCurrentNavPath.Value;
                txtName.Enabled = false;

                NavigationPath path = NavigationPaths.Find(currentWiki, txtCurrentNavPath.Value);
                foreach (string page in path.Pages)
                {
                    PageContent pageContent = Pages.FindPage(currentWiki, page);
                    if (pageContent != null)
                    {
                        lstPages.Items.Add(new ListItem(FormattingPipeline.PrepareTitle(currentWiki, pageContent.Title, false, FormattingContext.Other, pageContent.FullName), pageContent.FullName));
                    }
                }

                cvName2.Enabled   = false;
                btnCreate.Visible = false;
                btnSave.Visible   = true;
                btnDelete.Visible = true;

                pnlList.Visible        = false;
                pnlEditNavPath.Visible = true;

                lblResult.Text = "";
            }
        }
Exemplo n.º 19
0
    public void FollowNavigationPath(NavigationPath path)
    {
        this.path = path;
        waypoint  = path.Waypoints[1];
        waypoint.GetTargetPositionAndAlignment(out Vector3 targetPosition, out Vector3 targetForward);
        flightPath = PathUtils.GetBezierCurve(
            transform.position,
            transform.position + transform.forward * 200,
            targetPosition - targetForward * 200,
            targetPosition,
            10);

        Debug.DrawRay(transform.position, Vector3.up * 5, Color.green, 5f);
        Debug.DrawRay(transform.position + transform.forward * 50, Vector3.up * 5, Color.green, 5f);
        Debug.DrawRay(targetPosition - targetForward * 50, Vector3.up * 5, Color.green, 5f);
        Debug.DrawRay(targetPosition, Vector3.up * 5, Color.green, 5f);

        for (int i = 0; i < flightPath.Count - 1; i++)
        {
            Debug.DrawLine(flightPath[i], flightPath[i + 1], Color.red, 5f);
        }

        transform.DOPath(flightPath.ToArray(), 15f, PathType.Linear, PathMode.Full3D);
    }
Exemplo n.º 20
0
        public void MigratePagesStorageProviderData()
        {
            var mocks = new MockRepository();

            var source      = mocks.StrictMock <IPagesStorageProviderV30>();
            var destination = mocks.StrictMock <IPagesStorageProviderV30>();

            // Setup SOURCE -------------------------

            // Setup snippets
            var s1 = new Snippet("S1", "Blah1", source);
            var s2 = new Snippet("S2", "Blah2", source);

            Expect.Call(source.GetSnippets()).Return(new[] { s1, s2 });

            // Setup content templates
            var ct1 = new ContentTemplate("CT1", "Template 1", source);
            var ct2 = new ContentTemplate("CT2", "Template 2", source);

            Expect.Call(source.GetContentTemplates()).Return(new[] { ct1, ct2 });

            // Setup namespaces
            var ns1 = new NamespaceInfo("NS1", source, null);
            var ns2 = new NamespaceInfo("NS2", source, null);

            Expect.Call(source.GetNamespaces()).Return(new[] { ns1, ns2 });

            // Setup pages
            var p1 = new PageInfo("Page", source, DateTime.Now);
            var p2 = new PageInfo(NameTools.GetFullName(ns1.Name, "Page"), source, DateTime.Now);
            var p3 = new PageInfo(NameTools.GetFullName(ns1.Name, "Page1"), source, DateTime.Now);

            Expect.Call(source.GetPages(null)).Return(new[] { p1 });
            Expect.Call(source.GetPages(ns1)).Return(new[] { p2, p3 });
            Expect.Call(source.GetPages(ns2)).Return(new PageInfo[0]);

            // Set default page for NS1
            ns1.DefaultPage = p2;

            // Setup categories/bindings
            var c1 = new CategoryInfo("Cat", source);

            c1.Pages = new[] { p1.FullName };
            var c2 = new CategoryInfo(NameTools.GetFullName(ns1.Name, "Cat"), source);

            c2.Pages = new[] { p2.FullName };
            var c3 = new CategoryInfo(NameTools.GetFullName(ns1.Name, "Cat1"), source);

            c3.Pages = new string[0];
            Expect.Call(source.GetCategories(null)).Return(new[] { c1 });
            Expect.Call(source.GetCategories(ns1)).Return(new[] { c2, c3 });
            Expect.Call(source.GetCategories(ns2)).Return(new CategoryInfo[0]);

            // Setup drafts
            var d1 = new PageContent(p1, "Draft", "NUnit", DateTime.Now, "Comm", "Cont", new[] { "k1", "k2" }, "Descr");

            Expect.Call(source.GetDraft(p1)).Return(d1);
            Expect.Call(source.GetDraft(p2)).Return(null);
            Expect.Call(source.GetDraft(p3)).Return(null);

            // Setup content
            var ctn1 = new PageContent(p1, "Title1", "User1", DateTime.Now, "Comm1", "Cont1", null, "Descr1");
            var ctn2 = new PageContent(p2, "Title2", "User2", DateTime.Now, "Comm2", "Cont2", null, "Descr2");
            var ctn3 = new PageContent(p3, "Title3", "User3", DateTime.Now, "Comm3", "Cont3", null, "Descr3");

            Expect.Call(source.GetContent(p1)).Return(ctn1);
            Expect.Call(source.GetContent(p2)).Return(ctn2);
            Expect.Call(source.GetContent(p3)).Return(ctn3);

            // Setup backups
            Expect.Call(source.GetBackups(p1)).Return(new[] { 0, 1 });
            Expect.Call(source.GetBackups(p2)).Return(new[] { 0 });
            Expect.Call(source.GetBackups(p3)).Return(new int[0]);
            var bak1_0 = new PageContent(p1, "K1_0", "U1_0", DateTime.Now, "", "Cont", null, null);
            var bak1_1 = new PageContent(p1, "K1_1", "U1_1", DateTime.Now, "", "Cont", null, null);
            var bak2_0 = new PageContent(p2, "K2_0", "U2_0", DateTime.Now, "", "Cont", null, null);

            Expect.Call(source.GetBackupContent(p1, 0)).Return(bak1_0);
            Expect.Call(source.GetBackupContent(p1, 1)).Return(bak1_1);
            Expect.Call(source.GetBackupContent(p2, 0)).Return(bak2_0);

            // Messages
            var m1 = new Message(1, "User1", "Subject1", DateTime.Now, "Body1");

            m1.Replies = new[] { new Message(2, "User2", "Subject2", DateTime.Now, "Body2") };
            Message[] p1m = { m1 };
            var       p2m = new Message[0];
            var       p3m = new Message[0];

            Expect.Call(source.GetMessages(p1)).Return(p1m);
            Expect.Call(source.GetMessages(p2)).Return(p2m);
            Expect.Call(source.GetMessages(p3)).Return(p3m);

            // Setup navigation paths
            var n1 = new NavigationPath("N1", source);

            n1.Pages = new[] { p1.FullName };
            var n2 = new NavigationPath(NameTools.GetFullName(ns1.Name, "N1"), source);

            n2.Pages = new[] { p2.FullName, p3.FullName };
            Expect.Call(source.GetNavigationPaths(null)).Return(new[] { n1 });
            Expect.Call(source.GetNavigationPaths(ns1)).Return(new[] { n2 });
            Expect.Call(source.GetNavigationPaths(ns2)).Return(new NavigationPath[0]);

            // Setup DESTINATION --------------------------

            // Snippets
            Expect.Call(destination.AddSnippet(s1.Name, s1.Content))
            .Return(new Snippet(s1.Name, s1.Content, destination));
            Expect.Call(source.RemoveSnippet(s1.Name)).Return(true);
            Expect.Call(destination.AddSnippet(s2.Name, s2.Content))
            .Return(new Snippet(s2.Name, s2.Content, destination));
            Expect.Call(source.RemoveSnippet(s2.Name)).Return(true);

            // Content templates
            Expect.Call(destination.AddContentTemplate(ct1.Name, ct1.Content))
            .Return(new ContentTemplate(ct1.Name, ct1.Name, destination));
            Expect.Call(source.RemoveContentTemplate(ct1.Name)).Return(true);
            Expect.Call(destination.AddContentTemplate(ct2.Name, ct2.Content))
            .Return(new ContentTemplate(ct2.Name, ct2.Name, destination));
            Expect.Call(source.RemoveContentTemplate(ct2.Name)).Return(true);

            // Namespaces
            var ns1Out = new NamespaceInfo(ns1.Name, destination, null);
            var ns2Out = new NamespaceInfo(ns2.Name, destination, null);

            Expect.Call(destination.AddNamespace(ns1.Name)).Return(ns1Out);
            Expect.Call(source.RemoveNamespace(ns1)).Return(true);
            Expect.Call(destination.AddNamespace(ns2.Name)).Return(ns2Out);
            Expect.Call(source.RemoveNamespace(ns2)).Return(true);

            // Pages/drafts/content/backups/messages
            var p1Out = new PageInfo(p1.FullName, destination, p1.CreationDateTime);

            Expect.Call(destination.AddPage(null, p1.FullName, p1.CreationDateTime)).Return(p1Out);
            Expect.Call(destination.ModifyPage(p1Out, ctn1.Title, ctn1.User, ctn1.LastModified, ctn1.Comment,
                                               ctn1.Content, ctn1.Keywords, ctn1.Description, SaveMode.Normal)).Return(true);
            Expect.Call(destination.ModifyPage(p1Out, d1.Title, d1.User, d1.LastModified, d1.Comment, d1.Content,
                                               d1.Keywords, d1.Description, SaveMode.Draft)).Return(true);
            Expect.Call(destination.SetBackupContent(bak1_0, 0)).Return(true);
            Expect.Call(destination.SetBackupContent(bak1_1, 1)).Return(true);
            Expect.Call(destination.BulkStoreMessages(p1Out, p1m)).Return(true);
            Expect.Call(source.RemovePage(p1)).Return(true);

            var p2Out = new PageInfo(p2.FullName, destination, p2.CreationDateTime);

            Expect.Call(destination.AddPage(p2.Namespace, p2.Name, p2.CreationDateTime)).Return(p2Out);
            Expect.Call(destination.ModifyPage(p2Out, ctn2.Title, ctn2.User, ctn2.LastModified, ctn2.Comment,
                                               ctn2.Content, ctn2.Keywords, ctn2.Description, SaveMode.Normal)).Return(true);
            Expect.Call(destination.SetBackupContent(bak2_0, 0)).Return(true);
            Expect.Call(destination.BulkStoreMessages(p2Out, p2m)).Return(true);
            Expect.Call(source.RemovePage(p2)).Return(true);

            var p3Out = new PageInfo(p3.FullName, destination, p3.CreationDateTime);

            Expect.Call(destination.AddPage(p3.Namespace, p3.Name, p3.CreationDateTime)).Return(p3Out);
            Expect.Call(destination.ModifyPage(p3Out, ctn3.Title, ctn3.User, ctn3.LastModified, ctn3.Comment,
                                               ctn3.Content, ctn3.Keywords, ctn3.Description, SaveMode.Normal)).Return(true);
            Expect.Call(destination.BulkStoreMessages(p3Out, p3m)).Return(true);
            Expect.Call(source.RemovePage(p3)).Return(true);

            // Categories/bindings
            var c1Out = new CategoryInfo(c1.FullName, destination);
            var c2Out = new CategoryInfo(c2.FullName, destination);
            var c3Out = new CategoryInfo(c3.FullName, destination);

            Expect.Call(destination.AddCategory(null, c1.FullName)).Return(c1Out);
            Expect.Call(destination.AddCategory(NameTools.GetNamespace(c2.FullName), NameTools.GetLocalName(c2.FullName)))
            .Return(c2Out);
            Expect.Call(destination.AddCategory(NameTools.GetNamespace(c3.FullName), NameTools.GetLocalName(c3.FullName)))
            .Return(c3Out);
            Expect.Call(destination.RebindPage(p1Out, new[] { c1.FullName })).Return(true);
            Expect.Call(destination.RebindPage(p2Out, new[] { c2.FullName })).Return(true);
            Expect.Call(destination.RebindPage(p3Out, new string[0])).Return(true);
            Expect.Call(source.RemoveCategory(c1)).Return(true);
            Expect.Call(source.RemoveCategory(c2)).Return(true);
            Expect.Call(source.RemoveCategory(c3)).Return(true);

            // Navigation paths
            var n1Out = new NavigationPath(n1.FullName, destination);

            n1Out.Pages = n1.Pages;
            var n2Out = new NavigationPath(n2.FullName, destination);

            n2Out.Pages = n2.Pages;

            Expect.Call(destination.AddNavigationPath(null, n1.FullName, new[] { p1 })).Return(n1Out).Constraints(
                RMC.Is.Null(), RMC.Is.Equal(n1.FullName),
                RMC.Is.Matching(delegate(PageInfo[] array) { return(array[0].FullName == p1.FullName); }));

            Expect.Call(destination.AddNavigationPath(NameTools.GetNamespace(n2.FullName),
                                                      NameTools.GetLocalName(n2.FullName), new[] { p2, p3 })).Return(n2Out).Constraints(
                RMC.Is.Equal(NameTools.GetNamespace(n2.FullName)), RMC.Is.Equal(NameTools.GetLocalName(n2.FullName)),
                RMC.Is.Matching(
                    delegate(PageInfo[] array)
            {
                return(array[0].FullName == p2.FullName && array[1].FullName == p3.FullName);
            }));

            Expect.Call(source.RemoveNavigationPath(n1)).Return(true);
            Expect.Call(source.RemoveNavigationPath(n2)).Return(true);

            Expect.Call(destination.SetNamespaceDefaultPage(ns1Out, p2Out)).Return(ns1Out);
            Expect.Call(destination.SetNamespaceDefaultPage(ns2Out, null)).Return(ns2Out);

            // Used for navigation paths
            Expect.Call(destination.GetPages(null)).Return(new[] { p1Out });
            Expect.Call(destination.GetPages(ns1Out)).Return(new[] { p2Out, p3Out });
            Expect.Call(destination.GetPages(ns2Out)).Return(new PageInfo[0]);

            mocks.Replay(source);
            mocks.Replay(destination);

            DataMigrator.MigratePagesStorageProviderData(source, destination);

            mocks.Verify(source);
            mocks.Verify(destination);
        }
        /// <summary>
        /// Adds a new Navigation Path.
        /// </summary>
        /// <param name="transaction">A database transaction.</param>
        /// <param name="nspace">The target namespace (<c>null</c> for the root).</param>
        /// <param name="name">The Name of the Path.</param>
        /// <param name="pages">The Pages array.</param>
        /// <returns>The correct <see cref="T:NavigationPath"/> object.</returns>
        private NavigationPath AddNavigationPath(DbTransaction transaction, string nspace, string name, PageInfo[] pages)
        {
            ICommandBuilder builder = GetCommandBuilder();
            QueryBuilder queryBuilder = new QueryBuilder(builder);

            string query, finalQuery = "";
            List<Parameter> parameters = new List<Parameter>(3 * pages.Length);
            int count = 0;
            string countString;

            foreach(PageInfo page in pages) {
                countString = count.ToString();

                query = queryBuilder.InsertInto("NavigationPath", new string[] { "Name", "Namespace", "Page", "Number" },
                    new string[] { "Name" + countString, "Namespace" + countString, "Page" + countString, "Number" + countString });

                parameters.Add(new Parameter(ParameterType.String, "Name" + countString, name));
                parameters.Add(new Parameter(ParameterType.String, "Namespace" + countString, nspace));
                parameters.Add(new Parameter(ParameterType.String, "Page" + countString, NameTools.GetLocalName(page.FullName)));
                parameters.Add(new Parameter(ParameterType.Int32, "Number" + countString, (short)count));

                finalQuery = queryBuilder.AppendForBatch(finalQuery, query);

                count++;
            }

            DbCommand command = builder.GetCommand(transaction, finalQuery, parameters);

            int rows = ExecuteNonQuery(command, false);

            if(rows == pages.Length) {
                NavigationPath result = new NavigationPath(NameTools.GetFullName(nspace, name), this);
                result.Pages = Array.ConvertAll<PageInfo, string>(pages, (x) => { return x.FullName; });
                return result;
            }
            else return null;
        }
Exemplo n.º 22
0
 /// <summary>
 /// Writes an array of Navigation Paths to disk.
 /// </summary>
 /// <param name="paths">The array.</param>
 private void DumpNavigationPaths(NavigationPath[] paths)
 {
     lock(this) {
         StringBuilder sb = new StringBuilder();
         for(int i = 0; i < paths.Length; i++) {
             sb.Append(paths[i].FullName);
             for(int k = 0; k < paths[i].Pages.Length; k++) {
                 sb.Append("|");
                 sb.Append(paths[i].Pages[k]);
             }
             if(i != paths.Length - 1) sb.Append("\r\n");
         }
         File.WriteAllText(GetFullPath(NavigationPathsFile), sb.ToString());
     }
 }
Exemplo n.º 23
0
        /// <summary>
        /// Extracts an instance of <see cref="T:NavigationPath" /> from a line in the navigation paths file.
        /// </summary>
        /// <param name="fileLine">The line to process.</param>
        /// <returns>The instance of <see cref="T:NavigationPath" /></returns>
        private NavigationPath BuildNavigationPath(string fileLine)
        {
            // Structure
            // Namespace.PathName|Page1|Page2|...
            // First field can be 'Namespace.PathName' or 'PathName'

            string[] fields = fileLine.Split('|');
            string[] fullName = fields[0].Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries);
            string nspace, name;

            if(fullName.Length == 1) {
                nspace = null;
                name = fullName[0];
            }
            else {
                nspace = fullName[0];
                name = fullName[1];
            }

            NavigationPath result = new NavigationPath(NameTools.GetFullName(nspace, name), this);
            List<string> tempPages = new List<string>(10);
            for(int k = 1; k < fields.Length; k++) {
                tempPages.Add(fields[k]);
            }
            result.Pages = tempPages.ToArray();

            return result;
        }
Exemplo n.º 24
0
        /// <summary>
        /// Adds a new Navigation Path.
        /// </summary>
        /// <param name="nspace">The target namespace (<c>null</c> for the root).</param>
        /// <param name="name">The Name of the Path.</param>
        /// <param name="pages">The Pages array.</param>
        /// <returns>The correct <see cref="T:NavigationPath" /> object.</returns>
        /// <exception cref="ArgumentNullException">If <paramref name="name"/> or <paramref name="pages"/> are <c>null</c>.</exception>
        /// <exception cref="ArgumentException">If <paramref name="name"/> or <paramref name="pages"/> are empty.</exception>
        public NavigationPath AddNavigationPath(string nspace, string name, PageInfo[] pages)
        {
            if(name == null) throw new ArgumentNullException("name");
            if(name.Length == 0) throw new ArgumentException("Name cannot be empty", "name");
            if(pages == null) throw new ArgumentNullException("pages");
            if(pages.Length == 0) throw new ArgumentException("Pages cannot be empty");

            lock(this) {
                NavigationPathComparer comp = new NavigationPathComparer();
                NavigationPath temp = new NavigationPath(NameTools.GetFullName(nspace, name), this);
                if(Array.Find(GetAllNavigationPaths(), delegate(NavigationPath p) { return comp.Compare(p, temp) == 0; }) != null) return null;
                temp = null;

                foreach(PageInfo page in pages) {
                    if(page == null) throw new ArgumentNullException("pages", "A page element cannot be null");
                    if(LoadLocalPageInfo(page) == null) throw new ArgumentException("Page not found", "pages");
                }

                NavigationPath result = new NavigationPath(NameTools.GetFullName(nspace, name), this);
                List<string> tempPages = new List<string>(pages.Length);

                StringBuilder sb = new StringBuilder(500);

                sb.Append("\r\n");
                sb.Append(result.FullName);
                for(int i = 0; i < pages.Length; i++) {
                    if(pages[i].Provider == this) {
                        sb.Append("|");
                        sb.Append(pages[i].FullName);
                        tempPages.Add(pages[i].FullName);
                    }
                }
                result.Pages = tempPages.ToArray();

                File.AppendAllText(GetFullPath(NavigationPathsFile), sb.ToString());
                return result;
            }
        }
        /// <summary>
        /// Removes a Navigation Path.
        /// </summary>
        /// <param name="path">The navigation path to remove.</param>
        /// <returns><c>true</c> if the path is removed, <c>false</c> otherwise.</returns>
        /// <exception cref="ArgumentNullException">If <paramref name="path"/> is <c>null</c>.</exception>
        public bool RemoveNavigationPath(NavigationPath path)
        {
            if(path == null) throw new ArgumentNullException("path");

            string nspace, name;
            NameTools.ExpandFullName(path.FullName, out nspace, out name);
            if(nspace == null) nspace = "";

            ICommandBuilder builder = GetCommandBuilder();
            DbConnection connection = builder.GetConnection(connString);

            bool removed = RemoveNavigationPath(connection, path);
            CloseConnection(connection);

            return removed;
        }
Exemplo n.º 26
0
 private void findPathToGoal()
 {
     //	Debug.Log("---------------- generating random path -----------------");
     StateConfig start = new StateConfig(new float[]{robot.transform.position.x, robot.transform.position.z});
     StateConfig end = new StateConfig(new float[]{goal.first, goal.second});
     NavigationPath path = null;
     path = prm.findShortestPath(start,end);
     if (path == null) {
         //GUI TEXT
         Debug.Log("Path not found!");
         return;
     }
     //		Debug.Log("Free path between start and goal? " + grid.obstacleFreeStraightPath(st.getPosition(), en.getPosition()));
     path.drawPath(0,"RobotCamera");
     //Debug.Log("---------------- trimming path -----------------");
     pathToGoal = path.trimPath(grid);
     pathToGoal.drawPath(1,"RobotCamera");
 }
        /// <summary>
        /// Removes a Navigation Path.
        /// </summary>
        /// <param name="connection">A database connection.</param>
        /// <param name="path">The navigation path to remove.</param>
        /// <returns><c>true</c> if the path is removed, <c>false</c> otherwise.</returns>
        private bool RemoveNavigationPath(DbConnection connection, NavigationPath path)
        {
            string nspace, name;
            NameTools.ExpandFullName(path.FullName, out nspace, out name);
            if(nspace == null) nspace = "";

            ICommandBuilder builder = GetCommandBuilder();
            QueryBuilder queryBuilder = new QueryBuilder(builder);

            string query = queryBuilder.DeleteFrom("NavigationPath");
            query = queryBuilder.Where(query, "Name", WhereOperator.Equals, "Name");
            query = queryBuilder.AndWhere(query, "Namespace", WhereOperator.Equals, "Namespace");

            List<Parameter> parameters = new List<Parameter>(2);
            parameters.Add(new Parameter(ParameterType.String, "Name", name));
            parameters.Add(new Parameter(ParameterType.String, "Namespace", nspace));

            DbCommand command = builder.GetCommand(connection, query, parameters);

            int rows = ExecuteNonQuery(command, false);

            return rows > 0;
        }
 /// <summary>
 ///     Convert this object into a string representation.
 /// </summary>
 /// <returns>
 ///     A string that represents this object.
 /// </returns>
 public override string ToString()
 {
     return($"{QuerySource.ItemName}.{NavigationPath.Select(n => n.Name).Join(".")}");
 }
Exemplo n.º 29
0
 public void NavigateMenuItem(NavigationPath navigationPath)
 {
     _navigationService.NavigatePath(navigationPath);
     Navigated?.Invoke(this, new NavigationServiceEventArgs(_navigationService.Title));
 }
Exemplo n.º 30
0
    public NavigationPath GetPathBetweenWaypoints(NavigationWaypoint start, NavigationWaypoint end)
    {
        HashSet <NavigationWaypoint> exploredWaypoints = new HashSet <NavigationWaypoint>();
        Queue <NavigationWaypoint>   waypointsQueue    = new Queue <NavigationWaypoint>();
        Dictionary <NavigationWaypoint, NavigationWaypoint> previousWaypoint = new Dictionary <NavigationWaypoint, NavigationWaypoint>();

        // Add the start to the queue and mark it as explored
        exploredWaypoints.Add(start);
        waypointsQueue.Enqueue(start);

        bool pathFound = false;

        while (waypointsQueue.Count > 0 && pathFound == false)
        {
            // Remove current waypoint from queue
            NavigationWaypoint waypoint = waypointsQueue.Dequeue();

            // For each unexplored neighbour
            foreach (NavigationWaypoint connectedWaypoint in waypoint.connectedWaypoints)
            {
                if (exploredWaypoints.Contains(connectedWaypoint))
                {
                    continue;
                }

                // Set it to explored
                exploredWaypoints.Add(connectedWaypoint);

                // Check if its the goal
                if (connectedWaypoint == end)
                {
                    pathFound = true;
                    previousWaypoint.Add(end, waypoint);
                    break;
                }
                else                 // Else add it to the queue with it's origin waypoint
                {
                    waypointsQueue.Enqueue(connectedWaypoint);
                    previousWaypoint.Add(connectedWaypoint, waypoint);
                }
            }
        }

        // Retrace our steps from the end waypoint to the start then reverse and return the path
        if (pathFound)
        {
            NavigationPath path = new NavigationPath();

            path.Waypoints.Add(end);

            NavigationWaypoint waypoint = previousWaypoint[end];
            while (waypoint != start)
            {
                path.Waypoints.Add(waypoint);
                waypoint = previousWaypoint[waypoint];
            }

            path.Waypoints.Add(start);

            path.Waypoints.Reverse();

            return(path);
        }

        return(null);
    }
Exemplo n.º 31
0
 public bool RemoveNavigationPath(NavigationPath path)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 32
0
 public NavigationPath ModifyNavigationPath(NavigationPath path, string[] pages)
 {
     throw new NotImplementedException();
 }
 /// <summary>
 ///     Convert this object into a string representation.
 /// </summary>
 /// <returns>
 ///     A string that represents this object.
 /// </returns>
 public override string ToString()
 => $"{QuerySource.ItemName}.{NavigationPath.Select(n => n.Name).Join(".")}";     // Interpolation okay; strings
Exemplo n.º 34
0
        /// <summary>
        /// Modifies an existing Navigation Path.
        /// </summary>
        /// <param name="path">The Navigation Path to modify.</param>
        /// <param name="pages">The new Pages array.</param>
        /// <returns>The correct <see cref="T:NavigationPath" /> object.</returns>
        /// <exception cref="ArgumentNullException">If <paramref name="path"/> or <paramref name="pages"/> are <c>null</c>.</exception>
        /// <exception cref="ArgumentException">If <paramref name="pages"/> is empty.</exception>
        public NavigationPath ModifyNavigationPath(NavigationPath path, PageInfo[] pages)
        {
            if(path == null) throw new ArgumentNullException("path");
            if(pages == null) throw new ArgumentNullException("pages");
            if(pages.Length == 0) throw new ArgumentException("Pages cannot be empty");

            lock(this) {
                foreach(PageInfo page in pages) {
                    if(page == null) throw new ArgumentNullException("pages", "A page element cannot be null");
                    if(LoadLocalPageInfo(page) == null) throw new ArgumentException("Page not found", "pages");
                }

                NavigationPath[] paths = GetAllNavigationPaths();
                NavigationPathComparer comp = new NavigationPathComparer();
                for(int i = 0; i < paths.Length; i++) {
                    if(comp.Compare(path, paths[i]) == 0) {
                        paths[i].Pages = new string[0];

                        NavigationPath np = new NavigationPath(path.FullName, this);
                        List<string> tempPages = new List<string>(pages.Length);

                        for(int k = 0; k < pages.Length; k++) {
                            if(pages[k].Provider == this) {
                                tempPages.Add(pages[k].FullName);
                            }
                        }
                        np.Pages = tempPages.ToArray();
                        paths[i] = np;

                        DumpNavigationPaths(paths);
                        return np;
                    }
                }
            }
            return null;
        }
Exemplo n.º 35
0
        public void MigratePagesStorageProviderData()
        {
            MockRepository mocks = new MockRepository();

            IPagesStorageProviderV30 source = mocks.StrictMock<IPagesStorageProviderV30>();
            IPagesStorageProviderV30 destination = mocks.StrictMock<IPagesStorageProviderV30>();

            // Setup SOURCE -------------------------

            // Setup snippets
            Snippet s1 = new Snippet("S1", "Blah1", source);
            Snippet s2 = new Snippet("S2", "Blah2", source);
            Expect.Call(source.GetSnippets()).Return(new Snippet[] { s1, s2 });

            // Setup content templates
            ContentTemplate ct1 = new ContentTemplate("CT1", "Template 1", source);
            ContentTemplate ct2 = new ContentTemplate("CT2", "Template 2", source);
            Expect.Call(source.GetContentTemplates()).Return(new ContentTemplate[] { ct1, ct2 });

            // Setup namespaces
            NamespaceInfo ns1 = new NamespaceInfo("NS1", source, null);
            NamespaceInfo ns2 = new NamespaceInfo("NS2", source, null);
            Expect.Call(source.GetNamespaces()).Return(new NamespaceInfo[] { ns1, ns2 });

            // Setup pages
            PageInfo p1 = new PageInfo("Page", source, DateTime.Now);
            PageInfo p2 = new PageInfo(NameTools.GetFullName(ns1.Name, "Page"), source, DateTime.Now);
            PageInfo p3 = new PageInfo(NameTools.GetFullName(ns1.Name, "Page1"), source, DateTime.Now);
            Expect.Call(source.GetPages(null)).Return(new PageInfo[] { p1 });
            Expect.Call(source.GetPages(ns1)).Return(new PageInfo[] { p2, p3 });
            Expect.Call(source.GetPages(ns2)).Return(new PageInfo[0]);

            // Set default page for NS1
            ns1.DefaultPage = p2;

            // Setup categories/bindings
            CategoryInfo c1 = new CategoryInfo("Cat", source);
            c1.Pages = new string[] { p1.FullName };
            CategoryInfo c2 = new CategoryInfo(NameTools.GetFullName(ns1.Name, "Cat"), source);
            c2.Pages = new string[] { p2.FullName };
            CategoryInfo c3 = new CategoryInfo(NameTools.GetFullName(ns1.Name, "Cat1"), source);
            c3.Pages = new string[0];
            Expect.Call(source.GetCategories(null)).Return(new CategoryInfo[] { c1 });
            Expect.Call(source.GetCategories(ns1)).Return(new CategoryInfo[] { c2, c3 });
            Expect.Call(source.GetCategories(ns2)).Return(new CategoryInfo[0]);

            // Setup drafts
            PageContent d1 = new PageContent(p1, "Draft", "NUnit", DateTime.Now, "Comm", "Cont", new string[] { "k1", "k2" }, "Descr");
            Expect.Call(source.GetDraft(p1)).Return(d1);
            Expect.Call(source.GetDraft(p2)).Return(null);
            Expect.Call(source.GetDraft(p3)).Return(null);

            // Setup content
            PageContent ctn1 = new PageContent(p1, "Title1", "User1", DateTime.Now, "Comm1", "Cont1", null, "Descr1");
            PageContent ctn2 = new PageContent(p2, "Title2", "User2", DateTime.Now, "Comm2", "Cont2", null, "Descr2");
            PageContent ctn3 = new PageContent(p3, "Title3", "User3", DateTime.Now, "Comm3", "Cont3", null, "Descr3");
            Expect.Call(source.GetContent(p1)).Return(ctn1);
            Expect.Call(source.GetContent(p2)).Return(ctn2);
            Expect.Call(source.GetContent(p3)).Return(ctn3);

            // Setup backups
            Expect.Call(source.GetBackups(p1)).Return(new int[] { 0, 1 });
            Expect.Call(source.GetBackups(p2)).Return(new int[] { 0 });
            Expect.Call(source.GetBackups(p3)).Return(new int[0]);
            PageContent bak1_0 = new PageContent(p1, "K1_0", "U1_0", DateTime.Now, "", "Cont", null, null);
            PageContent bak1_1 = new PageContent(p1, "K1_1", "U1_1", DateTime.Now, "", "Cont", null, null);
            PageContent bak2_0 = new PageContent(p2, "K2_0", "U2_0", DateTime.Now, "", "Cont", null, null);
            Expect.Call(source.GetBackupContent(p1, 0)).Return(bak1_0);
            Expect.Call(source.GetBackupContent(p1, 1)).Return(bak1_1);
            Expect.Call(source.GetBackupContent(p2, 0)).Return(bak2_0);

            // Messages
            Message m1 = new Message(1, "User1", "Subject1", DateTime.Now, "Body1");
            m1.Replies = new Message[] { new Message(2, "User2", "Subject2", DateTime.Now, "Body2") };
            Message[] p1m = new Message[] { m1 };
            Message[] p2m = new Message[0];
            Message[] p3m = new Message[0];
            Expect.Call(source.GetMessages(p1)).Return(p1m);
            Expect.Call(source.GetMessages(p2)).Return(p2m);
            Expect.Call(source.GetMessages(p3)).Return(p3m);

            // Setup navigation paths
            NavigationPath n1 = new NavigationPath("N1", source);
            n1.Pages = new string[] { p1.FullName };
            NavigationPath n2 = new NavigationPath(NameTools.GetFullName(ns1.Name, "N1"), source);
            n2.Pages = new string[] { p2.FullName, p3.FullName };
            Expect.Call(source.GetNavigationPaths(null)).Return(new NavigationPath[] { n1 });
            Expect.Call(source.GetNavigationPaths(ns1)).Return(new NavigationPath[] { n2 });
            Expect.Call(source.GetNavigationPaths(ns2)).Return(new NavigationPath[0]);

            // Setup DESTINATION --------------------------

            // Snippets
            Expect.Call(destination.AddSnippet(s1.Name, s1.Content)).Return(new Snippet(s1.Name, s1.Content, destination));
            Expect.Call(source.RemoveSnippet(s1.Name)).Return(true);
            Expect.Call(destination.AddSnippet(s2.Name, s2.Content)).Return(new Snippet(s2.Name, s2.Content, destination));
            Expect.Call(source.RemoveSnippet(s2.Name)).Return(true);

            // Content templates
            Expect.Call(destination.AddContentTemplate(ct1.Name, ct1.Content)).Return(new ContentTemplate(ct1.Name, ct1.Name, destination));
            Expect.Call(source.RemoveContentTemplate(ct1.Name)).Return(true);
            Expect.Call(destination.AddContentTemplate(ct2.Name, ct2.Content)).Return(new ContentTemplate(ct2.Name, ct2.Name, destination));
            Expect.Call(source.RemoveContentTemplate(ct2.Name)).Return(true);

            // Namespaces
            NamespaceInfo ns1Out = new NamespaceInfo(ns1.Name, destination, null);
            NamespaceInfo ns2Out = new NamespaceInfo(ns2.Name, destination, null);
            Expect.Call(destination.AddNamespace(ns1.Name)).Return(ns1Out);
            Expect.Call(source.RemoveNamespace(ns1)).Return(true);
            Expect.Call(destination.AddNamespace(ns2.Name)).Return(ns2Out);
            Expect.Call(source.RemoveNamespace(ns2)).Return(true);

            // Pages/drafts/content/backups/messages
            PageInfo p1Out = new PageInfo(p1.FullName, destination, p1.CreationDateTime);
            Expect.Call(destination.AddPage(null, p1.FullName, p1.CreationDateTime)).Return(p1Out);
            Expect.Call(destination.ModifyPage(p1Out, ctn1.Title, ctn1.User, ctn1.LastModified, ctn1.Comment, ctn1.Content, ctn1.Keywords, ctn1.Description, SaveMode.Normal)).Return(true);
            Expect.Call(destination.ModifyPage(p1Out, d1.Title, d1.User, d1.LastModified, d1.Comment, d1.Content, d1.Keywords, d1.Description, SaveMode.Draft)).Return(true);
            Expect.Call(destination.SetBackupContent(bak1_0, 0)).Return(true);
            Expect.Call(destination.SetBackupContent(bak1_1, 1)).Return(true);
            Expect.Call(destination.BulkStoreMessages(p1Out, p1m)).Return(true);
            Expect.Call(source.RemovePage(p1)).Return(true);

            PageInfo p2Out = new PageInfo(p2.FullName, destination, p2.CreationDateTime);
            Expect.Call(destination.AddPage(NameTools.GetNamespace(p2.FullName), NameTools.GetLocalName(p2.FullName),
                p2.CreationDateTime)).Return(p2Out);
            Expect.Call(destination.ModifyPage(p2Out, ctn2.Title, ctn2.User, ctn2.LastModified, ctn2.Comment, ctn2.Content, ctn2.Keywords, ctn2.Description, SaveMode.Normal)).Return(true);
            Expect.Call(destination.SetBackupContent(bak2_0, 0)).Return(true);
            Expect.Call(destination.BulkStoreMessages(p2Out, p2m)).Return(true);
            Expect.Call(source.RemovePage(p2)).Return(true);

            PageInfo p3Out = new PageInfo(p3.FullName, destination, p3.CreationDateTime);
            Expect.Call(destination.AddPage(NameTools.GetNamespace(p3.FullName), NameTools.GetLocalName(p3.FullName),
                p3.CreationDateTime)).Return(p3Out);
            Expect.Call(destination.ModifyPage(p3Out, ctn3.Title, ctn3.User, ctn3.LastModified, ctn3.Comment, ctn3.Content, ctn3.Keywords, ctn3.Description, SaveMode.Normal)).Return(true);
            Expect.Call(destination.BulkStoreMessages(p3Out, p3m)).Return(true);
            Expect.Call(source.RemovePage(p3)).Return(true);

            // Categories/bindings
            CategoryInfo c1Out = new CategoryInfo(c1.FullName, destination);
            CategoryInfo c2Out = new CategoryInfo(c2.FullName, destination);
            CategoryInfo c3Out = new CategoryInfo(c3.FullName, destination);
            Expect.Call(destination.AddCategory(null, c1.FullName)).Return(c1Out);
            Expect.Call(destination.AddCategory(NameTools.GetNamespace(c2.FullName), NameTools.GetLocalName(c2.FullName))).Return(c2Out);
            Expect.Call(destination.AddCategory(NameTools.GetNamespace(c3.FullName), NameTools.GetLocalName(c3.FullName))).Return(c3Out);
            Expect.Call(destination.RebindPage(p1Out, new string[] { c1.FullName })).Return(true);
            Expect.Call(destination.RebindPage(p2Out, new string[] { c2.FullName })).Return(true);
            Expect.Call(destination.RebindPage(p3Out, new string[0])).Return(true);
            Expect.Call(source.RemoveCategory(c1)).Return(true);
            Expect.Call(source.RemoveCategory(c2)).Return(true);
            Expect.Call(source.RemoveCategory(c3)).Return(true);

            // Navigation paths
            NavigationPath n1Out = new NavigationPath(n1.FullName, destination);
            n1Out.Pages = n1.Pages;
            NavigationPath n2Out = new NavigationPath(n2.FullName, destination);
            n2Out.Pages = n2.Pages;

            Expect.Call(destination.AddNavigationPath(null, n1.FullName, new PageInfo[] { p1 })).Return(n1Out).Constraints(
                RMC.Is.Null(), RMC.Is.Equal(n1.FullName),
                RMC.Is.Matching<PageInfo[]>(delegate(PageInfo[] array) {
                    return array[0].FullName == p1.FullName;
                }));

            Expect.Call(destination.AddNavigationPath(NameTools.GetNamespace(n2.FullName), NameTools.GetLocalName(n2.FullName), new PageInfo[] { p2, p3 })).Return(n2Out).Constraints(
                RMC.Is.Equal(NameTools.GetNamespace(n2.FullName)), RMC.Is.Equal(NameTools.GetLocalName(n2.FullName)),
                RMC.Is.Matching<PageInfo[]>(delegate(PageInfo[] array) {
                    return array[0].FullName == p2.FullName && array[1].FullName == p3.FullName;
                }));

            Expect.Call(source.RemoveNavigationPath(n1)).Return(true);
            Expect.Call(source.RemoveNavigationPath(n2)).Return(true);

            Expect.Call(destination.SetNamespaceDefaultPage(ns1Out, p2Out)).Return(ns1Out);
            Expect.Call(destination.SetNamespaceDefaultPage(ns2Out, null)).Return(ns2Out);

            // Used for navigation paths
            Expect.Call(destination.GetPages(null)).Return(new PageInfo[] { p1Out });
            Expect.Call(destination.GetPages(ns1Out)).Return(new PageInfo[] { p2Out, p3Out });
            Expect.Call(destination.GetPages(ns2Out)).Return(new PageInfo[0]);

            mocks.Replay(source);
            mocks.Replay(destination);

            DataMigrator.MigratePagesStorageProviderData(source, destination);

            mocks.Verify(source);
            mocks.Verify(destination);
        }
Exemplo n.º 36
0
        /// <summary>
        /// Removes a Navigation Path.
        /// </summary>
        /// <param name="path">The Navigation Path to remove.</param>
        /// <returns>True if the Path is removed successfully.</returns>
        /// <exception cref="ArgumentNullException">If <paramref name="path"/> is <c>null</c>.</exception>
        public bool RemoveNavigationPath(NavigationPath path)
        {
            if(path == null) throw new ArgumentNullException("path");

            lock(this) {
                List<NavigationPath> paths = new List<NavigationPath>(GetAllNavigationPaths());
                NavigationPathComparer comp = new NavigationPathComparer();
                for(int i = 0; i < paths.Count; i++) {
                    if(comp.Compare(path, paths[i]) == 0) {
                        paths.Remove(paths[i]);
                        DumpNavigationPaths(paths.ToArray());
                        return true;
                    }
                }
            }
            return false;
        }
Exemplo n.º 37
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:NavigationPathRow" /> class.
 /// </summary>
 /// <param name="path">The original navigation path.</param>
 /// <param name="canSelect">A value indicating whether the path can be selected.</param>
 /// <param name="selected">A value indicating whether the navigation path is selected.</param>
 public NavigationPathRow(NavigationPath path, bool canSelect, bool selected)
 {
     fullName = path.FullName;
     pages = path.Pages.Length.ToString();
     provider = path.Provider.Information.Name;
     this.canSelect = canSelect;
     additionalClass = selected ? " selected" : "";
 }
        /// <summary>
        /// Modifies an existing navigation path.
        /// </summary>
        /// <param name="path">The navigation path to modify.</param>
        /// <param name="pages">The new pages array.</param>
        /// <returns>The correct <see cref="T:NavigationPath"/> object.</returns>
        /// <exception cref="ArgumentNullException">If <paramref name="path"/> or <paramref name="pages"/> are <c>null</c>.</exception>
        /// <exception cref="ArgumentException">If <paramref name="pages"/> is empty.</exception>
        public NavigationPath ModifyNavigationPath(NavigationPath path, PageInfo[] pages)
        {
            if(path == null) throw new ArgumentNullException("path");
            if(pages == null) throw new ArgumentNullException("pages");
            if(pages.Length == 0) throw new ArgumentException("Pages cannot be empty");

            ICommandBuilder builder = GetCommandBuilder();
            DbConnection connection = builder.GetConnection(connString);
            DbTransaction transaction = BeginTransaction(connection);

            foreach(PageInfo page in pages) {
                if(page == null) {
                    RollbackTransaction(transaction);
                    throw new ArgumentNullException("pages");
                }
                if(GetPage(transaction, page.FullName) == null) {
                    RollbackTransaction(transaction);
                    throw new ArgumentException("Page not found", "pages");
                }
            }

            if(RemoveNavigationPath(transaction, path)) {
                string nspace, name;
                NameTools.ExpandFullName(path.FullName, out nspace, out name);
                if(nspace == null) nspace = "";

                NavigationPath result = AddNavigationPath(transaction, nspace, name, pages);

                if(result != null) {
                    CommitTransaction(transaction);
                    return result;
                }
                else {
                    RollbackTransaction(transaction);
                    return null;
                }
            }
            else {
                RollbackTransaction(transaction);
                return null;
            }
        }
Exemplo n.º 39
0
        /// <summary>
        /// Prepares the previous and next pages link for navigation paths.
        /// </summary>
        /// <param name="previousPageLink">The previous page link.</param>
        /// <param name="nextPageLink">The next page link.</param>
        private void SetupAdjacentPages()
        {
            StringBuilder prev = new StringBuilder(50), next = new StringBuilder(50);

            if (Request["NavPath"] != null)
            {
                NavigationPath path = NavigationPaths.Find(Request["NavPath"]);

                if (path != null)
                {
                    int idx = Array.IndexOf(path.Pages, currentPage.FullName);
                    if (idx != -1)
                    {
                        if (idx > 0)
                        {
                            PageInfo prevPage = Pages.FindPage(path.Pages[idx - 1]);
                            prev.Append(@"<a href=""");
                            UrlTools.BuildUrl(prev, "Default.aspx?Page=", Tools.UrlEncode(prevPage.FullName),
                                              "&amp;NavPath=", Tools.UrlEncode(path.FullName));

                            prev.Append(@""" title=""");
                            prev.Append(Properties.Messages.PrevPage);
                            prev.Append(": ");
                            prev.Append(FormattingPipeline.PrepareTitle(Content.GetPageContent(prevPage, true).Title, false, FormattingContext.PageContent, currentPage));
                            prev.Append(@"""><b>&laquo;</b></a> ");
                        }
                        if (idx < path.Pages.Length - 1)
                        {
                            PageInfo nextPage = Pages.FindPage(path.Pages[idx + 1]);
                            next.Append(@" <a href=""");
                            UrlTools.BuildUrl(next, "Default.aspx?Page=", Tools.UrlEncode(nextPage.FullName),
                                              "&amp;NavPath=", Tools.UrlEncode(path.FullName));

                            next.Append(@""" title=""");
                            next.Append(Properties.Messages.NextPage);
                            next.Append(": ");
                            next.Append(FormattingPipeline.PrepareTitle(Content.GetPageContent(nextPage, true).Title, false, FormattingContext.PageContent, currentPage));
                            next.Append(@"""><b>&raquo;</b></a>");
                        }
                    }
                }
            }

            if (prev.Length > 0)
            {
                lblPreviousPage.Text = prev.ToString();
            }
            else
            {
                lblPreviousPage.Visible = false;
            }

            if (next.Length > 0)
            {
                lblNextPage.Text = next.ToString();
            }
            else
            {
                lblNextPage.Visible = false;
            }
        }
Exemplo n.º 40
0
 public PathRenderer()
 {
     navPath = new NavigationPath[2];
 }