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


C# IContext.ResolvePath方法代码示例

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


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

示例1: XmlConfigurationLoader

 public XmlConfigurationLoader(IContext context, string filePath, List<ISettingValidator> validators,
                                Dictionary<string, Type> typeAliases)
     : base(context, validators, typeAliases)
 {
     _filePath = context.ResolvePath(filePath);
     InitialiseFileWatcher();
 }
开发者ID:aqueduct,项目名称:Aqueduct.SitecoreLib,代码行数:7,代码来源:XmlConfigurationLoader.cs

示例2: Load

        public ApplicationMode Load (IContext context)
        {
            if (_stream != null)
                return GetModeFromStream();

            string filePath = context.ResolvePath ("~/" + _fileName);

            if (!File.Exists (filePath))
                return ApplicationMode.Auto;

            using (StreamReader sr = new StreamReader (filePath))
            {
                return sr.ReadLine ().ToEnum(ApplicationMode.Auto);
            }
        }
开发者ID:aqueduct,项目名称:Aqueduct.SitecoreLib,代码行数:15,代码来源:FileApplicationModeLoader.cs

示例3: ResolveProject

        private Project ResolveProject(IContext context, string projectName)
        {
            Project project = null;
            var nodeFactory = new SolutionProjectsNodeFactory(_references.DTE as DTE2);
            project = nodeFactory.ResolveProjectFromName(projectName);
            if (null != project)
            {
                return project;
            }

            ProjectNodeFactory projectNodeFactory =
                context.ResolvePath(projectName) as ProjectNodeFactory;
            if (null != projectNodeFactory)
            {
                project = projectNodeFactory.Project;
            }

            return project;
        }
开发者ID:wangchunlei,项目名称:MyGit,代码行数:19,代码来源:ReferenceCollectionNodeFactory.cs

示例4: GetOrCreateCommand

        internal static ShellCommand GetOrCreateCommand(IContext context, DTE2 dte, string caption,
                                                        object commandPathOrScript)
        {
            var stringValue = commandPathOrScript as string;
            var script = commandPathOrScript as ScriptBlock;

            ShellCommand cmd = null;
            if (null != stringValue)
            {
                // locate an existing command by path
                try
                {
                    var command = context.ResolvePath(stringValue);
                    if (null != command)
                    {
                        var value = command.GetNodeValue();
                        if (null != value)
                        {
                            cmd = value.Item as ShellCommand;
                        }
                    }
                }
                catch
                {
                }

                // locate an existing command by name
                if (null == cmd)
                {
                    var node = context.ResolvePath("dte:/commands");
                    var factories = node.Resolve(context, stringValue);
                    if (null != factories && factories.Any())
                    {
                        var value = factories.First().GetNodeValue();
                        if (null != value)
                        {
                            cmd = value.Item as ShellCommand;
                        }
                    }
                }

                // assume the string is script;
                if (null == cmd)
                {
                    script = ScriptBlock.Create(stringValue);
                }
            }

            if (null == cmd && null != script)
            {
                var coll =
                    new CommandCollectionPathNodeFactory(dte.Commands as Commands2);
                var pm = new CommandCollectionPathNodeFactory.NewItemDynamicParameters
                             {
                                 Button = true,
                                 Label = caption,
                                 Supported = true,
                                 Enabled = true
                             };
                cmd =
                    coll.NewItem(
                        new Context(context, pm),
                        "anonymousCommand_" + Guid.NewGuid().ToString("N"),
                        null, script
                        ).Item as ShellCommand;
            }
            return cmd;
        }
开发者ID:wangchunlei,项目名称:MyGit,代码行数:68,代码来源:CommandUtilities.cs

示例5: GetDocumentFromSourcePath

        private string GetDocumentFromSourcePath(IContext context, string sourcePath)
        {
            if (String.IsNullOrEmpty(sourcePath))
            {
                return null;
            }

            var paths = context.SessionState.Path.GetResolvedPSPathFromPSPath(sourcePath);
            sourcePath = paths[0].Path;
            var nodeFactory = context.ResolvePath(sourcePath);
            var item = nodeFactory.GetNodeValue().Item;
            var i = item as ShellProjectItem;

            if (null != i)
            {
                return i.FileNames[0];
            }

            return sourcePath;
        }
开发者ID:wangchunlei,项目名称:MyGit,代码行数:20,代码来源:ErrorListNodeFactory.cs

示例6: GetProjectFromSourcePath

        private Project GetProjectFromSourcePath(IContext context, IVsSolution sln, string sourcePath)
        {
            if (String.IsNullOrEmpty(sourcePath))
            {
                return null;
            }

            var paths = context.SessionState.Path.GetResolvedPSPathFromPSPath(sourcePath);
            sourcePath = paths[0].Path;
            var nodeFactory = context.ResolvePath(sourcePath);
            var item = nodeFactory.GetNodeValue().Item;
            var p = item as ShellProject;
            var i = item as ShellProjectItem;

            if (null != p)
            {
                return p.Object as Project;
            }

            if (null != i)
            {
                return i.ContainingProject.AsProject();
            }

            return null;
        }
开发者ID:wangchunlei,项目名称:MyGit,代码行数:26,代码来源:ErrorListNodeFactory.cs


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