• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# DelegateCollection类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中DelegateCollection的典型用法代码示例。如果您正苦于以下问题:C# DelegateCollection类的具体用法?C# DelegateCollection怎么用?C# DelegateCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DelegateCollection类属于命名空间,在下文中一共展示了DelegateCollection类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: WriteBindings

        void WriteBindings(DelegateCollection delegates, FunctionCollection wrappers, EnumCollection enums)
        {
            Console.WriteLine("Writing bindings to {0}", Settings.OutputPath);
            if (!Directory.Exists(Settings.OutputPath))
                Directory.CreateDirectory(Settings.OutputPath);

            // Hack: Fix 3dfx extension category so it doesn't start with a digit
            if (wrappers.ContainsKey("3dfx"))
            {
                var three_dee_fx = wrappers["3dfx"];
                wrappers.Remove("3dfx");
                wrappers.Add(DigitPrefix + "3dfx", three_dee_fx);
            }

            using (var sw = sw_h)
            {
                WriteLicense(sw);

                sw.WriteLine("package {0}.{1};", Settings.OutputNamespace, Settings.GLClass);
                sw.WriteLine();
                sw.WriteLine("import java.nio.*;");
                sw.WriteLine();

                WriteDefinitions(sw, enums, wrappers, Type.CSTypes);

                sw.Flush();
                sw.Close();
            }

            string output_header = Path.Combine(Settings.OutputPath, OutputFileHeader);
            Move(sw_h.File, output_header);
        }
开发者ID:hultqvist,项目名称:opentk,代码行数:32,代码来源:JavaSpecWriter.cs


示例2: ReadDelegates

        public void ReadDelegates(string file, DelegateCollection delegates, string apiname, string apiversions)
        {
            var specs = new XPathDocument(file);

            // The pre-GL4.4 spec format does not distinguish between
            // different apinames (it is assumed that different APIs
            // are stored in distinct signature.xml files).
            // To maintain compatibility, we detect the version of the
            // signatures.xml file and ignore apiname if it is version 1.
            var specversion = GetSpecVersion(specs);
            if (specversion == "1")
            {
                apiname = null;
            }

            foreach (var apiversion in apiversions.Split('|'))
            {
                string xpath_add, xpath_delete;
                GetSignaturePaths(apiname, apiversion, out xpath_add, out xpath_delete);

                foreach (XPathNavigator nav in specs.CreateNavigator().Select(xpath_delete))
                {
                    foreach (XPathNavigator node in nav.SelectChildren("function", String.Empty))
                        delegates.Remove(node.GetAttribute("name", String.Empty));
                }
                foreach (XPathNavigator nav in specs.CreateNavigator().Select(xpath_add))
                {
                    delegates.AddRange(ReadDelegates(nav, apiversion));
                }
            }
        }
开发者ID:jpbruyere,项目名称:opentk,代码行数:31,代码来源:XmlSpecReader.cs


示例3: Generator

        public Generator(Settings settings, string dirName)
        {
            if (settings == null)
                throw new ArgumentNullException("settings");
            if (dirName == null)
                dirName = "GL2";

            Settings = settings.Clone();

            glTypemap = "GL2/gl.tm";
            csTypemap = Settings.LanguageTypeMapFile;

            enumSpec = Path.Combine(dirName, "signatures.xml");
            enumSpecExt = String.Empty;
            glSpec = Path.Combine(dirName, "signatures.xml");
            glSpecExt = String.Empty;
            Settings.OverridesFile = Path.Combine(dirName, "overrides.xml");

            Settings.ImportsClass = "Core";
            Settings.DelegatesClass = "Delegates";
            Settings.OutputClass = "GL";

            Delegates = new DelegateCollection();
            Enums = new EnumCollection();
            Wrappers = new FunctionCollection();

            SpecReader = new XmlSpecReader(Settings);
        }
开发者ID:RegApp4Me,项目名称:opentk,代码行数:28,代码来源:Generator.cs


