Esempio n. 1
0
 public PropertiesNode(ActivityBuilderXamlWriter.BuilderClassNode classNode, ActivityBuilderXamlWriter writer) : base(writer)
 {
     this.classNode       = classNode;
     this.propertiesNodes = new XamlNodeQueue(writer.SchemaContext);
     base.CurrentWriter   = this.propertiesNodes.Writer;
     base.CurrentWriter.WriteStartMember(XamlLanguage.Members);
 }
Esempio n. 2
0
 public PropertyReferenceNode(XamlType owningType, ActivityBuilderXamlWriter writer, XamlMember originalStartMember) : base(writer)
 {
     this.owningType             = owningType;
     this.propertyReferenceNodes = new XamlNodeQueue(writer.SchemaContext);
     this.originalStartMember    = originalStartMember;
     base.CurrentWriter          = this.propertyReferenceNodes.Writer;
 }
Esempio n. 3
0
        public override void WriteStartObject(XamlType type)
        {
            switch (this.currentState)
            {
            case ActivityTemplateFactoryBuilderWriterStates.InitialState:
                if (type.Equals(new XamlType(typeof(ActivityTemplateFactoryBuilder), this.schemaContext)))
                {
                    this.queuedNodes  = new XamlNodeQueue(this.schemaContext);
                    this.currentState = ActivityTemplateFactoryBuilderWriterStates.BufferingState;
                }
                else
                {
                    this.currentState = ActivityTemplateFactoryBuilderWriterStates.BypassState;
                    this.underlyingWriter.WriteStartObject(type);
                }

                break;

            case ActivityTemplateFactoryBuilderWriterStates.BypassState:
                this.underlyingWriter.WriteStartObject(type);
                break;

            default:
                SharedFx.Assert(
                    this.currentState == ActivityTemplateFactoryBuilderWriterStates.BufferingState ||
                    this.currentState == ActivityTemplateFactoryBuilderWriterStates.BufferingNameState ||
                    this.currentState == ActivityTemplateFactoryBuilderWriterStates.BufferingTargetTypeState,
                    "These are the only possible ActivityTemplateFactoryBuilderWriterStates.");
                SharedFx.Assert("It is impossible to start any object during the buffering state.");
                break;
            }
        }
