예제 #1
0
        private static int FFI_Using(ILuaState lua)
        {
            var name = lua.ToString(1);

            UsingList.Add(name);
            return(0);
        }
예제 #2
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",
            });
        }
예제 #3
0
        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.");
        }
예제 #4
0
 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));
 }
예제 #5
0
    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();
        }
    }
예제 #6
0
        /// <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();
            }
        }
예제 #7
0
    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>());
    }
예제 #8
0
 private static int FFI_ClearUsingList(ILuaState lua)
 {
     UsingList.Clear();
     return(0);
 }
예제 #9
0
 /// <summary>
 /// Adds a using directive to write separately.
 /// </summary>
 public void AddUsing(string usingDirective)
 {
     UsingList.Add(usingDirective);
 }
예제 #10
0
 public FluentSyntax()
 {
     Usings = new UsingList();
     Operations = new OperationList();
 }
예제 #11
0
 public void AddRange(IEnumerable <Using> usings)
 {
     UsingList.AddRange(usings);
 }
예제 #12
0
 public void Add(Using @using)
 {
     UsingList.Add(@using);
 }