// List of branches.
 public BindingList <BranchData> BranchList()
 {
     using (SqlConnection conn = new SqlConnection(conStr))
     {
         conn.Open();
         BindingList <BranchData> list = new BindingList <BranchData>();
         string sql = "Execute BranchList";
         Console.WriteLine(sql);
         using (SqlCommand command = new SqlCommand(sql, conn))
         {
             using (SqlDataReader reader = command.ExecuteReader())
             {
                 while (reader.Read())
                 {
                     BranchData branch = new BranchData
                     {
                         BranchID   = reader.GetInt32(0),
                         BranchName = reader.GetString(1)
                     };
                     list.Add(branch);
                 }
             }
         }
         return(list);
     }
 }
Пример #2
0
        internal Branch ToBranch(StashedState stashedState, string name)
        {
            Verify.Argument.IsValidGitObject(stashedState, Repository, "stashedState");

            using (Repository.Monitor.BlockNotifications(
                       RepositoryNotifications.BranchChanged,
                       RepositoryNotifications.Checkout,
                       RepositoryNotifications.WorktreeUpdated,
                       RepositoryNotifications.IndexUpdated,
                       RepositoryNotifications.StashChanged))
            {
                Repository.Accessor.StashToBranch.Invoke(
                    new StashToBranchParameters(((IRevisionPointer)stashedState).Pointer, name));
            }

            lock (SyncRoot)
            {
                _stash.RemoveAt(stashedState.Index);
                for (int i = stashedState.Index; i < _stash.Count; ++i)
                {
                    --_stash[i].Index;
                }
                InvokeStashedStateDeleted(stashedState);
            }

            Repository.Status.Refresh();

            var branchInformation = new BranchData(name,
                                                   stashedState.Revision.Parents[0].Hash, false, true);
            var branch = Repository.Refs.Heads.NotifyCreated(branchInformation);

            Repository.Head.Pointer = branch;

            return(branch);
        }
Пример #3
0
    public void GetBranchData(List <string[]> optiondata)
    {
        int optionNumber = optiondata.Count;

        for (int i = 0; i < optionNumber; i++)
        {
            string     branchValue  = optiondata[i][0];
            int        branchNumber = int.Parse(optiondata[i][1]);
            BranchData branchData   = new BranchData(branchValue, branchNumber);
            branchDatas.Add(branchData);
        }
        for (int i = 0; i < branchDatas.Count; i++)
        {
            int jumpFrontNumber = 0;
            int jumpAfterNumber = 0;
            for (int j = 0; j < i; j++)
            {
                jumpFrontNumber += branchDatas[j].branchNumber;
            }
            for (int k = optionNumber - 1; k > i; k--)
            {
                jumpAfterNumber += branchDatas[k].branchNumber;
            }
            branchDatas[i].jumpFrontNumber = jumpFrontNumber + 1;
            branchDatas[i].jumpAfterNumber = jumpAfterNumber + 1;
        }
    }
Пример #4
0
        private void SetDAddress()
        {
            var  brn = BranchBiz.GetBranch(cmbDocBranch.SelectedValue);
            bool enb = (brn == null);

            if (brn == null)
            {
                brn = new BranchData();
            }

            txtDAddressno.Text = brn.slm_House_No;
            txtDBuilding.Text  = brn.slm_Building;
            txtDFloor.Text     = brn.slm_Village;
            txtDSoi.Text       = brn.slm_Soi;
            txtDStreet.Text    = brn.slm_Street;
            AppUtil.SetComboValue(cmbDProvince, brn.slm_ProvinceId.ToString());
            SetDAmphur();
            AppUtil.SetComboValue(cmbDAmphur, brn.slm_AmphurId.ToString());
            SetDTambol();
            AppUtil.SetComboValue(cmbDTambol, brn.slm_TambolId.ToString());
            txtDPostCode.Text = brn.slm_Zipcode;

            txtDAddressno.ReadOnly = !enb;
            txtDBuilding.ReadOnly  = !enb;
            txtDFloor.ReadOnly     = !enb;
            txtDSoi.ReadOnly       = !enb;
            txtDStreet.ReadOnly    = !enb;
            cmbDProvince.Enabled   = enb;
            cmbDAmphur.Enabled     = enb;
            cmbDTambol.Enabled     = enb;
            txtDPostCode.ReadOnly  = !enb;
        }
