示例#1
0
 protected PomonaModule(IPomonaSessionFactory sessionFactory,
                        string modulePath            = "/",
                        IPomonaDataSource dataSource = null)
     : base(modulePath)
 {
     Initialize(sessionFactory, dataSource);
 }
示例#2
0
 public DataSourceRootNode(ITypeMapper typeMapper, IPomonaDataSource dataSource)
     : base(typeMapper, null, "/")
 {
     if (dataSource == null)
         throw new ArgumentNullException("dataSource");
     this.dataSource = dataSource;
 }
 public static IQueryable Query(this IPomonaDataSource dataSource, Type type)
 {
     if (dataSource == null)
     {
         throw new ArgumentNullException(nameof(dataSource));
     }
     if (type == null)
     {
         throw new ArgumentNullException(nameof(type));
     }
     return(queryMethodInvoker(type, dataSource));
 }
        public static object Post(this IPomonaDataSource dataSource, Type type, object form)
        {
            if (dataSource == null)
            {
                throw new ArgumentNullException(nameof(dataSource));
            }
            if (type == null)
            {
                throw new ArgumentNullException(nameof(type));
            }
            if (form == null)
            {
                throw new ArgumentNullException(nameof(form));
            }

            return(postMethodInvoker(type, dataSource, form));
        }
        public static object Patch(this IPomonaDataSource dataSource, Type type, object patchedObject)
        {
            if (dataSource == null)
            {
                throw new ArgumentNullException(nameof(dataSource));
            }
            if (type == null)
            {
                throw new ArgumentNullException(nameof(type));
            }
            if (patchedObject == null)
            {
                throw new ArgumentNullException(nameof(patchedObject));
            }

            return(patchMethodInvoker(type, dataSource, patchedObject));
        }
示例#6
0
        private void Initialize(IPomonaSessionFactory sessionFactory, IPomonaDataSource dataSource)
        {
            if (sessionFactory == null)
            {
                sessionFactory = PomonaModuleConfigurationBinder.Current.GetFactory(this);
            }

            this.sessionFactory = sessionFactory;
            this.dataSource     = dataSource;

            // HACK TO SUPPORT NANCY TESTING (set a valid host name)
            Before += ctx =>
            {
                if (String.IsNullOrEmpty(ctx.Request.Url.HostName))
                {
                    ctx.Request.Url.HostName = "test";
                }
                return(null);
            };

            foreach (var route in this.sessionFactory.Routes.Children)
            {
                RegisterRoutesFor((ResourceType)route.ResultItemType);
            }

            // For root resource links!
            Register(Get, "/", x => ProcessRequest());

            Get[PomonaRouteMetadataProvider.JsonSchema, "/schemas"] = x => GetSchemas();

            var clientAssemblyFileName = $"/{TypeMapper.Filter.ClientMetadata.AssemblyName}.dll";

            Get[PomonaRouteMetadataProvider.ClientAssembly, clientAssemblyFileName] = x => GetClientLibrary();

            RegisterClientNugetPackageRoute();

            RegisterSerializationProvider(TypeMapper);
        }
示例#7
0
        protected PomonaModule(
            IPomonaDataSource dataSource,
            TypeMapper typeMapper)
        {
            // HACK TO SUPPORT NANCY TESTING (set a valid host name)
            Before += ctx =>
            {
                if (String.IsNullOrEmpty(ctx.Request.Url.HostName))
                    ctx.Request.Url.HostName = "test";
                return null;
            };

            this.dataSource = dataSource;

            this.typeMapper = typeMapper;

            foreach (var transformedType in this.typeMapper
                .TransformedTypes.OfType<ResourceType>()
                .Select(x => x.UriBaseType)
                .Where(x => x != null && !x.IsAnonymous() && x.IsRootResource)
                .Distinct())
                RegisterRoutesFor(transformedType);

            Get["/schemas"] = x => GetSchemas();

            Get[String.Format("/{0}.dll", this.typeMapper.Filter.GetClientAssemblyName())] = x => GetClientLibrary();

            RegisterClientNugetPackageRoute();

            Get["/"] = x => GetJsonBrowserHtmlResponse();
            RegisterResourceContent("antlr3-all-min.js");
            RegisterResourceContent("antlr3-all.js");
            RegisterResourceContent("PomonaQueryJsLexer.js");
            RegisterResourceContent("PomonaQueryJsParser.js");
            RegisterResourceContent("QueryEditor.css");
            RegisterResourceContent("QueryEditor.js");
        }
示例#8
0
 public TestPomonaModule(IPomonaDataSource dataSource, TypeMapper typeMapper)
     : base(dataSource, typeMapper)
 {
 }
示例#9
0
 protected PomonaModule(IPomonaDataSource dataSource, TypeMapper typeMapper, string modulePath)
     : this(typeMapper.SessionFactory, modulePath, dataSource)
 {
 }
示例#10
0
 protected PomonaModule(IPomonaDataSource dataSource, TypeMapper typeMapper)
     : this(dataSource, typeMapper, "/")
 {
 }
示例#11
0
 public ModuleContainer(NancyContext nancyContext, IPomonaDataSource dataSource, PomonaModule module)
     : base(nancyContext)
 {
     this.dataSource = dataSource;
     this.module     = module;
 }