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


C# RegistrationContext.EscapePath方法代码示例

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


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

示例1: Register

        /// <summary>
        /// Called to register this attribute with the given context.
        /// </summary>
        /// <param name="context">
        /// Contains the location where the registration information should be placed.
        /// It also contains other informations as the type being registered and path information.
        /// </param>
        public override void Register(RegistrationContext context) {
            if (context == null) {
                return;
            }
            using (Key childKey = context.CreateKey(LanguageName())) {
                childKey.SetValue("", LanguageGuid);

                string snippetIndexPath = context.ComponentPath;
                snippetIndexPath = Path.Combine(snippetIndexPath, IndexPath);
                snippetIndexPath = context.EscapePath(System.IO.Path.GetFullPath(snippetIndexPath));

                childKey.SetValue("DisplayName", DisplayName.ToString(CultureInfo.InvariantCulture));
                childKey.SetValue("IndexPath", snippetIndexPath);
                childKey.SetValue("LangStringId", LanguageStringId.ToLowerInvariant());
                childKey.SetValue("Package", context.ComponentType.GUID.ToString("B"));
                childKey.SetValue("ShowRoots", ShowRoots ? 1 : 0);

                //The following enables VS to look into a user directory for more user-created snippets
                string myDocumentsPath = @"%MyDocs%\Code Snippets\" + LanguageStringId + @"\My Code Snippets\";
                using (Key forceSubKey = childKey.CreateSubkey("ForceCreateDirs")) {
                    forceSubKey.SetValue(LanguageStringId, myDocumentsPath);
                }

                using (Key pathsSubKey = childKey.CreateSubkey("Paths")) {
                    pathsSubKey.SetValue(LanguageStringId, myDocumentsPath);
                }
            }
        }
开发者ID:Microsoft,项目名称:RTVS,代码行数:35,代码来源:ProvideCodeExpansionsAttribute.cs

示例2: Register

        /// <summary>
        /// Called to register this attribute with the given context.
        /// </summary>
        /// <param name="context">
        /// Contains the location where the registration information should be placed.
        /// It also contains other informations as the type being registered and path information.
        /// </param>
        public override void Register(RegistrationContext context) {
            using (Key childKey = context.CreateKey(LanguageName())) {
                string snippetPaths = context.ComponentPath;
                snippetPaths = System.IO.Path.Combine(snippetPaths, Paths);
                snippetPaths = context.EscapePath(System.IO.Path.GetFullPath(snippetPaths));

                using (Key pathsSubKey = childKey.CreateSubkey("Paths")) {
                    pathsSubKey.SetValue(_description, snippetPaths);
                }
            }
        }
开发者ID:CforED,项目名称:Node.js-Tools-for-Visual-Studio,代码行数:18,代码来源:ProvideCodeExpansionPathAttribute.cs

示例3: Register

        /// <include file='doc\RegisterProjectItemAttribute.uex' path='docs/doc[@for="Register"]' />
        /// <devdoc>
        ///     Called to register this attribute with the given context.  The context
        ///     contains the location where the registration inforomation should be placed.
        ///     it also contains such as the type being registered, and path information.
        ///
        ///     This method is called both for registration and unregistration.  The difference is
        ///     that unregistering just uses a hive that reverses the changes applied to it.
        /// </devdoc>
        public override void Register(RegistrationContext context)
        {
            context.Log.WriteLine(SR.GetString(SR.Reg_NotifyProjectItems, factory.ToString("B")));

            using (Key childKey = context.CreateKey(ProjectRegKeyName(context)))
            {
                childKey.SetValue("", itemType);

                Uri url = new Uri(context.ComponentType.Assembly.CodeBase, true);
                string templates = url.LocalPath;
                templates = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(templates), templateDir);
                templates = context.EscapePath(System.IO.Path.GetFullPath(templates));
                childKey.SetValue("TemplatesDir", templates);

                childKey.SetValue("SortPriority", Priority);
            }
        }
开发者ID:hesam,项目名称:SketchSharp,代码行数:26,代码来源:RegisterProjectItem.cs

