예제 #1
0
        private MobeelizerModelFieldCredentialsDefinition HasAccess(MobeelizerModelFieldDefinition field, string role)
        {
            foreach (MobeelizerModelFieldCredentialsDefinition credentials in field.Credentials)
            {
                if (credentials.Role.Equals(role))
                {
                    if (credentials.CreateAllowed != MobeelizerCredential.NONE ||
                        credentials.UpdateAllowed != MobeelizerCredential.NONE ||
                        credentials.ReadAllowed != MobeelizerCredential.NONE)
                    {
                        return(credentials);
                    }
                    break;
                }
            }

            return(null);
        }
예제 #2
0
        private MobeelizerModelFieldDefinition ParseField(XElement field)
        {
            MobeelizerModelFieldDefinition fieldDef = new MobeelizerModelFieldDefinition();

            fieldDef.Name       = field.Attribute(MobeelizerDefinitionTag.NAME_TAG).Value;
            fieldDef.IsRequired = Boolean.Parse(field.Attribute(MobeelizerDefinitionTag.REQUIRED_TAG).Value);
            fieldDef.Type       = (MobeelizerFieldType)Enum.Parse(typeof(MobeelizerFieldType), field.Attribute(MobeelizerDefinitionTag.TYPE_TAG).Value, true);
            if (field.Attribute(MobeelizerDefinitionTag.DEFAULT_VALUE_TAG) != null)
            {
                fieldDef.DefaultValue = field.Attribute(MobeelizerDefinitionTag.DEFAULT_VALUE_TAG).Value;
            }

            XElement fieldCredentials = field.Element(XName.Get(MobeelizerDefinitionTag.CREDENTIALS_TAG, MobeelizerDefinitionTag.NAMESPACE));

            if (fieldCredentials != null)
            {
                fieldDef.Credentials = new List <MobeelizerModelFieldCredentialsDefinition>();
                foreach (XElement credential in fieldCredentials.Elements(XName.Get(MobeelizerDefinitionTag.CREDENTIAL_TAG, MobeelizerDefinitionTag.NAMESPACE)))
                {
                    fieldDef.Credentials.Add(ParseModelFieldCredentials(credential));
                }
            }

            XElement options = field.Element(XName.Get(MobeelizerDefinitionTag.OPTIONS_TAG, MobeelizerDefinitionTag.NAMESPACE));

            fieldDef.Options = new Dictionary <string, string>();
            if (options != null)
            {
                foreach (XElement option in options.Elements(XName.Get(MobeelizerDefinitionTag.OPTION_TAG, MobeelizerDefinitionTag.NAMESPACE)))
                {
                    String name  = option.Attribute(MobeelizerDefinitionTag.NAME_TAG).Value;
                    String value = option.Value;
                    fieldDef.Options.Add(name, value);
                }
            }
            return(fieldDef);
        }
        private MobeelizerModelFieldDefinition ParseField(XElement field)
        {
            MobeelizerModelFieldDefinition fieldDef = new MobeelizerModelFieldDefinition();
            fieldDef.Name = field.Attribute(MobeelizerDefinitionTag.NAME_TAG).Value;
            fieldDef.IsRequired = Boolean.Parse(field.Attribute(MobeelizerDefinitionTag.REQUIRED_TAG).Value);
            fieldDef.Type = (MobeelizerFieldType)Enum.Parse(typeof(MobeelizerFieldType), field.Attribute(MobeelizerDefinitionTag.TYPE_TAG).Value, true);
            if(field.Attribute(MobeelizerDefinitionTag.DEFAULT_VALUE_TAG)!= null)
            {
                fieldDef.DefaultValue = field.Attribute(MobeelizerDefinitionTag.DEFAULT_VALUE_TAG).Value;
            }

            XElement fieldCredentials = field.Element(XName.Get(MobeelizerDefinitionTag.CREDENTIALS_TAG, MobeelizerDefinitionTag.NAMESPACE));
            if (fieldCredentials != null)
            {
                fieldDef.Credentials = new List<MobeelizerModelFieldCredentialsDefinition>();
                foreach (XElement credential in fieldCredentials.Elements(XName.Get(MobeelizerDefinitionTag.CREDENTIAL_TAG, MobeelizerDefinitionTag.NAMESPACE)))
                {
                    fieldDef.Credentials.Add(ParseModelFieldCredentials(credential));
                }
            }

            XElement options = field.Element(XName.Get(MobeelizerDefinitionTag.OPTIONS_TAG, MobeelizerDefinitionTag.NAMESPACE));
            fieldDef.Options = new Dictionary<string, string>();
            if (options != null)
            {
                foreach (XElement option in options.Elements(XName.Get(MobeelizerDefinitionTag.OPTION_TAG, MobeelizerDefinitionTag.NAMESPACE)))
                {
                    String name = option.Attribute(MobeelizerDefinitionTag.NAME_TAG).Value;
                    String value = option.Value;
                    fieldDef.Options.Add(name, value);
                }
            }
            return fieldDef;
        }
        private MobeelizerModelFieldCredentialsDefinition HasAccess(MobeelizerModelFieldDefinition field, string role)
        {
            foreach (MobeelizerModelFieldCredentialsDefinition credentials in field.Credentials)
            {
                if (credentials.Role.Equals(role))
                {
                    if (credentials.CreateAllowed != MobeelizerCredential.NONE
                            || credentials.UpdateAllowed != MobeelizerCredential.NONE
                            || credentials.ReadAllowed != MobeelizerCredential.NONE)
                    {
                        return credentials;
                    }
                    break;
                }
            }

            return null;
        }