当前位置: 首页>>代码示例>>C#>>正文


C# DelegateCollection.Add方法代码示例

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


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

示例1: 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

示例2: 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);
                }

                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:hultqvist,项目名称:opentk,代码行数:55,代码来源:XmlSpecReader.cs

示例3: 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.Add(t.Name, t);
     }
 }
开发者ID:jwatte,项目名称:gears,代码行数:13,代码来源:Utilities.cs

示例4: 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

示例5: ReadDelegates

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

            //List<Bind.Structures.Delegate> delegates = new List<Bind.Structures.Delegate>();
            DelegateCollection delegates = new DelegateCollection();

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

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

                    Bind.Structures.Delegate d = new Bind.Structures.Delegate();

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

                    //if (d.Name.Contains("QueryHyperpipeBestAttribSGIX"))
                    //{
                    //}

                    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") ? true : words[4].Contains("reference") ? true : false;
                                p.Flow = words[3] == "in" ? Parameter.FlowDirection.In : Parameter.FlowDirection.Out;
 
                                d.Parameters.Add(p);
                                break;

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

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

                    d.Translate();

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

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

示例6: ReadDelegates

        public override DelegateCollection ReadDelegates(StreamReader specFile)
        {
            DelegateCollection delegates = new DelegateCollection();
            XPathDocument specs = new XPathDocument(specFile);
            XPathDocument overrides = new XPathDocument(new StreamReader(Path.Combine(Settings.InputPath, functionOverridesFile)));

            foreach (XPathNavigator nav in new XPathNavigator[] {
                specs.CreateNavigator().SelectSingleNode("/signatures"),
                overrides.CreateNavigator().SelectSingleNode("/overrides/add") })
            {
                if (nav != null)
                {
                    foreach (XPathNavigator node in nav.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);
                        }

                        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))
                                        p.ElementCount = Int32.Parse(element_count);

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

                                    d.Parameters.Add(p);
                                    break;
                            }
                        }
                        d.Translate(overrides);
                        delegates.Add(d);
                    }
                }
            }

            return delegates;
        }
开发者ID:dakahler,项目名称:alloclave,代码行数:61,代码来源:ESGenerator.cs

示例7: Process

        public FunctionCollection Process(EnumProcessor enum_processor, DocProcessor doc_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)
                    {
                        var replace = GetFuncOverride(nav, d, apiname, apiversion);
                        TranslateExtension(d);
                        TranslateReturnType(d, replace, nav, enum_processor, enums, apiname, version);
                        TranslateParameters(d, replace, nav, enum_processor, enums, apiname, version);
                        TranslateAttributes(d, replace, nav, 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_elements = GetFuncOverload(nav, d, apiname, apiversion);
                    foreach (XPathNavigator overload_element in overload_elements)
                    {
                        var overload = new Delegate(d);
                        TranslateReturnType(overload, overload_element, nav, enum_processor, enums, apiname, version);
                        TranslateParameters(overload, overload_element, nav, enum_processor, enums, apiname, version);
                        TranslateAttributes(overload, overload_element, nav, apiname, version);
                        overload_list.Add(overload);
                    }
                }
                foreach (var overload in overload_list)
                {
                    delegates.Add(overload);
                }
            }

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

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

            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);

            Console.WriteLine("Generating address table.");
            GenerateAddressTable(delegates);

            Console.WriteLine("Generating documentation.");
            GenerateDocumentation(wrappers, enum_processor, doc_processor);

            return wrappers;
        }
开发者ID:PieterMarius,项目名称:PhysicsEngine,代码行数:66,代码来源:FuncProcessor.cs

示例8: ReadDelegates

        DelegateCollection ReadDelegates(XPathNavigator specs, string apiversion)
        {
            DelegateCollection delegates = new DelegateCollection();
            var extensions = new List<string>();

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

                // Ignore functions that have a higher version number than
                // our current apiversion. Extensions do not have a version,
                // so we add them anyway (which is desirable).
                if (!String.IsNullOrEmpty(version) && !String.IsNullOrEmpty(apiversion) &&
                    Decimal.Parse(version) > Decimal.Parse(apiversion))
                    continue;

                // Check whether we are adding to an existing delegate or creating a new one.
                var d = new Delegate
                {
                    Name = name,
                    EntryPoint = name,
                    Version = node.GetAttribute("version", String.Empty).Trim(),
                    Category = node.GetAttribute("category", String.Empty).Trim(),
                    DeprecatedVersion = node.GetAttribute("deprecated", String.Empty).Trim(),
                    Deprecated = !String.IsNullOrEmpty(node.GetAttribute("deprecated", String.Empty)),
                    Extension = node.GetAttribute("extension", String.Empty).Trim() ?? "Core",
                    Obsolete = node.GetAttribute("obsolete", String.Empty).Trim()
                };
                if (!extensions.Contains(d.Extension))
                    extensions.Add(d.Extension);

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

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

                            string element_count = param.GetAttribute("elementcount", String.Empty).Trim();
                            if (String.IsNullOrEmpty(element_count))
                            {
                                element_count = param.GetAttribute("count", String.Empty).Trim();
                                if (!String.IsNullOrEmpty(element_count))
                                {
                                    int count;
                                    if (Int32.TryParse(element_count, out count))
                                    {
                                        p.ElementCount = count;
                                    }
                                }
                            }

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

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

                delegates.Add(d);
            }

            Utilities.InitExtensions(extensions);
            return delegates;
        }
开发者ID:jpbruyere,项目名称:opentk,代码行数:73,代码来源:XmlSpecReader.cs


注:本文中的DelegateCollection.Add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。