示例4: Process

        public FunctionCollection Process(DelegateCollection delegates, EnumCollection enums)
        {
            Console.WriteLine("Processing delegates.");
            var nav = new XPathDocument(Overrides).CreateNavigator();
            foreach (var d in delegates.Values)
            {
                var function_override = GetFuncOverride(nav, d);
		if (function_override != null) {
                    string obsolete = function_override.GetAttribute ("obsolete", "");
                    if (!string.IsNullOrEmpty (obsolete))
                        d.Obsolete = obsolete;
                }

                TranslateReturnType(nav, d, enums);
                TranslateParameters(nav, d, enums);
            }

            Console.WriteLine("Generating wrappers.");
            var wrappers = CreateWrappers(delegates, enums);
            Console.WriteLine("Creating CLS compliant overloads.");
            wrappers = CreateCLSCompliantWrappers(wrappers, enums);
            Console.WriteLine("Removing non-CLS compliant duplicates.");

            return MarkCLSCompliance(wrappers);
        }
开发者ID:renanyoy,项目名称:mono-opentk,代码行数:25,代码来源:FuncProcessor.cs


示例5: Process

        public FunctionCollection Process(EnumProcessor enum_processor, DelegateCollection delegates, EnumCollection enums,
            string apiname, string apiversion)
        {
            Console.WriteLine("Processing delegates.");
            var nav = new XPathDocument(Overrides).CreateNavigator();
            foreach (var version in apiversion.Split('|'))
            {
                // Translate each delegate:
                // 1st using the <replace> elements in overrides.xml
                // 2nd using the hardcoded rules in FuncProcessor (e.g. char* -> string)
                foreach (var signatures in delegates.Values)
                {
                    foreach (var d in signatures)
                    {
                        TranslateExtension(d);
                        TranslateReturnType(enum_processor, nav, d, enums, apiname, version);
                        TranslateParameters(enum_processor, nav, d, enums, apiname, version);
                        TranslateAttributes(nav, d, enums, apiname, version);
                    }
                }

                // Create overloads for backwards compatibility,
                // by resolving <overload> elements
                var overload_list = new List<Delegate>();
                foreach (var d in delegates.Values.Select(v => v.First()))
                {
                    var overload_element = GetFuncOverload(nav, d, apiname, apiversion);
                    if (overload_element != null)
                    {
                        var overload = new Delegate(d);
                        ApplyParameterReplacement(overload, overload_element);
                        ApplyReturnTypeReplacement(overload, overload_element);
                        overload_list.Add(overload);
                    }
                }
                foreach (var overload in overload_list)
                {
                    delegates.Add(overload);
                }
            }

            Console.WriteLine("Generating convenience overloads.");
            delegates.AddRange(CreateConvenienceOverloads(delegates));

            Console.WriteLine("Generating wrappers.");
            var wrappers = CreateWrappers(delegates, enums);

            Console.WriteLine("Generating CLS compliant overloads.");
            wrappers = CreateCLSCompliantWrappers(wrappers, enums);

            Console.WriteLine("Removing non-CLS compliant duplicates.");
            wrappers = MarkCLSCompliance(wrappers);

            Console.WriteLine("Removing overloaded delegates.");
            RemoveOverloadedDelegates(delegates, wrappers);

            return wrappers;
        }
开发者ID:BrainSlugs83,项目名称:opentk,代码行数:58,代码来源:FuncProcessor.cs


示例6: WriteBindings

        void WriteBindings(DelegateCollection delegates, FunctionCollection wrappers, EnumCollection enums)
        {
            Console.WriteLine("Writing bindings to {0}", Settings.OutputPath);
            if (!Directory.Exists(Settings.OutputPath))
                Directory.CreateDirectory(Settings.OutputPath);

            // Hack: Fix 3dfx extension category so it doesn't start with a digit
            if (wrappers.ContainsKey("3dfx"))
            {
                var three_dee_fx = wrappers["3dfx"];
                wrappers.Remove("3dfx");
                wrappers.Add(DigitPrefix + "3dfx", three_dee_fx);
            }

            Settings.DefaultOutputNamespace = "OpenTK";

            // Enums
            using (var sw = sw_h_enums)
            {
                WriteEnums(sw, enums);
                sw.Flush();
                sw.Close();
            }

            // Core definitions
            using (var sw = sw_h)
            {
                WriteDefinitions(sw, enums, wrappers, Type.CSTypes, false);
                sw.Flush();
                sw.Close();
            }

            // Compatibility definitions
            using (var sw = sw_h_compat)
            {
                WriteDefinitions(sw, enums, wrappers, Type.CSTypes, true);
                sw.Flush();
                sw.Close();
            }

            // Core & compatibility declarations
            using (var sw = sw_cpp)
            {
                WriteDeclarations(sw, wrappers, Type.CSTypes);
                sw.Flush();
                sw.Close();
            }

            string output_header = Path.Combine(Settings.OutputPath, OutputFileHeader);
            string output_cpp = Path.Combine(Settings.OutputPath, OutputFileCpp);
            string output_header_compat = Path.Combine(Settings.OutputPath, OutputFileHeaderCompat);
            string output_header_enums = Path.Combine(Settings.OutputPath, OutputFileHeaderEnums);

            Move(sw_h.File, output_header);
            Move(sw_cpp.File, output_cpp);
            Move(sw_h_compat.File, output_header_compat);
            Move(sw_h_enums.File, output_header_enums);
        }