Пример #5
0
        /// <summary>
        ///     Creates a connection using token.
        /// </summary>
        /// <param name="companyId">Company context</param>
        /// <param name="token">The predefined token from Visma.net</param>
        /// <param name="branchId">Branch ID to work with in the Visma.net Company (optional)</param>
        public VismaNet(int companyId, string token, int branchId = 0)
        {
            if (string.IsNullOrEmpty(token))
            {
                throw new InvalidArgumentsException("Token is missing");
            }

            Auth = new VismaNetAuthorization
            {
                Token     = token,
                CompanyId = companyId,
                BranchId  = branchId
            };
            Customer           = new CustomerData(Auth);
            CustomerInvoice    = new CustomerInvoiceData(Auth);
            Supplier           = new SupplierData(Auth);
            SupplierInvoice    = new SupplierInvoiceData(Auth);
            CashSale           = new CashSaleData(Auth);
            CustomerDocument   = new CustomerDocumentData(Auth);
            Dimension          = new DimensionData(Auth);
            Inventory          = new InventoryData(Auth);
            JournalTransaction = new JournalTransactionData(Auth);
            Account            = new FinAccountData(Auth);
            Employee           = new EmployeeData(Auth);
            CreditNote         = new CreditNoteData(Auth);
            Shipment           = new ShipmentData(Auth);
            Contact            = new ContactData(Auth);
            Project            = new ProjectData(Auth);
            SalesOrder         = new SalesOrderData(Auth);
            Payment            = new PaymentData(Auth);
            Branch             = new BranchData(Auth);
            Warehouse          = new WarehouseData(Auth);
            Location           = new LocationData(Auth);
        }
Пример #6
0
        public void SaveUpdateBranch(BranchModel model)
        {
            BranchData obj;

            if (model.IsDefault)
            {
                UpdateExistDefaultBranch(model.CompanyId, model.Id.Value);
            }

            if (model.Id > 0)
            {
                obj = _branchRepository.GetCompanyBranches(model.CompanyId).FirstOrDefault(x => x.Id == model.Id);

                obj.IsActive    = model.IsActive;
                obj.Name        = model.Name;
                obj.Description = model.Description;
                obj.Address     = model.Address;
                obj.IsDefault   = model.IsDefault;
                _branchRepository.SaveUpdateBranch(obj);
            }
            else
            {
                BranchData company = new BranchData(model.Id, model.CompanyId, model.Code.Value, model.Name, model.Description, model.Address, model.IsDefault, true, DateTime.Now, model.UpdatedDate, model.ModifiedBy, model.CreatedBy);
                _branchRepository.SaveUpdateBranch(company);
            }
        }
Пример #7
0
 public SpellData saveSpellData(Transform s)
 {
     if (s.GetComponent <SpellScript>())
     {
         int spriteIndex            = 0;
         List <BranchData> branches = new List <BranchData>();
         foreach (Transform branch in s.transform)
         {
             if (branch.GetComponent <SpellBranch>())
             {
                 List <PointData> points = new List <PointData>();
                 int index = -1;
                 foreach (Transform point in branch)
                 {
                     spriteIndex = point.GetComponent <SpellPoint>().spriteIndex;
                     recursiveSaveSpellPoint(point, index, points);
                 }
                 BranchData b = new BranchData(points);
                 branches.Add(b);
             }
         }
         SpellData spellData = new SpellData(s.transform.position, branches, s.GetComponent <SpellScript>().cost, spriteIndex, spellName);
         return(spellData);
     }
     return(null);
 }
Пример #8
0
        /// <summary>Notifies that remote branch was created externally.</summary>
        /// <param name="branchData">Created remote branch data.</param>
        /// <returns>Created remote branch.</returns>
        internal RemoteBranch NotifyCreated(BranchData branchData)
        {
            var branch = ObjectFactories.CreateRemoteBranch(Repository, branchData);

            AddObject(branch);
            return(branch);
        }
