public void Train(IWebApplication webApplication, IMLModel mlModel)
        {
            foreach (string watcher in this.Watchers)
            {
                Core.UIMatrix.AddElement(webApplication, watcher);
            }

            foreach (ModelDefinitionState validModel in this.Valid)
            {
                var validation = validModel.RunValidation(webApplication, mlModel,
                                                          this, validModel, true);
#if TRACE
                Console.WriteLine($"Validation matrix: {validation}");
#endif
            }

            foreach (ModelDefinitionState validModel in this.Invalid)
            {
                var validation = validModel.RunValidation(webApplication, mlModel,
                                                          this, validModel, false);
#if TRACE
                Console.WriteLine($"Validation matrix: {validation}");
#endif
            }
        }
示例#2
0
        public override DesignerDataSourceView GetView(string viewName)
        {
            if (!(viewName.Equals(ControllerDataSourceView.DefaultViewName)))
            {
                return(null);
            }
            IWebApplication webApp = ((IWebApplication)(this.Component.Site.GetService(typeof(IWebApplication))));

            if (webApp == null)
            {
                return(null);
            }
            IProjectItem item = webApp.GetProjectItemFromUrl("~/Controllers");

            if (_view == null)
            {
                _view = new ControllerDataSourceDesignView(this, ControllerDataSourceView.DefaultViewName);
            }
            _view.DataController = _control.DataController;
            _view.DataView       = _control.DataView;
            if (item != null)
            {
                _view.BasePath = item.PhysicalPath;
            }
            return(_view);
        }
        public override object EvaluateExpression(string expression, object parseTimeData, Type propertyType, IServiceProvider serviceProvider)
        {
            KeyValueConfigurationCollection customSettings = null;

            if (serviceProvider != null)
            {
                IWebApplication webApp = (IWebApplication)serviceProvider.GetService(typeof(IWebApplication));
                if (webApp != null)
                {
                    Configuration config = webApp.OpenWebConfiguration(true);
                    if (config != null)
                    {
                        AppSettingsSection settingsSection = config.AppSettings;
                        if (settingsSection != null)
                        {
                            customSettings = settingsSection.Settings;
                        }
                    }
                }
            }

            if (customSettings != null)
            {
                return(customSettings[expression]);
            }

            return(expression);
        }
        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";
 *          }
 */
        }
        public static ExpressionEditor GetExpressionEditor(string expressionPrefix, IServiceProvider serviceProvider)
        {
            if (serviceProvider == null)
            {
                throw new ArgumentNullException("serviceProvider");
            }
            if (expressionPrefix.Length == 0)
            {
                return(null);
            }
            ExpressionEditor editor  = null;
            IWebApplication  service = (IWebApplication)serviceProvider.GetService(typeof(IWebApplication));

            if (service != null)
            {
                IDictionary expressionEditorsCache = GetExpressionEditorsCache(service);
                if (expressionEditorsCache != null)
                {
                    editor = (ExpressionEditor)expressionEditorsCache[expressionPrefix];
                }
                if (editor == null)
                {
                    string str;
                    Type   expressionBuilderType = GetExpressionBuilderType(expressionPrefix, serviceProvider, out str);
                    if (expressionBuilderType != null)
                    {
                        editor = GetExpressionEditorInternal(expressionBuilderType, str, service, serviceProvider);
                    }
                }
            }
            return(editor);
        }