开发者ID:rozgo,项目名称:opentk,代码行数:58,代码来源:CppSpecWriter.cs


示例7: ReadDelegates

        private DelegateCollection ReadDelegates(XPathNavigator specs)
        {
            DelegateCollection delegates = new DelegateCollection();

            foreach (XPathNavigator node in specs.SelectChildren("function", String.Empty))
            {
                var name = node.GetAttribute("name", String.Empty);

                // Check whether we are adding to an existing delegate or creating a new one.
                Delegate d = null;
                if (delegates.ContainsKey(name))
                {
                    d = delegates[name];
                }
                else
                {
                    d = new Delegate();
                    d.Name = name;
                    d.Version = node.GetAttribute("version", String.Empty);
                    d.Category = node.GetAttribute("category", String.Empty);
                    d.DeprecatedVersion = node.GetAttribute("deprecated", String.Empty);
                    d.Deprecated = !String.IsNullOrEmpty(d.DeprecatedVersion);
                    d.Obsolete = node.GetAttribute("obsolete", String.Empty);
                }

                foreach (XPathNavigator param in node.SelectChildren(XPathNodeType.Element))
                {
                    switch (param.Name)
                    {
                        case "returns":
                            d.ReturnType.CurrentType = param.GetAttribute("type", String.Empty);
                            break;

                        case "param":
                            Parameter p = new Parameter();
                            p.CurrentType = param.GetAttribute("type", String.Empty);
                            p.Name = param.GetAttribute("name", String.Empty);

                            string element_count = param.GetAttribute("elementcount", String.Empty);
                            if (String.IsNullOrEmpty(element_count))
                                element_count = param.GetAttribute("count", String.Empty);
                            if (!String.IsNullOrEmpty(element_count))
                                p.ElementCount = Int32.Parse(element_count);

                            p.Flow = Parameter.GetFlowDirection(param.GetAttribute("flow", String.Empty));

                            d.Parameters.Add(p);
                            break;
                    }
                }

                delegates.Add(d);
            }

            return delegates;
        }
开发者ID:renanyoy,项目名称:mono-opentk,代码行数:56,代码来源:XmlSpecReader.cs


示例8: ReadDelegates

 public void ReadDelegates(string file, DelegateCollection delegates)
 {
     var specs = new XPathDocument(file);
     foreach (XPathNavigator nav in specs.CreateNavigator().Select("/signatures/delete"))
     {
         foreach (XPathNavigator node in nav.SelectChildren("function", String.Empty))
             delegates.Remove(node.GetAttribute("name", String.Empty));
     }
     foreach (XPathNavigator nav in specs.CreateNavigator().Select("/signatures/add"))
     {
         Utilities.Merge(delegates, ReadDelegates(nav));
     }
 }
开发者ID:hultqvist,项目名称:opentk,代码行数:13,代码来源:XmlSpecReader.cs


示例9: Process

        public FunctionCollection Process(DelegateCollection delegates, EnumCollection enums)
        {
            Console.WriteLine("Processing delegates.");
            var nav = new XPathDocument(Overrides).CreateNavigator();
            foreach (var d in delegates.Values)
            {
                TranslateReturnType(nav, d, enums);
                TranslateParameters(nav, d, enums);
            }

            Console.WriteLine("Generating wrappers.");
            var wrappers = CreateWrappers(delegates, enums);
            Console.WriteLine("Creating CLS compliant overloads.");
            wrappers = CreateCLSCompliantWrappers(wrappers, enums);
            Console.WriteLine("Removing non-CLS compliant duplicates.");

            return MarkCLSCompliance(wrappers);
        }