Пример #9
0
        private void PopulateLibraryData()
        {
            // From https://docs.microsoft.com/en-us/dotnet/framework/network-programming/how-to-request-data-using-the-webrequest-class
            // Create a request for the URL.
            WebRequest request = WebRequest.Create(BranchData.QueryUrl(null, null));
            // Get the response.
            WebResponse response = request.GetResponse();

            // Display the status.
            Console.WriteLine(((HttpWebResponse)response).StatusDescription);
            // Get the stream containing content returned by the server.
            Stream dataStream = response.GetResponseStream();
            // Open the stream using a StreamReader for easy access.
            StreamReader reader = new StreamReader(dataStream);
            // Read the content.
            string responseFromServer = reader.ReadToEnd();

            // Display the content.
            Console.WriteLine(responseFromServer);
            // Clean up the streams and the response.
            reader.Close();
            response.Close();


            // From https://stackoverflow.com/a/39902334
            var doc = new XmlDocument();

            doc.LoadXml(responseFromServer); //or XDocument.Load(path)
            string jsonText = JsonConvert.SerializeXmlNode(doc.LastChild, Newtonsoft.Json.Formatting.Indented, true);
            var    dyn      = JsonConvert.DeserializeObject <EPLBranches>(jsonText);

            // Bind to display
            //EPLBranchView.DataSource = dyn.BranchesInfo
            //EPLBranchView.DataBind();
        }
Пример #10
0
        public void getBranchsDataTest()
        {
            var service = new Service1();

            BranchData branchs = service.getBranchsData();

            Assert.IsTrue(branchs.branchsTable.Rows.Count > 0);
        }
Пример #11
0
        public BranchData ParseBranch(QueryBranchRestriction restriction)
        {
            BranchData res;
            bool       current = CheckValue('*');

            Skip(2);
            int eol   = FindNewLineOrEndOfString();
            int space = FindSpace();

            if (current && (space == Position + 3) && CheckValue(GitConstants.NoBranch))
            {
                Skip(GitConstants.NoBranch.Length);
                Skip(' ');
                var sha1 = new Hash(String, Position);
                res = new BranchData(GitConstants.NoBranch, sha1, true, false, true);
            }
            else
            {
                var name = ReadStringUpTo(space, 1);
                Skip(' ');
                if (!(restriction == QueryBranchRestriction.Local) && CheckValue('-'))                // it's a remote head indicator, skip it
                {
                    res = null;
                }
                else
                {
                    var  sha1 = new Hash(String, Position);
                    bool remote;
                    switch (restriction)
                    {
                    case QueryBranchRestriction.All:
                        remote = !current && name.StartsWith(GitConstants.RemoteBranchShortPrefix);
                        if (remote)
                        {
                            name = name.Substring(8);
                        }
                        break;

                    case QueryBranchRestriction.Local:
                        remote = false;
                        break;

                    case QueryBranchRestriction.Remote:
                        remote = true;
                        break;

                    default:
                        throw new ArgumentException("restriction");
                    }
                    res = new BranchData(name, sha1, remote, current);
                }
            }
            Position = eol + 1;
            return(res);
        }
Пример #12
0
        /// <summary>Notifies about external branch reset.</summary>
        /// <param name="branchInformation">Updated branch information.</param>
        /// <exception cref="ArgumentNullException"><paramref name="branchInformation"/> == <c>null</c>.</exception>
        internal void NotifyReset(BranchData branchInformation)
        {
            Verify.Argument.IsNotNull(branchInformation, nameof(branchInformation));

            if (Revision.Hash != branchInformation.SHA1)
            {
                lock (Repository.Revisions.SyncRoot)
                {
                    Pointer = Repository.Revisions.GetOrCreateRevision(branchInformation.SHA1);
                }
            }
        }
Пример #13
0
    void Update()
    {
        if (reroll)
        {
            reroll = false;
            InitRandoms();
            //seed = Mathf.FloorToInt (Random.value * 1000);
        }


        if (branches == null)
        {
            branches = new ArrayList();
        }
        //	return;
        //if ()
        branches.Clear();
        branchIndex = 0;
        //Random.InitState (seed);

        windForce = windSource.forward * windStrength * Mathf.PerlinNoise(Time.time, 0);

        Branch(transform.position, 2, Quaternion.LookRotation(Vector3.forward, Vector3.up));

        //if (windSource != null) {
        //	windForce = windSource.forward * windStrength * Mathf.PerlinNoise (Time.time, 0);
        //}

        for (int i = 0; i < branches.Count; ++i)
        {
            BranchData tData = (BranchData)branches [i];
            Matrix4x4  m     = Matrix4x4.TRS(tData.start + tData.direction * 0.5f, tData.rotation, tData.scale);
            Graphics.DrawMesh(meshToDraw, m, mat, 0);
        }

        /*Matrix4x4[] allMatrices = new Matrix4x4[branches.Count];
         * for (int i = 0; i < allMatrices.Length; ++i) {
         *      //allMatrices [i] = (Matrix4x4)branches [i];
         *      BranchData tData = (BranchData)branches [i];
         *      //Vector3 newVector = tData.direction + windForce;
         *      //Quaternion windRot = Quaternion.FromToRotation (tData.direction, newVector);
         *      //Vector3 newDir = windRot * tData.direction;
         *
         *      allMatrices [i] = Matrix4x4.TRS (tData.start, tData.rotation, tData.scale);
         *      //allMatrices [i] = Matrix4x4.TRS (tData.start + newDir * 0.5f, windRot * tData.rotation, tData.scale);
         *
         *
         * }*/

        //Matrix4x4[] allMatrices = branches.ToArray () as Matrix4x4[];
        //Graphics.DrawMeshInstanced (meshToDraw, 0, mat, allMatrices);
    }
