Beispiel #1
0
        public void Application_Start()
        {
            var edmx = new XmlDocument();
            edmx.Load(HttpContext.Current.Server.MapPath(WesentConfiguration.DefaultInstance.Model));
            var modelParser = new EdmxParser(edmx);

            var types = new RuntimeTypeGenerator(modelParser).GenerateTypes();

            GlobalConfiguration.Configure(config =>
            {

                //config.MessageHandlers.Add(new BasicAuthenticationHandler());
                //config.Filters.Add(new BasicAuthorizationFilter());

                ODataConventionModelBuilder builder = new ODataConventionModelBuilder();

                config.Services.Replace(typeof(IHttpControllerSelector), new DynamicControllerSelector(config, types));

                foreach (var kv in types)
                {
                    var mi = typeof(ODataConventionModelBuilder).GetMethod("EntitySet").MakeGenericMethod(kv.Value); ;
                    mi.Invoke(builder, new[] { kv.Key });
                }
                config.Routes.MapODataRoute("odata", "", builder.GetEdmModel());

                if(!Directory.Exists("C:\\LogFiles\\wesent\\"))
                {
                    Directory.CreateDirectory("C:\\LogFiles\\wesent\\");
                }
                File.AppendAllLines("C:\\LogFiles\\wesent\\log.log", new[] { DateTime.Now.ToString() });

            });
        }
Beispiel #2
0
        public void ParseEdmx_ProducesCorrectResults()
        {
            //arrange
            var config = WesentConfiguration.DefaultInstance;
            var edmx = new XmlDocument();
            edmx.Load(config.Model);

            //act
            string @namespace;
            var model = new EdmxParser(edmx).Parse(out @namespace);
        }
Beispiel #3
0
 public RuntimeTypeGenerator(EdmxParser modelParser)
 {
     this._modelParser = modelParser;
 }