Bind.Utilities.Merge C# (CSharp) Method

Merge() static private method

Places a new constant in the specified enum, if it doesn't already exist. The existing constant is replaced iff the new has a numeric value and the old has a reference value (eg 0x5 is preferred over AttribMask.Foo)
static private Merge ( Bind.Structures.Enum s, Constant t ) : Bind.Structures.Enum
s Bind.Structures.Enum
t Bind.Structures.Constant
return Bind.Structures.Enum
        internal static Enum Merge(Enum s, Constant t)
        {
            if (!s.ConstantCollection.ContainsKey(t.Name))
            {
                s.ConstantCollection.Add(t.Name, t);
            }
            else
            {
                // Tried to add a constant that already exists. If one constant
                // is like: 'Foo = 0x5' and the other like: 'Foo = Bar.Foo', then 
                // keep the first one.
                if (!Char.IsDigit(((Constant)s.ConstantCollection[t.Name]).Value[0]))
                {
                    s.ConstantCollection.Remove(t.Name);
                    s.ConstantCollection.Add(t.Name, t);
                }
            }

            return s;
        }

Same methods

Utilities::Merge ( DelegateCollection delegates, Bind.Structures.Delegate t ) : void
Utilities::Merge ( DelegateCollection delegates, DelegateCollection new_delegates ) : void
Utilities::Merge ( EnumCollection enums, Bind.Structures.Enum t ) : void
Utilities::Merge ( EnumCollection enums, EnumCollection new_enums ) : void

Usage Example

Beispiel #1
0
        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));
            }
        }
All Usage Examples Of Bind.Utilities::Merge