public static Type GetType(string name, bool throwOnError) { if (JsTypeHelper._HasTypeArguments(name)) { var jsTypeAndArgs = JsTypeHelper._GetTypeWithArguments(name, throwOnError); if (jsTypeAndArgs == null) { return(null); } var genericType = JsCompilerGlobal._TypeOf(jsTypeAndArgs[0].As <JsType>()); var jsTypeArgs = jsTypeAndArgs[1].As <JsExtendedArray>(); for (var i = 0; i < jsTypeArgs.length; i++) { jsTypeArgs[i] = JsCompilerGlobal._TypeOf(jsTypeArgs[i].As <JsType>()); } var type = genericType.As <JsImplType>()._MakeGenericType(jsTypeArgs); return(type); } var jsType = JsTypeHelper.GetType(name); if (jsType == null) { if (throwOnError) { throw new Exception("Type " + name + " was not found"); } return(null); } return(JsCompilerGlobal._TypeOf(jsType)); }
internal void VerifyCustomAttributesOnTypeAndMembers() { if (verifiedCustomAttributesOnTypeAndMembers) { return; } verifiedCustomAttributesOnTypeAndMembers = true; if (_JsType.customAttributes == null) { return; } for (var i = 0; i < _JsType.customAttributes.length; i++) { var attDef = _JsType.customAttributes[i].As <JsAttribute>(); var attType = JsTypeHelper.GetType(attDef.typeName); var jsCtor = attType.As <JsObject>()[attDef.ctorName].As <JsFunction>(); var att = Js.ApplyNew(jsCtor, attDef.positionalArguments); if (attDef.namedArguments != null) { foreach (string propName in attDef.namedArguments) { var value = attDef.namedArguments[propName]; if (Js.Typeof(value) == "function") { value = value.As <JsFunction>().call(null); } att.As <JsObject>()["set_" + propName].As <JsFunction>().call(att, value); } } var target = GetAttributeTarget(attDef.targetType, attDef.targetMemberName); if (target._CustomAttributes == null) { target._CustomAttributes = new JsExtendedArray(); } target._CustomAttributes.push(att); } }