当前位置: 首页>>代码示例>>C#>>正文


C# Uri.Path方法代码示例

本文整理汇总了C#中System.Uri.Path方法的典型用法代码示例。如果您正苦于以下问题:C# Uri.Path方法的具体用法?C# Uri.Path怎么用?C# Uri.Path使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Uri的用法示例。


在下文中一共展示了Uri.Path方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CheckOut

        /// <summary>
        /// Checks out an item</summary>
        /// <param name="uri">URI representing the path to item</param>
        public override void CheckOut(Uri uri)
        {
            CheckUri(uri);

            FileInfo info = GetInfo(uri);
            if (info.IsLocked)
            {
                var lockUser = string.IsNullOrEmpty(info.OtherLock) ? m_connectionManager.UserName : info.OtherLock;

                // There's no guarantee that the caller is in a transaction, and so throwing an
                //  InvalidTransactionException here could crash the app. Let's just output the message.
                Outputs.WriteLine(OutputMessageType.Warning, "The document is locked by another user: " + lockUser);
                return;
            }

            AddPerforceFileRequest(
                uri,
                u => RunCommand("edit", uri.Path())
                     && AllowMultipleCheckout
                     || RunCommand("lock", uri.Path()));
        }
开发者ID:sbambach,项目名称:ATF,代码行数:24,代码来源:PerforceService.cs

示例2: Export

        /// <summary>
        /// Exports a file of the specified revision to a designated location</summary>
        /// <param name="sourceUri">Source file URI</param>
        /// <param name="destUri">Designated location URI</param>
        /// <param name="revision">Source control revision of file</param>
        public override void Export(Uri sourceUri, Uri destUri, SourceControlRevision revision)
        {
            if (!(Enabled && m_connectionManager.InitializeConnection()))
                return;
            
            string toPath = destUri.Path();
            string fromPath = sourceUri.Path();

            switch (revision.Kind)
            {
                case SourceControlRevisionKind.Number:
                    fromPath += "#" + revision.Number;
                    break;
                case SourceControlRevisionKind.Unspecified:
                    throw new NotSupportedException("Can't export revision of none ");
                //fromPath += "#none";
                //break;
                case SourceControlRevisionKind.Base:
                    fromPath += "#have";
                    break;
                case SourceControlRevisionKind.Head:
                    fromPath += "#head";
                    break;
                case SourceControlRevisionKind.Working:
                    //just file copy 
                    System.IO.File.Copy(fromPath, toPath, true);
                    return;
                case SourceControlRevisionKind.Date:
                    fromPath += "@" + revision.Date;
                    break;
                case SourceControlRevisionKind.ChangeList:
                    fromPath += "@" + revision.ChangeListNumber;
                    break;
            }

            RunP4Command("print", "-q", "-o", toPath, fromPath);

        }
开发者ID:sbambach,项目名称:ATF,代码行数:43,代码来源:PerforceService.cs

示例3: GetRevisionLog

        /// <summary>
        /// Get the revision logs for an item</summary>
        /// <param name="uri">URI representing the path to item</param>
        /// <returns>Returns revision history logs in a table, where each row is a revision record</returns>
        public override DataTable GetRevisionLog(Uri uri)
        {
            CheckUri(uri);

            DataTable p4DataTable = new DataTable("Perforce Revisions");

            if (Enabled && m_connectionManager.InitializeConnection())
            {
                var path = uri.Path();

                var p4RecordSet =
                    RunP4Command("changes", "-s", "submitted", "-l", "-m", "100", path);

                if (p4RecordSet.TaggedOutput.Count == 0)
                    return p4DataTable;

                p4DataTable.Columns.Add(
                    new DataColumn
                    {
                        DataType = Type.GetType("System.Int32"),
                        ColumnName = "revision",
                        ReadOnly = true,
                        Unique = true
                    });

                p4DataTable.Columns.Add(
                    new DataColumn
                    {
                        DataType = Type.GetType("System.String"),
                        ColumnName = "user"
                    });

                p4DataTable.Columns.Add(
                    new DataColumn
                    {
                        DataType = Type.GetType("System.String"),
                        ColumnName = "description"
                    });

                p4DataTable.Columns.Add(
                    new DataColumn
                    {
                        DataType = Type.GetType("System.String"),
                        ColumnName = "status"
                    });

                p4DataTable.Columns.Add(
                    new DataColumn
                    {
                        DataType = Type.GetType("System.String"),
                        ColumnName = "client"
                    });

                p4DataTable.Columns.Add(
                    new DataColumn
                    {
                        DataType = Type.GetType("System.DateTime"),
                        ColumnName = "time"
                    });

                // Valid keys on each record in this particular record set:
                // "user", "change", "desc", "status", "client", "time"
                foreach (var record in p4RecordSet.TaggedOutput)
                {
                    string change = record["change"];
                    string user = record["user"];
                    string desc = record["desc"];
                    string status = record["status"];
                    string client = record["client"];
                    string time = record["time"];

                    DateTime date;
                    {
                        double dTime = double.Parse(time);
                        date =
                            (new DateTime(1970, 1, 1, 0, 0, 0)
                            .AddSeconds(dTime)
                            .ToLocalTime());
                    }

                    DataRow row = p4DataTable.NewRow();
                    row["revision"] = Int32.Parse(change);
                    row["user"] = user;
                    row["description"] = desc;
                    row["status"] = status;
                    row["client"] = client;
                    row["time"] = date;

                    p4DataTable.Rows.Add(row);
                }

            }
            return p4DataTable;
        }
开发者ID:sbambach,项目名称:ATF,代码行数:98,代码来源:PerforceService.cs