示例#6
0
 internal static string MapPath(IServiceProvider serviceProvider, string path)
 {
     if (path.Length != 0)
     {
         if (IsAbsolutePhysicalPath(path))
         {
             return(path);
         }
         WebFormsRootDesigner designer = null;
         if (serviceProvider != null)
         {
             IDesignerHost service = (IDesignerHost)serviceProvider.GetService(typeof(IDesignerHost));
             if ((service != null) && (service.RootComponent != null))
             {
                 designer = service.GetDesigner(service.RootComponent) as WebFormsRootDesigner;
                 if (designer != null)
                 {
                     string          appRelativeUrl = designer.ResolveUrl(path);
                     IWebApplication application    = (IWebApplication)serviceProvider.GetService(typeof(IWebApplication));
                     if (application != null)
                     {
                         IProjectItem projectItemFromUrl = application.GetProjectItemFromUrl(appRelativeUrl);
                         if (projectItemFromUrl != null)
                         {
                             return(projectItemFromUrl.PhysicalPath);
                         }
                     }
                 }
             }
         }
     }
     return(null);
 }
        private void LoadExpressionEditors()
        {
            this._expressionEditors = new HybridDictionary(true);
            IWebApplication service = (IWebApplication)base.ServiceProvider.GetService(typeof(IWebApplication));

            if (service != null)
            {
                try
                {
                    System.Configuration.Configuration configuration = service.OpenWebConfiguration(true);
                    if (configuration != null)
                    {
                        CompilationSection section = (CompilationSection)configuration.GetSection("system.web/compilation");
                        foreach (ExpressionBuilder builder in section.ExpressionBuilders)
                        {
                            string           expressionPrefix = builder.ExpressionPrefix;
                            ExpressionEditor expressionEditor = ExpressionEditor.GetExpressionEditor(expressionPrefix, base.ServiceProvider);
                            if (expressionEditor != null)
                            {
                                this._expressionEditors[expressionPrefix] = expressionEditor;
                                this._expressionBuilderComboBox.Items.Add(new ExpressionItem(expressionPrefix));
                            }
                        }
                    }
                }
                catch
                {
                }
                this._expressionBuilderComboBox.InvalidateDropDownWidth();
            }
            this._expressionBuilderComboBox.Items.Add(this.NoneItem);
        }
        private void CreateImageHandler()
        {
            IWebApplication webApp = (IWebApplication)Component.Site.GetService(typeof(IWebApplication));

            GeneratedImage generatedImageControl = Component as GeneratedImage;

            if (generatedImageControl == null)
            {
                return;
            }

            try {
                var    rootFolder = (IFolderProjectItem)webApp.RootProjectItem;
                var    document   = webApp.GetProjectItemFromUrl(this.RootDesigner.DocumentUrl);
                string template   = GetHandlerTemplate(InferLanguage(document));

                var handlerDocument = rootFolder.AddDocument("ImageHandler1.ashx", ASCIIEncoding.Default.GetBytes(template));
                var handlerItem     = handlerDocument as IProjectItem;

                // REVIEW setting the property directly on the control instance does not seem to work
                //generatedImageControl.ImageHandlerUrl = handlerItem.AppRelativeUrl;
                PropertyDescriptor disc = TypeDescriptor.GetProperties(generatedImageControl)["ImageHandlerUrl"];
                if (disc != null)
                {
                    disc.SetValue(generatedImageControl, handlerItem.AppRelativeUrl);
                }

                handlerDocument.Open();
            }
            catch (Exception) {
                // don't do anything, happens if a file existed and user chose not to override
            }
        }
示例#9
0
        /// <summary>
        /// Run 'valid' and 'invalid' validations.
        /// </summary>
        /// <param name="webApplication">Web application handler.</param>
        /// <param name="mlModel">ML model context.</param>
        /// <param name="modelDefiner">Model definer context.</param>
        /// <param name="validModel">Valid or invalid model context.</param>
        /// <param name="valid">Validity.</param>
        /// <returns>Matrix.</returns>
        public IList <double> RunValidation(IWebApplication webApplication, IMLModel mlModel, IModelDefinition modelDefiner, IModelDefinitionState validModel, bool valid)
        {
            Core.UIMatrix.Init(webApplication);

            foreach (string watcher in modelDefiner.Watchers)
            {
                Core.UIMatrix.AddElement(webApplication, watcher);
            }

            foreach (ModelDefinitionAction action in validModel.Actions)
            {
                switch (action.Action)
                {
                case "SetValue":
                    Application.DOM.IDomElement genericElement =
                        new GenericElement(webApplication.Driver)
                    {
                        Name = action.Selector
                    };

                    (genericElement as GenericElement).SetValue(action.Value?.ToString());
                    break;
                }
            }

            IList <double> matrix =
                Core.UIMatrix.CalculateMatrices(webApplication);

            mlModel.WriteDataToCsv(csvFilePath: "Data/modelData.csv",
                                   features: matrix, validity: valid);

            webApplication.Driver.Navigate().GoToUrl(webApplication.Url);

            return(matrix);
        }