Esempio n. 4
0
            public void SetXClass(string builderName, XamlNodeQueue nameNodes)
            {
                this.xClassNodes = new XamlNodeQueue(base.Writer.SchemaContext);
                this.xClassNodes.Writer.WriteStartMember(XamlLanguage.Class);
                this.xClassNamespace = null;
                string str = builderName;

                if (string.IsNullOrEmpty(str))
                {
                    str = string.Format(CultureInfo.CurrentCulture, "_{0}", new object[] { Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 4) });
                }
                if (nameNodes != null)
                {
                    XamlServices.Transform(nameNodes.Reader, this.xClassNodes.Writer, false);
                }
                else
                {
                    this.xClassNodes.Writer.WriteValue(str);
                    this.xClassNodes.Writer.WriteEndMember();
                }
                int length = str.LastIndexOf('.');

                if (length > 0)
                {
                    this.xClassNamespace = builderName.Substring(0, length);
                    str = builderName.Substring(length + 1);
                }
                object[] args = new object[] { this.xClassNamespace ?? string.Empty };
                this.xClassNamespace = string.Format(CultureInfo.CurrentUICulture, "clr-namespace:{0}", args);
                this.xClassXamlType  = new XamlType(this.xClassNamespace, str, null, base.Writer.SchemaContext);
            }
        public DynamicActivityXamlReader(bool isBuilder, XamlReader innerReader, XamlSchemaContext schemaContext)
        {
            this.isBuilder                  = isBuilder;
            this.innerReader                = innerReader;
            this.schemaContext              = schemaContext ?? innerReader.SchemaContext;
            this.xamlTypeXamlType           = this.schemaContext.GetXamlType(typeof(XamlType));
            this.typeXamlType               = this.schemaContext.GetXamlType(typeof(System.Type));
            this.baseActivityXamlType       = this.schemaContext.GetXamlType(typeof(Activity));
            this.activityPropertyXamlType   = this.schemaContext.GetXamlType(typeof(DynamicActivityProperty));
            this.activityPropertyType       = this.activityPropertyXamlType.GetMember("Type");
            this.activityPropertyName       = this.activityPropertyXamlType.GetMember("Name");
            this.activityPropertyValue      = this.activityPropertyXamlType.GetMember("Value");
            this.activityPropertyAttributes = this.activityPropertyXamlType.GetMember("Attributes");
            this.namespaceTable             = new NamespaceTable();
            this.frontLoadedDirectives      = true;
            this.nodeQueue                  = new XamlNodeQueue(this.schemaContext);
            this.nodeReader                 = this.nodeQueue.Reader;
            IXamlLineInfo info = innerReader as IXamlLineInfo;

            if ((info != null) && info.HasLineInfo)
            {
                this.innerReaderLineInfo = info;
                this.nodeReaderLineInfo  = (IXamlLineInfo)this.nodeQueue.Reader;
                this.hasLineInfo         = true;
            }
        }
 public bool ProcessNode(XamlReader reader, XamlWriter targetWriter, int currentDepth, IXamlLineInfo readerLineInfo)
 {
     if ((currentDepth == this.Depth) && ((reader.NodeType == XamlNodeType.NamespaceDeclaration) || (reader.NodeType == XamlNodeType.None)))
     {
         this.bufferedNodes.Writer.WriteNode(reader, readerLineInfo);
         reader.Read();
         return(true);
     }
     if ((((reader.NodeType == XamlNodeType.StartObject) && reader.Type.IsGeneric) && ((reader.Type.UnderlyingType != null) && (reader.Type.Name == "PropertyReferenceExtension"))) && (reader.Type.UnderlyingType.GetGenericTypeDefinition() == typeof(PropertyReferenceExtension <>)))
     {
         if (this.bufferedNodes.Count > 0)
         {
             XamlServices.Transform(this.bufferedNodes.Reader, targetWriter, false);
             this.bufferedNodes = null;
         }
         XamlType   type     = reader.Type;
         XamlReader reader2  = reader.ReadSubtree();
         XamlType   xamlType = reader.SchemaContext.GetXamlType(typeof(ActivityBuilder));
         XamlType   type3    = reader.SchemaContext.GetXamlType(typeof(ActivityPropertyReference));
         targetWriter.WriteStartMember(xamlType.GetAttachableMember("PropertyReference"), readerLineInfo);
         reader2.Read();
         targetWriter.WriteStartObject(type3, readerLineInfo);
         targetWriter.WriteStartMember(type3.GetMember("TargetProperty"), readerLineInfo);
         targetWriter.WriteValue(this.currentMember.Name, readerLineInfo);
         targetWriter.WriteEndMember(readerLineInfo);
         bool flag  = reader2.Read();
         bool flag2 = false;
         while (flag)
         {
             if (((reader2.NodeType == XamlNodeType.StartMember) && (reader2.Member.DeclaringType == type)) && (reader2.Member.Name == "PropertyName"))
             {
                 flag2 = true;
             }
             else if (flag2)
             {
                 if (reader2.NodeType == XamlNodeType.EndMember)
                 {
                     flag2 = false;
                 }
                 else if (reader2.NodeType == XamlNodeType.Value)
                 {
                     targetWriter.WriteStartMember(type3.GetMember("SourceProperty"), readerLineInfo);
                     targetWriter.WriteValue((string)reader2.Value, readerLineInfo);
                     targetWriter.WriteEndMember(readerLineInfo);
                 }
             }
             flag = reader2.Read();
         }
         targetWriter.WriteEndObject(readerLineInfo);
         targetWriter.WriteEndMember(readerLineInfo);
         this.ExitObject = true;
         reader2.Close();
     }
     else
     {
         this.FlushBuffer(targetWriter);
         targetWriter.WriteNode(reader, readerLineInfo);
     }
     return(false);
 }
Esempio n. 7
0
        public NullWrappingXamlReader(XamlReader wrappedReader)
        {
            _wrappedReader = wrappedReader;

            _pipe   = new XamlNodeQueue(wrappedReader.SchemaContext);
            _reader = _pipe.Reader;
            _writer = _pipe.Writer;
        }
