2 using System.Collections.Generic;
5 using System.Web.DynamicData;
6 using System.Web.DynamicData.ModelProviders;
8 namespace MonoTests.Common
12 public static MetaModel GetModel<ContextType> ()
14 // This is really, really dumb but we need that since if the type has already
15 // been registered by another test, or tests are re-ran without nunit having
16 // reloaded the dll we'll get a duplicate entry exception.
19 m = MetaModel.GetModel (typeof (ContextType));
20 } catch (InvalidOperationException) {
22 m.RegisterContext (typeof (ContextType));
24 MetaModel.ResetRegistrationException ();
30 public static void RegisterContext (DataModelProvider model)
32 RegisterContext (model, null);
35 public static void RegisterContext (DataModelProvider model, ContextConfiguration config)
37 // Just in case no model has been created yet
38 MetaModel m = new MetaModel ();
40 // And get the default model instead, whatever it is
41 m = MetaModel.Default;
43 m.RegisterContext (model, config);
44 } catch (InvalidOperationException ex) {
45 Console.WriteLine ("RegisterContext exception:");
46 Console.WriteLine (ex);
50 public static string BuildActionName (MetaTable table, string action)
52 return "/" + table.Name + "/" + action + ".aspx";
55 public static string BuildActionName (MetaTable table, string action, string query)
57 string ret = "/" + table.Name + "/" + action + ".aspx";
58 if (!String.IsNullOrEmpty (query))