示例#10
0
        public static ExpressionEditor GetExpressionEditor(string expressionPrefix, IServiceProvider serviceProvider)
        {
            if (serviceProvider == null)
            {
                return(null);
            }

            IWebApplication webApp = (IWebApplication)serviceProvider.GetService(typeof(IWebApplication));

            if (webApp == null)
            {
                return(null);
            }

            _Configuration config = webApp.OpenWebConfiguration(true);

            if (config == null)
            {
                return(null);
            }

            CompilationSection sec = (CompilationSection)config.GetSection("system.web/compilation");

            System.Web.Configuration.ExpressionBuilder builder = sec.ExpressionBuilders [expressionPrefix];

            if (builder == null)
            {
                return(null);
            }

            return(GetExpressionEditor(Type.GetType(builder.Type), serviceProvider));
        }
示例#11
0
 /// <summary>
 /// Add multiple matrix elements.
 /// </summary>
 /// <param name="webApplication">Web application handler.</param>
 /// <param name="elementSelectors">Element selectors.</param>
 public static void AddElements(IWebApplication webApplication, params string[] elementSelectors)
 {
     foreach (string selector in elementSelectors)
     {
         AddElement(webApplication, selector);
     }
 }
        private IWebApplication GetWebApplication()
        {
            IWebApplication webApplication = (IWebApplication)DesignerHost.GetService(typeof(IWebApplication));

            Assertion.IsNotNull(webApplication, "The 'IServiceProvider' failed to return an 'IWebApplication' service.");

            return(webApplication);
        }
示例#13
0
 /// <summary>
 /// Instantiates a new process contrext for inversion.
 /// </summary>
 /// <remarks>You can think of this type here as "being Inversion". This is the thing.</remarks>
 /// <param name="underlyingContext">The underlying http context to wrap.</param>
 /// <param name="services">The service container the context will use.</param>
 /// <param name="resources">The resources available to the context.</param>
 public OwinProcessContext(IOwinContext underlyingContext, IServiceContainer services, IResourceAdapter resources)
     : base(services, resources)
 {
     _underlyingContext = underlyingContext;
     _application       = null;
     _response          = new OwinResponse(this.UnderlyingContext.Response);
     _request           = new OwinRequest(this.UnderlyingContext.Request);
 }
示例#14
0
 internal WebResourceReader(IWebApplication webApplication)
 {
     _webApplication = webApplication;
     _resourceReader = ServiceLocator.WebResourceReader;
     if (_resourceReader == null)
     {
         _resourceReader = this;
     }
 }
示例#15
0
        public override string GetDesignTimeHtml()
        {
            IWebApplication webApp = this.GetService(typeof(IWebApplication)) as IWebApplication;

            if (webApp != null)
            {
                Configuration config = webApp.OpenWebConfiguration(true);
            }
            return(base.GetDesignTimeHtml());
        }
        private string ReturnThumbnail(string imageUrl, Size size, int quality)
        {
            IWebApplication webApp = (IWebApplication)Component.Site.GetService(typeof(IWebApplication));
            IProjectItem    item   = webApp.GetProjectItemFromUrl(imageUrl);

            string basePath = item.PhysicalPath.Replace("\\", "-").Replace(":", "");
            string path     = Path.Combine(Path.GetTempPath(), string.Format("{0}-{1}{2}{3}.jpg", basePath, size.Height, size.Width, quality));

            return(File.Exists(path) ? string.Concat("<img src=\"", path, "\" />") : CreateNewThumbnail(item, size, path, quality));
        }
 private string CreateConnectionString(IServiceProvider serviceProvider)
 {
     if (serviceProvider == null)
     {
         return(System.Configuration.ConfigurationManager.AppSettings[DatabaseLocationKey]);
     }
     else
     {
         IWebApplication webApp = (IWebApplication)serviceProvider.GetService(typeof(IWebApplication));
         return(webApp.OpenWebConfiguration(true).ConnectionStrings.ConnectionStrings[DatabaseLocationKey].ConnectionString);
     }
 }
