private MobeelizerApplicationDefinition ParseDefinition(XDocument document)
        {
            MobeelizerApplicationDefinition definition = new MobeelizerApplicationDefinition();
            XElement application = document.Root;
            definition.Application = application.Attribute(MobeelizerDefinitionTag.APPLICATION_TAG).Value;
            definition.ConflictMode = application.Attribute(MobeelizerDefinitionTag.CONFLICT_MODE_TAG).Value;
            definition.Vendor = application.Attribute(MobeelizerDefinitionTag.VENDOR_TAG).Value;
            XElement devices = application.Element(XName.Get(MobeelizerDefinitionTag.DEVICES_TAG, MobeelizerDefinitionTag.NAMESPACE));
            if (devices != null)
            {
                definition.Devices = new List<MobeelizerDeviceDefinition>();
                foreach (XElement device in devices.Elements(XName.Get(MobeelizerDefinitionTag.DEVICE_TAG, MobeelizerDefinitionTag.NAMESPACE)))
                {
                    MobeelizerDeviceDefinition deviceDef = new MobeelizerDeviceDefinition();
                    deviceDef.Name = device.Attribute(MobeelizerDefinitionTag.NAME_TAG).Value;
                    definition.Devices.Add(deviceDef);
                }
            }

            XElement groups = application.Element(XName.Get(MobeelizerDefinitionTag.GROUPS_TAG, MobeelizerDefinitionTag.NAMESPACE));
            if (groups != null)
            {
                definition.Groups = new List<MobeelizerGroupDefinition>();
                foreach (XElement group in groups.Elements(XName.Get(MobeelizerDefinitionTag.GROUP_TAG, MobeelizerDefinitionTag.NAMESPACE)))
                {
                    MobeelizerGroupDefinition groupDef = new MobeelizerGroupDefinition();
                    groupDef.Name = group.Attribute(MobeelizerDefinitionTag.NAME_TAG).Value;
                    definition.Groups.Add(groupDef);
                }
            }

            XElement roles = application.Element(XName.Get(MobeelizerDefinitionTag.ROLES_TAG, MobeelizerDefinitionTag.NAMESPACE));
            if (roles != null)
            {
                definition.Roles = new List<MobeelizerRoleDefinition>();
                foreach (XElement role in roles.Elements(XName.Get(MobeelizerDefinitionTag.ROLE_TAG, MobeelizerDefinitionTag.NAMESPACE)))
                {
                    MobeelizerRoleDefinition roleDef = new MobeelizerRoleDefinition();
                    roleDef.Device = role.Attribute(MobeelizerDefinitionTag.DEVICE_TAG).Value;
                    roleDef.Group = role.Attribute(MobeelizerDefinitionTag.GROUP_TAG).Value;
                    definition.Roles.Add(roleDef);
                }
            }

            XElement models = application.Element(XName.Get(MobeelizerDefinitionTag.MODELS_TAG, MobeelizerDefinitionTag.NAMESPACE));
            if (models != null)
            {
                definition.Models = new List<MobeelizerModelDefinition>();
                foreach (XElement model in models.Elements(XName.Get(MobeelizerDefinitionTag.MODEL_TAG, MobeelizerDefinitionTag.NAMESPACE)))
                {
                    definition.Models.Add(ParseModel(model));
                }
            }

            return definition;
        }
Exemple #2
0
        private MobeelizerApplicationDefinition ParseDefinition(XDocument document)
        {
            MobeelizerApplicationDefinition definition = new MobeelizerApplicationDefinition();
            XElement application = document.Root;

            definition.Application  = application.Attribute(MobeelizerDefinitionTag.APPLICATION_TAG).Value;
            definition.ConflictMode = application.Attribute(MobeelizerDefinitionTag.CONFLICT_MODE_TAG).Value;
            definition.Vendor       = application.Attribute(MobeelizerDefinitionTag.VENDOR_TAG).Value;
            XElement devices = application.Element(XName.Get(MobeelizerDefinitionTag.DEVICES_TAG, MobeelizerDefinitionTag.NAMESPACE));

            if (devices != null)
            {
                definition.Devices = new List <MobeelizerDeviceDefinition>();
                foreach (XElement device in devices.Elements(XName.Get(MobeelizerDefinitionTag.DEVICE_TAG, MobeelizerDefinitionTag.NAMESPACE)))
                {
                    MobeelizerDeviceDefinition deviceDef = new MobeelizerDeviceDefinition();
                    deviceDef.Name = device.Attribute(MobeelizerDefinitionTag.NAME_TAG).Value;
                    definition.Devices.Add(deviceDef);
                }
            }

            XElement groups = application.Element(XName.Get(MobeelizerDefinitionTag.GROUPS_TAG, MobeelizerDefinitionTag.NAMESPACE));

            if (groups != null)
            {
                definition.Groups = new List <MobeelizerGroupDefinition>();
                foreach (XElement group in groups.Elements(XName.Get(MobeelizerDefinitionTag.GROUP_TAG, MobeelizerDefinitionTag.NAMESPACE)))
                {
                    MobeelizerGroupDefinition groupDef = new MobeelizerGroupDefinition();
                    groupDef.Name = group.Attribute(MobeelizerDefinitionTag.NAME_TAG).Value;
                    definition.Groups.Add(groupDef);
                }
            }

            XElement roles = application.Element(XName.Get(MobeelizerDefinitionTag.ROLES_TAG, MobeelizerDefinitionTag.NAMESPACE));

            if (roles != null)
            {
                definition.Roles = new List <MobeelizerRoleDefinition>();
                foreach (XElement role in roles.Elements(XName.Get(MobeelizerDefinitionTag.ROLE_TAG, MobeelizerDefinitionTag.NAMESPACE)))
                {
                    MobeelizerRoleDefinition roleDef = new MobeelizerRoleDefinition();
                    roleDef.Device = role.Attribute(MobeelizerDefinitionTag.DEVICE_TAG).Value;
                    roleDef.Group  = role.Attribute(MobeelizerDefinitionTag.GROUP_TAG).Value;
                    definition.Roles.Add(roleDef);
                }
            }

            XElement models = application.Element(XName.Get(MobeelizerDefinitionTag.MODELS_TAG, MobeelizerDefinitionTag.NAMESPACE));

            if (models != null)
            {
                definition.Models = new List <MobeelizerModelDefinition>();
                foreach (XElement model in models.Elements(XName.Get(MobeelizerDefinitionTag.MODEL_TAG, MobeelizerDefinitionTag.NAMESPACE)))
                {
                    definition.Models.Add(ParseModel(model));
                }
            }

            return(definition);
        }