예제 #1
0
        private void RegisterBinders()
        {
            // TODO: this should be constructed via IoC container
            DataModelBinder binder = new DataModelBinder(new DataReaderProvider(new IDataReader[] {
                new JsonDataReader(JsonDataReader.CreateSettings(this.Context.IsDebuggingEnabled)),
                new XmlDataReader(XmlDataReader.CreateSettings(), new XmlSerializerNamespaces())
            }));

            binder.DefaultBinder = ModelBinders.Binders.DefaultBinder;

            // set as the new default
            ModelBinders.Binders.DefaultBinder = binder;
        }
예제 #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();
        }