示例#18
0
        /// <summary>
        /// Finds the valid connection string for your data source.
        /// </summary>
        /// <param name="connectionString">The connection string.</param>
        /// <param name="grid">The grid object</param>
        /// <returns>The connection string</returns>
        public static string FindConnectionString(string connectionString, Grid grid)
        {
            DataBaseConnectionType connection_type = ConnectionType.FindConnectionType(connectionString);

            if (string.IsNullOrEmpty(connectionString) == false &&
                connectionString.IndexOf("|DataDirectory|", StringComparison.OrdinalIgnoreCase) > -1)
            {
                if (!Grid.GotHttpContext)
                {
                    if (grid == null || grid.Site == null)
                    {
                        return(connectionString);
                    }
                    IWebApplication webApp = (IWebApplication)grid.Site.GetService(typeof(IWebApplication));
                    if (webApp != null)
                    {
                        string directory = webApp.RootProjectItem.PhysicalPath;

                        if (directory == null)
                        {
                            throw new ApplicationException("No Physical path found for |DataDirectory|");
                        }
                        if (Directory.Exists(Path.Combine(directory, "App_data")))
                        {
                            directory = Path.Combine(directory, "App_data");
                        }
                        AppDomain.CurrentDomain.SetData("DataDirectory", directory);
                    }
                }
            } // We already got valid connection string
            if (connection_type != DataBaseConnectionType.Unknown)
            {
                return(connectionString);
            }
            // Load default connection string from AppSettings
            if (string.IsNullOrEmpty(connectionString))
            {
                connectionString = "WGConnectionString";
            }
            if (GridConfig.Get(connectionString, null as string) == null)
            {
                //If not try to load it from ConnectionStrings
                if (ConfigurationManager.ConnectionStrings != null && ConfigurationManager.ConnectionStrings[connectionString] != null)
                {
                    return(ConfigurationManager.ConnectionStrings[connectionString].ConnectionString);
                }
                return(null);
            }
            connectionString = GridConfig.Get(connectionString, null as string);
            return(connectionString);
        }
示例#19
0
        public string MapPath(string originalPath)
        {
            string result = null;
            ISite  site   = this.Component.Site;

            if (site != null)
            {
                IWebApplication vWA = (IWebApplication)site.GetService(typeof(IWebApplication));
                if (vWA != null)
                {
                    string path     = originalPath.Replace("/", "\\");
                    bool   fromRoot = false;

                    while (path.Length > 0 && (path.Substring(0, 1) == "\\" || path.Substring(0, 1) == "~"))
                    {
                        fromRoot = true;
                        path     = path.Substring(1);
                        if (path.Length == 0)
                        {
                            break;
                        }
                    }

                    string fAppRootFolder = vWA.RootProjectItem.PhysicalPath;

                    if (fromRoot)
                    {
                        result = Path.Combine(fAppRootFolder, path);
                    }
                    else
                    {
                        string pageUrl = Path.GetDirectoryName(this.RootDesigner.DocumentUrl).Replace("/", "\\");
                        while (pageUrl.Length > 0 && (pageUrl.Substring(0, 1) == "\\" || pageUrl.Substring(0, 1) == "~"))
                        {
                            pageUrl = pageUrl.Substring(1);
                            if (pageUrl.Length == 0)
                            {
                                break;
                            }
                        }
                        result = Path.Combine(Path.Combine(fAppRootFolder, pageUrl), path);
                    }
                    result = this.RootDesigner.ResolveUrl(result).Substring(8).Replace("/", "\\");
                    if (result.IndexOf(fAppRootFolder, StringComparison.OrdinalIgnoreCase) != 0) // outside Web Application
                    {
                        result = null;
                    }
                }
            }
            return(result);
        }