Esempio n. 8
0
 public void AddDefaultValue(string propertyName, XamlNodeQueue value)
 {
     if (this.defaultValueNodes == null)
     {
         this.defaultValueNodes = new List <KeyValuePair <string, XamlNodeQueue> >();
     }
     if (string.IsNullOrEmpty(propertyName))
     {
         propertyName = string.Format(CultureInfo.CurrentCulture, "_{0}", new object[] { Guid.NewGuid().ToString().Replace("-", string.Empty) });
     }
     this.defaultValueNodes.Add(new KeyValuePair <string, XamlNodeQueue>(propertyName, value));
 }
 public BuilderMemberNode(DynamicActivityXamlReader parent, int depth)
 {
     this.parent        = parent;
     this.Depth         = depth;
     this.currentMember = parent.innerReader.Member;
     if (parent.hasLineInfo)
     {
         this.currentMemberLineNumber   = parent.innerReaderLineInfo.LineNumber;
         this.currentMemberLinePosition = parent.innerReaderLineInfo.LinePosition;
     }
     this.bufferedNodes = new XamlNodeQueue(parent.SchemaContext);
 }
Esempio n. 10
0
 protected internal override void Complete()
 {
     if (this.defaultValue != null)
     {
         if (string.IsNullOrEmpty(this.propertyName))
         {
             this.propertyName = string.Format(CultureInfo.CurrentCulture, "_{0}", new object[] { Guid.NewGuid().ToString().Replace("-", string.Empty) });
         }
         if ((this.defaultValue != null) && (this.propertyType != null))
         {
             this.defaultValue = StripTypeWrapping(this.defaultValue, this.propertyType);
         }
         this.properties.AddDefaultValue(this.propertyName, this.defaultValue);
     }
 }
		public void Read ()
		{
			var q = new XamlNodeQueue (new XamlSchemaContext ());
			Assert.IsFalse (q.Reader.Read (), "#1");
			Assert.IsTrue (q.Reader.IsEof, "#1-2");

			q.Writer.WriteStartObject (XamlLanguage.String);
			Assert.IsTrue (q.Reader.Read (), "#2");
			Assert.IsFalse (q.Reader.IsEof, "#2-2");
			Assert.AreEqual (XamlLanguage.String, q.Reader.Type, "#2-3");
			Assert.IsNull (q.Reader.Member, "#2-4");
			Assert.IsNull (q.Reader.Value, "#2-5");

			Assert.IsFalse (q.Reader.Read (), "#3");
			Assert.IsTrue (q.Reader.IsEof, "#3-2");
		}
Esempio n. 12
0
        public void Read()
        {
            var q = new XamlNodeQueue(new XamlSchemaContext());

            Assert.IsFalse(q.Reader.Read(), "#1");
            Assert.IsTrue(q.Reader.IsEof, "#1-2");

            q.Writer.WriteStartObject(XamlLanguage.String);
            Assert.IsTrue(q.Reader.Read(), "#2");
            Assert.IsFalse(q.Reader.IsEof, "#2-2");
            Assert.AreEqual(XamlLanguage.String, q.Reader.Type, "#2-3");
            Assert.IsNull(q.Reader.Member, "#2-4");
            Assert.IsNull(q.Reader.Value, "#2-5");

            Assert.IsFalse(q.Reader.Read(), "#3");
            Assert.IsTrue(q.Reader.IsEof, "#3-2");
        }
            public void FlushTo(XamlNodeQueue targetNodeQueue, DynamicActivityXamlReader parent)
            {
                this.FlushValueHolders(parent);
                XamlReader    reader     = this.outerNodes.Reader;
                IXamlLineInfo readerInfo = parent.hasLineInfo ? (reader as IXamlLineInfo) : null;

                while (reader.Read())
                {
                    if (reader.NodeType == XamlNodeType.Value)
                    {
                        ActivityPropertyHolder holder = reader.Value as ActivityPropertyHolder;
                        if (holder != null)
                        {
                            holder.CopyTo(targetNodeQueue, readerInfo);
                            continue;
                        }
                    }
                    targetNodeQueue.Writer.WriteNode(reader, readerInfo);
                }
            }