Пример #14
0
        /// <summary>
        ///     Creates a connection using token.
        /// </summary>
        /// <param name="companyId">Company context</param>
        /// <param name="token">The predefined token from Visma.net</param>
        /// <param name="branchId">Branch ID to work with in the Visma.net Company (optional)</param>
        public VismaNet(int companyId, string token, int branchId = 0)
        {
            if (string.IsNullOrEmpty(token))
            {
                throw new InvalidArgumentsException("Token is missing");
            }

            Auth = new VismaNetAuthorization
            {
                Token     = token,
                CompanyId = companyId,
                BranchId  = branchId
            };
            Attribute                = new AttributeData(Auth);
            Customer                 = new CustomerData(Auth);
            Currency                 = new CurrencyData(Auth);
            CustomerInvoice          = new CustomerInvoiceData(Auth);
            Supplier                 = new SupplierData(Auth);
            SupplierInvoice          = new SupplierInvoiceData(Auth);
            CashSale                 = new CashSaleData(Auth);
            CustomerDocument         = new CustomerDocumentData(Auth);
            Dimension                = new DimensionData(Auth);
            Discount                 = new DiscountData(Auth);
            Inventory                = new InventoryData(Auth);
            JournalTransaction       = new JournalTransactionData(Auth);
            GeneralLedgerTransaction = new GeneralLedgerTransactionData(Auth);
            GeneralLedgerBalance     = new GeneralLedgerBalanceData(Auth);
            Account         = new FinAccountData(Auth);
            FinancialPeriod = new FinancialPeriodData(Auth);
            Employee        = new EmployeeData(Auth);
            Shipment        = new ShipmentData(Auth);
            Contact         = new ContactData(Auth);
            Project         = new ProjectData(Auth);
#pragma warning disable CS0618 // Type or member is obsolete
            SalesOrder = new SalesOrderData(Auth);
#pragma warning restore CS0618 // Type or member is obsolete
            Branch             = new BranchData(Auth);
            Warehouse          = new WarehouseData(Auth);
            Location           = new LocationData(Auth);
            Subaccount         = new SubaccountData(Auth);
            CustomerPayment    = new CustomerPaymentData(Auth);
            Dynamic            = new VismaNetDynamicEndpoint(null, Auth);
            Resources          = new VismaNetDynamicEndpoint(null, Auth, true);
            SupplierDocument   = new SupplierDocumentData(Auth);
            InventoryIssue     = new InventoryIssueData(Auth);
            InventoryReceipt   = new InventoryReceiptData(Auth);
            PurchaseReceipt    = new PurchaseReceiptData(Auth);
            CustomerSalesPrice = new CustomerSalesPriceData(Auth);
            CustomerCreditNote = new CustomerCreditNoteData(Auth);
            PurchaseOrder      = new PurchaseOrderData(Auth);
            CashTransaction    = new CashTransactionData(Auth);
        }
Пример #15
0
        public static RemoteBranch CreateRemoteBranch(Repository repository, BranchData branchData)
        {
            Verify.Argument.IsNotNull(repository, "repository");
            Verify.Argument.IsNotNull(branchData, "branchData");
            Verify.Argument.IsTrue(branchData.IsRemote, "branchData", "Cannot create local branch.");

            Revision revision;

            lock (repository.Revisions.SyncRoot)
            {
                revision = repository.Revisions.GetOrCreateRevision(branchData.SHA1);
            }
            return(new RemoteBranch(repository, branchData.Name, revision));
        }
