/// <summary> /// Builds a method binding argument for the specified argument of the specified type /// </summary> /// <param name="argumentName"></param> /// <param name="type"></param> /// <param name="bindingType"></param> /// <returns></returns> public static IMethodBindingArgument BuildArgumentOfType(string argumentName, Type type, Enum bindingType) { if (bindingType is ChangeableMethodBindingArgumentType changable) { switch (bindingType) { case ChangeableMethodBindingArgumentType.Static: return(new StaticMethodBindingArgument(argumentName, GetDefault.GetDefaultValueFromType(type))); case ChangeableMethodBindingArgumentType.Memory: return(new MemoryMethodBindingArgument(argumentName)); case ChangeableMethodBindingArgumentType.Argument: return(new ArgumentMethodBindingArgument(argumentName)); } } else if (bindingType is NonChangeableMethodBindingType nonChangeable) { switch (bindingType) { case NonChangeableMethodBindingType.Params: return(new ArgumentMethodBindingArgument(argumentName)); } } throw new ArgumentException($"Unknown binding type {bindingType}"); }
/// <summary> /// 生成 /// </summary> /// <param name="authentication">アクセス認証用設定値</param> /// <returns></returns> public static Get Create(AuthenticationStruct?authentication = null) { var createClass = new GetDefault(); createClass.AuthenticationData = authentication; return(createClass); }
public StaticMethodBindingArgument(ParameterInfo info) { this.argName = info.Name; if (info.ParameterType == typeof(string)) { this.ArgValue = ""; } else { this.ArgValue = GetDefault.GetDefaultValueFromType(info.ParameterType); } }
public void Validate(MethodBindingValidationContext validation) { this.type = validation.GetTypeOfArgument(ArgName); if (ArgValue == null) { if (type != null) { if (type == typeof(string)) { ArgValue = ""; } else if (type.IsPrimitive || type.IsValueType) { ArgValue = GetDefault.GetDefaultValueFromType(type); } } } }
public override Value Get() { var value = Arguments[0]; var defaultValue = GetDefault.Create(value); var keys = getIndicators(); Value get; switch (keys.Length) { case 0: return(new Array()); case 1: var key = keys[0]; if (array.ContainsKey(key)) { return(array[key]); } get = defaultValue.Value(); array[key] = get; return(get); default: var newArray = new Array(); foreach (var keyToFind in keys) { if (array.ContainsKey(keyToFind)) { newArray.Add(array[keyToFind]); } else { get = defaultValue.Value(); array[keyToFind] = get; newArray.Add(get); } } return(newArray); } }
/// <summary> /// Creates an instance of Payment entity with corresponding data needed. /// </summary> /// <param name="Is_PaymentRecievable">Specify if Payment being created is meant to Recieve (Sales) then True., Payable (Purchase) then False.</param> /// <returns>Payment Instance ready for use.</returns> public payment New(bool Is_PaymentRecievable) { payment payment = new entity.payment(); payment.status = Status.Documents_General.Pending; payment.State = EntityState.Added; if (Is_PaymentRecievable) { payment.id_range = GetDefault.Return_RangeID(entity.App.Names.PaymentUtility); app_document_range _app_document_range = app_document_range.Where(x => x.id_range == payment.id_range).FirstOrDefault(); if (_app_document_range != null) { payment.app_document_range = _app_document_range; } } payment.IsSelected = true; return(payment); }
/// <summary> /// Create a new method binding from the givin method info /// </summary> /// <param name="info"></param> public MethodBinding(MethodInfo info) { this.className = info.DeclaringType.ToString(); this.methodName = info.Name; arguments = info .GetParameters() .Select( x => { if (x.GetCustomAttribute <ParamArrayAttribute>() != null) { return((IMethodBindingArgument) new ParamsMethodBindingArgument(x)); } else { return((IMethodBindingArgument) new StaticMethodBindingArgument(x.Name, GetDefault.GetDefaultValueFromType(x.ParameterType))); } }) .ToArray(); PruneArgs(); }