public void WriteString(XamlMarkupExtensionWriter writer, string value)
 {
     if (ContainCharacterToEscape(value) || value.Length == 0)
     {
         value = FormatStringInCorrectSyntax(value);
     }
     writer.sb.Append(value);
 }
 protected void WritePrefix(XamlMarkupExtensionWriter writer, string prefix)
 {
     if (!string.IsNullOrEmpty(prefix))
     {
         writer.sb.Append(prefix);
         writer.sb.Append(":");
     }
 }
            public override void WriteEndMember(XamlMarkupExtensionWriter writer)
            {
                Node node = writer.nodes.Pop();

                if (node.NodeType != XamlNodeType.StartMember || node.XamlProperty != XamlLanguage.PositionalParameters)
                {
                    throw new InvalidOperationException(SR.Get(SRID.XamlMarkupExtensionWriterInputInvalid));
                }
                writer.currentState = InObjectAfterMember.State;
            }
 public override void WriteStartMember(XamlMarkupExtensionWriter writer, XamlMember property)
 {
     UpdateStack(writer, property);
     if (property == XamlLanguage.PositionalParameters)
     {
         writer.currentState = InPositionalParametersBeforeValue.State;
     }
     else
     {
         WriteNonPositionalParameterMember(writer, property);
     }
 }
            public override void WriteStartObject(XamlMarkupExtensionWriter writer, XamlType type)
            {
                writer.Reset();

                string prefix = writer.LookupPrefix(type);

                writer.sb.Append("{");
                WritePrefix(writer, prefix);
                writer.sb.Append(XamlXmlWriter.GetTypeName(type));

                writer.nodes.Push(new Node {
                    NodeType = XamlNodeType.StartObject, XamlType = type
                });
                writer.currentState = InObjectBeforeMember.State;
            }
            public override void WriteEndMember(XamlMarkupExtensionWriter writer)
            {
                if (writer.nodes.Count == 0)
                {
                    throw new InvalidOperationException(SR.Get(SRID.XamlMarkupExtensionWriterInputInvalid));
                }

                Node member = writer.nodes.Pop();

                if (member.NodeType != XamlNodeType.StartMember)
                {
                    throw new InvalidOperationException(SR.Get(SRID.XamlMarkupExtensionWriterInputInvalid));
                }

                writer.currentState = InObjectAfterMember.State;
            }
            public override void WriteStartObject(XamlMarkupExtensionWriter writer, XamlType type)
            {
                if (!type.IsMarkupExtension)
                {
                    // can not write a non-ME object in this state in curly form
                    writer.failed = true;
                    return;
                }
                string prefix = writer.LookupPrefix(type);

                writer.sb.Append("{");
                WritePrefix(writer, prefix);
                writer.sb.Append(XamlXmlWriter.GetTypeName(type));

                writer.nodes.Push(new Node {
                    NodeType = XamlNodeType.StartObject, XamlType = type
                });
                writer.currentState = InObjectBeforeMember.State;
            }
            public override void WriteEndObject(XamlMarkupExtensionWriter writer)
            {
                if (writer.nodes.Count == 0)
                {
                    throw new InvalidOperationException(SR.Get(SRID.XamlMarkupExtensionWriterInputInvalid));
                }

                Node node = writer.nodes.Pop();

                if (node.NodeType != XamlNodeType.StartObject)
                {
                    throw new InvalidOperationException(SR.Get(SRID.XamlMarkupExtensionWriterInputInvalid));
                }

                writer.sb.Append("}");

                if (writer.nodes.Count == 0)
                {
                    writer.currentState = Start.State;
                }
                else
                {
                    Node member = writer.nodes.Peek();
                    if (member.NodeType != XamlNodeType.StartMember)
                    {
                        throw new InvalidOperationException(SR.Get(SRID.XamlMarkupExtensionWriterInputInvalid));
                    }

                    if (member.XamlProperty == XamlLanguage.PositionalParameters)
                    {
                        writer.currentState = InPositionalParametersAfterValue.State;
                    }
                    else
                    {
                        writer.currentState = InMemberAfterValueOrEndObject.State;
                    }
                }
            }
            protected void UpdateStack(XamlMarkupExtensionWriter writer, XamlMember property)
            {
                if (writer.nodes.Count == 0)
                {
                    throw new InvalidOperationException(SR.Get(SRID.XamlMarkupExtensionWriterInputInvalid));
                }

                Node objectNode = writer.nodes.Peek();

                if (objectNode.NodeType != XamlNodeType.StartObject)
                {
                    throw new InvalidOperationException(SR.Get(SRID.XamlMarkupExtensionWriterInputInvalid));
                }

                writer.CheckMemberForUniqueness(objectNode, property);

                writer.nodes.Push(new Node
                {
                    NodeType     = XamlNodeType.StartMember,
                    XamlType     = objectNode.XamlType,
                    XamlProperty = property
                });
            }
 public virtual void WriteStartObject(XamlMarkupExtensionWriter writer, XamlType type)
 {
     writer.failed = true;
 }
 public virtual void WriteStartMember(XamlMarkupExtensionWriter writer, XamlMember property)
 {
     writer.failed = true;
 }
 public override void WriteValue(XamlMarkupExtensionWriter writer, string value)
 {
     WriteString(writer, value);
     writer.currentState = InMemberAfterValueOrEndObject.State;
 }
 public virtual void WriteEndMember(XamlMarkupExtensionWriter writer)
 {
     writer.failed = true;
 }
 public override void WriteStartObject(XamlMarkupExtensionWriter writer, XamlType type)
 {
     writer.sb.Append(Delimiter);
     writer.currentState = InMember.State;
     writer.currentState.WriteStartObject(writer, type);
 }
 public override void WriteValue(XamlMarkupExtensionWriter writer, string value)
 {
     writer.sb.Append(Delimiter);
     WriteString(writer, value);
     writer.currentState = InPositionalParametersAfterValue.State;
 }
 public override void WriteStartMember(XamlMarkupExtensionWriter writer, XamlMember property)
 {
     UpdateStack(writer, property);
     WriteNonPositionalParameterMember(writer, property);
 }
 public virtual void WriteValue(XamlMarkupExtensionWriter writer, string value)
 {
     writer.failed = true;
 }
 public virtual void WriteGetObject(XamlMarkupExtensionWriter writer)
 {
     writer.failed = true;
 }
 public virtual void WriteNamespace(XamlMarkupExtensionWriter writer, NamespaceDeclaration namespaceDeclaration)
 {
     writer.failed = true;
 }