private VarItem ImportVar(IBranch varBranch, bool native)
        {
            // protect ourselves from recursion
            if (varBranch == FormulaBeingEdited)
            {
                return null;
            }
            else
            {
                Func<String, String> attr = s => varBranch.GetValue(s) == null ? "" : varBranch.GetValue(s).ContentString;
                _varNames.Add(varBranch.VPath, attr("name"));
                _varTypes.Add(varBranch.VPath, attr("type"));
                var @newitem = new VarItem(varBranch, _varNames[varBranch.VPath], varBranch.VPath.ToElfIdentifier());

                if (native)
                {
                    _native.Add(@newitem);
                }
                else
                {
                    if (new VariableExpression(@newitem.InternalName).PieType() == PieType.Var)
                    {
                        _externalVars.Add(@newitem);
                    }
                    else
                    {
                        _externalNodes.Add(@newitem);
                    }
                }

                return @newitem;
            }
        }
        public TillerIntegrationContext(IBranch common, IBranch activeParticle, Func<IBranch> branchSelector, Func<IBranch> nodeSelector)
        {
            Common = common;
            FormulaBeingEdited = activeParticle;
            BranchSelector = branchSelector;
            NodeSelector = nodeSelector;

            var svds = Enumerable.Empty<IBranch>();
            if (FormulaBeingEdited != null)
            {
                var particle = FormulaBeingEdited.Parent.Parent;
                var partDecl = particle.GetBranches().SingleOrDefault(b => b.Name == "_sourceValueDeclarations");
                var partFlae = particle.GetBranches().SingleOrDefault(b => b.Name == "_formulaDeclarations");

                if (partFlae != null) svds = partFlae.AsArray().Concat(svds);
                if (partDecl != null) svds = partDecl.AsArray().Concat(svds);
            }

            Func<IBranch, String> type = b => b.GetValue("type") == null ? null : b.GetValue("type").ContentString;
            svds.Distinct().SelectMany(svd => svd.GetBranches())
                .Where(var => var != FormulaBeingEdited && type(var) != "text" && type(var) != "string")
                .ForEach(var => ImportVar(var));

            var elf = activeParticle.GetValue("elfCode") == null ? null : activeParticle.GetValue("elfCode").ContentString;
            if (elf != null) elf.RenderLightElfAsPublicText(this); // as a side effect this will fill in the externals
        }
Example #3
0
        public override void DoImpl()
        {
            Func<int, String> namegen = i => i == 1 ? BranchInClipboard.Name : String.Format(
                Resources.New_BranchDefaultPastedName, BranchInClipboard.Name, i - 1);
            var lastUsedIndex = 1.Seq(i => i + 1, i => Branch.GetBranches().Any(b => b.Name == namegen(i))).LastOrDefault();
            var unusedName = namegen(lastUsedIndex + 1);

#if DOWNGRADE_STRUCTURE_VERSION_TO_REV299
            // one can't use SetDefault() here, because the default value will be copied
            // from the clipboard rather than created manually
            CreatedBranch = Branch.CreateBranch(unusedName).SetId(Guid.NewGuid());
#else
            // upd. safe to use SetDefault2 because branches no longer have default values
            CreatedBranch = Branch.CreateBranch(unusedName).SetDefault2();
#endif

            // the line below works fine only because the branch in clipboard is actually a clone that is disconnected from reality. 
            // only imagine what if you press Ctrl+C on a branch w/o sub-branches for simplicity and then sequentially press Ctrl+V
            // 1st paste will actually work fine and create a sub-branch w/o no sub-branches and the same values as the source branch had
            // 2nd paste will use THE CHANGED source branch and will created a sub-sub-branch with a single sub-branch (which is counter-intuitive)

            var branches = BranchInClipboard.GetBranchesRecursive();
            branches.ForEach(b => CreatedBranch.GetOrCreateBranch(b.VPath - BranchInClipboard.VPath));
            BranchInClipboard.GetValuesRecursive().ForEach(v => CreatedBranch
                .CreateValue(v.VPath - BranchInClipboard.VPath, () => v.ContentStream)
                .SetDefault2().SetTypeToken2(v.GetTypeToken2()));

            Tree.SelectedNode = Tree.Nodes[0].SelectNode(Branch.VPath);
            Tree.SelectedNode = Ctx.CreateTreeNodesRecursive(Tree.SelectedNode, CreatedBranch);
        }