Esempio n. 14
0
 public void FlushPendingNodes(string classNamespace)
 {
     base.CurrentWriter = base.Writer.innerWriter;
     if (!base.Writer.notRewriting)
     {
         if (!this.wroteXamlNamespace)
         {
             string prefix = this.GenerateNamespacePrefix("x");
             this.WriteNamespace(new NamespaceDeclaration("http://schemas.microsoft.com/winfx/2006/xaml", prefix));
         }
         if (classNamespace != null)
         {
             bool       flag        = false;
             XamlReader reader      = this.pendingNodes.Reader;
             XamlWriter innerWriter = base.Writer.innerWriter;
             while (reader.Read() && (reader.NodeType == XamlNodeType.NamespaceDeclaration))
             {
                 if (classNamespace.Equals(reader.Namespace.Namespace))
                 {
                     flag = true;
                 }
                 innerWriter.WriteNode(reader);
             }
             if (!flag)
             {
                 string str2 = this.GenerateNamespacePrefix("this");
                 innerWriter.WriteNamespace(new NamespaceDeclaration(classNamespace, str2));
             }
             if (!reader.IsEof)
             {
                 innerWriter.WriteNode(reader);
             }
         }
         this.rootLevelPrefixes = null;
     }
     XamlServices.Transform(this.pendingNodes.Reader, base.Writer.innerWriter, false);
     this.pendingNodes = null;
 }
        // We don't know what namespaces are actually used inside convertible values, so any namespaces
        // that were in the parent scope on load need to be regurgitated on save, unless the prefixes were
        // shadowed in the child scope.
        // This can potentially cause namespace bloat, but the alternative is emitting unloadable XAML.
        private static XamlReader InsertNamespaces(XamlReader reader, IEnumerable <NamespaceDeclaration> parentNamespaces)
        {
            XamlNodeQueue    namespaceNodes = new XamlNodeQueue(reader.SchemaContext);
            HashSet <string> childPrefixes  = new HashSet <string>();

            while (reader.Read() && reader.NodeType == XamlNodeType.NamespaceDeclaration)
            {
                childPrefixes.Add(reader.Namespace.Prefix);
                namespaceNodes.Writer.WriteNode(reader);
            }
            foreach (NamespaceDeclaration parentNamespace in parentNamespaces)
            {
                if (!childPrefixes.Contains(parentNamespace.Prefix) &&
                    !IsXmlNamespace(parentNamespace))
                {
                    namespaceNodes.Writer.WriteNamespace(parentNamespace);
                }
            }
            if (!reader.IsEof)
            {
                namespaceNodes.Writer.WriteNode(reader);
            }
            return(new ConcatenatingXamlReader(namespaceNodes.Reader, reader));
        }
Esempio n. 16
0
 public RootNode(ActivityBuilderXamlWriter writer) : base(writer)
 {
     this.pendingNodes  = new XamlNodeQueue(writer.SchemaContext);
     base.CurrentWriter = this.pendingNodes.Writer;
 }
 public void FlushBuffer(XamlWriter targetWriter)
 {
     targetWriter.WriteStartMember(this.currentMember, this.currentMemberLineNumber, this.currentMemberLinePosition);
     XamlServices.Transform(this.bufferedNodes.Reader, targetWriter, false);
     this.bufferedNodes = null;
 }