示例4: Register

        /// <devdoc>
        ///     Called to register this attribute with the given context.  The context
        ///     contains the location where the registration inforomation should be placed.
        ///     it also contains such as the type being registered, and path information.
        ///
        ///     This method is called both for registration and unregistration.  The difference is
        ///     that unregistering just uses a hive that reverses the changes applied to it.
        /// </devdoc>
        /// <param name="context">
        ///     Contains the location where the registration inforomation should be placed.
        ///     It also contains other information such as the type being registered 
        ///     and path of the assembly.
        /// </param>
        public override void Register(RegistrationContext context)
        {
            Type t = context.ComponentType;
            context.Log.WriteLine(string.Format(Resources.Culture, Resources.Reg_NotifyPackage, t.Name, t.GUID.ToString("B")));

            Key packageKey = null;
            try
            {
                packageKey = context.CreateKey(RegKeyName(context));

                //use a friendly description if it exists.
                DescriptionAttribute attr = TypeDescriptor.GetAttributes(t)[typeof(DescriptionAttribute)] as DescriptionAttribute;
                if (attr != null && !String.IsNullOrEmpty(attr.Description)) {
                    packageKey.SetValue(string.Empty, attr.Description);
                }
                else {
                    packageKey.SetValue(string.Empty, t.AssemblyQualifiedName);
                }

                packageKey.SetValue("InprocServer32", context.InprocServerPath);
                packageKey.SetValue("Class", t.FullName);

                // If specified on the command line, let the command line option override
                if (context.RegistrationMethod != RegistrationMethod.Default)
                {
                    registrationMethod = context.RegistrationMethod;
                }

                // Select registration method
                switch (registrationMethod)
                {
                    case RegistrationMethod.Assembly:
                    case RegistrationMethod.Default:
                        packageKey.SetValue("Assembly", t.Assembly.FullName);
                        break;

                    case RegistrationMethod.CodeBase:
                        packageKey.SetValue("CodeBase", context.CodeBase);
                        break;
                }

                Key childKey = null;
                if (!useManagedResources)
                {
                    try
                    {
                        childKey = packageKey.CreateSubkey("SatelliteDll");

                        // Register the satellite dll
                        string satelliteDllPath;
                        if (SatellitePath != null)
                        {
                            // Use provided path
                            satelliteDllPath = context.EscapePath(SatellitePath);
                        }
                        else
                        {
                            // Default to package path
                            satelliteDllPath = context.ComponentPath;
                        }
                        childKey.SetValue("Path", satelliteDllPath);
                        childKey.SetValue("DllName", String.Format(CultureInfo.InvariantCulture, "{0}UI.dll", Path.GetFileNameWithoutExtension(t.Assembly.ManifestModule.Name)));
                    }
                    finally
                    {
                        if (childKey != null)
                            childKey.Close();
                    }
                }
            }
            finally
            {
                if (packageKey != null)
                    packageKey.Close();
            }
        }
开发者ID:Graham-Pedersen,项目名称:IronPlot,代码行数:89,代码来源:PackageRegistrationAttribute.cs

示例5: Register

        /// <include file='doc\ProvideEditorExtensionAttribute.uex' path='docs/doc[@for="Register"]' />
        /// <devdoc>
        ///     Called to register this attribute with the given context.  The context
        ///     contains the location where the registration inforomation should be placed.
        ///     it also contains such as the type being registered, and path information.
        ///
        ///     This method is called both for registration and unregistration.  The difference is
        ///     that unregistering just uses a hive that reverses the changes applied to it.
        /// </devdoc>
        public override void Register(RegistrationContext context) {
            using (Key editorKey = context.CreateKey(RegKeyName)) {
                if (!string.IsNullOrEmpty(DefaultName)) {
                    editorKey.SetValue(null, DefaultName);
                }
                if (0 != _editorNameResId)
                    editorKey.SetValue("DisplayName", "#" + _editorNameResId.ToString(CultureInfo.InvariantCulture));
                else if (0 != _resId)
                    editorKey.SetValue("DisplayName", "#" + _resId.ToString(CultureInfo.InvariantCulture));
                if (_linkedEditorGuid != Guid.Empty) {
                    editorKey.SetValue("LinkedEditorGuid", _linkedEditorGuid.ToString("B"));
                }
                if (_commonViewAttrs != 0) {
                    editorKey.SetValue("CommonPhysicalViewAttributes", (int)_commonViewAttrs);
                }
                editorKey.SetValue("Package", context.ComponentType.GUID.ToString("B"));
            }

            using (Key extensionKey = context.CreateKey(RegKeyName + "\\Extensions")) {
                extensionKey.SetValue(Extension.Substring(1), Priority);

                if (_extensions != null && _extensions.Length > 0) {
                    foreach (var extension in _extensions) {
                        var extensionAndPri = extension.Split(':');
                        int pri;
                        if (extensionAndPri.Length != 2 || !Int32.TryParse(extensionAndPri[1], out pri)) {
                            throw new InvalidOperationException("Expected extension:priority");
                        }

                        extensionKey.SetValue(extensionAndPri[0], pri);
                    }
                }
            }

            // Build the path of the registry key for the "Add file to project" entry
            if (_project != Guid.Empty) {
                string prjRegKey = ProjectRegKeyName(context) + "\\/1";
                using (Key projectKey = context.CreateKey(prjRegKey)) {
                    if (0 != _resId)
                        projectKey.SetValue("", "#" + _resId.ToString(CultureInfo.InvariantCulture));
                    if (_templateDir.Length != 0) {
                        Uri url = new Uri(context.ComponentType.Assembly.CodeBase);
                        string templates = url.LocalPath;
                        templates = PathUtils.GetAbsoluteDirectoryPath(Path.GetDirectoryName(templates), _templateDir);
                        templates = context.EscapePath(templates);
                        projectKey.SetValue("TemplatesDir", templates);
                    }
                    projectKey.SetValue("SortPriority", Priority);
                }
            }

            // Register the EditorFactoryNotify
            if (EditorFactoryNotify) {
                // The IVsEditorFactoryNotify interface is called by the project system, so it doesn't make sense to
                // register it if there is no project associated to this editor.
                if (_project == Guid.Empty)
                    throw new ArgumentException("project");

                // Create the registry key
                using (Key edtFactoryNotifyKey = context.CreateKey(EditorFactoryNotifyKey)) {
                    edtFactoryNotifyKey.SetValue("EditorFactoryNotify", Factory.ToString("B"));
                }
            }
        }
