public void Awake() { base.Initial(); ModelHolder modelHolder = Resources.Load <ModelHolder>("ExcelAsset/ModelHolder"); //阵营 foreach (CampModel campModel in modelHolder.campModels) { CampModelDic.Add(campModel.campID, campModel); CampName_IDDic.Add(campModel.campName, campModel.campID); } //卡牌 foreach (CardModel cardModel in modelHolder.cardModels) { CardModelDic.Add(cardModel.cardID, cardModel); } //地形表 foreach (TerrainModel terrainModel in modelHolder.terrainModels) { terrainModelDic.Add(terrainModel.terrainID, terrainModel); } //地形_地图表 foreach (Terrain_MapModel terrain_mapModel in modelHolder.terrain_MapModels) { terrain_MapModelDic.Add(terrain_mapModel.size, terrain_mapModel); } }
public object GetSession(Type type) { if (CommonDbContext == null) { CommonDbContext = new CommonDbContext(ModelHolder.GetCompiledDbModel()); } return(CommonDbContext); }
private static void RunSingleOperationManually() { // Run an operation manually. TestModelA testModelA = new TestModelA(); ModelHolder<TestModelA> modelHolder = new ModelHolder<TestModelA>(testModelA); SetValueString setValueStringOperation = new SetValueString(); setValueStringOperation.Execute(modelHolder); }
private static void RunPipelineOfOperationsUsingBasicOperationPipelineRunner() { // Run a pipeline of operations by using the pipeline operation runner. ModelHolder<IModel> modelHolder = new ModelHolder<IModel>(); modelHolder.Instance = null; // This should be the Environment model. SetTestModelAValues pipeline = new SetTestModelAValues(); BasicOperationPipelineRunner pipelineRunner = new BasicOperationPipelineRunner(); IRun runResult = pipelineRunner.Run(pipeline, modelHolder); }
private static void RunSingleOperationUsingBasicOperationRunner() { // Run an operation using the BasicOperationRunner. TestModelA testModelA = new TestModelA(); ModelHolder<TestModelA> modelHolder = new ModelHolder<TestModelA>(testModelA); SetValueString setValueStringOperation = new SetValueString(); BasicOperationRunner basicRunner = new BasicOperationRunner(); IRun runResult = basicRunner.Run(setValueStringOperation, modelHolder); }
public Recommender( // PredictionEnginePool<CourseRatingMl, RatingPrediction> predictionEnginePool, ProductDbContext dbContext, MLContext mlContext, ModelHolder modelHolder) { // _predictionEnginePool = predictionEnginePool; _dbContext = dbContext; _mlContext = mlContext; _modelHolder = modelHolder; maxRating = 5.0; maxAttempts = 3; coursesPerAttempt = 52; requiredCourses = 5; }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddCors(options => { options.AddDefaultPolicy(builder => { builder.AllowAnyHeader(); builder.AllowAnyMethod(); builder.AllowAnyOrigin(); }); }); string connectionString = @"Data Source=Recommender.db"; connectionString = Environment.GetEnvironmentVariable("CONNECTION_STRING"); if (connectionString == null) { connectionString = Configuration.GetConnectionString("CONNECTION_STRING"); Environment.SetEnvironmentVariable("CONNECTION_STRING", connectionString); } services.AddDbContext <ProductDbContext>(options => // options.UseSqlite(connectionString) options.UseNpgsql(connectionString) ); services.AddControllers(options => { options.Conventions.Add(new RouteTokenTransformerConvention(new SlugifyParameterTransformer())); }) .AddJsonOptions(options => options.JsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.CamelCase); // HACK var modelPath = Path.Combine(Environment.CurrentDirectory, "Data", "CourseRecommenderModel.zip"); services.AddTransient <MLContext>(); var mlModel = new ModelHolder(); DataViewSchema modelSchema; var _mlContext = new MLContext(); ITransformer trainedModel = _mlContext.Model.Load(modelPath, out modelSchema); mlModel.Model = trainedModel; services.AddSingleton(mlModel); // services.AddPredictionEnginePool<CourseRatingMl, RatingPrediction>() // .FromFile( // modelName:"CourseRecommender", // filePath: modelPath, // watchForChanges: true); }
public void Save(Transform model, bool hideCompnents = false) { if (setting.disablePool) { Destroy(model.gameObject); return; } var mh = new ModelHolder(); mh.model = model; if (isDebug || !list.ContainsKey(mh)) { list.Add(mh, model.name); mh._Pool = this; mh.HideCompnents = hideCompnents; mh.Hide(); model.parent = transform; } }
public override void Initial() { base.Initial(); ModelHolder modelHolder = Resources.Load <ModelHolder>("ExcelAsset/ModelHolder"); //阵营 foreach (CampModel campModel in modelHolder.campModels) { CampModelDic.Add(campModel.campID, campModel); } //地形表 foreach (TerrainModel terrainModel in modelHolder.terrainModels) { terrainModelDic.Add(terrainModel.terrainID, terrainModel); } //地形_地图表 foreach (Terrain_MapModel terrain_mapModel in modelHolder.terrain_MapModels) { terrain_MapModelDic.Add(terrain_mapModel.size, terrain_mapModel); } }
public BattleshipBuilder(ModelHolder modelHolder, Player player1, Player player2, int state) { TookShoot = false; BoatsPlaced = false; resetBoard = false; CurrentState = state; this.modelHolder = modelHolder; this.Player1 = player1; this.Player1.Name = "Player1"; this.Player2 = player2; this.Player2.Name = "Player2"; currentPlayer = player1; if (state == State.PLACE_BOAT_STATE) { visibleBoard = currentPlayer.UserBoard; } else { visibleBoard = currentPlayer.TargetBoard; } modelHolder.modelChanged(visibleBoard); }
//public Transform LoadAndParent(string path, Transform parent) //{ // var g2 = (GameObject)Resources.Load(path); // var g = Load(path); // Transform t1 = g.transform; // Transform t2 = g2.transform; // t1.parent = parent; // t1.localPosition = t2.position; // t1.localRotation = t2.rotation; // return t1; //} public GameObject Load(GameObject path, Vector3 pos, Quaternion rot) { if (!setting.disablePool) { var name = Path.GetFileName(path.name) + "(Clone)"; var keyvalue = list.FirstOrDefault(a => a.Value == name); ModelHolder mh = keyvalue.Key; if (mh != null && mh.model == null) { Debug.LogError("Pool Model Removed"); list.Remove(mh); mh = null; } if (mh != null) { mh.model.position = pos; mh.model.rotation = rot; mh.UnHide(); list.Remove(mh); return(mh.model.gameObject); } } return((GameObject)Instantiate(path, pos, rot)); }