示例4: AddPerforceFileRequest

 private void AddPerforceFileRequest(Uri uri, Func<Uri, bool> doRequest)
 {
     var path = uri.Path();
     FileInfo info;
     lock (m_infoCache)
         if (!m_infoCache.TryGetValue(path, out info))
             m_infoCache[path] = info = new FileInfo(uri);
     lock (m_pendingRequests)
         m_pendingRequests.Enqueue(new PerforceRequest(info, doRequest));
     m_queryRequestedEvent.Set(); // Trigger the worker thread to talk to the Perforce server.
 }
开发者ID:sbambach,项目名称:ATF,代码行数:11,代码来源:PerforceService.cs

示例5: Uncache

 private void Uncache(Uri uri)
 {
     lock (m_infoCache)
     {
         FileInfo info;
         if (m_infoCache.TryGetValue(uri.Path(), out info))
             info.ClearRecord();
     }
 }
开发者ID:sbambach,项目名称:ATF,代码行数:9,代码来源:PerforceService.cs

示例6: AddPerforceFileRequest

 private void AddPerforceFileRequest(Uri uri, Func<Uri, bool> doRequest, Func<Uri, bool> requestComplete)
 {
     var path = uri.Path();
     FileInfo info;
     if (!m_infoCache.TryGetValue(path, out info))
         m_infoCache[path] = info = new FileInfo(uri);
     RequestProcessed = false;
     m_pendingRequests.Enqueue(new PerforceRequest(info, doRequest, requestComplete));
 }
开发者ID:vincenthamm,项目名称:ATF,代码行数:9,代码来源:PerforceService.cs

示例7: Open

        public FtpClient Open(bool isSource, ref Uri url)
        {
            var queue = Queue[Key(isSource, url)];
            var ftp = queue.DequeueOrBlock();
            try {
                if (ftp == null) {
                    ftp = new Silversite.FtpSync.FtpClient(Sync, url.Host, url.Port, url.Scheme == "ftps" ? FtpSecurityProtocol.Tls1Explicit : FtpSecurityProtocol.None, ++clientIndex, isSource);
                    //ftp.IsLoggingOn = Sync.Verbose;
                    if (Sync.Verbose) {
                        ftp.ClientRequest += new EventHandler<FtpRequestEventArgs>((sender, args) => {
                            lock (Log.Lock) { Log.YellowLabel("FTP" + ftp.Index + "> "); Log.Text(args.Request.Text); }
                        });
                        ftp.ServerResponse += new EventHandler<FtpResponseEventArgs>((sender, args) => {
                            lock (Log.Lock) { Log.Label("FTP" + ftp.Index + ": "); Log.Text(args.Response.Text); }
                        });
                    }
                    if (url.Query()["passive"] != null || url.Query()["active"] == null) ftp.DataTransferMode = TransferMode.Passive;
                    else ftp.DataTransferMode = TransferMode.Active;
                    ftp.AutoChecksumValidation = HashingFunction.None;
                    if (url.Query()["md5"] != null) ftp.AutoChecksumValidation = HashingFunction.Md5;
                    else if (url.Query()["sha"] != null) ftp.AutoChecksumValidation = HashingFunction.Sha1;
                    else if (url.Query()["crc"] != null) ftp.AutoChecksumValidation = HashingFunction.Crc32;
                } else {
                    if (!ftp.IsConnected) ftp.Reopen();
                }
                if (!ftp.IsConnected) {
                    if (!string.IsNullOrEmpty(url.UserInfo)) {
                        if (url.UserInfo.Contains(':')) {
                            var user = url.UserInfo.Split(':');
                            ftp.Open(user[0], user[1]);
                        } else {
                            ftp.Open(url.UserInfo, string.Empty);
                        }
                    } else {
                        ftp.Open("Anonymous", "anonymous");
                    }
                    // enable UTF8
                    ftp.Quote("OPTS UTF8 ON");
                }

                // change path
                var path = url.Path();
                if (!path.StartsWith("/")) path = "/" + path;
                path = ftp.CorrectPath(path);
                if (url.Query()["raw"] != null && ftp.IsCompressionEnabled) ftp.CompressionOff();
                if (url.Query()["zip"] != null && ftp.IsCompressionEnabled) ftp.CompressionOn();
                if (ftp.CurrentDirectory != path) {
                    try {
                        if (url.Query()["old"] != null) ftp.ChangeDirectoryMultiPath(path);
                        else ftp.ChangeDirectory(path);
                    } catch (Exception ex) {
                        ftp.MakeDirectory(path);
                        if (url.Query()["old"] != null) ftp.ChangeDirectoryMultiPath(path);
                        else ftp.ChangeDirectory(path);
                    }
                }
                // get server local time offset
                var offset = TimeOffset(url);
                if (offset.HasValue) ftp.TimeOffset = offset;
                else if (!ftp.TimeOffset.HasValue) {
                    lock (queue) {
                        var offsetclient = queue.FirstOrDefault(client => client != null && client.TimeOffset.HasValue);
                        if (offsetclient != null) ftp.TimeOffset = offsetclient.TimeOffset;
                        ftp.TimeOffset = ftp.ServerTimeOffset;
                    }
                }
            } catch (FtpDataConnectionException ex) {
                if (url.Query()["passive"] == null) {
                    url = new Uri(url.ToString() + (url.Query().Count > 0 ? "&" : "%3F") + "passive");
                    //ftp.Close();
                    ftp.DataTransferMode = TransferMode.Passive;
                    Pass(ftp);
                    return Open(isSource, ref url);
                } else {
                    Log.Exception(ex);
                }
            } catch (Exception e) {
                Log.Exception(e);
            }
            return ftp;
        }
开发者ID:simonegli8,项目名称:Silversite,代码行数:81,代码来源:FtpConnections.cs


注:本文中的System.Uri.Path方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。