Пример #1
0
        internal static Conflict FromXml(XElement element, Workspace workspace)
        {
            Conflict conflict = new Conflict();

            conflict.ConflictId      = GeneralHelper.XmlAttributeToInt(element.GetAttribute("cid"));
            conflict.PendingChangeId = GeneralHelper.XmlAttributeToInt(element.GetAttribute("pcid"));
            //Your
            conflict.YourChangeType        = EnumHelper.ParseChangeType(element.GetAttribute("ychg"));
            conflict.YourServerItem        = element.GetAttribute("ysitem");
            conflict.YourServerItemSource  = element.GetAttribute("ysitemsrc");
            conflict.YourEncoding          = GeneralHelper.XmlAttributeToInt(element.GetAttribute("yenc"));
            conflict.YourItemType          = EnumHelper.ParseItemType(element.GetAttribute("ytype"));
            conflict.YourVersion           = GeneralHelper.XmlAttributeToInt(element.GetAttribute("yver"));
            conflict.YourItemId            = GeneralHelper.XmlAttributeToInt(element.GetAttribute("yitemid"));
            conflict.YourDeletionId        = GeneralHelper.XmlAttributeToInt(element.GetAttribute("ydid"));
            conflict.YourLocalChangeType   = EnumHelper.ParseChangeType(element.GetAttribute("ylchg"));
            conflict.YourLastMergedVersion = GeneralHelper.XmlAttributeToInt(element.GetAttribute("ylmver"));
            //Base
            conflict.BaseServerItem = element.GetAttribute("bsitem");
            conflict.BaseEncoding   = GeneralHelper.XmlAttributeToInt(element.GetAttribute("benc"));
            conflict.BaseItemId     = GeneralHelper.XmlAttributeToInt(element.GetAttribute("bitemid"));
            conflict.BaseVersion    = GeneralHelper.XmlAttributeToInt(element.GetAttribute("bver"));
            conflict.BaseHashValue  = GeneralHelper.ToByteArray(element.GetAttribute("bhash"));
            conflict.BaseDeletionId = GeneralHelper.XmlAttributeToInt(element.GetAttribute("bdid"));
            conflict.BaseItemType   = EnumHelper.ParseItemType(element.GetAttribute("btype"));
            conflict.BaseChangeType = EnumHelper.ParseChangeType(element.GetAttribute("bchg"));
            //Their
            conflict.TheirItemId            = GeneralHelper.XmlAttributeToInt(element.GetAttribute("titemid"));
            conflict.TheirVersion           = GeneralHelper.XmlAttributeToInt(element.GetAttribute("tver"));
            conflict.TheirServerItem        = element.GetAttribute("tsitem");
            conflict.TheirEncoding          = GeneralHelper.XmlAttributeToInt(element.GetAttribute("tenc"));
            conflict.TheirHashValue         = GeneralHelper.ToByteArray(element.GetAttribute("thash"));
            conflict.TheirDeletionId        = GeneralHelper.XmlAttributeToInt(element.GetAttribute("tdid"));
            conflict.TheirItemType          = EnumHelper.ParseItemType(element.GetAttribute("ttype"));
            conflict.TheirLastMergedVersion = GeneralHelper.XmlAttributeToInt(element.GetAttribute("tlmver"));
            conflict.SourceLocalItem        = TfsPath.ToPlatformPath(element.GetAttribute("srclitem"));
            conflict.TargetLocalItem        = TfsPath.ToPlatformPath(element.GetAttribute("tgtlitem"));

            conflict.ConflictType        = EnumHelper.ParseConflictType(element.GetAttribute("ctype"));
            conflict.Reason              = GeneralHelper.XmlAttributeToInt(element.GetAttribute("reason"));
            conflict.IsNamespaceConflict = GeneralHelper.XmlAttributeToBool(element.GetAttribute("isnamecflict"));
            conflict.IsForced            = GeneralHelper.XmlAttributeToBool(element.GetAttribute("isforced"));
            conflict.IsResolved          = GeneralHelper.XmlAttributeToBool(element.GetAttribute("tgtlitem"));

            conflict.BaseDowloadUrl  = element.GetAttribute("bdurl");
            conflict.TheirDowloadUrl = element.GetAttribute("tdurl");
            conflict.YourDowloadUrl  = element.GetAttribute("ydurl");

            conflict.Workspace = workspace;
            return(conflict);
        }
Пример #2
0
        internal static PendingChange FromXml(XElement element)
        {
            PendingChange change = new PendingChange();

            change.ServerItem      = element.GetAttribute("item");
            change.LocalItem       = TfsPath.ToPlatformPath(element.GetAttribute("local"));
            change.ItemId          = GeneralHelper.XmlAttributeToInt(element.GetAttribute("itemid"));
            change.Encoding        = GeneralHelper.XmlAttributeToInt(element.GetAttribute("enc"));
            change.Version         = GeneralHelper.XmlAttributeToInt(element.GetAttribute("ver"));
            change.CreationDate    = DateTime.Parse(element.GetAttribute("date"));
            change.Hash            = GeneralHelper.ToByteArray(element.GetAttribute("hash"));
            change.uploadHashValue = GeneralHelper.ToByteArray(element.GetAttribute("uhash"));
            change.ItemType        = EnumHelper.ParseItemType(element.GetAttribute("type"));
            change.DownloadUrl     = element.GetAttribute("durl");
            change.ChangeType      = EnumHelper.ParseChangeType(element.GetAttribute("chg"));
            if (change.ChangeType == ChangeType.Edit)
            {
                change.ItemType = ItemType.File;
            }
            return(change);
        }