开发者ID:challal,项目名称:scallion,代码行数:18,代码来源:FuncProcessor.cs


示例10: Generator

        public Generator()
        {
            if (Settings.Compatibility == Settings.Legacy.Tao)
            {
                Settings.OutputNamespace = "Tao.OpenGl";
                Settings.OutputClass = "Gl";
            }
            else
            {
                // Defaults
            }

            Settings.ImportsFile = "GLCore.cs";
            Settings.DelegatesFile = "GLDelegates.cs";
            Settings.EnumsFile = "GLEnums.cs";
            Settings.WrappersFile = "GL.cs";

            Delegates = new DelegateCollection();
            Enums = new EnumCollection();
            Wrappers = new FunctionCollection();
        }
开发者ID:challal,项目名称:scallion,代码行数:21,代码来源:Generator.cs


示例11: CreateWrappers

        FunctionCollection CreateWrappers(DelegateCollection delegates, EnumCollection enums)
        {
            var wrappers = new FunctionCollection();
            foreach (var d in delegates.Values.SelectMany(v => v))
            {
                wrappers.AddRange(CreateNormalWrappers(d, enums));
            }

            if ((Settings.Compatibility & Settings.Legacy.KeepUntypedEnums) != 0)
            {
                // Generate an "All" overload for every function that takes strongly-typed enums
                var overloads = new List<Function>();
                foreach (var list in wrappers.Values)
                {
                    overloads.AddRange(list.Where(f => f.Parameters.Any(p => p.IsEnum)).Select(f =>
                    {
                        var fnew = new Function(f);
                        fnew.Obsolete = "Use strongly-typed overload instead";
                        // Note that we can only overload parameters, not the return type
                        foreach (var p in fnew.Parameters)
                        {
                            if (p.IsEnum)
                            {
                                p.CurrentType = Settings.CompleteEnumName;
                            }
                        }

                        return fnew;
                    }));
                }
                wrappers.AddRange(overloads);
            }
            return wrappers;
        }
开发者ID:PieterMarius,项目名称:PhysicsEngine,代码行数:34,代码来源:FuncProcessor.cs


示例12: WriteImports

        public virtual void WriteImports(BindStreamWriter sw, DelegateCollection delegates)
        {
            Trace.WriteLine(String.Format("Writing imports to:\t{0}.{1}.{2}", Settings.OutputNamespace, Settings.OutputClass, Settings.ImportsClass));

            sw.WriteLine("#pragma warning disable 3019");   // CLSCompliant attribute
            sw.WriteLine("#pragma warning disable 1591");   // Missing doc comments

            sw.WriteLine();
            sw.WriteLine("partial class {0}", Settings.OutputClass);
            sw.WriteLine("{");
            sw.Indent();
            sw.WriteLine();
            sw.WriteLine("internal static partial class {0}", Settings.ImportsClass);
            sw.WriteLine("{");
            sw.Indent();
            //sw.WriteLine("static {0}() {1} {2}", Settings.ImportsClass, "{", "}");    // Disable BeforeFieldInit
            sw.WriteLine();
            foreach (Delegate d in delegates.Values)
            {
                sw.WriteLine("[System.Security.SuppressUnmanagedCodeSecurity()]");
                sw.WriteLine(
                    "[System.Runtime.InteropServices.DllImport({0}.Library, EntryPoint = \"{1}{2}\"{3})]",
                    Settings.OutputClass,
                    Settings.FunctionPrefix,
                    d.Name,
                    d.Name.EndsWith("W") || d.Name.EndsWith("A") ? ", CharSet = CharSet.Auto" : ", ExactSpelling = true"
                );
                sw.WriteLine("internal extern static {0};", d.DeclarationString());
            }
            sw.Unindent();
            sw.WriteLine("}");
            sw.Unindent();
            sw.WriteLine("}");
        }
