示例#1
0
        /// <summary>
        /// Override with IoC container resolution of DataResult
        /// </summary>
        /// <returns></returns>
        protected virtual DataResult DataResult()
        {
            bool isDebug =
                this.ControllerContext.HttpContext != null ?
                this.ControllerContext.HttpContext.IsDebuggingEnabled :
                false;

            return(new DataResult(
                       new DataWriterProvider(new IDataWriter[]
            {
                new JsonDataWriter(JsonDataWriter.CreateSettings(isDebug)),
                new XmlDataWriter(XmlDataWriter.CreateSettings(Encoding.UTF8, isDebug), new XmlSerializerNamespaces())
            })));
        }
示例#2
0
        public override void Load()
        {
            // serialization
            this.Bind <IDataWriter>().To <JsonDataWriter>().InSingletonScope();
            this.Bind <JsonWriterSettings>().ToConstant(JsonDataWriter.CreateSettings(false));
            this.Bind <IDataWriter>().To <XmlDataWriter>().InSingletonScope();
            this.Bind <XmlWriterSettings>().ToConstant(XmlDataWriter.CreateSettings(Encoding.UTF8, false));
            this.Bind <XmlSerializerNamespaces>().ToConstant(new XmlSerializerNamespaces());
            this.Bind <IDataWriterProvider>().To <DataWriterProvider>().InSingletonScope();

            this.Bind <IDataReader>().To <JsonDataReader>().InSingletonScope();
            this.Bind <JsonReaderSettings>().ToConstant(JsonDataReader.CreateSettings(true));
            this.Bind <IDataReader>().To <XmlDataReader>().InSingletonScope();
            this.Bind <XmlReaderSettings>().ToConstant(XmlDataReader.CreateSettings());
            this.Bind <IDataReaderProvider>().To <DataReaderProvider>().InSingletonScope();

            // MVC and IoC types
            this.Bind <IActionInvoker>().To <NinjectActionInvoker>().InTransientScope();
        }