Exemplo n.º 1
0
        public static SCIMRepresentationAttribute ToDomain(this SCIMRepresentationAttributeModel representationAttribute, SCIMRepresentationAttribute parent = null)
        {
            var result = new SCIMRepresentationAttribute
            {
                Id              = representationAttribute.Id,
                Parent          = parent == null ? (representationAttribute.Parent == null ? null : representationAttribute.Parent.ToDomain()) : parent,
                SchemaAttribute = representationAttribute.SchemaAttribute.ToDomain(),
                ValuesBoolean   = representationAttribute.SchemaAttribute.Type != SCIMSchemaAttributeTypes.BOOLEAN ? new List <bool>() : representationAttribute.Values.Select(v => v.ValueBoolean.Value).ToList(),
                ValuesDateTime  = representationAttribute.SchemaAttribute.Type != SCIMSchemaAttributeTypes.DATETIME ? new List <DateTime>() : representationAttribute.Values.Select(v => v.ValueDateTime.Value).ToList(),
                ValuesInteger   = representationAttribute.SchemaAttribute.Type != SCIMSchemaAttributeTypes.INTEGER ? new List <int>() : representationAttribute.Values.Select(v => v.ValueInteger.Value).ToList(),
                ValuesReference = representationAttribute.SchemaAttribute.Type != SCIMSchemaAttributeTypes.REFERENCE ? new List <string>() : representationAttribute.Values.Select(v => v.ValueReference).ToList(),
                ValuesString    = representationAttribute.SchemaAttribute.Type != SCIMSchemaAttributeTypes.STRING ? new List <string>() : representationAttribute.Values.Select(v => v.ValueString).ToList(),
                ValuesDecimal   = representationAttribute.SchemaAttribute.Type != SCIMSchemaAttributeTypes.DECIMAL ? new List <decimal>() : representationAttribute.Values.Select(v => v.ValueDecimal.Value).ToList(),
                ValuesBinary    = representationAttribute.SchemaAttribute.Type != SCIMSchemaAttributeTypes.BINARY ? new List <byte[]>() : representationAttribute.Values.Select(v => v.ValueByte).ToList(),
                Values          = new List <SCIMRepresentationAttribute>()
            };

            if (representationAttribute.Children != null && representationAttribute.Children.Any())
            {
                foreach (var val in representationAttribute.Children)
                {
                    result.Values.Add(val.ToDomain(result));
                }
            }


            return(result);
        }
Exemplo n.º 2
0
        public static SCIMRepresentationAttributeModel ToModel(this SCIMRepresentationAttribute a)
        {
            var result = new SCIMRepresentationAttributeModel
            {
                Id              = a.Id,
                ValuesBoolean   = a.ValuesBoolean,
                ValuesDateTime  = a.ValuesDateTime,
                ValuesInteger   = a.ValuesInteger,
                ValuesReference = a.ValuesReference,
                ValuesString    = a.ValuesString,
                ValuesByte      = a.ValuesBinary,
                ValuesDecimal   = a.ValuesDecimal,
                SchemaAttribute = a.SchemaAttribute.ToModel()
            };

            if (a.Values != null && a.Values.Any())
            {
                foreach (var r in a.Values)
                {
                    result.Children.Add(ToModel(r));
                }
            }

            return(result);
        }
Exemplo n.º 3
0
        public static SCIMRepresentationAttribute ToDomain(this SCIMRepresentationAttributeModel representationAttribute, SCIMRepresentationAttribute parent = null)
        {
            var result = new SCIMRepresentationAttribute
            {
                Id              = representationAttribute.Id,
                Parent          = parent == null ? null : parent,
                SchemaAttribute = representationAttribute.SchemaAttribute.ToDomain(),
                ValuesBoolean   = representationAttribute.SchemaAttribute.Type != SCIMSchemaAttributeTypes.BOOLEAN ? new List <bool>() : representationAttribute.ValuesBoolean,
                ValuesDateTime  = representationAttribute.SchemaAttribute.Type != SCIMSchemaAttributeTypes.DATETIME ? new List <DateTime>() : representationAttribute.ValuesDateTime,
                ValuesInteger   = representationAttribute.SchemaAttribute.Type != SCIMSchemaAttributeTypes.INTEGER ? new List <int>() : representationAttribute.ValuesInteger,
                ValuesReference = representationAttribute.SchemaAttribute.Type != SCIMSchemaAttributeTypes.REFERENCE ? new List <string>() : representationAttribute.ValuesReference,
                ValuesString    = representationAttribute.SchemaAttribute.Type != SCIMSchemaAttributeTypes.STRING ? new List <string>() : representationAttribute.ValuesString,
                Values          = new List <SCIMRepresentationAttribute>()
            };

            if (representationAttribute.Children != null && representationAttribute.Children.Any())
            {
                foreach (var val in representationAttribute.Children)
                {
                    result.Values.Add(val.ToDomain(result));
                }
            }


            return(result);
        }
Exemplo n.º 4
0
        public static SCIMRepresentationAttributeModel ToModel(this SCIMRepresentationAttribute a, string representationId)
        {
            var values = new List <SCIMRepresentationAttributeValueModel>();

            values.AddRange(a.ValuesBoolean.Select(b => new SCIMRepresentationAttributeValueModel
            {
                ValueBoolean = b,
                Id           = Guid.NewGuid().ToString()
            }));
            values.AddRange(a.ValuesDateTime.Select(d => new SCIMRepresentationAttributeValueModel
            {
                ValueDateTime = d,
                Id            = Guid.NewGuid().ToString()
            }));
            values.AddRange(a.ValuesInteger.Select(i => new SCIMRepresentationAttributeValueModel
            {
                ValueInteger = i,
                Id           = Guid.NewGuid().ToString()
            }));
            values.AddRange(a.ValuesReference.Select(r => new SCIMRepresentationAttributeValueModel
            {
                ValueReference = r,
                Id             = Guid.NewGuid().ToString()
            }));
            values.AddRange(a.ValuesString.Select(s => new SCIMRepresentationAttributeValueModel
            {
                ValueString = s,
                Id          = Guid.NewGuid().ToString()
            }));
            values.AddRange(a.ValuesDecimal.Select(s => new SCIMRepresentationAttributeValueModel
            {
                ValueDecimal = s,
                Id           = Guid.NewGuid().ToString()
            }));
            values.AddRange(a.ValuesBinary.Select(s => new SCIMRepresentationAttributeValueModel
            {
                ValueByte = s,
                Id        = Guid.NewGuid().ToString()
            }));
            var result = new SCIMRepresentationAttributeModel
            {
                Id                = a.Id,
                Values            = values,
                RepresentationId  = representationId,
                ParentId          = a.Parent == null ? null : a.Parent.Id,
                SchemaAttributeId = a.SchemaAttribute.Id,
                Children          = new List <SCIMRepresentationAttributeModel>()
            };

            if (a.Values != null && a.Values.Any())
            {
                foreach (var r in a.Values)
                {
                    result.Children.Add(ToModel(r, representationId));
                }
            }

            return(result);
        }