Example #4
0
        public static void SetOrderForBranch(INetwork network, IBranch branch)
        {
            // node is new if it is exclusive to branch
            var connectionsFromNodeCount = branch.Source.IncomingBranches.Count + branch.Source.OutgoingBranches.Count;
            var connectionsToNodeCount = branch.Target.IncomingBranches.Count + branch.Target.OutgoingBranches.Count;
            if (connectionsFromNodeCount == 1 && connectionsToNodeCount == 1)
            {
                // new branch, not connected (do not assign -1 since user might have assigned it when constructing object)
                return;
            }

            if(connectionsFromNodeCount > 2 || connectionsToNodeCount > 2)
            {
                branch.OrderNumber = -1;
                return;
            }
            if (connectionsFromNodeCount == 1 && connectionsToNodeCount == 2)
            {
                branch.OrderNumber = ComputeMaximumOrderForNode(network, branch.Target);
                return;
            }
            if (connectionsFromNodeCount == 2 && connectionsToNodeCount == 1)
            {
                branch.OrderNumber = ComputeMaximumOrderForNode(network, branch.Source);
                return;
            }
        }
Example #5
0
        public ScenarionBrowser(BrowserMode mode, ScenarioDepot scenario, IBranch initialSelection, IBranch formulaBeingEdited)
        {
            InitializeComponent();

            Mode = mode;
            Text = mode == BrowserMode.SelectNode ? Resources.ScenarionBrowser_SelectNode : Resources.ScenarionBrowser_SelectBranch;

            Scenario = scenario;
            InitialSelection = initialSelection;
            FormulaBeingEdited = formulaBeingEdited;

						foreach (ScenarioNode root in Scenario)
						{
							LoadBranch(root, null);
						}


            var allNodes = treeScenario.Nodes.Cast<TreeNode>()
                .SelectMany(tn => tn.Flatten(n => n.Nodes.Cast<TreeNode>()));
            treeScenario.SelectedNode = allNodes.FirstOrDefault(n => n.Tag == initialSelection);

            tabControlBranchOptions.Visible = false;
            _emptySelectionTipRtb.Visible = true;
            splitContainer1.Panel2.Padding = new Padding(5, 5, 5, 5);
            ResyncOkAvailability();
        }
Example #6
0
        public NetworkLocation(IBranch branch, double offset)
        {
            Branch = branch;
            Offset = offset;
            

            
        }
 /// <summary>
 ///     One or more items in the branch have changed
 /// </summary>
 /// <param name="changes">The fields that have changed</param>
 /// <param name="branch">The branch that has changed</param>
 /// <param name="startRow">The first index in the branch that changed</param>
 /// <param name="column">The column to update, or -1 for all columns</param>
 /// <param name="count">The number of items changed</param>
 public DisplayDataChangedData(VirtualTreeDisplayDataChanges changes, IBranch branch, int startRow, int column, int count)
 {
     myChanges = changes;
     myBranch = branch;
     myStartRow = startRow;
     myColumn = column;
     myCount = count;
 }
 /// <summary>
 ///     All items in the branch have changed
 /// </summary>
 /// <param name="branch">The branch to modify</param>
 public DisplayDataChangedData(IBranch branch)
 {
     myChanges = VirtualTreeDisplayDataChanges.VisibleElements;
     myBranch = branch;
     myStartRow = -1;
     myColumn = -1;
     myCount = 0;
 }
 internal VirtualTreeItemInfo(IBranch branch, int row, int column, int level)
 {
     myBranch = branch;
     myColumn = column;
     myRow = row;
     myLevel = level;
     myFlags = 0;
 }
Example #10
0
 public NetworkLocation(IBranch branch, double offset)
 {
     Branch = branch;
     Chainage = offset;
     
     var branchName = (branch != null ? branch.Name : "");
     Name = String.Format(CultureInfo.InvariantCulture, "{0}_{1:0.000}", branchName, offset);
 }
Example #11
0
 protected virtual IBranch Visit(IVault copyCat, IBranch branch)
 {
     var copy = copyCat.GetOrCreateBranch(branch.VPath);
     copy.SetEntireMetadata(branch.Metadata);
     branch.GetBranches().ForEach(b => Visit(copyCat, b));
     ((Branch)branch).GetValues(ValueKind.Regular).ForEach(v => Visit(copyCat, (IValue)v));
     ((Branch)branch).GetValues(ValueKind.Internal).ForEach(v => VisitInternal(copyCat, v));
     return copy;
 }
Example #12
0
 public static XmlBranchDto FromBranch(IBranch branch)
 {
     return new XmlBranchDto 
     {
         Name = branch.Name,
         Metadata = ((Branch)branch).Metadata.Raw,
         Values = ((Branch)branch).GetValues(ValueKind.RegularAndInternal).Select(v => XmlValueDto.FromValue(v)).ToArray(),
         Branches = branch.GetBranches().Select(b => XmlBranchDto.FromBranch(b)).ToArray(),
     };
 }
Example #13
0
 public int CompareTo(IBranch other)
 {
     if (this == other)
     {
         return 0;
     }
     if (Network.Branches.IndexOf(this) > Network.Branches.IndexOf(other))
     {
         return 1;
     }
     return -1;
 }