Пример #16
0
        public static void UpdateRemoteBranch(RemoteBranch remoteBranch, BranchData branchData)
        {
            Verify.Argument.IsNotNull(remoteBranch, "remoteBranch");
            Verify.Argument.IsNotNull(branchData, "branchData");
            Verify.Argument.IsTrue(branchData.IsRemote, "branchData", "Cannot update local branch.");

            if (remoteBranch.Revision.Hash != branchData.SHA1)
            {
                var revisionCache = remoteBranch.Repository.Revisions;
                lock (revisionCache.SyncRoot)
                {
                    remoteBranch.Pointer = revisionCache.GetOrCreateRevision(branchData.SHA1);
                }
            }
        }
Пример #17
0
        public static Branch CreateBranch(Repository repository, BranchData branchData)
        {
            Verify.Argument.IsNotNull(repository, "repository");
            Verify.Argument.IsNotNull(branchData, "branchData");
            Verify.Argument.IsFalse(branchData.IsRemote, "branchData", "Cannot create remote branch.");

            Revision revision;
            lock(repository.Revisions.SyncRoot)
            {
                revision = repository.Revisions.GetOrCreateRevision(branchData.SHA1);
            }
            var branch = new Branch(repository, branchData.Name, revision);
            if(branchData.IsCurrent) repository.Head.Pointer = branch;
            return branch;
        }
    public override void ViewNext(IList <Branch> branches)
    {
        var validBranches = from branch in branches where branch.IsValid select branch;

        _currentData       = new BranchData();
        AboutToRequestMain = false;

        if (validBranches.Count() <= 1 || ArticyManager.Instance.CharacterHub)
        {
            return;
        }
        AboutToRequestMain = true;
        Debug.Log("BranchesManager about to request main.");

        //We create buttons for all posible options
        foreach (var branch in validBranches)
        {
            var menuObject = branch.Target as IObjectWithText;
            var text       = menuObject?.Text ?? "";
            _currentData.AddButton(new BranchButtonData {
                text = text, callback = () => EndDecision(branch)
            });
        }

        //Create the text and show image
        if (_flowPlayer.CurrentObject.HasReference)
        {
            var node = _flowPlayer.CurrentObject.GetObject();
            if (node is IObjectWithText textObject)
            {
                _currentData.description = textObject.Text;
            }

            if (node is DialogueFragment dialog)
            {
                if (dialog.Speaker is IObjectWithPreviewImage previewImage)
                {
                    var asset = previewImage.PreviewImage.Asset;
                    if (asset != null)
                    {
                        _currentData.portrait = asset.LoadAssetAsSprite();
                        return;
                    }
                }
            }
        }
    }
Пример #19
0
    public void StartAction(Input input, Direction direction, Speed speed)
    {
        try
        {
            System.Random rand = new System.Random();

            if (!m_Action.IsReset())
            {
                return;
            }

            BranchData[] branches = branch.results[input][direction][speed];
            branch     = branches[rand.Next(branches.Length)];
            m_Cooldown = branch.cooldown;

            m_Action.StartAction(GetAction());
        }
        catch (NullReferenceException e) { }
    }
Пример #20
0
    private static void LoadBranchData()
    {
        instance = Resources.Load(BDAssetName) as BranchData;

        if (instance == null)
        {
            instance = CreateInstance <BranchData>();

                        #if UNITY_EDITOR
            if (!Directory.Exists(BDAssetPath))
            {
                Directory.CreateDirectory(BDAssetPath);
                AssetDatabase.Refresh();
            }

            string fullPath = Path.Combine(Path.Combine("Assets", BDAssetPath), BDAssetName + BDAssetExtension);
            AssetDatabase.CreateAsset(instance, fullPath);
                        #endif
        }
    }
Пример #21
0
        public static void UpdateBranch(Branch branch, BranchData branchData)
        {
            Verify.Argument.IsNotNull(branch, "branch");
            Verify.Argument.IsNotNull(branchData, "branchData");
            Verify.Argument.IsFalse(branchData.IsRemote, "branchData", "Cannot update remote branch.");

            var repo = branch.Repository;

            if (branch.Revision.Hash != branchData.SHA1)
            {
                lock (repo.Revisions.SyncRoot)
                {
                    branch.Pointer = repo.Revisions.GetOrCreateRevision(branchData.SHA1);
                }
            }
            if (branchData.IsCurrent)
            {
                repo.Head.Pointer = branch;
            }
        }
