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


C# ISite.GetService方法代码示例

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


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

示例1: WebConfigManager

        internal WebConfigManager(ISite site)
        {
            Debug.Assert(site != null);
            _site = site;

            IWebApplication webApplicationService = (IWebApplication)_site.GetService(typeof(IWebApplication));
            if (webApplicationService != null) {
                IProjectItem dataFileProjectItem = webApplicationService.GetProjectItemFromUrl("~/web.config");
                if (dataFileProjectItem != null) {
                    _path = dataFileProjectItem.PhysicalPath;
                }
            }

/* VSWhidbey 271075, 257678
            // the following inspired by:
            // \VSDesigner\Designer\Microsoft\VisualStudio\Designer\Serialization\BaseDesignerLoader.cs

            Type projectItemType = Type.GetType("EnvDTE.ProjectItem, " + AssemblyRef.EnvDTE);
            if (projectItemType != null)
            {
                Object currentProjItem = _site.GetService(projectItemType);
                PropertyInfo containingProjectProp = projectItemType.GetProperty("ContainingProject");
                Object dteProject = containingProjectProp.GetValue(currentProjItem, new Object[0]);
                Type projectType = Type.GetType("EnvDTE.Project, " + AssemblyRef.EnvDTE);
                PropertyInfo fullNameProperty = projectType.GetProperty("FullName");
                String projectPath = (String)fullNameProperty.GetValue(dteProject, new Object[0]);

                _path = Path.GetDirectoryName(projectPath) + "\\web.config";
            }
*/
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:31,代码来源:WebConfigManager.cs

示例2: ResolveFileName

        public static string ResolveFileName(string filename, ISite site, bool designMode)
        {
            string fileName = null;
            if (!Path.IsPathRooted(filename))
            {
                // in design mode, resolve url using IUrlResolutionService
                if (designMode)
                {
                    IWebApplication app = (IWebApplication) site.GetService(typeof(IWebApplication));
                    if (app != null)
                    {
                        IProjectItem projectItem = app.GetProjectItemFromUrl(filename);
                        if (projectItem == null)
                            throw new InvalidOperationException("Could not load ProjectItem corresponding to source filename '" + filename + "'.");

                        fileName = projectItem.PhysicalPath;
                    }
                }
                else if (HttpContext.Current != null)
                {
                    fileName = HttpContext.Current.Server.MapPath(filename);
                }

                if (fileName == null)
                    throw new InvalidOperationException("Could not resolve source filename.");
            }
            else
            {
                fileName = filename;
            }

            return fileName;
        }
开发者ID:dbre2,项目名称:dynamic-image,代码行数:33,代码来源:FileSourceHelper.cs

示例3: CommandSet

 public CommandSet(ISite site)
 {
     this.site = site;
     this.eventService = (IEventHandlerService) site.GetService(typeof(IEventHandlerService));
     this.eventService.EventHandlerChanged += new EventHandler(this.OnEventHandlerChanged);
     IDesignerHost host = (IDesignerHost) site.GetService(typeof(IDesignerHost));
     if (host != null)
     {
         host.Activated += new EventHandler(this.UpdateClipboardItems);
     }
     this.statusCommandUI = new StatusCommandUI(site);
     IUIService uiService = site.GetService(typeof(IUIService)) as IUIService;
     this.commandSet = new CommandSetItem[] {
         new CommandSetItem(this, new EventHandler(this.OnStatusDelete), new EventHandler(this.OnMenuDelete), StandardCommands.Delete, uiService), new CommandSetItem(this, new EventHandler(this.OnStatusCopy), new EventHandler(this.OnMenuCopy), StandardCommands.Copy, uiService), new CommandSetItem(this, new EventHandler(this.OnStatusCut), new EventHandler(this.OnMenuCut), StandardCommands.Cut, uiService), new ImmediateCommandSetItem(this, new EventHandler(this.OnStatusPaste), new EventHandler(this.OnMenuPaste), StandardCommands.Paste, uiService), new CommandSetItem(this, new EventHandler(this.OnStatusSelectAll), new EventHandler(this.OnMenuSelectAll), StandardCommands.SelectAll, true, uiService), new CommandSetItem(this, new EventHandler(this.OnStatusAlways), new EventHandler(this.OnMenuDesignerProperties), MenuCommands.DesignerProperties, uiService), new CommandSetItem(this, new EventHandler(this.OnStatusAlways), new EventHandler(this.OnKeyCancel), MenuCommands.KeyCancel, uiService), new CommandSetItem(this, new EventHandler(this.OnStatusAlways), new EventHandler(this.OnKeyCancel), MenuCommands.KeyReverseCancel, uiService), new CommandSetItem(this, new EventHandler(this.OnStatusPrimarySelection), new EventHandler(this.OnKeyDefault), MenuCommands.KeyDefaultAction, true, uiService), new CommandSetItem(this, new EventHandler(this.OnStatusAnySelection), new EventHandler(this.OnKeyMove), MenuCommands.KeyMoveUp, true, uiService), new CommandSetItem(this, new EventHandler(this.OnStatusAnySelection), new EventHandler(this.OnKeyMove), MenuCommands.KeyMoveDown, true, uiService), new CommandSetItem(this, new EventHandler(this.OnStatusAnySelection), new EventHandler(this.OnKeyMove), MenuCommands.KeyMoveLeft, true, uiService), new CommandSetItem(this, new EventHandler(this.OnStatusAnySelection), new EventHandler(this.OnKeyMove), MenuCommands.KeyMoveRight, true), new CommandSetItem(this, new EventHandler(this.OnStatusAnySelection), new EventHandler(this.OnKeyMove), MenuCommands.KeyNudgeUp, true, uiService), new CommandSetItem(this, new EventHandler(this.OnStatusAnySelection), new EventHandler(this.OnKeyMove), MenuCommands.KeyNudgeDown, true, uiService), new CommandSetItem(this, new EventHandler(this.OnStatusAnySelection), new EventHandler(this.OnKeyMove), MenuCommands.KeyNudgeLeft, true, uiService),
         new CommandSetItem(this, new EventHandler(this.OnStatusAnySelection), new EventHandler(this.OnKeyMove), MenuCommands.KeyNudgeRight, true, uiService)
      };
     this.selectionService = (ISelectionService) site.GetService(typeof(ISelectionService));
     if (this.selectionService != null)
     {
         this.selectionService.SelectionChanged += new EventHandler(this.OnSelectionChanged);
     }
     this.menuService = (IMenuCommandService) site.GetService(typeof(IMenuCommandService));
     if (this.menuService != null)
     {
         for (int i = 0; i < this.commandSet.Length; i++)
         {
             this.menuService.AddCommand(this.commandSet[i]);
         }
     }
     IDictionaryService service = site.GetService(typeof(IDictionaryService)) as IDictionaryService;
     if (service != null)
     {
         service.SetValue(typeof(CommandID), new CommandID(new Guid("BA09E2AF-9DF2-4068-B2F0-4C7E5CC19E2F"), 0));
     }
 }
开发者ID:Reegenerator,项目名称:Sample-CustomizeDatasetCS,代码行数:35,代码来源:CommandSet.cs

示例4: GetVS7Font

 internal static Font GetVS7Font(ISite site)
 {
     System.Drawing.Font vsfont = Control.DefaultFont;
     if (site != null)
     {
         IUIService uiService = (IUIService) site.GetService(
             typeof(IUIService)
             );
         if (uiService != null)
         {
             vsfont = (Font) uiService.Styles["DialogFont"];
         }
     }
     return vsfont;
 }    
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:15,代码来源:GenericUI.cs

示例5: GetDesignTimeSection

        private static ConfigSection section; // = ConfigurationManager.GetSection(ConfigSectionName.FineUI) as ConfigSection;


        /// <summary>
        /// Refer:http://flimflan.com/blog/AccessingWebconfigAtDesignTimeInNET20.aspx
        /// </summary>
        /// <param name="site"></param>
        /// <returns></returns>
        public static ConfigSection GetDesignTimeSection(ISite site)
        {
            IWebApplication webApp = (IWebApplication)site.GetService(typeof(IWebApplication));
            if (webApp != null)
            {
                Configuration config = webApp.OpenWebConfiguration(false);
                if (config != null)
                {
                    ConfigurationSection section = config.GetSection(ConfigSectionName.FineUI);
                    if (section != null)
                    {
                        return section as ConfigSection;
                    }
                }
            }
            return null;
        }
开发者ID:erpframework,项目名称:FineUI,代码行数:25,代码来源:GlobalConfig.cs

示例6: GetWebResourceUrl

        /// <summary>
        /// 设计时嵌入资源url地址
        /// </summary>
        /// <param name="site"></param>
        /// <param name="resourceName"></param>
        /// <returns></returns>
        public static string GetWebResourceUrl(ISite site, string resourceName)
        {
            string resourceUrl = String.Empty;
            if (site != null)
            {
                IResourceUrlGenerator service = (IResourceUrlGenerator)site.GetService(typeof(IResourceUrlGenerator));
                if (service != null)
                {
                    resourceUrl = service.GetResourceUrl(site.Component.GetType(), resourceName);
                }
            }

            //// 告诉HttpCompress,不要设置ETag,同时设置Expires为一年后的今天
            //resourceUrl += "&expires=1";

            return resourceUrl;
        }
开发者ID:g992com,项目名称:esb,代码行数:23,代码来源:ResourceHelper.cs

示例7: GetExtenderProviders

            /// <devdoc> 
            ///      Retrieves the set of extender providers providing services for the given component. 
            /// </devdoc> 
            private IExtenderProvider[] GetExtenderProviders(ISite site) {
                // See if this component's site has an IExtenderListService.  If it
                // does, we get our list of extenders from that, not from the container.
                //
                IExtenderListService listService = (IExtenderListService)site.GetService(typeof(IExtenderListService));

                if (listService != null) {
                    return listService.GetExtenderProviders();
                }
                else {
                    ComponentCollection comps = site.Container.Components;
                    ArrayList exList = null;
                    foreach(IComponent comp in comps) {
                        if (comp is IExtenderProvider) {
                            if (exList == null) {
                                exList = new ArrayList(2);
                            }
                            exList.Add(comp);
                        }
                    }
                    if (exList == null) {
                        return null;
                    }
                    else {
                        IExtenderProvider[] temp = new IExtenderProvider[exList.Count];
                        exList.CopyTo(temp, 0);
                        return temp;
                    }
                }
            }
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:33,代码来源:DebugTypeDescriptor.cs

示例8: LoadSystemLanguages

 internal static string LoadSystemLanguages(string systemmessagefile, ISite site)
 {
     if (systemmessagefile != null &&
         systemmessagefile.StartsWith(HTTPCONST, StringComparison.OrdinalIgnoreCase) == false)
     {
         IWebApplication webApp = (IWebApplication) site.GetService(typeof (IWebApplication));
         if (webApp != null)
         {
             if (webApp.RootProjectItem.PhysicalPath == null)
                 throw new ApplicationException(
                     string.Format("No Phystical path found for web project '{0}'", webApp.RootProjectItem.Name));
             if (systemmessagefile.StartsWith("~/"))
                 systemmessagefile = systemmessagefile.Remove(0, 2);
             systemmessagefile = Path.Combine(webApp.RootProjectItem.PhysicalPath, systemmessagefile);
         }
     }
     return systemmessagefile;
 }
开发者ID:webgrid,项目名称:WebGrid,代码行数:18,代码来源:Config.cs

示例9: GetExtNetSection

        public static GlobalConfig GetExtNetSection(ISite site)
        {
            if (site != null)
            {
                IWebApplication app = (IWebApplication)site.GetService(typeof(IWebApplication));

                if (app != null)
                {
                    Configuration config = app.OpenWebConfiguration(false);

                    if (config != null)
                    {
                        ConfigurationSection section = config.GetSection("extnet");

                        if (section != null)
                        {
                            return section as GlobalConfig;
                        }
                    }
                }
            }

            return null;
        }
开发者ID:emayk,项目名称:Ext.NET.Pro,代码行数:24,代码来源:WebConfigUtils.cs

示例10: SetSite

        public void SetSite(ISite site)
        {
            // Overriding the Site property directly breaks the WinForms designer.
            this.Site = site;
            this.settings = (Settings)site.GetService(typeof(Settings));
            if (this.settings != null) {
                this.settings.Changed += new SettingsEventHandler(settings_Changed);
            }
            settings_Changed(this, "");
            this.editor.Site = site;

            XmlCache model = (XmlCache)site.GetService(typeof(XmlCache));
            model.ModelChanged += new EventHandler<ModelChangedEventArgs>(OnModelChanged);
        }
开发者ID:Podracer,项目名称:DAE-notepad,代码行数:14,代码来源:NodeTextView.cs

示例11: SetSite

 public void SetSite(ISite site)
 {
     this.site = site;
     IServiceProvider sp = (IServiceProvider)site;
     this.resolver = new XmlProxyResolver(sp);
     this.model = (XmlCache)site.GetService(typeof(XmlCache));
     this.model.ModelChanged -= new EventHandler<ModelChangedEventArgs>(OnModelChanged);
     this.model.ModelChanged += new EventHandler<ModelChangedEventArgs>(OnModelChanged);
 }
开发者ID:dbremner,项目名称:xmlnotepad,代码行数:9,代码来源:XsltViewer.cs

示例12: CheckConfiguration

        internal static void CheckConfiguration(ISite site)
        {
            if (site == null)
            {
                return;
            }

            IWebApplication app = (IWebApplication)site.GetService(typeof(IWebApplication));

            if (app == null)
            {
                return;
            }

            Configuration config = app.OpenWebConfiguration(false);

            HttpHandlersSection handlers = (HttpHandlersSection)config.GetSection("system.web/httpHandlers");

            // Does the httpHandlers Secton already exist?
            if (handlers == null)
            {
                // If not, add it...
                handlers = new HttpHandlersSection();

                ConfigurationSectionGroup group = config.GetSectionGroup("system.web");

                // Does the system.web Section already exist?
                if (group == null)
                {
                    // If not, add it...
                    config.SectionGroups.Add("system.web", new ConfigurationSectionGroup());
                    group = config.GetSectionGroup("system.web");
                }

                if (group != null)
                {
                    group.Sections.Add("httpHandlers", handlers);
                }
            }

            HttpHandlerAction action = new HttpHandlerAction("*/ext.axd", "Ext.Net.ResourceHandler", "*", false);

            // Does the ResourceHandler already exist?
            if (handlers.Handlers.IndexOf(action) < 0)
            {
                // If not, add it...
                handlers.Handlers.Add(action);
                config.Save();
            }



            HttpModulesSection modules = (HttpModulesSection)config.GetSection("system.web/httpModules");

            // Does the httpModules Secton already exist?
            if (modules == null)
            {
                // If not, add it...
                modules = new HttpModulesSection();

                ConfigurationSectionGroup group = config.GetSectionGroup("system.web");

                // Does the system.web Section already exist?
                if (group == null)
                {
                    // If not, add it...
                    config.SectionGroups.Add("system.web", new ConfigurationSectionGroup());
                    group = config.GetSectionGroup("system.web");
                }

                if (group != null)
                {
                    group.Sections.Add("httpModules", modules);
                }
            }


            //<add name="DirectRequestModule" type="Ext.Net.DirectRequestModule, Ext.Net" />

            HttpModuleAction action2 = new HttpModuleAction("DirectRequestModule", "Ext.Net.DirectRequestModule, Ext.Net");

            // Does the ResourceHandler already exist?
            if (modules.Modules.IndexOf(action2) < 0)
            {
                // If not, add it...
                modules.Modules.Add(action2);
                config.Save();
            }
        }
开发者ID:hh22333,项目名称:Ext.NET.Community,代码行数:89,代码来源:ResourceHandler.cs


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