コード例 #1
0
        public virtual bool WaitForFinish(TimeSpan timeout)
        {
            lock (this.TaskStateLock)
            {
                TaskState taskState = this.TaskState;

                if (taskState == TaskState.Unknown ||
                    taskState == TaskState.NotStarted ||
                    taskState == TaskState.Stopped)
                {
                    return(true);
                }
            }

            return(this.WaitForAnyTaskState(timeout, PredicateUtils.ObjectEqualsAny(TaskState.Finished, TaskState.Stopped)));
        }
コード例 #2
0
        public virtual void Run()
        {
            Play();

            TaskUtils.WaitForAnyTaskState(this, PredicateUtils.ObjectEqualsAny(TaskState.Finished, TaskState.Stopped));
        }
コード例 #3
0
        public static LocalNodeAddress Parse(string uri)
        {
            Group  group;
            Match  match = null;
            string root, scheme, query;

            // Often Parse will be called with the exact same URI reference that was last passed
            // to CanParse.  If this is the case then use the results cached by the last call to
            // CanParse from this thread.

            if ((object)uri == (object)lastCanParseUri)
            {
                match = lastCanParseMatch;
            }

            while (true)
            {
                if (match == null)
                {
                    match = localFileNameRegEx.Match(uri);
                }

                if (!match.Success)
                {
                    throw new MalformedUriException(uri);
                }

                bool schemeExplicitlyProvided;

                group = match.Groups["scheme"];

                if (group.Value == "")
                {
                    scheme = "file";
                    schemeExplicitlyProvided = false;
                }
                else
                {
                    scheme = group.Value;
                    schemeExplicitlyProvided = true;
                }

                group = match.Groups["uncserver"];

                if (group.Success)
                {
                    string path;
                    Pair <string, string> result;

                    path = match.Groups["path1"].Value;

                    result = path.SplitAroundCharFromLeft(1, PredicateUtils.ObjectEqualsAny('\\', '/'));

                    root = "//" + group.Value + result.Left.Replace('\\', '/');
                    path = "/" + result.Right;

                    if (path == "")
                    {
                        path = "/";
                    }

                    query = match.Groups["query"].Value;

                    return(new LocalNodeAddress(scheme, root, true, StringUriUtils.NormalizePath(path), query));
                }
                else
                {
                    string path;

                    group = match.Groups["root"];

                    if (group.Captures.Count > 0)
                    {
                        //
                        // Windows path specification
                        //

                        root = group.Value;

                        path = match.Groups["path2"].Value;

                        if (path.Length == 0)
                        {
                            path = FileSystemManager.SeperatorString;
                        }

                        query = match.Groups["query"].Value;

                        path = StringUriUtils.NormalizePath(path);

                        if (schemeExplicitlyProvided)
                        {
                            //
                            // Explicitly provided scheme means
                            // special characters are hexcoded
                            //

                            path  = TextConversion.FromEscapedHexString(path);
                            query = TextConversion.FromEscapedHexString(query);
                        }

                        return(new LocalNodeAddress(scheme, root, true, path, query));
                    }
                    else if (match.Groups["path3"].Value != "")
                    {
                        //
                        // Unix path specification
                        //

                        path  = match.Groups["path3"].Value;
                        query = match.Groups["query"].Value;

                        path = StringUriUtils.NormalizePath(path);

                        if (schemeExplicitlyProvided)
                        {
                            //
                            // Explicitly provided scheme means
                            // special characters are hexcoded
                            //

                            path  = TextConversion.FromEscapedHexString(path);
                            query = TextConversion.FromEscapedHexString(query);
                        }

                        return(new LocalNodeAddress(scheme, "", true, path, query));
                    }
                    else
                    {
                        //
                        // Relative path specification
                        //

                        path  = match.Groups["path4"].Value;
                        query = match.Groups["query"].Value;

                        path = StringUriUtils.Combine(Environment.CurrentDirectory, path);
                        path = StringUriUtils.NormalizePath(path);

                        if (!string.IsNullOrEmpty(query))
                        {
                            query = "?" + query;
                        }
                        else
                        {
                            query = "";
                        }

                        if (schemeExplicitlyProvided)
                        {
                            uri = scheme + "://" + path + "query";
                        }
                        else
                        {
                            uri = path + query;
                        }

                        match = null;
                    }
                }
            }
        }