开发者ID:RussBaz,项目名称:PTVS,代码行数:73,代码来源:ProvideEditorExtension2Attribute.cs

示例6: Register

        public override void Register(RegistrationContext context)
        {
            //context.Log.WriteLine(SR.GetString(SR.Reg_NotifyProjectFactory, FactoryType.Name));

            using (Key projectKey = context.CreateKey(ProjectRegKey))
            {
                projectKey.SetValue(string.Empty, Name);
                if (_displayName != null)
                    projectKey.SetValue("DisplayName", _displayName);
                if (_displayProjectFileExtensions != null)
                    projectKey.SetValue("DisplayProjectFileExtensions", _displayProjectFileExtensions);
                projectKey.SetValue("Package", context.ComponentType.GUID.ToString("B"));
                if (_defaultProjectExtension != null)
                    projectKey.SetValue("DefaultProjectExtension", _defaultProjectExtension);
                if (_possibleProjectExtensions != null)
                    projectKey.SetValue("PossibleProjectExtensions", _possibleProjectExtensions);
                if (_projectTemplatesDirectory != null)
                {
                    if (!System.IO.Path.IsPathRooted(_projectTemplatesDirectory))
                    {
                        // If path is not rooted, make it relative to package path
                        _projectTemplatesDirectory = System.IO.Path.Combine(context.ComponentPath, _projectTemplatesDirectory);
                    }
                    projectKey.SetValue("ProjectTemplatesDir", context.EscapePath(_projectTemplatesDirectory));
                }

                // VsTemplate Specific Keys
                //
                if (_languageVsTemplate != null)
                    projectKey.SetValue("Language(VsTemplate)", _languageVsTemplate);

                if (_showOnlySpecifiedTemplatesVsTemplate || _templateGroupIDsVsTemplate != null || _templateIDsVsTemplate != null)
                {
                    int showOnlySpecifiedTemplatesVsTemplate = _showOnlySpecifiedTemplatesVsTemplate ? 1 : 0;
                    projectKey.SetValue("ShowOnlySpecifiedTemplates(VsTemplate)", showOnlySpecifiedTemplatesVsTemplate);
                }

                if (_templateGroupIDsVsTemplate != null)
                    projectKey.SetValue("TemplateGroupIDs(VsTemplate)", _templateGroupIDsVsTemplate);

                if (_templateIDsVsTemplate != null)
                    projectKey.SetValue("TemplateIDs(VsTemplate)", _templateIDsVsTemplate);

                if (_displayProjectTypeVsTemplate != null)
                    projectKey.SetValue("DisplayProjectType(VsTemplate)", _displayProjectTypeVsTemplate);

                if (_projectSubTypeVsTemplate != null)
                    projectKey.SetValue("ProjectSubType(VsTemplate)", _projectSubTypeVsTemplate);

                if (_newProjectRequireNewFolderVsTemplate)
                    projectKey.SetValue("NewProjectRequireNewFolder(VsTemplate)", (int)1);
            }
        }
开发者ID:Graham-Pedersen,项目名称:IronPlot,代码行数:53,代码来源:WAProvideProjectFactoryAttribute.cs

