// Read the actual parameter info, i.e. the type of the paramter and its value.
        // The first element could be a V or an SO.
        private static void ReadParamInfo(XamlReader reader, XamlType type, NamespaceTable namespaceTable, string rootNamespace, AttributeParameterData paramInfo)
        {
            reader.Read();

            bool readNext = false;

            do
            {
                readNext = false;
                if (reader.NodeType == XamlNodeType.StartObject && reader.Type == XamlLanguage.Array)
                {
                    paramInfo.IsArray = true;
                    XamlReader xamlArrayReader = reader.ReadSubtree();
                    xamlArrayReader.Read();
                    while (readNext || xamlArrayReader.Read())
                    {
                        readNext = false;
                        if (xamlArrayReader.NodeType == XamlNodeType.StartMember && xamlArrayReader.Member.Name == "Type")
                        {
                            xamlArrayReader.Read();
                            if (xamlArrayReader.NodeType == XamlNodeType.Value)
                            {
                                XamlType arrayType = XamlBuildTaskServices.GetXamlTypeFromString(xamlArrayReader.Value as string, namespaceTable, xamlArrayReader.SchemaContext);
                                if (arrayType.UnderlyingType != null)
                                {
                                    paramInfo.Type = xamlArrayReader.SchemaContext.GetXamlType(arrayType.UnderlyingType.MakeArrayType());
                                }
                                else
                                {
                                    throw FxTrace.Exception.AsError(new InvalidOperationException(SR.AttributeParameterTypeUnknown(arrayType)));
                                }
                            }
                        }
                        else if (xamlArrayReader.NodeType == XamlNodeType.StartObject)
                        {
                            AttributeParameterData arrayEntry = new AttributeParameterData();
                            ReadParamInfo(xamlArrayReader.ReadSubtree(), null, namespaceTable, rootNamespace, arrayEntry);
                            paramInfo.AddArrayContentsEntry(arrayEntry);
                            readNext = true;
                        }
                    }
                }
                else if (reader.NodeType == XamlNodeType.StartObject || reader.NodeType == XamlNodeType.Value)
                {
                    paramInfo.IsArray = false;
                    string   paramVal;
                    object   paramObj = null;
                    XamlType paramType;
                    GetParamValueType(reader.ReadSubtree(), type, namespaceTable, rootNamespace, out paramVal, out paramType, out paramObj);
                    paramInfo.TextValue = paramVal;
                    paramInfo.Type      = paramType;
                    paramInfo.Value     = paramObj;
                }
            } while (readNext || reader.Read());
        }
Пример #2
0
 XamlType ReadPropertyType(XamlReader xamlReader)
 {
     while (xamlReader.Read())
     {
         if (xamlReader.NodeType == XamlNodeType.Value && xamlReader.Value is string)
         {
             return(XamlBuildTaskServices.GetXamlTypeFromString((string)xamlReader.Value, this.namespaceTable, xamlReader.SchemaContext));
         }
     }
     return(null);
 }
        // Parses a XAML QName to a CLR Type Name (and the corresponding ROL type, if available)
        private static Tuple <string, Type> ParseParameterValueTypeName(string paramValue, string rootNamespace, XamlSchemaContext schemaContext, NamespaceTable namespaceTable)
        {
            XamlType xamlType = XamlBuildTaskServices.GetXamlTypeFromString(paramValue, namespaceTable, schemaContext);

            string clrTypeName;

            if (!XamlBuildTaskServices.TryGetClrTypeName(xamlType, rootNamespace, out clrTypeName))
            {
                throw FxTrace.Exception.AsError(new InvalidOperationException(SR.TypeNameUnknown(XamlBuildTaskServices.GetFullTypeName(xamlType))));
            }
            return(Tuple.Create(clrTypeName, xamlType.UnderlyingType));
        }