Example #14
0
 public object Eval(IBranch b)
 {
     if (Scenario != null)
     {
         var esath = Scenario.AssertNotNull().Eval(b.VPath);
         return esath.GetType().GetProperty("Val").GetValue(esath, null);
     }
     else
     {
         return Eval2.AssertNotNull().Eval(b);
     }
 }
Example #15
0
        public override void DoImpl()
        {
            Func<int, String> namegen = i => String.Format(Resources.New_BranchDefaultName, i);
            var lastUsedIndex = 1.Seq(i => i + 1, i => Branch.GetBranches().Any(b => b.Name == namegen(i))).LastOrDefault();
            var unusedName = namegen(lastUsedIndex + 1);

            CreatedBranch = Branch.CreateBranch(unusedName).SetDefault2();

            Tree.SelectedNode = Tree.Nodes[0].SelectNode(Branch.VPath);
            var tn = CreatedBranch.AsUIElement();
            Tree.SelectedNode.Nodes.Add(tn);

            Tree.SelectedNode = tn;
            tn.BeginEdit();
        }
Example #16
0
				public override void DoImpl()
        {
            Func<int, String> namegen = i => String.Format(Resources.New_BranchDefaultName, i);
            var lastUsedIndex = 1.Seq(i => i + 1, i => Branch.GetBranches().Any(b => b.Name == namegen(i))).LastOrDefault();
            var unusedName = namegen(lastUsedIndex + 1);
            CreatedBranch = Branch.CreateBranch(unusedName).SetDefault2();
            CreatedBranch.Delete();

            try
            {
                for (var i = 0; i < ExcelRange.Rows.Length; i++)
                {
                    var row = ExcelRange.Rows[i];
                    var rowBranch = CreatedBranch.CreateBranch(row).SetDefault2();

                    for (var j = 0; j < ExcelRange.Data[i].Length; j++)
                    {
                        var col = ExcelRange.Columns[j];
                        var data = ExcelRange.Data[i][j];

                        var v = rowBranch.CreateValue(col, data).SetDefault2();
                        v.SetTypeToken2(ExcelRange.ColumnTypes[j].TypeToken);

                        // validate the data format
                        var aux = ContentTypes.ApplyCType(v).Value;
                    }
                }
            }
            catch(ArgumentException aex)
            {
                if (aex.Message.StartsWith("VPath"))
                {
                    var match = Regex.Match(aex.Message, 
                        @"VPath '(?<name>.*?)' is of invalid format \(expected '.*?'\)");

                    match.Success.AssertTrue();
                    throw new ValidationException(Resources.Validation_InvalidName, match.Result("${name}"));
                }
            }

            Branch.AttachBranch(CreatedBranch);
            Tree.SelectedNode = Tree.Nodes[0].SelectNode(Branch.VPath);
            var tn = Ctx.CreateTreeNodesRecursive(Tree.SelectedNode, CreatedBranch);

            Tree.SelectedNode = tn;
            tn.Expand();
            tn.BeginEdit();
        }
        public void Intialize()
        {
            var masterRemote = new Mock<LibGit2Sharp.Branch>();
            masterRemote.SetupGet(git => git.Tip).Returns(new Mock<LibGit2Sharp.Commit>().Object);
            masterRemote.SetupGet(git => git.FriendlyName).Returns("master");

            _initialBranch = new Branch("master", "refs/Heads/master", false, true, masterRemote.Object);

            var incoming = new List<ICommit> { new Commit("b9001d22", "Christopher J. McClellan", "Fixed the bazzle.") };
            var outgoing = new List<ICommit> { new Commit("6129ebf7", "Mathieu Guindon", "Grammar fix.") };

            _provider = new Mock<ISourceControlProvider>();
            _provider.SetupGet(git => git.CurrentBranch).Returns(_initialBranch);
            _provider.SetupGet(git => git.UnsyncedRemoteCommits).Returns(incoming);
            _provider.SetupGet(git => git.UnsyncedLocalCommits).Returns(outgoing);
        }
Example #18
0
        public IObservable<IPullRequestModel> CreatePullRequest(IRepositoryHost host,
            ILocalRepositoryModel sourceRepository, IRepositoryModel targetRepository,
            IBranch sourceBranch, IBranch targetBranch,
            string title, string body
        )
        {
            Extensions.Guard.ArgumentNotNull(host, nameof(host));
            Extensions.Guard.ArgumentNotNull(sourceRepository, nameof(sourceRepository));
            Extensions.Guard.ArgumentNotNull(targetRepository, nameof(targetRepository));
            Extensions.Guard.ArgumentNotNull(sourceBranch, nameof(sourceBranch));
            Extensions.Guard.ArgumentNotNull(targetBranch, nameof(targetBranch));
            Extensions.Guard.ArgumentNotNull(title, nameof(title));
            Extensions.Guard.ArgumentNotNull(body, nameof(body));

            return PushAndCreatePR(host, sourceRepository, targetRepository, sourceBranch, targetBranch, title, body).ToObservable();
        }