Esempio n. 18
0
 private void FlushPreamble()
 {
     if (this.otherNodes != null)
     {
         base.CurrentWriter = base.Writer.innerWriter;
         string classNamespace = null;
         if (this.defaultValueNodes != null)
         {
             classNamespace = this.xClassNamespace;
         }
         this.rootNode.FlushPendingNodes(classNamespace);
         this.rootNode = null;
         base.CurrentWriter.WriteStartObject(base.Writer.activityXamlType);
         if (this.xClassNodes == null)
         {
             this.SetXClass(null, null);
         }
         XamlServices.Transform(this.xClassNodes.Reader, base.CurrentWriter, false);
         XamlNodeQueue queue = null;
         if (this.defaultValueNodes != null)
         {
             foreach (KeyValuePair <string, XamlNodeQueue> pair in this.defaultValueNodes)
             {
                 XamlReader reader = pair.Value.Reader;
                 if (reader.Read())
                 {
                     bool flag = false;
                     if ((reader.NodeType == XamlNodeType.Value) && (reader.Value is string))
                     {
                         flag = true;
                     }
                     if (flag)
                     {
                         base.CurrentWriter.WriteStartMember(new XamlMember(pair.Key, this.xClassXamlType, true));
                         base.CurrentWriter.WriteNode(reader);
                         XamlServices.Transform(pair.Value.Reader, base.CurrentWriter, false);
                     }
                     else
                     {
                         if (queue == null)
                         {
                             queue = new XamlNodeQueue(base.Writer.SchemaContext);
                         }
                         queue.Writer.WriteStartMember(new XamlMember(pair.Key, this.xClassXamlType, true));
                         queue.Writer.WriteNode(reader);
                         XamlServices.Transform(pair.Value.Reader, queue.Writer, false);
                     }
                 }
             }
         }
         if (this.xClassAttributeNodes != null)
         {
             XamlServices.Transform(this.xClassAttributeNodes.Reader, base.CurrentWriter, false);
         }
         if (this.xPropertiesNodes != null)
         {
             XamlServices.Transform(this.xPropertiesNodes.Reader, base.CurrentWriter, false);
         }
         if (queue != null)
         {
             XamlServices.Transform(queue.Reader, base.CurrentWriter, false);
         }
         if (this.otherNodes.Count > 0)
         {
             XamlServices.Transform(this.otherNodes.Reader, base.CurrentWriter, false);
         }
         this.otherNodes = null;
     }
 }
 public ValueHolder(XamlSchemaContext schemaContext, XamlMember propertyValue, XamlReader reader, IXamlLineInfo lineInfo)
 {
     this.nodes         = new XamlNodeQueue(schemaContext);
     this.PropertyValue = propertyValue;
     XamlWriterExtensions.Transform(reader.ReadSubtree(), this.nodes.Writer, lineInfo, true);
 }
 public void CopyTo(XamlNodeQueue targetNodeQueue, IXamlLineInfo readerInfo)
 {
     XamlServices.Transform(this.nodes.Reader, targetNodeQueue.Writer, false);
     targetNodeQueue.Writer.WriteEndObject(readerInfo);
 }
                public ActivityPropertyHolder(DynamicActivityXamlReader parent, XamlReader reader)
                {
                    this.parent = parent;
                    this.nodes  = new XamlNodeQueue(parent.SchemaContext);
                    IXamlLineInfo innerReaderLineInfo = parent.innerReaderLineInfo;

                    reader.Read();
                    this.nodes.Writer.WriteStartObject(parent.activityPropertyXamlType, innerReaderLineInfo);
                    int  num  = 1;
                    int  a    = 0;
                    int  num3 = 0;
                    bool flag = reader.Read();

                    while (flag)
                    {
                        XamlMember activityPropertyName;
                        switch (reader.NodeType)
                        {
                        case XamlNodeType.StartObject:
                        case XamlNodeType.GetObject:
                        {
                            num++;
                            DynamicActivityXamlReader.IncrementIfPositive(ref a);
                            DynamicActivityXamlReader.IncrementIfPositive(ref num3);
                            if ((num3 <= 0) || !(reader.Type == parent.xamlTypeXamlType))
                            {
                                goto Label_0231;
                            }
                            this.nodes.Writer.WriteStartObject(parent.typeXamlType, innerReaderLineInfo);
                            flag = reader.Read();
                            continue;
                        }

                        case XamlNodeType.EndObject:
                        {
                            num--;
                            if (num != 0)
                            {
                                goto Label_0213;
                            }
                            flag = reader.Read();
                            continue;
                        }

                        case XamlNodeType.StartMember:
                            if (!(reader.Member.DeclaringType == XamlLanguage.Property))
                            {
                                goto Label_0231;
                            }
                            activityPropertyName = reader.Member;
                            if (!(activityPropertyName == DynamicActivityXamlReader.xPropertyName))
                            {
                                break;
                            }
                            activityPropertyName = parent.activityPropertyName;
                            if (a == 0)
                            {
                                a = 1;
                            }
                            goto Label_0115;

                        case XamlNodeType.EndMember:
                            DynamicActivityXamlReader.DecrementIfPositive(ref a);
                            DynamicActivityXamlReader.DecrementIfPositive(ref num3);
                            goto Label_0231;

                        case XamlNodeType.Value:
                            if (a != 1)
                            {
                                goto Label_014F;
                            }
                            this.Name = reader.Value as string;
                            goto Label_0231;

                        default:
                            goto Label_0231;
                        }
                        if (activityPropertyName == DynamicActivityXamlReader.xPropertyType)
                        {
                            activityPropertyName = parent.activityPropertyType;
                            if (num3 == 0)
                            {
                                num3 = 1;
                            }
                        }
                        else
                        {
                            if (activityPropertyName != DynamicActivityXamlReader.xPropertyAttributes)
                            {
                                throw FxTrace.Exception.AsError(DynamicActivityXamlReader.CreateXamlException(System.Activities.SR.PropertyMemberNotSupportedByActivityXamlServices(activityPropertyName.Name), innerReaderLineInfo));
                            }
                            activityPropertyName = parent.activityPropertyAttributes;
                        }
Label_0115:
                        this.nodes.Writer.WriteStartMember(activityPropertyName, innerReaderLineInfo);
                        flag = reader.Read();
                        continue;
Label_014F:
                        if (num3 == 1)
                        {
                            XamlTypeName xamlTypeName = XamlTypeName.Parse(reader.Value as string, parent.namespaceTable);
                            XamlType     xamlType     = parent.SchemaContext.GetXamlType(xamlTypeName);
                            if (xamlType == null)
                            {
                                throw FxTrace.Exception.AsError(DynamicActivityXamlReader.CreateXamlException(System.Activities.SR.InvalidPropertyType(reader.Value as string, this.Name), innerReaderLineInfo));
                            }
                            this.Type = xamlType;
                        }
                        goto Label_0231;
Label_0213:
                        DynamicActivityXamlReader.DecrementIfPositive(ref a);
                        DynamicActivityXamlReader.DecrementIfPositive(ref num3);
Label_0231:
                        this.nodes.Writer.WriteNode(reader, innerReaderLineInfo);
                        flag = reader.Read();
                    }
                    reader.Close();
                }