示例7: Register

        /// <include file='doc\RegisterEditorExtensionAttribute.uex' path='docs/doc[@for="Register"]' />
        /// <devdoc>
        ///     Called to register this attribute with the given context.  The context
        ///     contains the location where the registration inforomation should be placed.
        ///     it also contains such as the type being registered, and path information.
        ///
        ///     This method is called both for registration and unregistration.  The difference is
        ///     that unregistering just uses a hive that reverses the changes applied to it.
        /// </devdoc>
        public override void Register(RegistrationContext context) {
            context.Log.WriteLine(SR.GetString(SR.Reg_NotifyEditorExtension, Extension, Factory.ToString("B")));

            using (Key editorKey = context.CreateKey(RegKeyName))
            {
                if (0 != resId)
                    editorKey.SetValue("DisplayName", "#" + resId.ToString(CultureInfo.InvariantCulture));
                editorKey.SetValue("Package", context.ComponentType.GUID.ToString("B"));
            }

            using (Key extensionKey = context.CreateKey(RegKeyName + "\\Extensions"))
            {
                extensionKey.SetValue(Extension.Substring(1), Priority);
            }

            // Build the path of the registry key for the "Add file to project" entry
            if (project != Guid.Empty)
            {
                string prjRegKey = ProjectRegKeyName(context) + "\\/1";
                using (Key projectKey = context.CreateKey( prjRegKey ))
                {
                    if (0 != resId)
                        projectKey.SetValue("", "#" + resId.ToString(CultureInfo.InvariantCulture));
                    if (templateDir.Length != 0)
                    {
                        Uri url = new Uri(context.ComponentType.Assembly.CodeBase, true);
                        string templates = url.LocalPath;
                        templates = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(templates), templateDir);
                        templates = context.EscapePath( System.IO.Path.GetFullPath(templates) );
                        projectKey.SetValue("TemplatesDir", templates);
                    }
                    projectKey.SetValue("SortPriority", Priority);
                }
            }

            // Register the EditorFactoryNotify
            if ( EditorFactoryNotify )
            {
                // The IVsEditorFactoryNotify interface is called by the project system, so it doesn't make sense to
                // register it if there is no project associated to this editor.
                if (project == Guid.Empty)
                    throw new ArgumentException(SR.GetString(SR.Attributes_NoPrjForEditorFactoryNotify));

                // Create the registry key
                using (Key edtFactoryNotifyKey = context.CreateKey(EditorFactoryNotifyKey))
                {
                    edtFactoryNotifyKey.SetValue("EditorFactoryNotify", context.ComponentType.GUID.ToString("B"));
                }
            }
        }
开发者ID:hesam,项目名称:SketchSharp,代码行数:59,代码来源:RegisterEditorExtensionAttribute.cs

示例8: WriteValue

        private void WriteValue(RegistrationContext context, Key targetKey, string name, object value)
        {
            if (value == null)
            {
                return;
            }
            else if (value is Type)
            {
                Type type = (Type)value;
                Guid guid = type.GUID;

                if (guid != Guid.Empty)
                {
                    targetKey.SetValue(name, guid.ToString("B"));
                }
            }
            else if (value is Array)
            {
                Array array = value as Array;

                using (Key childKey = targetKey.CreateSubkey(name))
                {
                    for (int i = 0; i < array.Length; i++)
                    {
                        Object element = array.GetValue(i);
                        WriteValue(context, childKey, i.ToString(), element);
                    }
                }
            }
            else if (value.GetType().IsPrimitive)
            {
                targetKey.SetValue(name, Convert.ToInt32(value));
            }
            else
            {
                String str = value.ToString();
                if (!String.IsNullOrEmpty(str))
                {
                    targetKey.SetValue(name, context.EscapePath(str));
                }
            }
        }
开发者ID:vairam-svs,项目名称:poshtools,代码行数:42,代码来源:RegistrationAttributes.cs

示例9: Register

        /// <summary>
        /// Called to register this attribute with the given context.  The context
        /// contains the location where the registration information should be placed.
        /// It also contains other information such as the type being registered and path information.
        /// </summary>
        /// <param name="context">Given context to register in</param>
        public override void Register(RegistrationContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            packageType = context.ComponentType;
            context.Log.WriteLine(String.Format(CultureInfo.CurrentCulture, "WebSiteProject: LanguageID = {0} Language Name = {1}\n", languageID, languageName));

            //Register ProjectSubType(VsTemplates)
            using (Key childKey = context.CreateKey(string.Format(CultureInfo.InvariantCulture, "{0}\\{1}", ProjectSubTypePath, languageID)))
            {
                childKey.SetValue("", languageName);
            }

            //Register NewProjectTemplates
            using (Key childKey = context.CreateKey(string.Format(CultureInfo.InvariantCulture, "{0}\\{1}", ProjectTemplatesDir, languageID)))
            {
                childKey.SetValue("", languageName);
                childKey.SetValue("NewProjectDialogExOnly", 1);
                childKey.SetValue("SortPriority", 300);
                string templateDir = context.RootFolder.TrimEnd('\\') + string.Format(CultureInfo.InvariantCulture, "\\Web\\.\\WebProjects\\{0}", languageID);
                childKey.SetValue("TemplatesDir", context.EscapePath(templateDir));
                childKey.SetValue("DeveloperActivity", languageID);
            }
        }
开发者ID:Graham-Pedersen,项目名称:IronPlot,代码行数:32,代码来源:WebSiteProjectAttribute.cs


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