{"action":"created","issue":{"url":"https://api.github.com/repos/qcwgithub/qjsbunitynew/issues/10","labels_url":"https://api.github.com/repos/qcwgithub/qjsbunitynew/issues/10/labels{/name}","comments_url":"https://api.github.com/repos/qcwgithub/qjsbunitynew/issues/10/comments","events_url":"https://api.github.com/repos/qcwgithub/qjsbunitynew/issues/10/events","html_url":"https://github.com/qcwgithub/qjsbunitynew/issues/10","id":95093253,"number":10,"title":"enum类在js和cs交互出问题","user":{"login":"sonygod","id":748320,"avatar_url":"https://avatars.githubusercontent.com/u/748320?v=3","gravatar_id":"","url":"https://api.github.com/users/sonygod","html_url":"https://github.com/sonygod","followers_url":"https://api.github.com/users/sonygod/followers","following_url":"https://api.github.com/users/sonygod/following{/other_user}","gists_url":"https://api.github.com/users/sonygod/gists{/gist_id}","starred_url":"https://api.github.com/users/sonygod/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sonygod/subscriptions","organizations_url":"https://api.github.com/users/sonygod/orgs","repos_url":"https://api.github.com/users/sonygod/repos","events_url":"https://api.github.com/users/sonygod/events{/privacy}","received_events_url":"https://api.github.com/users/sonygod/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-07-15T03:02:11Z","updated_at":"2015-07-15T03:14:14Z","closed_at":null,"body":"enum 已经编译成js,但要传给cs.做分析，\r\npublic static T NodeValue<T>(XmlNode node, string nodeName){\r\n部分分析代码\r\n  if (typeof (T) == typeof (Enum))\r\n            {\r\n                int mInt;\r\n                if (int.TryParse(value.ToString(), out mInt))\r\n                {\r\n                    return (T) ((object) (int.Parse(value.ToString())));\r\n                }\r\n                else\r\n                {\r\n                    var tt = typeof (T);\r\n                    return (T) ((object) (Enum.Parse(tt, value.ToString())));\r\n                }\r\n}\r\n}\r\n\r\n\r\n但没有跳入这个条件\r\n\r\ndebug 后发现是一个不存在cs的类 myEnumID 无法转译成enum，返回string 1\r\n\r\n myEnumID id = pp.NodeValue <  myEnumID  > (\"ID\");\r\n\r\n这里就报错了，\r\n\r\n\r\n\r\n\r\n\r\n[JsType(JsMode.Clr,\r\n        \"../../../StreamingAssets/JavaScript/SharpKitGenerated/JSBinding/Samples/JSImpTest/Person.javascript\")]\r\npublic enum myEnumID\r\n{\r\n    zero,\r\n    one,\r\n    two,\r\n    three,\r\n    four,\r\n    fine,\r\n    six,\r\n    seven,\r\n    eight,\r\n    night,\r\n    ten,\r\n}\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/qcwgithub/qjsbunitynew/issues/comments/121471309","html_url":"https://github.com/qcwgithub/qjsbunitynew/issues/10#issuecomment-121471309","issue_url":"https://api.github.com/repos/qcwgithub/qjsbunitynew/issues/10","id":121471309,"user":{"login":"sonygod","id":748320,"avatar_url":"https://avatars.githubusercontent.com/u/748320?v=3","gravatar_id":"","url":"https://api.github.com/users/sonygod","html_url":"https://github.com/sonygod","followers_url":"https://api.github.com/users/sonygod/followers","following_url":"https://api.github.com/users/sonygod/following{/other_user}","gists_url":"https://api.github.com/users/sonygod/gists{/gist_id}","starred_url":"https://api.github.com/users/sonygod/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sonygod/subscriptions","organizations_url":"https://api.github.com/users/sonygod/orgs","repos_url":"https://api.github.com/users/sonygod/repos","events_url":"https://api.github.com/users/sonygod/events{/privacy}","received_events_url":"https://api.github.com/users/sonygod/received_events","type":"User","site_admin":false},"created_at":"2015-07-15T03:14:14Z","updated_at":"2015-07-15T03:14:14Z","body":"能不能在\r\n\r\njs 重写这个方法？\r\n\r\n//override in js?\r\n     public static void TryToEnum<T>(object value)\r\n    {\r\n        \r\n    }\r\nnamespace\r\n\r\n jsimp\r\n{\r\n//[JsType(JsMode.Clr,\"../../StreamingAssets/JavaScript/SharpKitGenerated/JSBinding/JSImp/Reflection.javascript\")]\r\n\r\n[JsType(JsMode.Clr,\"../../StreamingAssets/JavaScript/SharpKitGenerated/JSBinding/JSImp/Reflection.javascript\")]\r\n    public class Reflection\r\n    {\r\n        public static T CreateInstance<T>()\r\n        {\r\n            return Activator.CreateInstance<T>();\r\n        }\r\n\r\n        public static bool SetField(object obj, string fieldName, object value)\r\n        {\r\n            if (obj != null)\r\n            {\r\n                Type type = obj.GetType();\r\n                FieldInfo field = type.GetField(fieldName);\r\n                if (field != null)\r\n                {\r\n                    field.SetValue(obj, value);\r\n                    return true;\r\n                }\r\n            }\r\n            return false;\r\n        }\r\n\r\n\r\n        public static object GetFields(object obj)\r\n        {\r\n            return obj.GetType().GetFields();\r\n        }\r\n\r\n        public static object GetFieldType(object obj,string field)\r\n        {\r\n            return obj.GetType().GetField(field).FieldType;\r\n        }\r\n\r\n        public static object Getype(object obj)\r\n        {\r\n            return obj.GetType();\r\n        }\r\n//override in js?\r\n     public static void TryToEnum<T>(object value)\r\n    {\r\n        \r\n    }\r\n    }\r\n}"}}