Esempio n. 22
0
 public void SetAttributes(XamlNodeQueue attributeNodes)
 {
     this.xClassAttributeNodes = attributeNodes;
 }
 public BufferedPropertyList(DynamicActivityXamlReader parent)
 {
     this.parent     = parent;
     this.outerNodes = new XamlNodeQueue(parent.SchemaContext);
 }
Esempio n. 24
0
 public void SetProperties(XamlNodeQueue propertyNodes, List <KeyValuePair <string, XamlNodeQueue> > defaultValueNodes)
 {
     this.xPropertiesNodes  = propertyNodes;
     this.defaultValueNodes = defaultValueNodes;
     this.FlushPreamble();
 }
Esempio n. 25
0
 public BuilderNameNode(ActivityBuilderXamlWriter.BuilderClassNode classNode, ActivityBuilderXamlWriter writer) : base(writer)
 {
     this.classNode     = classNode;
     this.nameNodes     = new XamlNodeQueue(writer.SchemaContext);
     base.CurrentWriter = this.nameNodes.Writer;
 }
Esempio n. 26
0
 public void SetDefaultValue(XamlNodeQueue defaultValue)
 {
     this.defaultValue = defaultValue;
 }
Esempio n. 27
0
            private static XamlNodeQueue StripTypeWrapping(XamlNodeQueue valueNodes, XamlType propertyType)
            {
                XamlNodeQueue queue  = new XamlNodeQueue(valueNodes.Reader.SchemaContext);
                XamlReader    reader = valueNodes.Reader;
                XamlWriter    writer = queue.Writer;
                int           num    = 0;
                bool          flag   = false;
                bool          flag2  = false;

                while (reader.Read())
                {
                    switch (reader.NodeType)
                    {
                    case XamlNodeType.StartObject:
                    {
                        num++;
                        if (((queue.Count != 0) || (num != 1)) || (!(reader.Type == propertyType) || (valueNodes.Count != 5)))
                        {
                            goto Label_00DA;
                        }
                        flag2 = true;
                        continue;
                    }

                    case XamlNodeType.GetObject:
                        num++;
                        goto Label_00DA;

                    case XamlNodeType.EndObject:
                    {
                        num--;
                        if (!flag || (num != 0))
                        {
                            goto Label_00DA;
                        }
                        flag = false;
                        continue;
                    }

                    case XamlNodeType.StartMember:
                    {
                        num++;
                        if (!flag2)
                        {
                            goto Label_00DA;
                        }
                        if ((num != 2) || (reader.Member != XamlLanguage.Initialization))
                        {
                            break;
                        }
                        flag = true;
                        continue;
                    }

                    case XamlNodeType.EndMember:
                    {
                        num--;
                        if (!flag || (num != 1))
                        {
                            goto Label_00DA;
                        }
                        continue;
                    }

                    default:
                        goto Label_00DA;
                    }
                    flag2 = false;
                    queue.Writer.WriteStartObject(propertyType);
Label_00DA:
                    writer.WriteNode(reader);
                }
                return(queue);
            }
