public static void BuildMethodNode(DataNode dataNode, Type type, MethodInfo methodInfo, bool forceIsMethod) { var klassNode = OccApiGenerator.GetClassNode(dataNode, type); var isReadProperty = IsReadProperty(methodInfo); var isWriteProperty = IsWriteProperty(methodInfo); if (!forceIsMethod && (isReadProperty || isWriteProperty)) { var methodName = methodInfo.Name; if (isWriteProperty) { methodName = methodName.Remove(0, 3); } var returnType = isWriteProperty ? methodInfo.GetParameters()[0].ParameterType : methodInfo.ReturnType; var propertyNode = klassNode.Set(Consts.Properties).Set(methodName, Consts.Property); //var propertyNode = GetPropertiesNode(methodName, propertiesNode, returnType); var prettyName = OccApiGenerator.PrettyName(dataNode, returnType); propertyNode[Consts.ReturnType] = GetReturnPrettyName(prettyName); var attrsNode = propertyNode.Set(Consts.Attrs); if (isWriteProperty) { attrsNode[Consts.IsWriteProperty] = "true"; } if (isReadProperty) { attrsNode[Consts.IsReadProperty] = "true"; } if (methodInfo.IsStatic) { attrsNode[Consts.IsStatic] = "true"; } } else { var methodsNode = klassNode.Set(Consts.Methods); var methodNode = GetMethodNode(methodInfo, methodsNode, dataNode); methodNode.Children.Clear(); if (methodInfo.IsStatic) { methodNode.Set(Consts.Attrs).Set(Consts.IsStatic); } var primitiveTypeName = OccApiGenerator.PrettyName(dataNode, methodInfo.ReturnType); methodNode[Consts.ReturnType] = GetReturnPrettyName(primitiveTypeName); var paremetersNode = methodNode.Set(Consts.Parameters); foreach (var parameter in methodInfo.GetParameters()) { var node = paremetersNode.Set(parameter.Name, Consts.Parameter); var prettyName = OccApiGenerator.PrettyName(node, parameter.ParameterType); node[Consts.ParamType] = prettyName; } } }
public static void BuildConstructorNode(DataNode api, Type type, ConstructorInfo item) { var klassNode = OccApiGenerator.GetClassNode(api, type); var ctorsNode = klassNode.Set(Consts.Constructors); var ctorNode = GetConstructorNode(item, ctorsNode, ctorsNode); ctorNode.Children.Clear(); var paremetersNode = ctorNode.Set(Consts.Parameters); foreach (var parameter in item.GetParameters()) { var node = paremetersNode.Set(parameter.Name, Consts.Parameter); var prettyName = OccApiGenerator.PrettyName(node, parameter.ParameterType); node[Consts.ParamType] = prettyName; } }