开发者ID:jwatte,项目名称:gears,代码行数:34,代码来源:Generator.cs


示例13: WriteDelegates

        public virtual void WriteDelegates(BindStreamWriter sw, DelegateCollection delegates)
        {
            Trace.WriteLine(String.Format("Writing delegates to:\t{0}.{1}.{2}", Settings.OutputNamespace, Settings.OutputClass, Settings.DelegatesClass));

            sw.WriteLine("#pragma warning disable 3019");   // CLSCompliant attribute
            sw.WriteLine("#pragma warning disable 1591");   // Missing doc comments

            sw.WriteLine();
            sw.WriteLine("partial class {0}", Settings.OutputClass);
            sw.WriteLine("{");
            sw.Indent();

            sw.WriteLine("internal static partial class {0}", Settings.DelegatesClass);
            sw.WriteLine("{");
            sw.Indent();

            foreach (Delegate d in delegates.Values)
            {
                sw.WriteLine("[System.Security.SuppressUnmanagedCodeSecurity()]");
                sw.WriteLine("internal {0};", d.ToString());
                sw.WriteLine("internal {0}static {1} {2}{1};",   //  = null
                    d.Unsafe ? "unsafe " : "",
                    d.Name,
                    Settings.FunctionPrefix);
            }

            sw.Unindent();
            sw.WriteLine("}");

            sw.Unindent();
            sw.WriteLine("}");
        }
开发者ID:jwatte,项目名称:gears,代码行数:32,代码来源:Generator.cs


