internal static ClrSimpleTypeInfo CreateSimpleTypeInfo(XmlSchemaType type)
        {
            ClrSimpleTypeInfo typeInfo = null;

            Debug.Assert(type.Datatype != null);
            switch (type.Datatype.Variety)
            {
            case XmlSchemaDatatypeVariety.Atomic:
            {
                typeInfo = new AtomicSimpleTypeInfo(type);
                break;
            }

            case XmlSchemaDatatypeVariety.List:
            {
                typeInfo = new ListSimpleTypeInfo(type);
                break;
            }

            case XmlSchemaDatatypeVariety.Union:
            {
                typeInfo = new UnionSimpleTypeInfo(type);
                break;
            }
            }
            return(typeInfo);
        }
Ejemplo n.º 2
0
        internal static CodeExpression MaterializeSimpleTypeDef(
            ClrSimpleTypeInfo typeInfo,
            Dictionary <XmlSchemaObject, string> nameMappings,
            LinqToXsdSettings settings)
        {
            CodeObjectCreateExpression simpleTypeCreate = null;
            CodeExpressionCollection   expressions      = null;

            switch (typeInfo.Variety)
            {
            case XmlSchemaDatatypeVariety.Atomic:
                simpleTypeCreate = new CodeObjectCreateExpression(
                    Constants.AtomicSimpleTypeValidator);
                expressions = simpleTypeCreate.Parameters;
                expressions.Add(CreateGetBuiltInSimpleType(typeInfo.TypeCode));
                expressions.Add(CreateFacets(typeInfo));
                break;

            case XmlSchemaDatatypeVariety.List:
                simpleTypeCreate = new CodeObjectCreateExpression(
                    Constants.ListSimpleTypeValidator);
                expressions = simpleTypeCreate.Parameters;
                expressions.Add(CreateGetBuiltInSimpleType(typeInfo.TypeCode));
                expressions.Add(CreateFacets(typeInfo));

                ListSimpleTypeInfo listType = typeInfo as ListSimpleTypeInfo;
                ClrSimpleTypeInfo  itemType = listType.ItemType;
                expressions.Add(CreateSimpleTypeDef(
                                    itemType, nameMappings, settings, true));
                break;

            case XmlSchemaDatatypeVariety.Union:
                simpleTypeCreate = new CodeObjectCreateExpression(
                    Constants.UnionSimpleTypeValidator);
                expressions = simpleTypeCreate.Parameters;
                expressions.Add(CreateGetBuiltInSimpleType(typeInfo.TypeCode));
                expressions.Add(CreateFacets(typeInfo));

                UnionSimpleTypeInfo       unionType        = typeInfo as UnionSimpleTypeInfo;
                CodeArrayCreateExpression memberTypeCreate =
                    new CodeArrayCreateExpression();
                memberTypeCreate.CreateType = new CodeTypeReference(
                    Constants.SimpleTypeValidator);
                foreach (ClrSimpleTypeInfo st in unionType.MemberTypes)
                {
                    memberTypeCreate.Initializers.Add(CreateSimpleTypeDef(
                                                          st, nameMappings, settings, true));
                }
                expressions.Add(memberTypeCreate);
                break;
            }
            return(simpleTypeCreate);
        }
Ejemplo n.º 3
0
        internal static ClrSimpleTypeInfo CreateSimpleTypeInfo(XmlSchemaType type)
        {
             ClrSimpleTypeInfo typeInfo = null;

             Debug.Assert(type.Datatype != null);
             switch (type.Datatype.Variety)
             {
                 case XmlSchemaDatatypeVariety.Atomic: typeInfo = new AtomicSimpleTypeInfo(type);
                     break;
                 case XmlSchemaDatatypeVariety.List: typeInfo = new ListSimpleTypeInfo(type);
                     break;
                 case XmlSchemaDatatypeVariety.Union: typeInfo = new UnionSimpleTypeInfo(type);
                     break;
                 default:
                     break;
             }
             return typeInfo;
         }