Example #19
0
        private static Expression ExpandRhs(IBranch b, IVault repository, List<Expression> stack, Dictionary<String, IBranch> nodes)
        {
            var elf = b.GetValue("elfCode").ContentString.ToCanonicalElf();
            var script = (Script)new ElfAstBuilder(elf).BuildAst();
            var assign = (AssignmentExpression)((ExpressionStatement)
                script.Classes.Single().Funcs.Single().Body.Statements.Single()).Expression;

            var rhs = assign.Expression;
            if (stack.Contains(rhs))
            {
                throw new EvalStackOverflowException();
            }
            else
            {
                stack.Add(rhs);
                return Expand(rhs, b.Vault, repository, stack, nodes);
            }
        }
        public void Intialize()
        {
            _initialBranch = new Branch("master", "refs/Heads/master", false, true);

            var incoming = new List<ICommit>() { new Commit("b9001d22", "Christopher J. McClellan", "Fixed the bazzle.") };
            var outgoing = new List<ICommit>() { new Commit("6129ebf7", "Mathieu Guindon", "Grammar fix.") };

            _provider = new Mock<ISourceControlProvider>();
            _provider.SetupGet(git => git.CurrentBranch).Returns(_initialBranch);
            _provider.SetupGet(git => git.UnsyncedRemoteCommits).Returns(incoming);
            _provider.SetupGet(git => git.UnsyncedLocalCommits).Returns(outgoing);

            _view = new Mock<IUnsyncedCommitsView>();
            _view.SetupProperty(v => v.CurrentBranch, String.Empty);
            _view.SetupProperty(v => v.IncomingCommits);
            _view.SetupProperty(v => v.OutgoingCommits);

            _presenter = new UnsyncedCommitsPresenter(_view.Object) { Provider = _provider.Object };
        }
        internal AggregateBranch(IList branchList, int primaryBranchIndex)
        {
            if (branchList == null)
            {
                throw new ArgumentNullException("branchList");
            }

            _primaryBranch = (IBranch)branchList[primaryBranchIndex];

            _branchList = new ArrayList(branchList.Count);
            foreach (var obj in branchList)
            {
                var branch = obj as IBranch;
                if (branch != null)
                {
                    _branchList.Add(branch);
                    branch.OnBranchModification += OnInnerBranchModification;
                }
                else
                {
                    throw new ArgumentException("branchList");
                }
            }
        }
 public void UpdateWith(IBranch branch)
 {
     // Do nothing
 }
 public bool Exists(IBranch branch, out TBranch dataModel)
 {
     dataModel = GetBranch(branch.BranchId, branch.Type);
     return(dataModel != null);
 }
 internal ExpandedBranchData(IBranch branch, int level)
 {
     myBranch = branch;
     myLevel  = level;
 }
        private IEnumerable <BaseVersion> GetReleaseVersion(GitVersionContext context, IBranch releaseBranch)
        {
            var tagPrefixRegex = context.Configuration.GitTagPrefix;

            // Find the commit where the child branch was created.
            var baseSource = repositoryMetadataProvider.FindMergeBase(releaseBranch, context.CurrentBranch);

            if (Equals(baseSource, context.CurrentCommit))
            {
                // Ignore the branch if it has no commits.
                return(new BaseVersion[0]);
            }

            return(releaseVersionStrategy
                   .GetVersions(tagPrefixRegex, releaseBranch)
                   .Select(b => new BaseVersion(b.Source, true, b.SemanticVersion, baseSource, b.BranchNameOverride)));
        }