Esempio n. 28
0
 public BuilderClassNode(ActivityBuilderXamlWriter.RootNode rootNode, ActivityBuilderXamlWriter writer) : base(writer)
 {
     this.rootNode      = rootNode;
     this.otherNodes    = new XamlNodeQueue(writer.SchemaContext);
     base.CurrentWriter = this.otherNodes.Writer;
 }
Esempio n. 29
0
 public PropertyValueNode(ActivityBuilderXamlWriter.PropertyNode property, ActivityBuilderXamlWriter writer) : base(writer)
 {
     this.property      = property;
     this.valueNodes    = new XamlNodeQueue(writer.SchemaContext);
     base.CurrentWriter = this.valueNodes.Writer;
 }
Esempio n. 30
0
        public override bool Read()
        {
            switch (this.currentState)
            {
            case ActivityTemplateFactoryBuilderReaderStates.InitialState:
                bool hasMoreNodes = this.underlyingReader.Read();
                if (this.underlyingReader.NodeType == XamlNodeType.StartObject && IsActivityTemplateFactoryType(this.underlyingReader.Type))
                {
                    Type underlyingType = this.underlyingReader.Type.UnderlyingType;
                    Type targetType     = underlyingType.IsGenericType ? underlyingType.GetGenericArguments()[0] : null;

                    this.currentState = ActivityTemplateFactoryBuilderReaderStates.ReadingFromBufferState;
                    this.queuedNodes  = new XamlNodeQueue(this.schemaContext);
                    this.queuedNodes.Writer.WriteStartObject(this.ActivityTemplateFactoryBuilderType, (IXamlLineInfo)this.underlyingReader);

                    string className;

                    while (this.underlyingReader.Read())
                    {
                        if (this.underlyingReader.NodeType == XamlNodeType.StartMember && this.underlyingReader.Member == XamlLanguage.Class)
                        {
                            this.underlyingReader.Read();
                            className = (string)this.underlyingReader.Value;
                            this.underlyingReader.Read();
                            this.queuedNodes.Writer.WriteStartMember(this.ActivityTemplateFactoryBuilderNameMember, (IXamlLineInfo)this.underlyingReader);
                            this.queuedNodes.Writer.WriteValue(className, (IXamlLineInfo)this.underlyingReader);
                            this.queuedNodes.Writer.WriteEndMember((IXamlLineInfo)this.underlyingReader);
                            if (targetType != null)
                            {
                                this.queuedNodes.Writer.WriteStartMember(this.ActivityTemplateFactoryBuilderTargetTypeMember, (IXamlLineInfo)this.underlyingReader);
                                object targetTypeString = targetType;
                                this.queuedNodes.Writer.WriteValue(targetTypeString);
                                this.queuedNodes.Writer.WriteEndMember();
                            }
                        }
                        else if (this.underlyingReader.NodeType == XamlNodeType.StartMember && this.IsActivityTemplateFactoryImplementationMember(this.underlyingReader.Member))
                        {
                            this.queuedNodes.Writer.WriteStartMember(this.ActivityTemplateFactoryBuilderImplementationMember, (IXamlLineInfo)this.underlyingReader);
                            return(true);
                        }
                    }
                }

                return(hasMoreNodes);

            case ActivityTemplateFactoryBuilderReaderStates.ReadingFromBufferState:
                if (this.queuedNodes.Reader.Read())
                {
                    return(true);
                }
                else
                {
                    this.currentState = ActivityTemplateFactoryBuilderReaderStates.BypassState;
                    this.queuedNodes  = null;
                    return(this.underlyingReader.Read());
                }

            default:
                SharedFx.Assert(this.currentState == ActivityTemplateFactoryBuilderReaderStates.BypassState, "This is the only remaining ActivityTemplateFactoryBuilderReaderStates.");
                return(this.underlyingReader.Read());
            }
        }
 public WrappingXamlReader(XamlSchemaContext xamlSchemaContext)
 {
     _xamlNodeQueue = new XamlNodeQueue(xamlSchemaContext);
 }