示例#20
0
        internal static System.Web.Compilation.ExpressionBuilder GetExpressionBuilder(string expressionPrefix, VirtualPath virtualPath, IDesignerHost host)
        {
            if (expressionPrefix.Length == 0)
            {
                if (dataBindingExpressionBuilder == null)
                {
                    dataBindingExpressionBuilder = new DataBindingExpressionBuilder();
                }
                return(dataBindingExpressionBuilder);
            }
            CompilationSection compilationConfig = null;

            if (host != null)
            {
                IWebApplication application = (IWebApplication)host.GetService(typeof(IWebApplication));
                if (application != null)
                {
                    compilationConfig = application.OpenWebConfiguration(true).GetSection("system.web/compilation") as CompilationSection;
                }
            }
            if (compilationConfig == null)
            {
                compilationConfig = MTConfigUtil.GetCompilationConfig(virtualPath);
            }
            System.Web.Configuration.ExpressionBuilder builder = compilationConfig.ExpressionBuilders[expressionPrefix];
            if (builder == null)
            {
                throw new HttpParseException(System.Web.SR.GetString("InvalidExpressionPrefix", new object[] { expressionPrefix }));
            }
            Type c = null;

            if (host != null)
            {
                ITypeResolutionService service = (ITypeResolutionService)host.GetService(typeof(ITypeResolutionService));
                if (service != null)
                {
                    c = service.GetType(builder.Type);
                }
            }
            if (c == null)
            {
                c = builder.TypeInternal;
            }
            if (!typeof(System.Web.Compilation.ExpressionBuilder).IsAssignableFrom(c))
            {
                throw new HttpParseException(System.Web.SR.GetString("ExpressionBuilder_InvalidType", new object[] { c.FullName }));
            }
            return((System.Web.Compilation.ExpressionBuilder)HttpRuntime.FastCreatePublicInstance(c));
        }
示例#21
0
        public override void Initialize(System.ComponentModel.IComponent component)
        {
            base.Initialize(component);

            try
            {
                IWebApplication webApp = (IWebApplication)Component.Site.GetService(typeof(IWebApplication));
                Configuration   config = webApp.OpenWebConfiguration(false);
                DialogHandlerFactory.WriteHandlerToConfiguration(config);
            }
            catch (Exception ex)
            {
                // Gulp
                Debug.Write(ex.ToString());
            }
        }
示例#22
0
 internal static string GetPhysicalPath(Grid grid)
 {
     if (!Grid.GotHttpContext)
     {
         if (grid == null || grid.Site == null)
         {
             return(null);
         }
         IWebApplication webApp = (IWebApplication)grid.Site.GetService(typeof(IWebApplication));
         if (webApp != null)
         {
             return(webApp.RootProjectItem.PhysicalPath);
         }
     }
     return(null);
 }
        private static IDictionary GetExpressionEditorsCache(IWebApplication webApp)
        {
            IDictionaryService service = (IDictionaryService)webApp.GetService(typeof(IDictionaryService));

            if (service == null)
            {
                return(null);
            }
            IDictionary dictionary = (IDictionary)service.GetValue("ExpressionEditors");

            if (dictionary == null)
            {
                dictionary = new HybridDictionary(true);
                service.SetValue("ExpressionEditors", dictionary);
            }
            return(dictionary);
        }
        /// <summary>
        ///     Retrieves the HTML markup that is used to represent the control at design time.
        /// </summary>
        /// <returns>
        ///     The HTML markup used to represent the control at design time.
        /// </returns>
        public override string GetDesignTimeHtml()
        {
            string imageUrl = GetPropertyValue <string>("ImageUrl");

            bool resize = GetPropertyValue <bool>("Resize");

            if (!resize)
            {
                IWebApplication webApp = (IWebApplication)Component.Site.GetService(typeof(IWebApplication));
                IProjectItem    item   = webApp.GetProjectItemFromUrl(imageUrl);
                return(string.Concat("<img src=\"", item.PhysicalPath, "\" />"));
            }

            Size maximumSize = GetPropertyValue <Size>("MaximumSize");
            int  quality     = GetPropertyValue <int>("Quality");

            return(Compare.IsNullOrEmpty(imageUrl) ? "<img src=\"\" />" : ReturnThumbnail(imageUrl, maximumSize, quality));
        }
        public override void Initialize(System.ComponentModel.IComponent component)
        {
            base.Initialize(component);
            this.SetViewFlags(ViewFlags.TemplateEditing, true);

            try
            {
                IWebApplication webApp = (IWebApplication)component.Site.GetService(typeof(IWebApplication));
                Configuration   config = webApp.OpenWebConfiguration(false);

                ConfigHelper.WriteConfig(config);
            }
            catch (Exception ex)
            {
                // Gulp
                Debug.Write(ex.ToString());
            }
        }
