public InterceptionBuilder(Module module) { module.Add(() => new ServiceDefinition(typeof(IInterceptor <TService>), implementationFactory: _implementationFactory, implementationType: _implementationType, implementationInstance: _implementationInstance, lifecycle: _options.Lifecycle, precondition: _options.Precondition) ); }
public JsonResult Add(string models) { JsonResult result = new JsonResult(); Module bll = new Module(); List<sd_module> lst = new List<sd_module>(); lst = JsonConvert.DeserializeObject<List<sd_module>>(models); if (lst.Count > 0) { foreach (var item in lst) { bll.Add(item); } result.Data = lst; } //清除缓存 Cookie.Remove("zg_menu"); return result; }
public int?AddModule(ModuleEntity objModule) { if (WebOperationContext.Current.IncomingRequest.Method == "OPTIONS") { return(null); } else { try { return(Module.Add(objModule)); } catch (Exception ex) { throw new WebFaultException <string>(ex.Message, HttpStatusCode.ExpectationFailed); } } }
public void CanCreateServiceResolutionExpressionFromConstructorExpression() { var module = new Module(); var definition = new ServiceDefinition( typeof(IServiceWithDependencies), implementationFactory: req => new ServiceWithDependencies( Resolve.From <IServiceWithoutDependencies>(), "Hello world" ) ); module.Add(definition); module.Define <IServiceWithoutDependencies>().As <ServiceWithoutDependencies>(); var configuration = new Configuration(_options, module); var container = configuration.CreateContainer(); var service = container.GetService <IServiceWithDependencies>(); Assert.Equal("Hello world", service.Message); Assert.IsType <ServiceWithoutDependencies>(service.Dependency); }
public void CanCreateServiceResolutionExpressionFromDefaultConstructor() { var module = new Module(); var definition = new ServiceDefinition( typeof(IServiceWithDependencies), implementationType: typeof(ServiceWithDependencies) ); module.Add(definition); module.Define <IServiceWithoutDependencies>().As <ServiceWithoutDependencies>(); var configuration = new Configuration(_options, module); var constructor = _options.ConstructorSelector.SelectConstructor (definition.ImplementationType, configuration); var expression = _options.ExpressionBuilder.CreateResolutionExpressionFromDefaultConstructor(constructor); var expressionBody = expression.Body; Assert.IsType <NewExpression>(expressionBody); Assert.Equal(typeof(ServiceWithDependencies), expressionBody.Type); }
public UISkinInfo TextBox(UITextBoxStyleInfo style) { return(TextBox(Module.Add(style))); }
public UITextBoxStyleInfo Cursor <T>(UIDrawableInfo <T> cursor) where T : class, UI.IDrawable { return(Cursor(Module.Add(cursor))); }
public UITextBoxStyleInfo Active(UIStyleInfo style) { return(Active(Module.Add(style))); }
public UITextBoxStyleInfo Disabled(UIStyleInfo style) { return(Disabled(Module.Add(style))); }
public UITextBoxStyleInfo Hover(UIStyleInfo style) { return(Hover(Module.Add(style))); }
public IRefPool <TObject> Add <TObject>(int initCapacity) where TObject : class, new() { return(Module.Add <TObject>(initCapacity)); }
public IBaseRefPool Add(Type objectType, int initCapacity) { return(Module.Add(objectType, initCapacity)); }
public VoxelTypeInfo Skin(VoxelSkinInfo skinInfo) => Skin(Module.Add(skinInfo));
public DefinitionBuilder(Module module, Type type) { _implementationType = type; module.Add(() => Build(type)); }
protected VoxelTexture ResolveOrCreateTexture(string name) { return(Module.TryResolveAsset <VoxelTexture>(name, out var tex) ? tex : Module.Add(new VoxelTextureInfo(name))); }
public IBaseRefPool Add(Type objectType) { return(Module.Add(objectType)); }
public UIStyleInfo Background <T>(UIDrawableInfo <T> bg) where T : class, UI.IDrawable { return(Background(Module.Add(bg))); }
public UIStyleInfo Font(TileFontInfo font) { return(Font(Module.Add(font))); }
public IRefPool <TObject> Add <TObject>() where TObject : class, new() { return(Module.Add <TObject>()); }
public UISkinInfo Button(UIBoxStyleInfo style) { return(Button(Module.Add(style))); }
public UITextBoxStyleInfo Normal(UIStyleInfo style) { return(Normal(Module.Add(style))); }
static void Main(string[] args) { //Environment.SetEnvironmentVariable("MXNET_ENGINE_TYPE", "NaiveEngine"); mx.SetDevice(DeviceType.CPU); //uint batchSize = 200; //uint numFeatures = 13; //var x = Symbol.Variable("x"); //var trainData = ReadCsv("./data/train.csv"); //var x_train = trainData.SliceAxis(1, 1, 14); //var y_train = trainData.SliceAxis(1, 14, 15); //NDArrayIter dataIter = new NDArrayIter(x_train, y_train); //var fc1 = sym.FullyConnected(x, Symbol.Variable("fc1_w"), null, 64, no_bias: true, symbol_name: "fc1"); //var fc2 = sym.Relu(sym.FullyConnected(fc1, Symbol.Variable("fc2_w"), null, 32, no_bias: true, symbol_name: "fc2"), "relu2"); //var fc3 = sym.FullyConnected(fc2, Symbol.Variable("fc3_w"), null, 1, no_bias: true, symbol_name: "fc3"); //var output = sym.LinearRegressionOutput(fc3, Symbol.Variable("label"), symbol_name: "model"); //NDArrayDict parameters = new NDArrayDict(); //parameters["x"] = new NDArray(new Shape(batchSize, numFeatures)); //parameters["label"] = new NDArray(new Shape(batchSize)); //output.InferArgsMap(MXNet.Device, parameters, parameters); //foreach (var item in parameters.ToList()) //{ // if (item.Key == "x" || item.Key == "label") // continue; // item.Value.SampleUniform(); //} //var opt = new Adam(); //BaseMetric metric = new MAE(); //using (var exec = output.SimpleBind(MXNet.Device, parameters)) //{ // dataIter.SetBatch(batchSize); // var argNames = output.ListArguments(); // DataBatch batch; // for (int iter = 1; iter <= 1000; iter++) // { // dataIter.Reset(); // metric.Reset(); // while (dataIter.Next()) // { // batch = dataIter.GetDataBatch(); // batch.Data.CopyTo(parameters["x"]); // batch.Label.CopyTo(parameters["label"]); // exec.Forward(true); // exec.Backward(); // for (var i = 0; i < argNames.Count; ++i) // { // if (argNames[i] == "x" || argNames[i] == "label") // continue; // opt.Update(iter, i, exec.ArgmentArrays[i], exec.GradientArrays[i]); // } // metric.Update(parameters["label"], exec.Output); // } // Console.WriteLine("Iteration: {0}, Metric: {1}", iter, metric.Get()); // } //} //Global.Device = Context.Cpu(); ////Read Data CsvDataFrame trainReader = new CsvDataFrame("./data/train.csv", true); trainReader.ReadCsv(); var trainX = trainReader[1, 14]; var trainY = trainReader[14, 15]; CsvDataFrame valReader = new CsvDataFrame("./data/test.csv", true); valReader.ReadCsv(); var valX = valReader[1, 14]; NDArrayIter train = new NDArrayIter(trainX, trainY); //Build Model var model = new Module(13); model.Add(new Dense(64, ActivationType.ReLU)); model.Add(new Dense(32, ActivationType.ReLU)); model.Add(new Dense(1)); model.Compile(OptimizerRegistry.Adam(), LossType.MeanSquaredError, new MSE()); model.Fit(train, 1000, 32); Console.ReadLine(); }
public int AddModule(ModuleEntity objModule) { return(Module.Add(objModule)); }