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


C# DelegateCollection.ContainsKey方法代码示例

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


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

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

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

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


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