public void ExportClass(Type nClassType, string szPathName, bool bPartWrap, bool bOnlyThisApi, Dictionary <string, int> aDontWrapName, Dictionary <string, List <Type> > aTemplateFunc, FCRefClass pRefClass) { m_bPartWrap = bPartWrap; m_bOnlyThisAPI = bOnlyThisApi; m_nClassType = nClassType; m_szPathName = szPathName; m_pRefClass = pRefClass; m_DelayType.Clear(); m_szTempBuilder.Length = 0; m_CurRefNameSpace.Clear(); m_CurRefNameSpacesFlags.Clear(); m_CurDelegate.Clear(); m_CurDontWrapName = aDontWrapName; m_CurSupportTemplateFunc = aTemplateFunc; m_AllExportType[nClassType] = 1; Type nParentType = nClassType.BaseType; m_AllRefType[nParentType] = 1; PushParentType(nParentType); string szParentName = FCValueType.GetClassName(nParentType); if (szParentName == "UnityEvent`1") { szParentName = "UnityEventBase"; } m_szTempBuilder.AppendFormat("\r\nclass {0} : {1}\r\n", FCValueType.GetClassName(nClassType), szParentName); m_szTempBuilder.AppendLine("{"); MakeInnerEnum(); // 分析内部的枚举类 MakeConstructor(); // 分析构造函数 MakeProperty(); // 分析get - set方法 MakeMethod(); // 分析函数 MakeDelegate(); // 成生委托声明 m_szTempBuilder.AppendLine("};\r\n"); // 导出类外的枚举 MakeOuterEnum(); m_szFileBuilder.Length = 0; foreach (string szNameSpace in m_CurRefNameSpace) { if (szNameSpace.IndexOf("UnityEngine") != -1) { if (szNameSpace != "UnityEngine.Events") { continue; } } m_szFileBuilder.AppendFormat("using {0};\r\n", szNameSpace); } m_szFileBuilder.AppendLine(); m_szFileBuilder.Append(m_szTempBuilder.ToString()); File.WriteAllText(m_szPathName, m_szFileBuilder.ToString()); }
public void MergeFinder(FCRefClass other) { m_namesFinder = null; m_TemplateFinder = null; MakeNamesFinder(names); MakeNamesFinder(other.names); MakeTemplateFinder(TemplateParams); MakeTemplateFinder(other.TemplateParams); }
public FCRefClass FindClass(string szClassName) { FCRefClass ptr = null; if (m_Finder != null && m_Finder.TryGetValue(szClassName, out ptr)) { return(ptr); } return(null); }
//[MenuItem("FCScript/测试", false, 5)] static void TestXml() { Assembly assembly = Assembly.Load("UnityEngine.UI"); Type t1 = assembly.GetType("Button"); Type t2 = assembly.GetType("UnityEngine.UI.Button"); Type t3 = assembly.GetType("UnityEngine.Button"); string szPath = Application.dataPath; szPath = szPath.Substring(0, szPath.Length - 6); FCRefClassCfg ins = FCRefClassCfg.LoadCfg(szPath + "ref_name.xml"); string szCfgPathName = szPath + "test_name.xml"; if (File.Exists(szCfgPathName)) { File.Delete(szCfgPathName); } //FileStream stream = new FileStream(szCfgPathName, FileMode.Create, FileAccess.Write); UTF8Encoding utf8 = new UTF8Encoding(false); StreamWriter stream = new StreamWriter(szCfgPathName, false, utf8); System.Xml.Serialization.XmlSerializer xs = new System.Xml.Serialization.XmlSerializer(typeof(FCRefClassCfg)); FCRefClassCfg cfg = new FCRefClassCfg(); cfg.RefClass = new List <FCRefClass>(); FCRefClass node = new FCRefClass(); node.ClassName = "GameObject"; node.names.Add("Find"); node.names.Add("tag"); cfg.RefClass.Add(node); node = new FCRefClass(); node.ClassName = "Button"; node.names.Add("Enable"); node.names.Add("Active"); node.TemplateParams = new List <FCTemplateParams>(); FCTemplateParams sParam = new FCTemplateParams(); sParam.FuncName = "AddCompent"; sParam.names.Add("Button"); sParam.names.Add("Text"); sParam.names.Add("Sprite"); node.TemplateParams.Add(sParam); cfg.RefClass.Add(node); xs.Serialize(stream, cfg); stream.Close(); }
void MakerFinder(List <FCRefClass> rList) { if (rList == null) { return; } if (m_Finder == null) { m_Finder = new Dictionary <string, FCRefClass>(); } foreach (FCRefClass r in rList) { FCRefClass old = null; if (m_Finder.TryGetValue(r.ClassName, out old)) { old.MergeFinder(r); } else { m_Finder[r.ClassName] = r; } } }