Пример #22
0
        public static Branch CreateBranch(Repository repository, BranchData branchData)
        {
            Verify.Argument.IsNotNull(repository, "repository");
            Verify.Argument.IsNotNull(branchData, "branchData");
            Verify.Argument.IsFalse(branchData.IsRemote, "branchData", "Cannot create remote branch.");

            Revision revision;

            lock (repository.Revisions.SyncRoot)
            {
                revision = repository.Revisions.GetOrCreateRevision(branchData.SHA1);
            }
            var branch = new Branch(repository, branchData.Name, revision);

            if (branchData.IsCurrent)
            {
                repository.Head.Pointer = branch;
            }
            return(branch);
        }
Пример #23
0
        public static void UpdateRemoteBranch(RemoteBranch remoteBranch, BranchData branchData)
        {
            Verify.Argument.IsNotNull(remoteBranch, "remoteBranch");
            Verify.Argument.IsNotNull(branchData, "branchData");
            Verify.Argument.IsTrue(branchData.IsRemote, "branchData", "Cannot update local branch.");

            if(remoteBranch.Revision.Hash != branchData.SHA1)
            {
                var revisionCache = remoteBranch.Repository.Revisions;
                lock(revisionCache.SyncRoot)
                {
                    remoteBranch.Pointer = revisionCache.GetOrCreateRevision(branchData.SHA1);
                }
            }
        }
Пример #24
0
 public GameData(SerializationInfo info, StreamingContext ctxt)
 {
     Version = (string)info.GetValue("Version", typeof(string));
     Scene   = (string)info.GetValue("Scene", typeof(string));
     Branch  = (BranchData)info.GetValue("Branch", typeof(BranchData));
 }
Пример #25
0
    private void StartBranch(string branchName)
    {
        branch = GetBranch(branchName);

        m_Cooldown = branch.cooldown;
    }
Пример #26
0
        public ReferencesData ParseReferences(QueryReferencesParameters parameters, GitOutput output)
        {
            Assert.IsNotNull(parameters);
            Assert.IsNotNull(output);

            var refTypes = parameters.ReferenceTypes;

            bool needHeads		= (refTypes & ReferenceType.LocalBranch) == ReferenceType.LocalBranch;
            bool needRemotes	= (refTypes & ReferenceType.RemoteBranch) == ReferenceType.RemoteBranch;
            bool needTags		= (refTypes & ReferenceType.Tag) == ReferenceType.Tag;
            bool needStash		= (refTypes & ReferenceType.Stash) == ReferenceType.Stash;

            var heads	= needHeads   ? new List<BranchData>() : null;
            var remotes	= needRemotes ? new List<BranchData>() : null;
            var tags	= needTags    ? new List<TagData>()    : null;
            RevisionData stash = null;

            bool encounteredRemoteBranch = false;
            bool encounteredStash = false;
            bool encounteredTag = false;

            var refs = output.Output;
            int pos = 0;
            int l = refs.Length;
            while(pos < l)
            {
                var hash = new Hash(refs, pos);
                pos += 41;
                var end = refs.IndexOf('\n', pos);
                if(end == -1) end = l;

                if(!encounteredRemoteBranch && StringUtility.CheckValue(refs, pos, GitConstants.LocalBranchPrefix))
                {
                    if(needHeads)
                    {
                        pos += GitConstants.LocalBranchPrefix.Length;
                        var name = refs.Substring(pos, end - pos);
                        var branch = new BranchData(name, hash, false, false, false);
                        heads.Add(branch);
                    }
                }
                else if(!encounteredStash && StringUtility.CheckValue(refs, pos, GitConstants.RemoteBranchPrefix))
                {
                    encounteredRemoteBranch = true;
                    if(needRemotes)
                    {
                        pos += GitConstants.RemoteBranchPrefix.Length;
                        var name = refs.Substring(pos, end - pos);
                        if(!name.EndsWith("/HEAD"))
                        {
                            var branch = new BranchData(name, hash, false, true, false);
                            remotes.Add(branch);
                        }
                    }
                }
                else if(!encounteredTag && !encounteredStash && StringUtility.CheckValue(refs, pos, GitConstants.StashFullName))
                {
                    encounteredRemoteBranch = true;
                    encounteredStash = true;
                    if(needStash)
                    {
                        stash = new RevisionData(hash);
                    }
                }
                else if(StringUtility.CheckValue(refs, pos, GitConstants.TagPrefix))
                {
                    encounteredRemoteBranch = true;
                    encounteredStash = true;
                    encounteredTag = true;
                    if(needTags)
                    {
                        pos += GitConstants.TagPrefix.Length;
                        var name = refs.Substring(pos, end - pos);
                        var type = TagType.Lightweight;
                        if(end < l - 1)
                        {
                            int s2 = end + 1;
                            int pos2 = s2 + 41 + GitConstants.TagPrefix.Length;
                            var end2 = refs.IndexOf('\n', pos2);
                            if(end2 == -1) end2 = l;
                            if(end2 - pos2 == end - pos + 3)
                            {
                                if(StringUtility.CheckValue(refs, pos2, name) && StringUtility.CheckValue(refs, pos2 + name.Length, GitConstants.DereferencedTagPostfix))
                                {
                                    type = TagType.Annotated;
                                    hash = new Hash(refs, s2);
                                    end = end2;
                                }
                            }
                        }
                        var tag = new TagData(name, hash, type);
                        tags.Add(tag);
                    }
                    else break;
                }
                pos = end + 1;
            }
            return new ReferencesData(heads, remotes, tags, stash);
        }
