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


C# IProviderManager.GetProvider方法代码示例

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


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

示例1: ParseArguments

        public static Context ParseArguments(List<string> commandLineArguments, IProviderManager providerManager)
        {
            var context = new Context(providerManager);

            if (commandLineArguments.Count == 0)
            {
                Log.ErrorAndThrowException<GitLinkException>("Invalid number of arguments");
            }

            var firstArgument = commandLineArguments.First();
            if (IsHelp(firstArgument))
            {
                context.IsHelp = true;
                return context;
            }

            if (commandLineArguments.Count < 3)
            {
                Log.ErrorAndThrowException<GitLinkException>("Invalid number of arguments");
            }

            context.SolutionDirectory = firstArgument;

            var namedArguments = commandLineArguments.Skip(1).ToList();
            for (var index = 0; index < namedArguments.Count; index++)
            {
                var name = namedArguments[index];

                // First check everything without values
                if (IsSwitch("debug", name))
                {
                    context.IsDebug = true;
                    continue;
                }

                // After this point, all arguments should have a value
                index++;
                var valueInfo = GetValue(namedArguments, index);
                var value = valueInfo.Key;
                index = index + (valueInfo.Value - 1);

                if (IsSwitch("l", name))
                {
                    context.LogFile = value;
                    continue;
                }

                if (IsSwitch("c", name))
                {
                    context.ConfigurationName = value;
                    continue;
                }

                if (IsSwitch("p", name))
                {
                    context.PlatformName = value;
                    continue;
                }

                if (IsSwitch("u", name))
                {
                    context.TargetUrl = value;
                    continue;
                }

                if (IsSwitch("b", name))
                {
                    context.TargetBranch = value;
                    continue;
                }

                if (IsSwitch("s", name))
                {
                    context.ShaHash = value;
                    continue;
                }

                if (IsSwitch("f", name))
                {
                    context.SolutionFile = value;
                    continue;
                }

                if (IsSwitch("ignore", name))
                {
                    context.IgnoredProjects.AddRange(value.Split(new []{ ',' }, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim()));
                    continue;
                }

                Log.ErrorAndThrowException<GitLinkException>("Could not parse command line parameter '{0}'.", name);
            }

            if (!string.IsNullOrEmpty(context.TargetUrl))
            {
                context.Provider = providerManager.GetProvider(context.TargetUrl);
            }

            return context;
        }
开发者ID:samuelhewitt,项目名称:GitLink,代码行数:99,代码来源:ArgumentParser.cs

示例2: ParseArguments


//.........这里部分代码省略.........

                if (IsSwitch("l", name))
                {
                    context.LogFile = value;
                    continue;
                }

                if (IsSwitch("c", name))
                {
                    context.ConfigurationName = value;
                    continue;
                }

                if (IsSwitch("p", name))
                {
                    context.PlatformName = value;
                    continue;
                }

                if (IsSwitch("u", name))
                {
                    context.TargetUrl = value;
                    continue;
                }

                if (IsSwitch("b", name))
                {
                    context.TargetBranch = value;
                    continue;
                }

                if (IsSwitch("s", name))
                {
                    context.ShaHash = value;
                    continue;
                }

                if (IsSwitch("f", name))
                {
                    context.SolutionFile = value;
                    continue;
                }

                if (IsSwitch("d", name))
                {
                    context.PdbFilesDirectory = value;
                    continue;
                }

                if (IsSwitch("ignore", name))
                {
                    context.IgnoredProjects.AddRange(value.Split(new []{ ',' }, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim()));
                    continue;
                }

                throw Log.ErrorAndCreateException<GitLinkException>("Could not parse command line parameter '{0}'.", name);
            }

            if (string.IsNullOrEmpty(context.TargetUrl))
            {
                Log.Info("No target url was specified, trying to determine the target url automatically");

                var gitDir = GitDirFinder.TreeWalkForGitDir(context.SolutionDirectory);
                if (gitDir != null)
                {
                    using (var repo = RepositoryLoader.GetRepo(gitDir))
                    {
                        var currentBranch = repo.Head;

                        if (string.IsNullOrEmpty(context.ShaHash))
                        {
                            context.ShaHash = currentBranch.Tip.Sha;
                        }

                        if (currentBranch.Remote == null || currentBranch.IsDetachedHead())
                        {
                            currentBranch = repo.GetBranchesContainingCommit(context.ShaHash).FirstOrDefault(b => b.Remote != null);
                        }

                        if (currentBranch != null && currentBranch.Remote != null)
                        {
                            var url = currentBranch.Remote.Url;
                            if (url.StartsWith("https://"))
                            {
                                context.TargetUrl = url.OptimizeUrl();

                                Log.Info("Automatically determine target url '{0}'", context.TargetUrl);
                            }
                        }
                    }
                }
            }

            if (!string.IsNullOrEmpty(context.TargetUrl))
            {
                context.Provider = providerManager.GetProvider(context.TargetUrl);
            }

            return context;
        }
开发者ID:mwatts,项目名称:GitLink,代码行数:101,代码来源:ArgumentParser.cs


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