예제 #1
0
        private static void AddFields(App app, XmlNode manifest)
        {
            // add fields to the app
            XmlNodeList nodeList = manifest.SelectNodes("fields/field");
            if (nodeList != null)
            {
                foreach (XmlNode n in nodeList)
                {
                    string name = n.Attributes["name"].Value;
                    FieldType fType = FieldType.String;
                    if (n.Attributes["type"] != null)
                    {
                        if (!Enum.TryParse<FieldType>(n.Attributes["type"].Value, true, out fType))
                        {
                            fType = FieldType.String;
                        }
                    }
                    bool required = false;
                    if (n.Attributes["required"] != null)
                    {
                        if (!Boolean.TryParse(n.Attributes["required"].Value, out required))
                        {
                            required = false;
                        }
                    }

                    bool collection = false;
                    if (n.Attributes["collection"] != null)
                    {
                        if (!Boolean.TryParse(n.Attributes["collection"].Value, out collection))
                        {
                            collection = false;
                        }
                    }

                    Field field = new Field();
                    field.Name = name;
                    field.FieldType = fType;
                    field.IsRequired = required;
                    field.IsCollection = collection;

                    app.AddField(field);
                }
            }
        }