示例14: WriteBindings

        public void WriteBindings(DelegateCollection delegates, FunctionCollection functions, EnumCollection enums)
        {
            Console.WriteLine("Writing bindings to {0}", Settings.OutputPath);
            if (!Directory.Exists(Settings.OutputPath))
                Directory.CreateDirectory(Settings.OutputPath);

            string temp_enums_file = Path.GetTempFileName();
            string temp_delegates_file = Path.GetTempFileName();
            string temp_core_file = Path.GetTempFileName();
            string temp_wrappers_file = Path.GetTempFileName();

            // Enums
            using (BindStreamWriter sw = new BindStreamWriter(temp_enums_file))
            {
                WriteLicense(sw);
                
                sw.WriteLine("using System;");
                sw.WriteLine();

                if ((Settings.Compatibility & Settings.Legacy.NestedEnums) != Settings.Legacy.None)
                {
                    sw.WriteLine("namespace {0}", Settings.OutputNamespace);
                    sw.WriteLine("{");
                    sw.Indent();
                    sw.WriteLine("static partial class {0}", Settings.OutputClass);
                }
                else
                    sw.WriteLine("namespace {0}", Settings.EnumsOutput);

                sw.WriteLine("{");

                sw.Indent();
                WriteEnums(sw, Enum.GLEnums);
                sw.Unindent();

                if ((Settings.Compatibility & Settings.Legacy.NestedEnums) != Settings.Legacy.None)
                {
                    sw.WriteLine("}");
                    sw.Unindent();
                }

                sw.WriteLine("}");
            }

            // Delegates
            using (BindStreamWriter sw = new BindStreamWriter(temp_delegates_file))
            {
                WriteLicense(sw);
                sw.WriteLine("namespace {0}", Settings.OutputNamespace);
                sw.WriteLine("{");
                sw.Indent();

                sw.WriteLine("using System;");
                sw.WriteLine("using System.Text;");
                sw.WriteLine("using System.Runtime.InteropServices;");

                sw.WriteLine("#pragma warning disable 0649");
                WriteDelegates(sw, Delegate.Delegates);

                sw.Unindent();
                sw.WriteLine("}");
            }

            // Core
            using (BindStreamWriter sw = new BindStreamWriter(temp_core_file))
            {
                WriteLicense(sw);
                sw.WriteLine("namespace {0}", Settings.OutputNamespace);
                sw.WriteLine("{");
                sw.Indent();
                //specWriter.WriteTypes(sw, Bind.Structures.Type.CSTypes);
                sw.WriteLine("using System;");
                sw.WriteLine("using System.Text;");
                sw.WriteLine("using System.Runtime.InteropServices;");

                WriteImports(sw, Delegate.Delegates);

                sw.Unindent();
                sw.WriteLine("}");
            }

            // Wrappers
            using (BindStreamWriter sw = new BindStreamWriter(temp_wrappers_file))
            {
                WriteLicense(sw);
                sw.WriteLine("namespace {0}", Settings.OutputNamespace);
                sw.WriteLine("{");
                sw.Indent();

                sw.WriteLine("using System;");
                sw.WriteLine("using System.Text;");
                sw.WriteLine("using System.Runtime.InteropServices;");

                WriteWrappers(sw, Function.Wrappers, Type.CSTypes);

                sw.Unindent();
                sw.WriteLine("}");
            }

            string output_enums = Path.Combine(Settings.OutputPath, enumsFile);
//.........这里部分代码省略.........
开发者ID:jwatte,项目名称:gears,代码行数:101,代码来源:Generator.cs


示例15: ReadDelegates

        public virtual DelegateCollection ReadDelegates(StreamReader specFile)
        {
            Console.WriteLine("Reading function specs.");

            DelegateCollection delegates = new DelegateCollection();

            XPathDocument function_overrides = new XPathDocument(Path.Combine(Settings.InputPath, functionOverridesFile));

            do
            {
                string line = NextValidLine(specFile);
                if (String.IsNullOrEmpty(line))
                    break;

                while (line.Contains("(") && !specFile.EndOfStream)
                {
                    // Get next OpenGL function

                    Delegate d = new Delegate();

                    // Get function name:
                    d.Name = line.Split(Utilities.Separators, StringSplitOptions.RemoveEmptyEntries)[0];

                    do
                    {
                        // Get function parameters and return value

                        line = specFile.ReadLine();
                        List<string> words = new List<string>(
                            line.Replace('\t', ' ').Split(Utilities.Separators, StringSplitOptions.RemoveEmptyEntries)
                        );

                        if (words.Count == 0)
                            break;

                        // Identify line:
                        switch (words[0])
                        {
                            case "return":  // Line denotes return value
                                d.ReturnType.CurrentType = words[1];
                                break;

                            case "param":   // Line denotes parameter
                                Parameter p = new Parameter();

                                p.Name = Utilities.Keywords.Contains(words[1]) ? "@" + words[1] : words[1];
                                p.CurrentType = words[2];
                                p.Pointer += words[4].Contains("array") ? 1 : 0;
                                p.Pointer += words[4].Contains("reference") ? 1 : 0;
                                if (p.Pointer != 0 && words.Count > 5 && words[5].Contains("[1]"))
                                    p.ElementCount = 1;
                                p.Flow = words[3] == "in" ? FlowDirection.In : FlowDirection.Out;

                                d.Parameters.Add(p);
                                break;

                            // GetTexParameterIivEXT and GetTexParameterIuivEXT define two(!) versions (why?)
                            case "version": // Line denotes function version (i.e. 1.0, 1.2, 1.5)
                                d.Version = words[1];
                                break;

                            case "category":
                                d.Category = words[1];
                                break;
                        }
                    }
                    while (!specFile.EndOfStream);

                    d.Translate(function_overrides);

                    delegates.Add(d);
                }
            }
            while (!specFile.EndOfStream);

            return delegates;
        }
开发者ID:jwatte,项目名称:gears,代码行数:77,代码来源:Generator.cs


示例16: WriteBindings

        void WriteBindings(DelegateCollection delegates, FunctionCollection wrappers, EnumCollection enums)
        {
            Console.WriteLine("Writing bindings to {0}", Settings.OutputPath);
            if (!Directory.Exists(Settings.OutputPath))
                Directory.CreateDirectory(Settings.OutputPath);

            string temp_enums_file = Path.GetTempFileName();
            string temp_wrappers_file = Path.GetTempFileName();

            // Enums
            using (BindStreamWriter sw = new BindStreamWriter(temp_enums_file))
            {
                WriteLicense(sw);

                sw.WriteLine("using System;");
                sw.WriteLine();

                if ((Settings.Compatibility & Settings.Legacy.NestedEnums) != Settings.Legacy.None)
                {
                    sw.WriteLine("namespace {0}", Settings.OutputNamespace);
                    sw.WriteLine("{");
                    sw.Indent();
                    sw.WriteLine("static partial class {0}", Settings.OutputClass);
                }
                else
                    sw.WriteLine("namespace {0}", Settings.EnumsOutput);

                sw.WriteLine("{");

                sw.Indent();
                WriteEnums(sw, enums, wrappers);
                sw.Unindent();

                if ((Settings.Compatibility & Settings.Legacy.NestedEnums) != Settings.Legacy.None)
                {
                    sw.WriteLine("}");
                    sw.Unindent();
                }

                sw.WriteLine("}");
            }

            // Wrappers
            using (BindStreamWriter sw = new BindStreamWriter(temp_wrappers_file))
            {
                WriteLicense(sw);
                sw.WriteLine("namespace {0}", Settings.OutputNamespace);
                sw.WriteLine("{");
                sw.Indent();

                sw.WriteLine("using System;");
                sw.WriteLine("using System.Text;");
                sw.WriteLine("using System.Runtime.InteropServices;");

                WriteWrappers(sw, wrappers, delegates, enums, Generator.CSTypes);

                sw.Unindent();
                sw.WriteLine("}");
            }

            string output_enums = Path.Combine(Settings.OutputPath, Settings.EnumsFile);
            string output_delegates = Path.Combine(Settings.OutputPath, Settings.DelegatesFile);
            string output_core = Path.Combine(Settings.OutputPath, Settings.ImportsFile);
            string output_wrappers = Path.Combine(Settings.OutputPath, Settings.WrappersFile);

            if (File.Exists(output_enums)) File.Delete(output_enums);
            if (File.Exists(output_delegates)) File.Delete(output_delegates);
            if (File.Exists(output_core)) File.Delete(output_core);
            if (File.Exists(output_wrappers)) File.Delete(output_wrappers);

            File.Move(temp_enums_file, output_enums);
            File.Move(temp_wrappers_file, output_wrappers);
        }
开发者ID:RetroAchievements,项目名称:opentk,代码行数:73,代码来源:CSharpSpecWriter.cs


示例17: WriteWrappers

        void WriteWrappers(BindStreamWriter sw, FunctionCollection wrappers,
            DelegateCollection delegates, EnumCollection enums,
            IDictionary<string, string> CSTypes)
        {
            Trace.WriteLine(String.Format("Writing wrappers to:\t{0}.{1}", Settings.OutputNamespace, Settings.OutputClass));

            sw.WriteLine("#pragma warning disable 3019"); // CLSCompliant attribute
            sw.WriteLine("#pragma warning disable 1591"); // Missing doc comments
            sw.WriteLine("#pragma warning disable 1572"); // Wrong param comments
            sw.WriteLine("#pragma warning disable 1573"); // Missing param comments
            sw.WriteLine("#pragma warning disable 626"); // extern method without DllImport

            sw.WriteLine();
            sw.WriteLine("partial class {0}", Settings.OutputClass);
            sw.WriteLine("{");
            sw.Indent();
            
            // Write constructor
            sw.WriteLine("static {0}()", Settings.OutputClass);
            sw.WriteLine("{");
            sw.Indent();
            // Write entry point names.
            // Instead of strings, which are costly to construct,
            // we use a 1d array of ASCII bytes. Names are laid out
            // sequentially, with a nul-terminator between them.
            sw.WriteLine("EntryPointNames = new byte[]", delegates.Count);
            sw.WriteLine("{");
            sw.Indent();
            foreach (var d in delegates.Values.Select(d => d.First()))
            {
                if (d.RequiresSlot(Settings))
                {
                    var name = Settings.FunctionPrefix + d.Name;
                    sw.WriteLine("{0}, 0,", String.Join(", ",
                        System.Text.Encoding.ASCII.GetBytes(name).Select(b => b.ToString()).ToArray()));
                }
            }
            sw.Unindent();
            sw.WriteLine("};");
            // Write entry point name offsets.
            // This is an array of offsets into the EntryPointNames[] array above.
            sw.WriteLine("EntryPointNameOffsets = new int[]", delegates.Count);
            sw.WriteLine("{");
            sw.Indent();
            int offset = 0;
            foreach (var d in delegates.Values.Select(d => d.First()))
            {
                if (d.RequiresSlot(Settings))
                {
                    sw.WriteLine("{0},", offset);
                    var name = Settings.FunctionPrefix + d.Name;
                    offset += name.Length + 1;
                }
            }
            sw.Unindent();
            sw.WriteLine("};");
            sw.WriteLine("EntryPoints = new IntPtr[EntryPointNameOffsets.Length];");
            sw.Unindent();
            sw.WriteLine("}");
            sw.WriteLine();

            int current_wrapper = 0;
            foreach (string key in wrappers.Keys)
            {
                if (((Settings.Compatibility & Settings.Legacy.NoSeparateFunctionNamespaces) == Settings.Legacy.None) && key != "Core")
                {
                    if (!Char.IsDigit(key[0]))
                    {
                        sw.WriteLine("public static partial class {0}", key);
                    }
                    else
                    {
                        // Identifiers cannot start with a number:
                        sw.WriteLine("public static partial class {0}{1}", Settings.ConstantPrefix, key);
                    }
                    sw.WriteLine("{");
                    sw.Indent();
                }

                wrappers[key].Sort();
                foreach (Function f in wrappers[key])
                {
                    WriteWrapper(sw, f, enums);
                    current_wrapper++;
                }

                if (((Settings.Compatibility & Settings.Legacy.NoSeparateFunctionNamespaces) == Settings.Legacy.None) && key != "Core")
                {
                    sw.Unindent();
                    sw.WriteLine("}");
                    sw.WriteLine();
                }
            }

            // Emit native signatures.
            // These are required by the patcher.
            int current_signature = 0;
            foreach (var d in wrappers.Values.SelectMany(e => e).Select(w => w.WrappedDelegate).Distinct())
            {
                sw.WriteLine("[Slot({0})]", d.Slot);
//.........这里部分代码省略.........
开发者ID:RetroAchievements,项目名称:opentk,代码行数:101,代码来源:CSharpSpecWriter.cs


示例18: WriteDelegates

        void WriteDelegates(BindStreamWriter sw, DelegateCollection delegates)
        {
            Trace.WriteLine(String.Format("Writing delegates to:\t{0}.{1}.{2}", Settings.OutputNamespace, Settings.OutputClass, Settings.DelegatesClass));

            sw.WriteLine("#pragma warning disable 3019");   // CLSCompliant attribute
            sw.WriteLine("#pragma warning disable 1591");   // Missing doc comments

            sw.WriteLine();
            sw.WriteLine("partial class {0}", Settings.OutputClass);
            sw.WriteLine("{");
            sw.Indent();

            sw.WriteLine("internal static partial class {0}", Settings.DelegatesClass);
            sw.WriteLine("{");
            sw.Indent();

            foreach (var overloads in delegates.Values)
            {
                // Generate only one delegate per entry point..
                // Overloads are only used for wrapper generation,
                // so ignore them.
                var d = overloads.First();

                sw.WriteLine("[System.Security.SuppressUnmanagedCodeSecurity()]");
                sw.WriteLine("internal {0};", GetDeclarationString(d, true));
                sw.WriteLine("internal {0}static {2} {1}{2};",   //  = null
                         d.Unsafe ? "unsafe " : "",
                         Settings.FunctionPrefix,
                         d.Name);
            }

            sw.Unindent();
            sw.WriteLine("}");

            sw.Unindent();
            sw.WriteLine("}");
        }
开发者ID:BrainSlugs83,项目名称:opentk,代码行数:37,代码来源:CSharpSpecWriter.cs


示例19: Merge

 // Merges the given delegate into the delegate list.
 internal static void Merge(DelegateCollection delegates, Delegate t)
 {
     delegates.Add(t.Name, t);
 }
开发者ID:Munk801,项目名称:Journey-to-the-West-Video-Game,代码行数:5,代码来源:Utilities.cs


示例20: Merge

 /// <summary>
 /// Merges the given enum into the enum list. If an enum of the same name exists,
 /// it merges their respective constants.
 /// </summary>
 /// <param name="enums"></param>
 /// <param name="t"></param>
 internal static void Merge(DelegateCollection delegates, Delegate t)
 {
     if (!delegates.ContainsKey(t.Name))
     {
         delegates 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# DelegateCommand类代码示例发布时间:2022-05-24
下一篇:
C# Delegate类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap