public OGDotNetApp() { //Can't read default config directly if we're untrusted http://social.msdn.microsoft.com/Forums/en-US/clr/thread/1e14f665-10a3-426b-a75d-4e66354c5522 var config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); var section = config.Sections["castle"]; var configXml = section.SectionInformation.GetRawXml(); var resource = new StaticContentResource(configXml); var xmlInterpreter = new XmlInterpreter(resource); _container = new WindsorContainer(xmlInterpreter); FromAssembly.Containing <RemoteEngineContextFactory>().Install(_container, new DefaultConfigurationStore()); _container.Register(); //Give all of the windows the opportunity to pick up context var windowStyle = new Style(typeof(Window)); windowStyle.Setters.Add(new Setter(OGContextProperty, new Binding("OGContext") { Source = this })); windowStyle.Setters.Add(new Setter(OGContextFactoryProperty, new Binding("OGContextFactory") { Source = this })); FrameworkElement.StyleProperty.OverrideMetadata(typeof(Window), new FrameworkPropertyMetadata { DefaultValue = windowStyle } ); FreezeDetector.HookUp(Dispatcher, _container.Resolve <ILogger>()); }
/// <summary> /// Initializes a new instance of the <see cref="JsonInterpreter"/> class. /// </summary> /// <param name="source">The <see cref="IResource"/>.</param> public JsonInterpreter(IResource source) : base(source) { string xmlContents = string.Empty; using (source) { JsonReader reader = new JsonTextReader(new StreamReader(source.Stream)); reader.Read(); XmlNodeConverter toXml = new XmlNodeConverter(); XmlDocument xmlDoc = (XmlDocument)toXml.ReadJson(reader, typeof(XmlDocument)); xmlContents = xmlDoc.OuterXml; reader.Close(); } IResource resource = new StaticContentResource(xmlContents); xmlInterpreter = new XmlConfigurationInterpreter(resource); }
/// <summary> /// Registers the javascript. /// </summary> /// <param name="combiner">The combiner.</param> /// <param name="key">The key.</param> /// <param name="resourceRegistry">The resource registry.</param> /// <param name="javascriptHash">The javascript hash.</param> private void RegisterJavascript(CombinerConfig combiner, string key, IStaticResourceRegistry resourceRegistry, long javascriptHash) { if (combiner.JavascriptFiles.Count < 1) { return; } var script = CombineJSFileContent(combiner.JavascriptFiles); if (ScriptBuilder.Minify) { script = ScriptBuilder.CompressJavascript(script); } var staticContentResource = new StaticContentResource(script); resourceRegistry.RegisterCustomResource(key, null, javascriptHash.ToString(), staticContentResource, "application/x-javascript", DateTime.Now); }
/// <summary> /// Registers the CSS. /// </summary> /// <param name="combiner">The combiner.</param> /// <param name="resourceRegistry">The resource registry.</param> /// <param name="cssKey">The CSS key.</param> /// <param name="cssHash">The CSS hash.</param> private void RegisterCss(CombinerConfig combiner, IStaticResourceRegistry resourceRegistry, string cssKey, long cssHash) { if (combiner.CssFiles.Count < 1) { return; } var css = CombineCssFileContent(combiner); if (ScriptBuilder.Minify) { css = ScriptBuilder.CompressCSS(css); } var cssResource = new StaticContentResource(css); resourceRegistry.RegisterCustomResource(cssKey, null, cssHash.ToString(), cssResource, "text/css", DateTime.Now); }
protected void InitDataMapper() { Assembly assembly = this.GetType().Assembly; AssemblyName assemblyName = assembly.GetName(); Stream stream = assembly.GetManifestResourceStream(assemblyName.Name + ".Configs.SqlMap.config"); XmlDocument document = new XmlDocument(); document.Load(stream); stream.Close(); stream.Dispose(); string[] manifestResourceNames = assembly.GetManifestResourceNames(); System.Text.StringBuilder builder = new System.Text.StringBuilder(); foreach (string manifestResourceName in manifestResourceNames) { if (manifestResourceName.ToLower().EndsWith(ext)) { Match m = regex.Match(manifestResourceName); string namespaceName = m.Result("${namespaceName}"); string resourceName = m.Result("${resourceName}"); builder.Append(String.Format("<sqlMap uri=\"assembly://CySoft.DAL/{0}/{1}\" />", namespaceName, resourceName)); } } document.GetElementsByTagName("sqlMaps")[0].InnerXml = builder.ToString(); ConfigurationSetting configurationSetting = new ConfigurationSetting(); IConfigurationEngine engine = new DefaultConfigurationEngine(configurationSetting); IResource resource = new StaticContentResource(document.InnerXml); engine.RegisterInterpreter(new XmlConfigurationInterpreter(resource)); IMapperFactory mapperFactory = engine.BuildMapperFactory(); sessionFactory = engine.ModelStore.SessionFactory; dataMapper = ((IDataMapperAccessor)mapperFactory).DataMapper; }