Example #26
0
        /// <summary>
        /// Splits a branch at the given node and connect resulting 2 branches to the node.
        /// All related branch features are moved to the corresponding branch based on their geometry.
        /// </summary>
        /// <param name="network"></param>
        /// <param name="branch"></param>
        /// <param name="node"></param>
        public static IBranch SplitBranchAtNode(INetwork network, IBranch branch, INode node)
        {
            var originalFirstBranchGeometryLength = branch.Geometry.Length;

            var    lengthIndexedLine         = new LengthIndexedLine(branch.Geometry);
            double firstBranchGeometryLength = lengthIndexedLine.IndexOf(node.Geometry.Coordinates[0]);

            // compute geometries
            IGeometry firstBranchGeometry = (IGeometry)lengthIndexedLine.ExtractLine(0.0, firstBranchGeometryLength).Clone();

            if (firstBranchGeometry == GeometryCollection.Empty)
            {
                throw new ArgumentException(String.Format("Node {0} not located at line; unable to split branch {1}",
                                                          node.Id, branch.Id));
            }

            IGeometry secondBranchGeometry = (IGeometry)lengthIndexedLine.ExtractLine(firstBranchGeometryLength, originalFirstBranchGeometryLength).Clone();

            if (secondBranchGeometry == GeometryCollection.Empty)
            {
                throw new ArgumentException(String.Format("Node {0} not located at line; unable to split branch {1}",
                                                          node.Id, branch.Id));
            }

            if (secondBranchGeometry.Coordinates.Count() == 0 || firstBranchGeometry.Coordinates.Count() == 0 ||
                firstBranchGeometry.Length == 0.0 || secondBranchGeometry.Length == 0.0)
            {
                return(null); // nothing to split
            }

            // update existing branch
            var toNode = branch.Target;

            branch.Target = node;

            // create and add second branch
            var fraction = firstBranchGeometryLength / originalFirstBranchGeometryLength;

            var secondBranch = (IBranch)Activator.CreateInstance(branch.GetType());

            secondBranch.Name           = GetUniqueName(null, branch.Network.Branches, "branch");
            secondBranch.Source         = node;
            secondBranch.Target         = toNode;
            secondBranch.Geometry       = secondBranchGeometry;
            secondBranch.IsLengthCustom = branch.IsLengthCustom;
            secondBranch.Attributes     = branch.Attributes == null ? null : (IFeatureAttributeCollection)branch.Attributes.Clone();
            network.Branches.Add(secondBranch);

            branch.Geometry = firstBranchGeometry;

            // only update length of branch if it is not same as geometry.
            var originalLength = branch.Length;

            if (branch.IsLengthCustom)
            {
                branch.Length       = originalLength * fraction;
                secondBranch.Length = originalLength * (1 - fraction);
            }
            else
            {
                branch.Length       = branch.Geometry.Length;
                secondBranch.Length = secondBranch.Geometry.Length;
            }

            // adjust last segment of the first branch (+center, boundary)
            // SplitBranchSegments(node, firstBranch, secondBranch, originalFirstBranchGeometryLength);

            // remember all branch features to be moved to the second branch
            IBranchFeature[] branchFeatureToMove = branch.BranchFeatures.Where(bf => bf.Offset >= firstBranchGeometryLength).ToArray();

            // move all features from first branch to the second branch
            foreach (var branchFeature in branchFeatureToMove)
            {
                branch.BranchFeatures.Remove(branchFeature);
                branchFeature.Offset -= branch.Length;
                AddBranchFeatureToBranch(secondBranch, branchFeature, branchFeature.Offset);
                //secondBranch.BranchFeatures.Add(branchFeature);
                //branchFeature.Offset -= branch.Length;
            }

            return(secondBranch);
        }
 /// <summary>
 ///     Delete specific items without calling Realign
 /// </summary>
 /// <param name="branch">The branch where items have been removed</param>
 /// <param name="start">The first item to deleted</param>
 /// <param name="count">The number of items to delete</param>
 /// <returns>An events args object for IBranch.OnBranchModification</returns>
 public static BranchModificationEventArgs DeleteItems(IBranch branch, int start, int count)
 {
     return new BranchModificationMost(BranchModificationAction.DeleteItems, branch, start, count);
 }
Example #28
0
 public TagInfo(ITag tag, INode node, IBranch branch)
 {
     Tag              = tag;
     Node             = node;
     ContainingBranch = branch;
 }
Example #29
0
 public BranchGroupNode(IBranch branch)
 {
     Branch = branch;
 }
Example #30
0
 public HomeScreenBranch(IBranch branch) : base(branch)
 {
 }
Example #31
0
 public static void AddBranchFeatureToBranch(IBranch branch, IBranchFeature branchFeature, double offset)
 {
     branchFeature.Branch = branch;
     branchFeature.Offset = offset;
     branch.BranchFeatures.Add(branchFeature);
 }
Example #32
0
        public static IEnumerable <INetworkSegment> GenerateSegmentsPerLocation(IEnumerable <INetworkLocation> branchLocations, IBranch branch)
        {
            var segments = new List <INetworkSegment>();

            IList <INetworkLocation> bl = branchLocations.ToList();

            if (bl.Count == 1)
            {
                segments.Add(CreateSegment(branch, 0, branch.Length));
            }
            else
            {
                for (int i = 0; i < bl.Count; i++)
                {
                    double startOffset;
                    double endOffset;

                    if (0 == i)
                    {
                        startOffset = 0;
                        endOffset   = bl[i].Offset + (bl[i + 1].Offset - bl[i].Offset) / 2;
                    }
                    else if ((bl.Count - 1) == i)
                    {
                        startOffset = bl[i].Offset - (bl[i].Offset - bl[i - 1].Offset) / 2;
                        endOffset   = branch.Length;
                    }
                    else
                    {
                        startOffset = bl[i].Offset - (bl[i].Offset - bl[i - 1].Offset) / 2;
                        endOffset   = bl[i].Offset + (bl[i + 1].Offset - bl[i].Offset) / 2;
                    }
                    segments.Add(CreateSegment(branch, startOffset, endOffset));
                }
            }

            //foreach (var networkLocation in branchLocations)
            //{
            //    double endOffset;

            //    if (networkLocation == branchLocations.Last())
            //    {
            //        endOffset = branch.Length;
            //    }
            //    else
            //    {
            //        endOffset = networkLocation.Offset + (branchLocations.First().Offset - networkLocation.Offset) / 2;
            //    }

            //    segments.Add(CreateSegment(branch, startOffset, endOffset));
            //    startOffset = endOffset;
            //}

            return(segments);
        }