示例#26
0
        /// <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.ExtAspNet);
                    if (section != null)
                    {
                        return(section as ConfigSection);
                    }
                }
            }
            return(null);
        }
示例#27
0
 /// <summary>
 /// Ricava la connectionstring da utilizzare.
 /// </summary>
 /// <param name="provider"></param>
 /// <returns></returns>
 public static string GetConnectionString(IServiceProvider provider)
 {
     if (provider == null)
     {
         if (String.IsNullOrEmpty(ConfigurationManager.AppSettings[DatabaseLocationKey]))
         {
             return(ConfigurationManager.ConnectionStrings["connectionstring_sql"].ToString());
         }
         else
         {
             return(ConfigurationManager.AppSettings[DatabaseLocationKey].ToString());
         }
     }
     else
     {
         IWebApplication webApp = (IWebApplication)provider.GetService(typeof(IWebApplication));
         return(webApp.OpenWebConfiguration(true).ConnectionStrings.ConnectionStrings["connectionstring_sql"].ToString());
     }
 }
示例#28
0
        /// <summary>
        ///     Retrieves the HTML markup that is used to represent the control at design time.
        /// </summary>
        /// <returns>
        ///     The HTML markup used to represent the control at design time.
        /// </returns>
        public override string GetDesignTimeHtml()
        {
            string imageUrl  = GetPropertyValue <string>("ImageUrl");
            string text      = GetPropertyValue <string>("Text");
            string color     = ColorTranslator.ToHtml(GetPropertyValue <Color>("ForeColor"));
            string fontNames = string.Join(",", GetPropertyValue <FontInfo>("Font").Names);

            IWebApplication webApp = (IWebApplication)Component.Site.GetService(typeof(IWebApplication));
            IProjectItem    item   = webApp.GetProjectItemFromUrl(imageUrl);

            return(string.Concat("<div style=\"color:", color, ";",
                                 "text-align:center;",
                                 "padding-top:30;",
                                 "font-family:", fontNames, ";",
                                 "font-size:12px;\">",
                                 text,
                                 "<br><br><img src=\"", item.PhysicalPath,
                                 "\" alt=\"busy\" /></div>"));
        }
示例#29
0
 private KeyValueConfigurationCollection GetAppSettings(IServiceProvider serviceProvider)
 {
     if (serviceProvider != null)
     {
         IWebApplication service = (IWebApplication)serviceProvider.GetService(typeof(IWebApplication));
         if (service != null)
         {
             System.Configuration.Configuration configuration = service.OpenWebConfiguration(true);
             if (configuration != null)
             {
                 AppSettingsSection appSettings = configuration.AppSettings;
                 if (appSettings != null)
                 {
                     return(appSettings.Settings);
                 }
             }
         }
     }
     return(null);
 }
