public ContentResult OnGet() { var positionOptions = new PositionOptions(); // Bind the PositionOptions class to the Position section of appSettings.json file // In the preceding code, by default, changes to the JSON configuration file after the app has started are read. //Configuration.GetSection(PositionOptions.Position).Bind(positionOptions); //return Content($"Title: {positionOptions.Title} \n" + // $"Name: {positionOptions.Name}"); // ConfigurationBinder.Get<T> binds and returns the specified type. // ConfigurationBinder.Get<T> may be more convenient than using ConfigurationBinder.Bind. // The following code shows how to use ConfigurationBinder.Get<T> with the PositionOptions class. // In the preceding code, by default, changes to the JSON configuration file after the app has started are read //positionOptions = Configuration.GetSection(PositionOptions.Position) // .Get<PositionOptions>(); //return Content($"Title: {positionOptions.Title} \n" + // $"Name: {positionOptions.Name}"); // An alternative approach when using the options pattern is to bind the Position section and add it to the dependency injection service container. // In the following code, PositionOptions is added to the service container with Configure and bound to configuration. // In the preceding code, changes to the JSON configuration file after the app has started are NOT read. // To read changes after the app has started, use IOptionsSnapshot return(Content($"Title: {_options.Title} \n" + $"Name: {_options.Name}")); }
public TodoController(TodoContext todoContext, ILogger <TodoController> logger, IOperationTransien operationTransien, IOperationScope operationScope, IOperationSingleton operationSingleton, IOptionsMonitor <PositionOptions> optionsMonitor, IOptionsSnapshot <TopItemSettings> namedOptionsAccessor, IOptions <MyConfigOptions> options, IHttpClientFactory httpClientFactory, IMemoryCache cache, IDistributedCache distributedCache) { _todoContext = todoContext; _logger = logger; _operationTransien = operationTransien; _operationScope = operationScope; _operationSingleton = operationSingleton; _positionOptions = optionsMonitor.CurrentValue; _monthTopItem = namedOptionsAccessor.Get(TopItemSettings.Month); _yearTopItem = namedOptionsAccessor.Get(TopItemSettings.Year); _myConfigOptions = options.Value; _clientFactory = httpClientFactory; _cache = cache; _distributedCache = distributedCache; }
public ContentResult OnGet(int?id) { var idLocal = 0; if (id.HasValue) { idLocal = id.Value; } string str = $"id: {idLocal}\n\n"; foreach (var provider in ConfigRoot.Providers.ToList()) { str += provider.ToString() + "\n"; } var title = Configuration["Position:Title"]; str += $"\nPosition: Title: {title}"; var positionOptions = new PositionOptions(); Configuration.GetSection(PositionOptions.Position).Bind(positionOptions); str += $"\nTitle: {positionOptions.Title} \n" + $"Name: {positionOptions.Name}"; return(Content(str)); }
public async Task OnGetAsync() { //Getting players from database var players = from p in _context.Players select p; //populating the Team Select options in the view page TeamOptions = await _context.Players.Select(t => new SelectListItem { Value = t.TeamId, Text = t.TeamId }).Distinct().ToListAsync(); //This inserts for the default all TeamOptions.Insert(0, new SelectListItem { Value = "All", Text = "All" }); //populating the Position options in the View page PositionOptions = await _context.Players.Select(p => new SelectListItem { Value = p.Position, Text = p.Position }).Distinct().ToListAsync(); PositionOptions.Insert(0, new SelectListItem { Value = "All", Text = "All" }); //Checks to see if the user inputed a name to search for, if so look and change the players list if (!String.IsNullOrEmpty(SearchString)) { players = from p in players where p.Name.ToLower().Contains(SearchString.ToLower()) select p; } //Checks to see if user changed selected team option from all, if so then change the resulting players shown if (SelectedTeam != "All") { players = from p in players where (p.TeamId == SelectedTeam) select p; } //Checks to see if user changed selected position option from all, if so then change the resulting players shown if (SelectedPosition != "All") { players = from p in players where (p.Position == SelectedPosition) select p; } //This is the end result of the players that get sent to the view page. Players = players.ToList(); }
//返回页面 public void OnGet() { string str = ""; //获取配置实现列表,其中 JsonConfigurationProvider //对于json加载文件是有先后顺序:appsettings.json,appsettings.{Environment}.json。 后面的同名参数会覆盖前面的。 //在程序运行期间,默认JsonConfigurationProvider是配置文件只要一修改,参数立即修改的。我在配置上加了TestParamReloadOnFileChange,改了之后,下一次请求页面就可以看到值也变了。 foreach (var provider in ConfigRoot.Providers.ToList()) { str += provider.ToString() + "\r\n"; } ViewData["Message"] = str; ViewData["Setting"] = ConfigRoot["DetailedErrors"] + " ~ " + ConfigRoot["Logging:LogLevel:Default"] + "~" + ConfigRoot["TestParamReloadOnFileChange"]; var positionOptionsByBind = new PositionOptions(); ConfigRoot.GetSection(PositionOptions.Position) .Bind(positionOptionsByBind); ViewData["Options Pattern1"] = positionOptionsByBind.Name + "~" + positionOptionsByBind.Title; var positionOptionsByGet = ConfigRoot.GetSection(PositionOptions.Position) .Get <PositionOptions>(); ViewData["Options Pattern2"] = positionOptionsByGet.Name + "~" + positionOptionsByGet.Title; ViewData["Options Pattern3"] = _options.Name + "~" + _options.Title; ViewData["ASPNETCORE_ENVIRONMENT"] = ConfigRoot["ASPNETCORE_ENVIRONMENT"]; ViewData["MyEnv1"] = ConfigRoot["MyEnv1"]; ViewData["Path"] = ConfigRoot["Path"]; }
public static Vector3 DoTargetPositionHandle(Vector3 worldPos, PositionOptions option, Transform owner, FsmGameObject target) { //var worldPos = GetTargetPosition(option, owner, target, position); EditorGUI.BeginChangeCheck(); var rotation = Quaternion.identity; var newPos = worldPos; switch (option) { case PositionOptions.CurrentPosition: break; case PositionOptions.WorldPosition: newPos = Handles.PositionHandle(worldPos, rotation); break; case PositionOptions.LocalPosition: if (owner.parent != null) { var parent = owner.parent; rotation = parent.transform.rotation; newPos = parent.InverseTransformPoint(Handles.PositionHandle(worldPos, rotation)); } else { newPos = Handles.PositionHandle(worldPos, rotation); } break; case PositionOptions.WorldOffset: newPos = Handles.PositionHandle(worldPos, rotation) - owner.position; break; case PositionOptions.LocalOffset: rotation = owner.rotation; newPos = owner.InverseTransformPoint(Handles.PositionHandle(worldPos, rotation)); break; case PositionOptions.TargetGameObject: if (target.Value == null) { return(worldPos); } rotation = target.Value.transform.rotation; newPos = target.Value.transform.InverseTransformPoint(Handles.PositionHandle(worldPos, rotation)); break; default: throw new ArgumentOutOfRangeException(); } if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(owner, "Move Scene Gizmo"); } return(newPos); }
public ContentResult OnGet() { // Bind positionOption var positionOption = new PositionOptions(); _configuration.GetSection(PositionOptions.Position).Bind(positionOption); var positionOptionSelection = _configuration.GetSection(PositionOptions.Position); if (positionOptionSelection.Exists()) { var children = positionOptionSelection.GetChildren(); } // two var pitionOption = _configuration.GetSection(PositionOptions.Position).Get <PositionOptions>(); var mykeyValue = _configuration["MyKey"]; var title = _configuration["Position:Title"]; var name = _configuration["Position:Name"]; var defaultLogLevel = _configuration["Logging:LogLevel:Default"]; return(Content($"MyKey value: {mykeyValue} \n" + $"Title: {title} \n" + $"Name: {name} \n" + $"Default Log Level: {defaultLogLevel}")); }
private void DoOptionsGUI(PositionOptions option, string positionField, string targetField) { switch (option) { case PositionOptions.CurrentPosition: break; case PositionOptions.WorldPosition: EditField(positionField, "World Position"); break; case PositionOptions.LocalPosition: EditField(positionField, "Local Position"); break; case PositionOptions.WorldOffset: EditField(positionField, "World Offset"); break; case PositionOptions.LocalOffset: EditField(positionField, "Local Offset"); break; case PositionOptions.TargetGameObject: EditField(targetField, "GameObject"); EditField(positionField, "Local Offset"); break; default: throw new ArgumentOutOfRangeException(); } }
public ContentResult OnGet() { positionOptions = Configuration.GetSection("Position").Get <PositionOptions>(); return(Content($"Title: {positionOptions.Title} \n" + $"Name: {positionOptions.Name}")); }
public ContentResult OnGet() { var positionOptions = new PositionOptions(); _configuration.GetSection(PositionOptions.Position).Bind(positionOptions); return(Content("Name: " + positionOptions.Name + "\r" + "Title: " + positionOptions.Title)); }
public Test26Model(IOptions <PositionOptions> options, IMyDependency myDependency, IOptions <ColorOptions> colorOptions) { _options = options.Value; _color_options = colorOptions.Value; _myDependency = myDependency; }
public ContentResult OnGet() { var positionsOptions = new PositionOptions(); Configuration.GetSection(PositionOptions.Position).Bind(positionsOptions); return(Content($"Title: {positionsOptions.Title} \n" + $"Name: {positionsOptions.Name}")); }
/// <inheritdoc/> public async Task <long?> WatchPosition(PositionOptions options = null) { var module = await _jsBinder.GetModule(); var callbackObj = DotNetObjectReference.Create(this); return(await module.InvokeAsync <int>("Geolocation.watchPosition", callbackObj, nameof(SetWatchPosition), options)); }
public void Reposition(PositionOptions positionOptions) { GetCurrentBar().PositionOptions.Top.Selected = positionOptions.Top.Selected; GetCurrentBar().PositionOptions.Right.Selected = positionOptions.Right.Selected; GetCurrentBar().PositionOptions.Bottom.Selected = positionOptions.Bottom.Selected; GetCurrentBar().PositionOptions.Left.Selected = positionOptions.Left.Selected; Add(GetCurrentBar()); AlignmentOptionsChanged(GetCurrentBar().PositionOptions); }
public int BindConfigeToEntityByGetMethod() { //第二种方法 var positionOptions = new PositionOptions(); positionOptions = Configuration.GetSection(PositionOptions.Position).Get <PositionOptions>(); Console.WriteLine($"Positioin Get"); Console.WriteLine($"PositionOptions.Title= {positionOptions.Title}"); Console.WriteLine($"PositionOptions.Name= {positionOptions.Name}"); return(1); }
public override void Reset() { base.Reset(); fromOption = PositionOptions.CurrentPosition; fromTarget = null; fromPosition = null; toOption = PositionOptions.WorldPosition; toTarget = null; toPosition = null; }
public static bool GetTargetPosition(PositionOptions option, Transform owner, FsmVector3 position, FsmGameObject target, out Vector3 targetPosition) { targetPosition = Vector3.zero; if (owner == null || !IsValidTargetPosition(option, position, target)) { return(false); } targetPosition = GetTargetPosition(option, owner, (target != null && target.Value != null) ? target.Value.transform : null, position.Value); return(true); }
/// <summary> /// 1.ConfigurationBinder.Bind /// 2.ConfigurationBinder.Get<T> /// </summary> /// <returns></returns> public IActionResult Privacy() { var positionOptions = new PositionOptions(); Configuration.GetSection(PositionOptions.Position).Bind(positionOptions); positionOptions = Configuration.GetSection(PositionOptions.Position) .Get <PositionOptions>(); return(Content($"Title: {positionOptions.Title} \n" + $"Name: {positionOptions.Name}")); }
public int BindConfigeToEntityByBindMethod() { //第一种方法 var positionOptions = new PositionOptions(); Configuration.GetSection(PositionOptions.Position).Bind(positionOptions); Console.WriteLine($"Positioin Bind"); Console.WriteLine($"PositionOptions.Title= {positionOptions.Title}"); Console.WriteLine($"PositionOptions.Name= {positionOptions.Name}"); return(1); }
public void PositionOptionsChanged(bool top, bool right, bool bottom, bool left) { var positionOptions = new PositionOptions { Top = new Location(top), Right = new Location(right), Bottom = new Location(bottom), Left = new Location(left) }; Model.Reposition(positionOptions); }
public WeatherForecastController ( ILogger <WeatherForecastController> logger, IOptions <PositionOptions> options, IOptions <ColorOptions> colorOptions // IMyDependency myDependency ) { _logger = logger; _positionOptions = options.Value; _colorOptions = colorOptions.Value; }
public OptionsBindController(IConfiguration configuration, IOptionsMonitor <PositionOptions> options, IOptionsSnapshot <TopItemSettings> optionsSnapshot, ILogger <OptionsBindController> logger ) { Configuration = configuration; _options = options.CurrentValue; _monthTopItem = optionsSnapshot.Get(TopItemSettings.Month); _yearTopItem = optionsSnapshot.Get(TopItemSettings.Year); _logger = logger; }
/// <summary> /// 计算并输出水印图片位置坐标(x轴,y轴) /// </summary> /// <param name="position">水印图片要放置的位置</param> /// <param name="waterWidth">水印图片的宽度</param> /// <param name="waterHeight">水印图片的高度</param> /// <param name="x">输出计算后的x轴</param> /// <param name="y">输出计算后的y轴</param> private void CalculateWaterPosition(PositionOptions position, double waterWidth, double waterHeight, out float x, out float y) { switch (position) { case PositionOptions.LeftAndTop: default: x = 0f; y = 0f; break; case PositionOptions.LeftAndCenter: x = 0f; y = (float)((_originalImage.Height - waterHeight) / 2); break; case PositionOptions.LeftAndBottom: x = 0f; y = (float)(_originalImage.Height - waterHeight); break; case PositionOptions.CenterAndTop: x = (float)((_originalImage.Width - waterWidth) / 2); y = 0f; break; case PositionOptions.Center: x = (float)((_originalImage.Width - waterWidth) / 2); y = (float)((_originalImage.Height - waterHeight) / 2); break; case PositionOptions.CenterAndBottom: x = (float)((_originalImage.Width - waterWidth) / 2); y = (float)(_originalImage.Height - waterHeight); break; case PositionOptions.RightAndTop: x = (float)(_originalImage.Width - waterWidth); y = 0f; break; case PositionOptions.RightAndCenter: x = (float)(_originalImage.Width - waterWidth); y = (float)((_originalImage.Height - waterHeight) / 2); break; case PositionOptions.RightAndBottom: x = (float)(_originalImage.Width - waterWidth); y = (float)(_originalImage.Height - waterHeight); break; } }
public static Vector3 GetTargetPosition(PositionOptions option, Transform owner, Transform target, Vector3 position) { if (owner == null) { return(Vector3.zero); } switch (option) { case PositionOptions.CurrentPosition: return(owner.position); case PositionOptions.WorldPosition: return(position); case PositionOptions.LocalPosition: if (owner.parent == null) { return(position); } return(owner.parent.TransformPoint(position)); case PositionOptions.WorldOffset: return(owner.position + position); case PositionOptions.LocalOffset: return(owner.TransformPoint(position)); case PositionOptions.TargetGameObject: if (target == null) { return(owner.position); } if (position != Vector3.zero) { return(target.TransformPoint(position)); } return(target.position); default: throw new ArgumentOutOfRangeException(); } }
public StripedBar() { _positionInfo = new PositionOptions { Top = new Location(available: true, selected: true), Right = new Location(available: false, selected: false), Bottom = new Location(available: true, selected: false), Left = new Location(available: false, selected: false) }; Image thumbnailImage = Resources.theme_solid; const string friendlyName = "Striped Bar"; _info = new BarInfo(thumbnailImage, friendlyName); }
public DottedBar() { Image thumbnailImage = Resources.theme_dotted; const string friendlyName = "Dotted Bar"; _barInfo = new BarInfo(thumbnailImage, friendlyName); _positionOptions = new PositionOptions { Top = new Location(available: true, selected: true), Right = new Location(available: true, selected: false), Bottom = new Location(available: true, selected: false), Left = new Location(available: true, selected: true) }; }
public static bool CanEditTargetPosition(PositionOptions option, NamedVariable position, FsmGameObject target) { switch (option) { case PositionOptions.CurrentPosition: return(false); case PositionOptions.WorldPosition: case PositionOptions.LocalPosition: case PositionOptions.WorldOffset: case PositionOptions.LocalOffset: return(!position.IsNone); case PositionOptions.TargetGameObject: return(target.Value != null); default: throw new ArgumentOutOfRangeException(); } }
private void ShowTargetOptions(ref PositionOptions positionChoice, ref int choice1dir, ref SerializedProperty vec, ref SerializedProperty obj, ref SerializedProperty dist) { positionChoice = (PositionOptions)EditorGUILayout.EnumPopup("Position type: ", positionChoice); switch (positionChoice) { case PositionOptions.Global: case PositionOptions.Local: EditorGUILayout.PropertyField(vec); break; case PositionOptions.GameObject: EditorGUILayout.PropertyField(obj); break; case PositionOptions.Direction: choice1dir = GUILayout.Toolbar(choice1dir, new string[] { "Forward", "Backward", "Left", "Right", "Up", "Down" }); EditorGUILayout.PropertyField(dist); break; } }
/// <summary> /// Initialize a new instance of the <see cref="OptionType"/> class. /// </summary> /// <param name="parser">The parser creating these arguments.</param> /// <param name="type">The type of the options</param> internal OptionType(Parser parser, Type type, string verb = null) { Parser = parser; Type = type; Verb = verb ?? type.GetCustomAttribute <VerbAttribute>(true)?.Verb; var properties = type.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) .Where(p => p.GetCustomAttribute <OptionAttribute>() != null && p.CanWrite); Options = properties.Select(p => new Option(p)).ToArray(); if (Options.GroupBy(o => o.Name).Any(g => g.Count() > 1)) { throw new ArgumentException($"Duplicate options on type {type.FullName}.", nameof(type)); } PositionOptions = Options.Where(o => o.Position.HasValue).OrderBy(o => o.Position).ToArray(); if (PositionOptions.Any(p => p.Position != Array.IndexOf(PositionOptions, p))) { throw new ArgumentException($"Bad positions for options on type {type.FullName}.", nameof(type)); } }
/// <summary> /// 添加图片水印 /// <remarks>注意:水印图片流waterImage没有进行释放,请自行释放</remarks> /// </summary> /// <param name="waterImage">水印图片</param> /// <param name="opacity">透明度,在 0.0f~1.0f 之间</param> /// <param name="position">水印位置</param> public void AddWaterByImage(Image waterImage, float opacity, PositionOptions position) { if (waterImage == null) { return; } if (_originalImage.Width < waterImage.Width || _originalImage.Height < waterImage.Height) { return; } var graphics = Graphics.FromImage(_originalImage); var colorMap = new[] { new ColorMap { OldColor = Color.FromArgb(255, 0, 255, 0), NewColor = Color.FromArgb(0, 0, 0, 0) } }; float[][] colorMatrixElements = { new [] { 1.0f, 0.0f, 0.0f, 0.0f, 0.0f }, new [] { 0.0f, 1.0f, 0.0f, 0.0f, 0.0f }, new [] { 0.0f, 0.0f, 1.0f, 0.0f, 0.0f }, new [] { 0.0f, 0.0f, 0.0f, opacity, 0.0f }, new [] { 0.0f, 0.0f, 0.0f, 0.0f, 1.0f } }; var colorMatrix = new ColorMatrix(colorMatrixElements); float x, y; CalculateWaterPosition(position, waterImage.Width, waterImage.Height, out x, out y); var imageAttr = new ImageAttributes(); imageAttr.SetRemapTable(colorMap, ColorAdjustType.Bitmap); imageAttr.SetColorMatrix(colorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap); graphics.DrawImage(waterImage, new Rectangle((int)x, (int)y, waterImage.Width, waterImage.Height), 0, 0, waterImage.Width, waterImage.Height, GraphicsUnit.Pixel, imageAttr); }
/// <summary> /// Changes PositionOptions.form layout depending on userRights /// </summary> /// <param name="email"></param> /// <param name="userRights"></param> internal void CheckPrivileges(string email, int userRights) { switch (userRights) { case 1: case 2: case 3: var loginform = new Login(); loginform.Hide(); var newPositionOptions = new PositionOptions(); newPositionOptions.Show(); newPositionOptions.CheckVisible(); newPositionOptions.FillDetails(Userinfo.FirstName, Userinfo.LastName, Userinfo.UserRights); break; default: MessageBox.Show(@"You don't have permission to view this."); break; } }
public void getCurrentPosition(PositionCallback successCallback, PositionErrorCallback errorCallback, PositionOptions options) {}
public int watchPosition(PositionCallback successCallback, PositionErrorCallback errorCallback, PositionOptions options) { return default(int); }