Example #33
0
        public static IEnumerable <INetworkSegment> GenerateSegmentsBetweenLocations(IEnumerable <INetworkLocation> branchLocations, IBranch branch, bool skipFirst, bool skipLast)
        {
            var segments = new List <INetworkSegment>();

            if (branchLocations.Count() > 1)
            {
                double startOffset;
                double endOffset;

                // first segment
                if (!skipFirst)
                {
                    var networkLocation = branchLocations.First();
                    startOffset = 0;
                    endOffset   = networkLocation.Offset;
                    segments.Add(CreateSegment(branch, startOffset, endOffset));
                }

                // segments in-between
                startOffset = branchLocations.First().Offset;
                foreach (var networkLocation in branchLocations.Skip(1))
                {
                    endOffset = networkLocation.Offset;
                    segments.Add(CreateSegment(branch, startOffset, endOffset));
                    startOffset = endOffset;
                }

                // last segment
                if (!skipLast)
                {
                    var networkLocation = branchLocations.Last();
                    startOffset = networkLocation.Offset;
                    endOffset   = branch.Length;
                    segments.Add(CreateSegment(branch, startOffset, endOffset));
                }
            }

            return(segments);
        }
 /// <summary>
 ///     A mechanism for changing a cell from simple or expandable
 ///     to complex, or vice versa. This enables a potentially
 ///     complex cell to begin life as a simple cell, then switch later.
 ///     The makeComplex variable is interpreted according to the
 ///     cell style settings for the given branch.
 /// </summary>
 /// <param name="branch">The branch to modify</param>
 /// <param name="row">Target row</param>
 /// <param name="column">Target column</param>
 /// <param name="makeComplex">True to switch to a complex cell, false to switch to a simple cell</param>
 /// <returns>An events args object for IBranch.OnBranchModification</returns>
 public static BranchModificationEventArgs UpdateCellStyle(IBranch branch, int row, int column, bool makeComplex)
 {
     return new BranchModificationMost(BranchModificationAction.UpdateCellStyle, branch, row, column, makeComplex);
 }
Example #35
0
 public GOUIBranch(IBranch branch) : base(branch)
 {
 }
 /// <summary>
 /// Clears this instance.
 /// </summary>
 public void Clear()
 {
     this.Label = -1;
     this.Offset = 0;
     this.Instruction = null;
     this.Operand1 = null;
     this.Operand2 = null;
     this.Operand3 = null;
     this.Result = null;
     this._packed = 0;
     this.Branch = null;
     this.Other = null;
     this.BranchHint = false;
 }
Example #37
0
        public IObservable <IPullRequestModel> CreatePullRequest(ILocalRepositoryModel sourceRepository, IRepositoryModel targetRepository,
                                                                 IBranch sourceBranch, IBranch targetBranch,
                                                                 string title, string body)
        {
            var keyobs = GetUserFromCache()
                         .Select(user => string.Format(CultureInfo.InvariantCulture, "{0}|{1}:{2}", CacheIndex.PRPrefix, targetRepository.Owner, targetRepository.Name));

            return(Observable.Defer(() => keyobs
                                    .SelectMany(key =>
                                                hostCache.PutAndUpdateIndex(key, () =>
                                                                            apiClient.CreatePullRequest(
                                                                                new NewPullRequest(title,
                                                                                                   string.Format(CultureInfo.InvariantCulture, "{0}:{1}", sourceRepository.Owner, sourceBranch.Name),
                                                                                                   targetBranch.Name)
            {
                Body = body
            },
                                                                                targetRepository.Owner,
                                                                                targetRepository.Name)
                                                                            .Select(PullRequestCacheItem.Create)
                                                                            ,
                                                                            TimeSpan.FromMinutes(30))
                                                )
                                    .Select(Create)
                                    ));
        }
 /// <summary>
 ///     Create a new child branch.
 /// </summary>
 internal ChildBranchInfo(IBranch branch, string name, object id)
 {
     _branch = branch;
     _name = name;
     _id = id;
 }
Example #39
0
 protected CultureAwareContentTypeAppliedToValue(IBranch parent)
     : base(parent)
 {
 }
