Lambda のアイデンティティベースの IAM ポリシーによると
AWSLambdaFullAccess と AWSLambdaReadOnlyAccessは 2021年3月1日に非推奨となったようです。
AWSLambdaFullAccess と AWSLambdaReadOnlyAccessは 2021年3月1日に非推奨となったようです。
| Number(1,0) | bool |
| Number(2,0) ~ Number(3,0) | byte |
| Number(4,0) | int16 |
| Number(5,0) ~ Number(9,0) | int32 |
| Number(10,0) ~ Number(18,0) | int64 |
<oracle.manageddataaccess.client>
<version number="*">
<edmMappings>
<edmNumberMapping>
<add NETType="int16" MinPrecision="1" MaxPrecision="4" DBType="Number"/>
</edmNumberMapping>
</edmMappings>
<dataSources>
<dataSource alias="XXXXX" descriptor="(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=XXX.XXX.XXX.XXX)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=XXXXX))) " />
</dataSources>
</version>
</oracle.manageddataaccess.client>
@Html.EditorFor(mdl => mdl.ID, new { htmlAttributes = new { @class = "form-control" } })
少しの事なんだけどメンドクサイ…
@Html.EditorForEx(mdl => mdl.ID, new { @class = "form-control" } )
using System;
using System.Linq.Expressions;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Html;
using System.Web.Routing;
using MyApp.Addon.Attributes;
namespace MyApp.Addon.Extentions
{
///
/// HTMLヘルパーに対する拡張クラス
///
public static class HtmlHelperEx
{
///
/// EditorForヘルパーを拡張したヘルパー
/// 機能
/// htmlAttributesの指定なしにclass属性を指定する
/// class属性にハードコーディングされる「text-box single-line」を削除する
///
///
///
///
///
///
public static IHtmlString EditorForEx<TModel, TValue>(this HtmlHelper<TModel> htmlHelper,
Expression<Func<TModel, TValue>> expression,
object viewData)
{
//属性をディクショナリに変換
var dicAttr = new RouteValueDictionary(viewData);
//何か固定で足したい属性があればここで足す
//属性を追加
dicAttr.Add("maxlength", 10);
/*
* EditorForヘルパーでHTML属性を指定するには
* @Html.EditorFor(mdl => mdl.ID, new { htmlAttributes = new { @class = "form-control", @readonly="readonly" } } )
* と指定しなければならない。
*
* これをEditorForExヘルパーでは
* @Html.EditorFor(mdl => mdl.ID, new { @class = "form-control", @readonly="readonly" } )
* と指定できるようにする。
*/
dynamic htmlAttr = new { htmlAttributes = dicAttr };
MvcHtmlString hstr = htmlHelper.EditorFor(expression, (object)htmlAttr);
/*
* 吐き出されるHtmlより class=属性の「text-box single-line」を外す
*/
hstr = MvcHtmlString.Create(hstr.ToString().Replace(" text-box single-line", ""));
return hstr;
}
}
}
よく使用するヘルパーであれば、Views/Web.configのnamespace要素に追加すると、各ビューにインポートを書かなくて済みます。web.configに追加しない場合は、各ビューの先頭でインポートしてください。・・・省略
@using MyApp.Addon.Extentions;
@Html.EditorFor(mdl => mdl.ID, new { htmlAttributes = new { @class = "form-control" } })
出力結果:
EditorForEx
@Html.EditorForEx(mdl => mdl.ID, new { @class = "form-control" })
出力結果
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using MyApp.Addon.Attributes;
namespace MyApp.ViewModels
{
///
/// ログイン ビューモデル
///
public class Login
{
[DisplayName("ID"),
Placeholder("IDを入力してください")]
public string ID { get; set; }
}
}
@Html.EditorFor(mdl => mdl.ID, new { htmlAttributes = new { @class = "form-control", placeholder = @Html.PlaceholderFor(mdl => mdl.ID) } })
using System;
namespace MyApp.Addon.Attributes
{
///
/// プレースホルダー属性
///
[System.AttributeUsage(AttributeTargets.Property)]
public class PlaceholderAttribute : System.Attribute
{
///
/// プレースホルダーとして表示値する値
///
public string DisplayValue { get; set; }
///
/// コンストラクタ
///
/// プレースホルダーとして表示する値
public PlaceholderAttribute(string displayValue)
{
DisplayValue = displayValue;
}
}
}
次に属性を読み取るモデルメタデータプロバイダーを作成します。using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
namespace MyApp.Addon.Attributes
{
///
/// 拡張したモデルメタデータプロバイダー
///
///
/// Global.asaxのApplication_Start()で、モデルプロバイダーに指定する。
///
public class ModelMetadataProvidersEx : DataAnnotationsModelMetadataProvider
{
///
/// 基底のCreateMetadataをオーバーライド
/// 指定したモデルのメタデータを作成します。
///
/// 属性
/// コンテナーの型。コンテナーが存在しない場合は null。
/// モデル アクセサー。
/// モデルの型。
/// プロパティ名。モデルがプロパティではない場合は、null。
/// モデルのメタデータ
protected override ModelMetadata CreateMetadata(IEnumerable attributes, Type containerType, Func<object> modelAccessor, Type modelType, string propertyName)
{
//元のCreateMetadataメソッドを呼び出し
ModelMetadata metadata = base.CreateMetadata(attributes, containerType, modelAccessor, modelType, propertyName);
//Placeholder属性を追加する
PlaceholderAttribute pha = attributes.OfType<PlaceholderAttribute>().FirstOrDefault();
if (pha != null)
{
metadata.AdditionalValues.Add("Placeholder", pha);
}
return metadata;
}
}
}
作成したモデルメタデータプロバイダーを、Grobal.asaxのApplication_Startメソッドで、属性の読み取りに使用する設定を行います。using System.Web.Mvc;
using System.Web.Routing;
namespace MyApp
{
///
/// アプリケーションイベント
///
public class MvcApplication : System.Web.HttpApplication
{
///
/// アプリケーション起動時
///
protected void Application_Start()
{
//エリア登録
AreaRegistration.RegisterAllAreas();
//ルート登録
RouteConfig.RegisterRoutes(RouteTable.Routes);
//データアノテーション属性の読み込みに、カスタマイズしたプロバイダーを使用する
ModelMetadataProviders.Current = new MyApp.Addon.Attributes.ModelMetadataProvidersEx();
}
}
}
以上で属性の作成は終了です。using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using MyApp.Addon.Attributes;
namespace MyApp.ViewModels
{
///
/// ログイン ビューモデル
///
public class Login
{
[DisplayName("ID"),
Placeholder("IDを入力してください")]
public string ID { get; set; }
}
}
using System;
using System.Linq.Expressions;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Html;
using System.Web.Routing;
using System.Dynamic;
using MyApp.Addon.Attributes;
namespace MyApp.Addon.Extentions
{
///
/// HTMLヘルパーに対する拡張クラス
///
public static class HtmlHelperEx
{
///
/// PlaceholderFor プレースホルダー属性に指定された値を出力するHtmlヘルパー
///
///
///
///
///
///
public static IHtmlString PlaceholderFor<TModel, TValue>(
this HtmlHelper<TModel> htmlHelper,
Expression<Func<TModel, TValue>> expression)
{
var attrList = ModelMetadata.FromLambdaExpression<TModel, TValue>(expression, htmlHelper.ViewData);
//プレースホルダーの属性値を返す
if (attrList.AdditionalValues.ContainsKey("Placeholder"))
{
var plhAttr = (PlaceholderAttribute)attrList.AdditionalValues["Placeholder"];
return new HtmlString(plhAttr.DisplayValue);
}
return new HtmlString("");
}
}
}
web.configに追加しない場合は、各ビューの先頭でインポートしてください。・・・省略
@using MyApp.Addon.Extentions;これでビューでは @Html.PlaceholderFor ヘルパーを使用して、プレースホルダーの値を表示できるようになります。
@Html.EditorFor(mdl => mdl.ID, new { htmlAttributes = new { @class = "form-control", placeholder = @Html.PlaceholderFor(mdl => mdl.ID) } })