private static int FFI_Using(ILuaState lua) { var name = lua.ToString(1); UsingList.Add(name); return(0); }
public void GenerateCode(State rootState, TextWriter output, string namespaceName, UsingList usings, string[] genericArguments) { _syntaxTypes.Clear(); var code = new CodeCompileUnit(); var ns = new CodeNamespace(namespaceName); code.Namespaces.Add(ns); ns.Imports.Add(new CodeNamespaceImport("System")); foreach (var u in usings) { ns.Imports.Add(new CodeNamespaceImport(u.Namespace)); } GenerateCode(t => ns.Types.Add(t), rootState, new HashSet<string>(), genericArguments); ns.Types.Add(new CodeTypeDeclaration(_syntaxEnd) { Attributes = MemberAttributes.Public, TypeAttributes = TypeAttributes.Interface | TypeAttributes.Public, IsPartial = true, }); var codeProvider = new CSharpCodeProvider(); codeProvider.GenerateCodeFromCompileUnit(code, output, new CodeGeneratorOptions { BracingStyle = "C", IndentString = "\t", }); }
private string AddUsings(IEnumerable <string> usings) { var collection = usings as string[] ?? usings.ToArray(); UsingList.AddRange(collection); return($"Added {collection.Length} usings. We now have {UsingList.Count} in total."); }
private string BuildCode(string source) { if (_illegalCalls.Any(x => source.IndexOf(x, StringComparison.InvariantCultureIgnoreCase) >= 0)) { throw new IllegalSnippetException(); } if (!(source.Contains("\n") || source.Contains(";"))) { source = $"return {source};"; } return(CssBase.Replace("<usings>", string.Join(Environment.NewLine, UsingList.Select(x => $"using {x};"))).Replace("<body>", source)); }
public void Free <T>(T asset) where T : Component { UsingList.Remove(asset.gameObject); FreeList.Push(asset.gameObject); asset.gameObject.SetActive(false); if (typeof(T).Name == "Character") { asset.gameObject.transform.localPosition = Vector3.zero; asset.gameObject.transform.localRotation = Quaternion.identity; asset.gameObject.transform.localScale = Vector3.one; } if (AssetManager.OnChanged != null) { AssetManager.OnChanged(); } }
/// <summary> /// Commits all accumulated lines. /// </summary> public void CommitLines() { List <string> SortedUsingList = new List <string>(UsingList); SortedUsingList.Sort(); int i = 0; while (i < SortedUsingList.Count) { if (i + 1 < SortedUsingList.Count && SortedUsingList[i] == SortedUsingList[i + 1]) { SortedUsingList.RemoveAt(i + 1); } else { i++; } } foreach (string UsingDirective in SortedUsingList) { WriteLine($" using {UsingDirective};"); } if (SortedUsingList.Count > 0) { WriteLine(string.Empty); } foreach (string Line in LineList) { WriteLine(Line); } if (UsingList.Count > 0 || LineList.Count > 0) { UsingList.Clear(); LineList.Clear(); Flush(); } }
public T Alloc <T>() where T : Component { GameObject asset = null; if (FreeList.Count > 0) { asset = FreeList.Pop(); } if (asset == null) { asset = GameObject.Instantiate <GameObject>(Prefab); } UsingList.Add(asset); asset.gameObject.SetActive(true); if (AssetManager.OnChanged != null) { AssetManager.OnChanged(); } return(asset.GetComponent <T>()); }
private static int FFI_ClearUsingList(ILuaState lua) { UsingList.Clear(); return(0); }
/// <summary> /// Adds a using directive to write separately. /// </summary> public void AddUsing(string usingDirective) { UsingList.Add(usingDirective); }
public FluentSyntax() { Usings = new UsingList(); Operations = new OperationList(); }
public void AddRange(IEnumerable <Using> usings) { UsingList.AddRange(usings); }
public void Add(Using @using) { UsingList.Add(@using); }