Example #40
0
 bool IEquatable <IBranch> .Equals(IBranch other) => false;
 public bool ContainsEdge(IBranch edge)
 {
     throw new NotImplementedException();
 }
Example #42
0
 public static IBranch[] ParentsAndI(this IBranch branch)
 {
     return(((IElement)branch).ParentsAndI().Cast <IBranch>().ToArray());
 }
Example #43
0
        //INetworkCoverage coverage,
        private static IEnumerable <INetworkSegment> UpdateSegmentsBranchSegmentBetweenLocations(bool fullyCover,
                                                                                                 IBranch branch, IEnumerable <INetworkLocation> branchLocations)
        {
            var segments = new List <INetworkSegment>();

            var length = branch.Length;

            // select all locations that have an offset within the branch
            var            factor  = 1.0;// branch.IsLengthCustom ? (branch.Geometry.Length / branch.Length) : 1.0;
            IList <double> offsets = branchLocations.Where(l => l.Offset <= length).Select(l => factor * l.Offset).ToList();

            if (0 == offsets.Count)
            {
                if (fullyCover)
                {
                    offsets.Add(0);
                    offsets.Add(length);
                }
                else
                {
                    return(segments);
                }
            }
            else
            {
                if (fullyCover)
                {
                    if (Math.Abs(offsets[0]) > 1.0e-6)
                    {
                        offsets.Insert(0, 0.0);
                    }
                    if (Math.Abs(offsets[offsets.Count - 1] - length) > 1.0e-6)
                    {
                        offsets.Add(length);
                    }
                }
            }

            var lengthIndexedLine = new LengthIndexedLine(branch.Geometry);

            for (int i = 1; i < offsets.Count; i++)
            {
                var segment = new NetworkSegment
                {
                    Branch = branch,
                    Offset = offsets[i - 1],
                    Length = Math.Abs(offsets[i] - offsets[i - 1]),
                    DirectionIsPositive = offsets[i] >= offsets[i - 1],
                    // thousand bombs and grenades: ExtractLine will give either a new coordinate or
                    // a reference to an existing object
                    Geometry = (IGeometry)lengthIndexedLine.ExtractLine(offsets[i - 1], offsets[i]).Clone()
                };
                segments.Add(segment);
                //coverage.Segments.Values.Add(segment);
            }
            return(segments);
        }
Example #44
0
 public static bool IsIndirectChildOf(this IElement element, IBranch branch)
 {
     return(element.Parents().Contains(branch));
 }
Example #45
0
 public bool Equals(IBranch other)
 {
     return(ReferenceEquals(this, other));
 }
Example #46
0
 public static IValue CreateValue(this IBranch branch, VPath vpath, String content)
 {
     return(branch.CreateValue(vpath, content.AsLazyStream()));
 }
Example #47
0
 public void UpdateWith(IBranch branch)
 {
     // Dummy implementation
 }
Example #48
0
 /// <summary>
 ///     IBranch interface implementation.
 /// </summary>
 public StateRefreshChanges SynchronizeState(int row, int column, IBranch matchBranch, int matchRow, int matchColumn)
 {
     // UNDONE: Do something here to support synchronizing multiselect checkbox states
     return(StateRefreshChanges.None);
 }
Example #49
0
 StateRefreshChanges IBranch.SynchronizeState(int row, int column, IBranch matchBranch, int matchRow, int matchColumn)
 {
     return(StateRefreshChanges.None);
 }
Example #50
0
        /// <summary>
        /// Gets or creates a new node on the branch by splitting the branch
        /// </summary>
        private static INode GetOrCreateNodeOnBranch(double offset, IBranchFeature node, IBranch branch)
        {
            var splitNode = SplitBranchAtNode(branch, offset);

            if (null != splitNode)
            {
                splitNode.Name = node.ToString();
            }
            else
            {
                //no split so it must be the end or the start of the node
                //find out if it was start or end using geometry of the startNode
                splitNode = (branch.Source.Geometry.Equals(node.Geometry)) ? branch.Source : branch.Target;
            }
            splitNode.Attributes["OriginalFeature"] = node;
            return(splitNode);
        }
 /// <summary>
 ///     Use to insert items without forcing a realign. InsertItems should be used
 ///     to adjust an existing branch: do not add a node with no children then immediately
 ///     call InsertItems repeatedly to add children. The branches VisibleItemCount is
 ///     assumed to be adjusted for the new items before a call to InsertItems. If the
 ///     items are inserted at the end of the visible portion of the branch, then
 ///     VisibleItemCount will be used to determine if the new items are hidden or visible.
 /// </summary>
 /// <param name="branch">The branch where items have been inserted.</param>
 /// <param name="after">The index to insert after. Use -1 to insert at the beginning</param>
 /// <param name="count">The number of items that have been inserted.</param>
 /// <returns>An events args object for IBranch.OnBranchModification</returns>
 public static BranchModificationEventArgs InsertItems(IBranch branch, int after, int count)
 {
     return new BranchModificationMost(BranchModificationAction.InsertItems, branch, after, count);
 }
