static private void generateSnippets(IEnumerable <Type> types) { Configuration configuration = Utility.GetConfiguration(); if (null != configuration) { BinderBase.SetLibraryOutputPath(configuration.snippetsOutputPath); } NamespaceBinder.Clear(); List <Type> nestedTypes = new List <Type>(); foreach (Type type in types) { if (type.IsNested) { nestedTypes.Add(type); continue; } generateSnippet(type); } foreach (Type type in nestedTypes) { generateSnippet(type); } foreach (NamespaceBinder space in NamespaceBinder.Spaces) { space.GenerateSnippets(true); } Entry.Log("General.Typescript snippets generate successfully!"); }
static private void generateBinders(IEnumerable <Type> types, List <Type> delegates) { Configuration configuration = Utility.GetConfiguration(); if (null != configuration) { BinderBase.SetBinderOutputPath(configuration.bindersOutputPath); } NamespaceBinder.Clear(); List <Type> nestedTypes = new List <Type>(); foreach (Type type in types) { if (type.IsNested) { nestedTypes.Add(type); continue; } generateBinder(type); } foreach (Type type in nestedTypes) { generateBinder(type); } foreach (NamespaceBinder space in NamespaceBinder.Spaces) { space.GenerateBinder(delegates, true); } AssetDatabase.Refresh(); Entry.Log("General.Typescript binders generate successfully!"); }
static internal NamespaceBinder GetNamespace(string name) { NamespaceBinder space = null; if (!sSpaces.TryGetValue(name, out space)) { NamespaceBinder parent = null; if (name.Contains(".")) { parent = GetNamespace(name.Substring(0, name.LastIndexOf('.'))); } space = new NamespaceBinder(name, parent); } return(space); }
//[MenuItem("General /Typescript/Generate Binders")] //static private void GenerateBinders() //{ // generateBinders(pickTypes()); //} //[MenuItem("General/Typescript/Generate Binders Subset")] //static private void GenerateBindersSubset() //{ // generateBinders(pickTypes(true)); //} static private void generateSnippet(Type type) { try { NamespaceBinder space = NamespaceBinder.GetNamespace(type.FullName.Substring(0, type.FullName.LastIndexOf("."))); if (null != space) { space.DeclareClass(type); } } catch (Exception e) { Entry.LogError(e); Entry.LogWarning(type); } }
static private void generateBinder(Type type) { if (!type.FullName.Contains(".")) { return; } try { NamespaceBinder space = NamespaceBinder.GetNamespace(type.FullName.Substring(0, type.FullName.LastIndexOf("."))); if (null != space) { space.DeclareClass(type); } } catch (Exception e) { Entry.LogError(e); Entry.LogError(type); } }
private NamespaceBinder(string name, NamespaceBinder parent = null) : base(name.Contains(".") ? name.Substring(name.LastIndexOf('.') + 1) : name, parent) { sSpaces.Add(mFullname, this); }