Beispiel #1
0
 void RewriteHandleDefinition(VkHandle vkHandle)
 {
     if (vkHandle.Name.StartsWith("Vk"))
     {
         vkHandle.Name = vkHandle.Name.Remove(0, 2); // trim `Vk`
     }
 }
Beispiel #2
0
        VkHandle ReadHandle(XElement xtype)
        {
            if (xtype.Name != "type")
            {
                throw new ArgumentException("Not a type element", nameof(xtype));
            }

            var xcategory = xtype.Attribute("category");

            if (xcategory == null || xcategory.Value != "handle")
            {
                throw new ArgumentException("Invalid category", nameof(xtype));
            }

            var xelements = xtype.Elements();

            if (!xelements.Any())
            {
                throw new ArgumentException("Contains no elements", nameof(xtype));
            }

            var vkHandle = new VkHandle();

            foreach (var xelm in xelements)
            {
                switch (xelm.Name.ToString())
                {
                case "type":
                    vkHandle.HandleType = xelm.Value;
                    break;

                case "name":
                    vkHandle.Name = xelm.Value;
                    break;

                default: throw new NotImplementedException(xelm.Name.ToString());
                }
            }

            var xattributes = xtype.Attributes();

            if (xattributes.Any())
            {
                foreach (var xattrib in xattributes)
                {
                    switch (xattrib.Name.ToString())
                    {
                    case "parent":
                        vkHandle.Parent = xattrib.Value;
                        break;

                    case "category": break;

                    default: throw new NotImplementedException(xattrib.Name.ToString());
                    }
                }
            }

            return(vkHandle);
        }