Example #52
0
 private bool HasAResolvePopUpToRemove(IBranch popUpToRemove)
 => !NoActiveResolvePopUps && _activeResolvePopUps.Contains(popUpToRemove);
 /// <summary>
 ///     Change the position of a single item in a branch
 /// </summary>
 /// <param name="branch">The branch where the item moved</param>
 /// <param name="fromRow">The row the item used to be on</param>
 /// <param name="toRow">The row the item is on now</param>
 /// <returns>An events args object for IBranch.OnBranchModification</returns>
 public static BranchModificationEventArgs MoveItem(IBranch branch, int fromRow, int toRow)
 {
     return new BranchModificationMost(BranchModificationAction.MoveItem, branch, fromRow, toRow);
 }
Example #54
0
 private bool HasAOptionalPopUpToRemove(IBranch popUpToRemove)
 => !NoActiveOptionalPopUps && _activeOptionalPopUps.Contains(popUpToRemove);
 /// <summary>
 ///     Remove all occurrences of branch from the tree. Note that removing all
 ///     items from a branch is not the same as removing the branch itself.
 /// </summary>
 /// <param name="branch">The branch to remove</param>
 /// <returns>An events args object for IBranch.OnBranchModification</returns>
 public static BranchModificationEventArgs RemoveBranch(IBranch branch)
 {
     return new BranchModificationMost(BranchModificationAction.RemoveBranch, branch);
 }
Example #56
0
        public void update(IBranch branch)
        {
            if ((branch.taken() != prediction) || (Math.Abs(sum) <= threshold))
            {
                for (int i = 0; i < numberOfTables; i++)
                {
                    if (branch.taken())
                    {
                        if (weights[i, tableHash[i]] < counterMax)
                        {
                            weights[i, tableHash[i]]++;
                        }
                    }
                    else
                    {
                        if (weights[i, tableHash[i]] > counterMin)
                        {
                            weights[i, tableHash[i]]--;
                        }
                    }
                }
            }

            if (adaptThresold)
            {
                if (branch.taken() != prediction)
                {
                    thresholdAdaptCount++;
                    if (thresholdAdaptCount == thresholdAdaptCountMax)
                    {
                        thresholdAdaptCount = 0;
                        threshold++;
                    }
                }
                else
                {
                    if (Math.Abs(sum) <= threshold)
                    {
                        thresholdAdaptCount--;
                        if (thresholdAdaptCount == thresholdAdaptCountMin)
                        {
                            thresholdAdaptCount = 0;
                            threshold--;
                        }
                    }
                }
            }

            // shift global history
            for (int i = globalHistoryLength - 1; i > 0; i--)
            {
                globalHistory[i] = globalHistory[i - 1];
            }

            if (branch.taken())
            {
                globalHistory[0] = 1;
            }
            else
            {
                globalHistory[0] = 0;
            }
        }
 /// <summary>
 /// Clears the instance.
 /// </summary>
 public void ClearAbbreviated()
 {
     this.Label = -1;
     this.Offset = 0;
     this.Instruction = null;
     this.Ignore = true;
     this.OperandCount = 0;
     this.ResultCount = 0;
     this.Branch = null;
     this.Other = null;
 }
Example #58
0
        public IObservable <IPullRequestModel> CreatePullRequest(IRepositoryHost host,
                                                                 ILocalRepositoryModel sourceRepository, IRepositoryModel targetRepository,
                                                                 IBranch sourceBranch, IBranch targetBranch,
                                                                 string title, string body
                                                                 )
        {
            Extensions.Guard.ArgumentNotNull(host, nameof(host));
            Extensions.Guard.ArgumentNotNull(sourceRepository, nameof(sourceRepository));
            Extensions.Guard.ArgumentNotNull(targetRepository, nameof(targetRepository));
            Extensions.Guard.ArgumentNotNull(sourceBranch, nameof(sourceBranch));
            Extensions.Guard.ArgumentNotNull(targetBranch, nameof(targetBranch));
            Extensions.Guard.ArgumentNotNull(title, nameof(title));
            Extensions.Guard.ArgumentNotNull(body, nameof(body));

            return(PushAndCreatePR(host, sourceRepository, targetRepository, sourceBranch, targetBranch, title, body).ToObservable());
        }
Example #59
0
 public static IContentTypeAppliedToValue ApplyCType(IBranch parentOfNewValue, String typeToken)
 {
     var ctype = typeToken.GetCTypeFromToken().AssertNotNull();
     return ctype.Apply(parentOfNewValue);
 }
Example #60
0
 public static IValue CreateValue(this IBranch branch, VPath vpath)
 {
     return(branch.CreateValue(vpath, ((String)null).AsLazyStream()));
 }