예제 #1
0
 private static SlabImageFile[] LoadSlabBindingImageFiles(XmlNode node)
 {
     if (node.LocalName != "images")
     {
         throw new SlabManifestFormatException(string.Format("images node expected. Found {0}", node.LocalName));
     }
     SlabImageFile[] array = new SlabImageFile[node.ChildNodes.Count];
     for (int i = 0; i < node.ChildNodes.Count; i++)
     {
         string attributeValue  = SlabManifestLoader.GetAttributeValue(node.ChildNodes[i], "name");
         string attributeValue2 = SlabManifestLoader.GetAttributeValue(node.ChildNodes[i], "layout");
         string attributeValue3 = SlabManifestLoader.GetAttributeValue(node.ChildNodes[i], "type");
         if (string.IsNullOrEmpty(attributeValue3))
         {
             throw new SlabManifestFormatException(string.Format("image node requires a type attribute", new object[0]));
         }
         if (attributeValue != null)
         {
             array[i] = new SlabImageFile
             {
                 Name   = attributeValue,
                 Type   = attributeValue3,
                 Layout = SlabManifestLoader.GetResourceLayout(attributeValue2)
             };
         }
     }
     return(array);
 }
예제 #2
0
 private static string[] LoadSlabBindingFeatures(XmlNode node)
 {
     if (node.LocalName != "features")
     {
         throw new SlabManifestFormatException(string.Format("features node expected. Found {0}", node.LocalName));
     }
     string[] array = new string[node.ChildNodes.Count];
     for (int i = 0; i < node.ChildNodes.Count; i++)
     {
         array[i] = SlabManifestLoader.GetAttributeValue(node.ChildNodes[i], "name");
     }
     return(array);
 }
예제 #3
0
 private static SlabConfiguration[] LoadSlabBindingConfigurations(XmlNode node)
 {
     if (node.LocalName != "configurations")
     {
         throw new SlabManifestFormatException(string.Format("configurations node expected. Found {0}", node.LocalName));
     }
     SlabConfiguration[] array = new SlabConfiguration[node.ChildNodes.Count];
     for (int i = 0; i < node.ChildNodes.Count; i++)
     {
         string attributeValue  = SlabManifestLoader.GetAttributeValue(node.ChildNodes[i], "type");
         string attributeValue2 = SlabManifestLoader.GetAttributeValue(node.ChildNodes[i], "layout");
         array[i] = new SlabConfiguration
         {
             Type   = attributeValue,
             Layout = SlabManifestLoader.GetResourceLayout(attributeValue2)
         };
     }
     return(array);
 }
예제 #4
0
 private static SlabStyleFile[] LoadSlabStyleFiles(XmlNode node)
 {
     if (node.LocalName != "styles" && node.LocalName != "packagedStyles")
     {
         throw new SlabManifestFormatException(string.Format("styles node expected. Found {0}", node.LocalName));
     }
     SlabStyleFile[] array = new SlabStyleFile[node.ChildNodes.Count];
     for (int i = 0; i < node.ChildNodes.Count; i++)
     {
         string attributeValue  = SlabManifestLoader.GetAttributeValue(node.ChildNodes[i], "layout");
         string attributeValue2 = SlabManifestLoader.GetAttributeValue(node.ChildNodes[i], "type");
         array[i] = new SlabStyleFile
         {
             Name   = SlabManifestLoader.GetAttributeValue(node.ChildNodes[i], "name"),
             Layout = SlabManifestLoader.GetResourceLayout(attributeValue),
             Type   = attributeValue2
         };
     }
     return(array);
 }
예제 #5
0
 private static SlabFontFile[] LoadSlabBindingFontFiles(XmlNode node)
 {
     if (node.LocalName != "fonts")
     {
         throw new SlabManifestFormatException(string.Format("fonts node expected. Found {0}", node.LocalName));
     }
     SlabFontFile[] array = new SlabFontFile[node.ChildNodes.Count];
     for (int i = 0; i < node.ChildNodes.Count; i++)
     {
         string attributeValue  = SlabManifestLoader.GetAttributeValue(node.ChildNodes[i], "name");
         string attributeValue2 = SlabManifestLoader.GetAttributeValue(node.ChildNodes[i], "layout");
         if (attributeValue != null)
         {
             array[i] = new SlabFontFile
             {
                 Name   = attributeValue,
                 Layout = SlabManifestLoader.GetResourceLayout(attributeValue2)
             };
         }
     }
     return(array);
 }
예제 #6
0
        private static KeyValuePair <string, T> LoadSlab <T>(XmlNode node) where T : SlabDefinition, new()
        {
            if (node.LocalName != "slab")
            {
                throw new SlabManifestFormatException(string.Format("slab node expected. Found {0}", node.LocalName));
            }
            string attributeValue = SlabManifestLoader.GetAttributeValue(node, "name");

            if (string.IsNullOrEmpty(attributeValue))
            {
                throw new SlabManifestFormatException("slab attribute 'name' was expected");
            }
            if (node["types"] == null)
            {
                throw new SlabManifestFormatException(string.Format("slab node must contain a 'types' node", new object[0]));
            }
            if (node["templates"] == null)
            {
                throw new SlabManifestFormatException(string.Format("slab node must contain a 'templates' node", new object[0]));
            }
            if (node["bindings"] == null)
            {
                throw new SlabManifestFormatException(string.Format("slab node must contain a 'bindings' node", new object[0]));
            }
            string[]            array  = SlabManifestLoader.LoadSlabTypes(node["types"]);
            string[]            array2 = SlabManifestLoader.LoadSlabTemplates(node["templates"]);
            IList <SlabBinding> list   = SlabManifestLoader.LoadSlabBindings(attributeValue, node["bindings"]);
            T t = Activator.CreateInstance <T>();

            Array.ForEach <string>(array, new Action <string>(t.AddType));
            Array.ForEach <string>(array2, new Action <string>(t.AddTemplate));
            foreach (SlabBinding binding in list)
            {
                t.AddBinding(binding);
            }
            return(new KeyValuePair <string, T>(attributeValue, t));
        }