Пример #3
0
        internal XElement ToXml(XName element)
        {
            XElement result = new XElement(element);

            if (this.RecursionType != RecursionType.None)
            {
                result.Add(new XAttribute("recurse", RecursionType));
            }
            if (this.DeletionId != 0)
            {
                result.Add(new XAttribute("did", DeletionId));
            }
            if (VersionControlPath.IsServerItem(Item))
            {
                result.Add(new XAttribute("item", Item));
            }
            else
            {
                result.Add(new XAttribute("item", TfsPath.FromPlatformPath(Item)));
            }
            return(result);
        }
        //          <ExtendedItem lver="int" did="int" latest="int" type="Any or Folder or File" enc="int" itemid="int" local="string" titem="string" sitem="string" chg="None or Add or Edit or Encoding or Rename or Delete or Undelete or Branch or Merge or Lock or Rollback or SourceRename or Property" chgEx="int" ochg="boolean" lock="None or Checkin or CheckOut or Unchanged" lowner="string" lownerdisp="string" date="dateTime">
        //            <IsBranch>boolean</IsBranch>
        //            <PropertyValues xsi:nil="true" />
        //          </ExtendedItem>
        //        <s:complexType name="ExtendedItem">
        //            <s:sequence>
        //                <s:element minOccurs="0" maxOccurs="1" default="false" name="IsBranch" type="s:boolean"/>
        //                <s:element minOccurs="0" maxOccurs="1" name="PropertyValues" type="tns:ArrayOfPropertyValue"/>
        //            </s:sequence>
        //            <s:attribute default="0" name="lver" type="s:int"/>
        //            <s:attribute default="0" name="did" type="s:int"/>
        //            <s:attribute default="0" name="latest" type="s:int"/>
        //            <s:attribute default="Any" name="type" type="tns:ItemType"/>
        //            <s:attribute default="-3" name="enc" type="s:int"/>
        //            <s:attribute default="0" name="itemid" type="s:int"/>
        //            <s:attribute name="local" type="s:string"/>
        //            <s:attribute name="titem" type="s:string"/>
        //            <s:attribute name="sitem" type="s:string"/>
        //            <s:attribute default="None" name="chg" type="tns:ChangeType"/>
        //            <s:attribute default="0" name="chgEx" type="s:int"/>
        //            <s:attribute default="false" name="ochg" type="s:boolean"/>
        //            <s:attribute default="None" name="lock" type="tns:LockLevel"/>
        //            <s:attribute name="lowner" type="s:string"/>
        //            <s:attribute name="lownerdisp" type="s:string"/>
        //            <s:attribute name="date" type="s:dateTime" use="required"/>
        //        </s:complexType>
        internal static ExtendedItem FromXml(XElement element)
        {
            ExtendedItem item = new ExtendedItem
            {
                ChangeType            = ChangeType.None,
                VersionLocal          = 0,
                DeletionId            = 0,
                VersionLatest         = 0,
                ItemType              = ItemType.Any,
                Encoding              = -3,
                ItemId                = 0,
                HasOtherPendingChange = false,
                LockStatus            = LockLevel.None
            };

            item.ChangeType            = EnumHelper.ParseChangeType(element.GetAttribute("chg"));
            item.HasOtherPendingChange = GeneralHelper.XmlAttributeToBool(element.GetAttribute("ochg"));
            item.LockStatus            = EnumHelper.ParseLockLevel(element.GetAttribute("lock"));
            item.LockOwner             = element.GetAttribute("lowner");
            item.LocalItem             = TfsPath.ToPlatformPath(element.GetAttribute("local"));
            item.TargetServerItem      = element.GetAttribute("titem");
            item.SourceServerItem      = element.GetAttribute("sitem");
            item.ItemType      = EnumHelper.ParseItemType(element.GetAttribute("type"));
            item.ItemId        = GeneralHelper.XmlAttributeToInt(element.GetAttribute("itemid"));
            item.Encoding      = GeneralHelper.XmlAttributeToInt(element.GetAttribute("enc"));
            item.VersionLocal  = GeneralHelper.XmlAttributeToInt(element.GetAttribute("lver"));
            item.VersionLatest = GeneralHelper.XmlAttributeToInt(element.GetAttribute("latest"));
            item.DeletionId    = GeneralHelper.XmlAttributeToInt(element.GetAttribute("did"));
            item.CheckinDate   = GeneralHelper.XmlAttributeToDate(element.GetAttribute("date"));

            if (element.Element(XmlNamespaces.GetMessageElementName("IsBranch")) != null &&
                !string.IsNullOrEmpty(element.Element(XmlNamespaces.GetMessageElementName("IsBranch")).Value))
            {
                item.IsBranch = GeneralHelper.XmlAttributeToBool(element.Element(XmlNamespaces.GetMessageElementName("IsBranch")).Value);
            }

            return(item);
        }
Пример #5
0
 public string TfsPathWithRoot(string root)
 {
     return(string.IsNullOrWhiteSpace(TfsPath) ? root.TrimEnd('/') : $"{root.TrimEnd('/')}/{TfsPath.TrimStart('/')}");
 }