Пример #27
0
        /// <summary>Notifies about external branch reset.</summary>
        /// <param name="branchInformation">Updated branch information.</param>
        /// <exception cref="ArgumentNullException"><paramref name="branchInformation"/> == <c>null</c>.</exception>
        internal void NotifyReset(BranchData branchInformation)
        {
            Verify.Argument.IsNotNull(branchInformation, "branchInformation");

            if(Revision.Hash != branchInformation.SHA1)
            {
                lock(Repository.Revisions.SyncRoot)
                {
                    Pointer = Repository.Revisions.GetOrCreateRevision(branchInformation.SHA1);
                }
            }
        }
Пример #28
0
        public static RemoteBranch CreateRemoteBranch(Repository repository, BranchData branchData)
        {
            Verify.Argument.IsNotNull(repository, "repository");
            Verify.Argument.IsNotNull(branchData, "branchData");
            Verify.Argument.IsTrue(branchData.IsRemote, "branchData", "Cannot create local branch.");

            Revision revision;
            lock(repository.Revisions.SyncRoot)
            {
                revision = repository.Revisions.GetOrCreateRevision(branchData.SHA1);
            }
            return new RemoteBranch(repository, branchData.Name, revision);
        }
Пример #29
0
        public static void UpdateBranch(Branch branch, BranchData branchData)
        {
            Verify.Argument.IsNotNull(branch, "branch");
            Verify.Argument.IsNotNull(branchData, "branchData");
            Verify.Argument.IsFalse(branchData.IsRemote, "branchData", "Cannot update remote branch.");

            var repo = branch.Repository;
            if(branch.Revision.Hash != branchData.SHA1)
            {
                lock(repo.Revisions.SyncRoot)
                {
                    branch.Pointer = repo.Revisions.GetOrCreateRevision(branchData.SHA1);
                }
            }
            if(branchData.IsCurrent)
            {
                repo.Head.Pointer = branch;
            }
        }
Пример #30
0
 public BranchData ParseBranch(QueryBranchRestriction restriction)
 {
     BranchData res;
     bool current = CheckValue('*');
     Skip(2);
     int eol = FindNewLineOrEndOfString();
     int space = FindSpace();
     if(current && (space == Position + 3) && CheckValue(GitConstants.NoBranch))
     {
         Skip(GitConstants.NoBranch.Length);
         Skip(' ');
         var sha1 = new Hash(String, Position);
         res = new BranchData(GitConstants.NoBranch, sha1, true, false, true);
     }
     else
     {
         var name = ReadStringUpTo(space, 1);
         Skip(' ');
         if(!(restriction == QueryBranchRestriction.Local) && CheckValue('-')) // it's a remote head indicator, skip it
         {
             res = null;
         }
         else
         {
             var sha1 = new Hash(String, Position);
             bool remote;
             switch(restriction)
             {
                 case QueryBranchRestriction.All:
                     remote = !current && name.StartsWith(GitConstants.RemoteBranchShortPrefix);
                     if(remote) name = name.Substring(8);
                     break;
                 case QueryBranchRestriction.Local:
                     remote = false;
                     break;
                 case QueryBranchRestriction.Remote:
                     remote = true;
                     break;
                 default:
                     throw new ArgumentException("restriction");
             }
             res = new BranchData(name, sha1, remote, current);
         }
     }
     Position = eol + 1;
     return res;
 }