Skip to content

Instantly share code, notes, and snippets.

@dharmatech
Last active December 13, 2020 01:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dharmatech/9c3d30bc77d6346b2ec3a5f0f67880b1 to your computer and use it in GitHub Desktop.
Save dharmatech/9c3d30bc77d6346b2ec3a5f0f67880b1 to your computer and use it in GitHub Desktop.
let input_helper (type_obj : System.Type) (property_name : string) (value_str : string) (name_str : string) (attrs_a : XmlAttribute list)=
let mutable type_value = ""
let mutable ls : XmlAttribute list = []
let properties = type_obj.GetProperties()
let property_info = properties.First(fun info -> info.Name = property_name)
if (property_info.PropertyType.Name = "Int64") then
type_value <- "number"
else
type_value <- "text"
let attr_a = System.Attribute.GetCustomAttribute(property_info, typedefof<StringLengthAttribute>) :?> StringLengthAttribute
if (not (isNull attr_a)) then
ls <- ls @ [ attr "data-val-length-max" (string attr_a.MaximumLength) ]
let attrs_b =
[
_type type_value
attr "data-val" "true"
] @ ls @ [
_id name_str
_name name_str
_value value_str
]
input (attrs_a @ attrs_b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment