protected virtual object CreateValue() { if (this.Type == null) { return(null); } try { object result = PluginUtility.BuildType(this.Type, (Type parameterType, string parameterName, out object parameterValue) => { return(PluginUtility.ObtainParameter(this.Plugin, parameterType, parameterName, out parameterValue)); }); if (result == null) { throw new PluginException(string.Format("Can not build instance of '{0}' type, Maybe that's cause type-generator not found matched constructor with parameters. in '{1}' plugin.", this.Type.FullName, this.Plugin)); } return(result); } catch (Exception ex) { throw new PluginException(string.Format("Occurred an exception on create a fixed-element instance of '{0}' type, at '{1}' plugin.", this.Type.FullName, this.Plugin), ex); } }
internal Builtin CreateBuiltin(string builderName, string name) { if (string.IsNullOrWhiteSpace(name)) { name = "$" + builderName + "-" + PluginUtility.GetAnonymousId(builderName).ToString(); } return(new Builtin(builderName, name, this)); }
internal static object BuildType(string typeName, Builtin builtin) { Type type = PluginUtility.GetType(typeName); if (type == null) { throw new PluginException(string.Format("Can not get type from '{0}' text for '{1}' builtin.", typeName, builtin)); } return(BuildType(type, builtin)); }
public object GetValue(Type valueType, object defaultValue) { if (_valueNode == null) { return(PluginUtility.ResolveValue(_owner, _rawValue, _name, valueType, defaultValue)); } var result = _valueNode.UnwrapValue(ObtainMode.Auto, _owner); if (valueType != null) { result = Zongsoft.Common.Convert.ConvertValue(result, valueType, defaultValue); } return(result); }
public static object BuildBuiltin(Builtin builtin, IEnumerable <string> ignoredProperties = null) { if (builtin == null) { throw new ArgumentNullException("builtin"); } var result = PluginUtility.BuildType(builtin); //设置更新目标对象的属性集 if (result != null) { UpdateProperties(result, builtin, ignoredProperties); } return(result); }
public object GetValue(Type valueType) { var original = System.Threading.Interlocked.CompareExchange(ref _evaluateValueRequired, 1, 0); if (original == 0) { if (valueType != null && string.IsNullOrEmpty(_parameterTypeName)) { _value = PluginUtility.ResolveValue(_constructor.Builtin, _rawValue, null, valueType, null); } else { _value = PluginUtility.ResolveValue(_constructor.Builtin, _rawValue, null, this.ParameterType, null); } } return(_value); }