示例#30
0
 private ConnectionStringSettingsCollection GetConnectionStringSettingsCollection(IServiceProvider serviceProvider)
 {
     if (serviceProvider != null)
     {
         IWebApplication service = (IWebApplication)serviceProvider.GetService(typeof(IWebApplication));
         if (service != null)
         {
             System.Configuration.Configuration configuration = service.OpenWebConfiguration(true);
             if (configuration != null)
             {
                 ConnectionStringsSection section = (ConnectionStringsSection)configuration.GetSection("connectionStrings");
                 if (section != null)
                 {
                     return(section.ConnectionStrings);
                 }
             }
         }
     }
     return(null);
 }
        internal EntityDataSourceDesignerHelper(EntityDataSource entityDataSource, bool interactiveMode)
        {
            Debug.Assert(entityDataSource != null, "null entityDataSource");

            _entityDataSource = entityDataSource;
            _interactiveMode = interactiveMode;

            _canLoadWebConfig = true;

            IServiceProvider serviceProvider = _entityDataSource.Site;
            if (serviceProvider != null)
            {
                // Get the designer instance associated with the specified data source control
                IDesignerHost designerHost = (IDesignerHost)serviceProvider.GetService(typeof(IDesignerHost));
                if (designerHost != null)
                {
                    _owner = designerHost.GetDesigner(this.EntityDataSource) as EntityDataSourceDesigner;
                }

                // Get other services used to determine design-time information                
                _webApplication = serviceProvider.GetService(typeof(IWebApplication)) as IWebApplication;

            }            
            Debug.Assert(_owner != null, "expected non-null owner");            
            Debug.Assert(_webApplication != null, "expected non-null web application service");            
        }
示例#32
0
 /// <summary>
 /// Creates an instance of <c>WebApplicationService</c> which hosts the specified web application.
 /// </summary>
 /// <param name="application">The web application to host in the Windows service.</param>
 public WebApplicationService(IWebApplication application)
 {
     _application = application;
 }
 internal static ExpressionEditor GetExpressionEditorInternal(Type expressionBuilderType, string expressionPrefix, IWebApplication webApp, IServiceProvider serviceProvider)
 {
     if (expressionBuilderType == null)
     {
         throw new ArgumentNullException("expressionBuilderType");
     }
     ExpressionEditor editor = null;
     object[] customAttributes = expressionBuilderType.GetCustomAttributes(typeof(ExpressionEditorAttribute), true);
     ExpressionEditorAttribute attribute = null;
     if (customAttributes.Length > 0)
     {
         attribute = (ExpressionEditorAttribute) customAttributes[0];
     }
     if (attribute != null)
     {
         string editorTypeName = attribute.EditorTypeName;
         Type c = Type.GetType(editorTypeName);
         if (c == null)
         {
             ITypeResolutionService service = (ITypeResolutionService) serviceProvider.GetService(typeof(ITypeResolutionService));
             if (service != null)
             {
                 c = service.GetType(editorTypeName);
             }
         }
         if ((c != null) && typeof(ExpressionEditor).IsAssignableFrom(c))
         {
             editor = (ExpressionEditor) Activator.CreateInstance(c);
             editor.SetExpressionPrefix(expressionPrefix);
         }
         IDictionary expressionEditorsCache = GetExpressionEditorsCache(webApp);
         if (expressionEditorsCache != null)
         {
             expressionEditorsCache[expressionPrefix] = editor;
         }
         IDictionary expressionEditorsByTypeCache = GetExpressionEditorsByTypeCache(webApp);
         if (expressionEditorsByTypeCache != null)
         {
             expressionEditorsByTypeCache[expressionBuilderType] = editor;
         }
     }
     return editor;
 }
 private static IDictionary GetExpressionEditorsCache(IWebApplication webApp)
 {
     IDictionaryService service = (IDictionaryService) webApp.GetService(typeof(IDictionaryService));
     if (service == null)
     {
         return null;
     }
     IDictionary dictionary = (IDictionary) service.GetValue("ExpressionEditors");
     if (dictionary == null)
     {
         dictionary = new HybridDictionary(true);
         service.SetValue("ExpressionEditors", dictionary);
     }
     return dictionary;
 }
 public void Start()
 {
     _application = new WebApplicationBuilder()
             .UseStartup<StartupExternallyControlled>()
             .Start(_urls.ToArray());
 }
 public AspNetCommunicationListener(IWebApplication webApp)
 {
     _webApp = webApp;
 }