/// <summary> /// Write start of a list complex property /// </summary> /// <remarks> /// For template parsing, treat complex property tags as /// xml element tags for the purpose of validity checking /// </remarks> public override void WritePropertyIListStart(XamlPropertyIListStartNode xamlNode) { StyleMode mode = _styleModeStack.Mode; if (_styleModeStack.Depth == 1) { if (xamlNode.PropName == XamlTemplateSerializer.TriggersPropertyName) { mode = StyleMode.TriggerBase; } else { ThrowException(SRID.TemplateUnknownProp, xamlNode.PropName, xamlNode.LineNumber, xamlNode.LinePosition); } } else if (mode == StyleMode.VisualTree) { _visualTreeComplexPropertyDepth++; } else if (mode == StyleMode.TriggerBase && _styleModeStack.Depth == 2) { mode = StyleMode.Base; } else if (mode == StyleMode.TriggerBase && _styleModeStack.Depth == 3 && xamlNode.PropName == XamlTemplateSerializer.EventTriggerActions) { mode = StyleMode.TriggerActions; } else if (mode == StyleMode.TriggerBase) { _triggerComplexPropertyDepth++; } _styleModeStack.Push(mode); base.WritePropertyIListStart(xamlNode); }
/// <summary> /// Write Property IList Start /// </summary> public virtual void WritePropertyIListStart(XamlPropertyIListStartNode xamlPropertyIListStartNode) { if (BamlRecordWriter != null) { BamlRecordWriter.WritePropertyIListStart(xamlPropertyIListStartNode); } }
// Write the start of a complex property that implements IList internal void WritePropertyIListStart( XamlPropertyIListStartNode xamlPropertyIListStart) { // initialize the element and add to the stack BamlPropertyIListStartRecord bamlPropertyIListStart = (BamlPropertyIListStartRecord) BamlRecordManager.GetWriteRecord(BamlRecordType.PropertyIListStart); bamlPropertyIListStart.AttributeId = MapTable.AddAttributeInfoMap(BinaryWriter, xamlPropertyIListStart.AssemblyName, xamlPropertyIListStart.TypeFullName, xamlPropertyIListStart.PropDeclaringType, xamlPropertyIListStart.PropName, null, BamlAttributeUsage.Default); WriteAndReleaseRecord(bamlPropertyIListStart, xamlPropertyIListStart); }
/// <summary> /// Create nodes for a complex property that surrounds an element tree. /// Note that this is for general properties and not def attributes. /// </summary> internal void CompileAttribute( ArrayList xamlNodes, AttributeData data) { // For MarkupExtension syntax, treat PropertyInfo as a CLR property, but MethodInfo // and DependencyProperty as a DependencyProperty. Note that the MarkupCompiler // will handle the case where a DependencyProperty callback is made if it gets // a MethodInfo for the attached property setter. string declaringTypeAssemblyName = data.DeclaringType.Assembly.FullName; string declaringTypeFullName = data.DeclaringType.FullName; // Find the PropertyRecordType to use in this case Type propertyType; bool propertyCanWrite; XamlTypeMapper.GetPropertyType(data.Info, out propertyType, out propertyCanWrite); BamlRecordType propertyRecordType = BamlRecordManager.GetPropertyStartRecordType(propertyType, propertyCanWrite); // Create the property start and end records XamlNode propertyStart; XamlNode propertyEnd; switch (propertyRecordType) { case BamlRecordType.PropertyArrayStart: { propertyStart = new XamlPropertyArrayStartNode( data.LineNumber, data.LinePosition, data.Depth, data.Info, declaringTypeAssemblyName, declaringTypeFullName, data.PropertyName); propertyEnd = new XamlPropertyArrayEndNode( data.LineNumber, data.LinePosition, data.Depth); break; } case BamlRecordType.PropertyIDictionaryStart: { propertyStart = new XamlPropertyIDictionaryStartNode( data.LineNumber, data.LinePosition, data.Depth, data.Info, declaringTypeAssemblyName, declaringTypeFullName, data.PropertyName); propertyEnd = new XamlPropertyIDictionaryEndNode( data.LineNumber, data.LinePosition, data.Depth); break; } case BamlRecordType.PropertyIListStart: { propertyStart = new XamlPropertyIListStartNode( data.LineNumber, data.LinePosition, data.Depth, data.Info, declaringTypeAssemblyName, declaringTypeFullName, data.PropertyName); propertyEnd = new XamlPropertyIListEndNode( data.LineNumber, data.LinePosition, data.Depth); break; } default: // PropertyComplexStart { propertyStart = new XamlPropertyComplexStartNode( data.LineNumber, data.LinePosition, data.Depth, data.Info, declaringTypeAssemblyName, declaringTypeFullName, data.PropertyName); propertyEnd = new XamlPropertyComplexEndNode( data.LineNumber, data.LinePosition, data.Depth); break; } } // NOTE: Add duplicate property checking here as is done in XamlReaderHelper xamlNodes.Add(propertyStart); CompileAttributeCore(xamlNodes, data); xamlNodes.Add(propertyEnd); }
/// <summary> /// Write start of a list complex property /// </summary> /// <remarks> /// For style parsing, treat complex property tags as /// xml element tags for the purpose of validity checking /// </remarks> public override void WritePropertyIListStart(XamlPropertyIListStartNode xamlNode) { StyleMode mode = _styleModeStack.Mode; int depth = _styleModeStack.Depth; if (depth == 1) { if (xamlNode.PropName == XamlStyleSerializer.VisualTriggersPropertyName) { mode = StyleMode.TriggerBase; } else if (xamlNode.PropName == XamlStyleSerializer.SettersPropertyName) { if (_setterElementEncountered) { ThrowException(SRID.StyleImpliedAndComplexChildren, XamlStyleSerializer.SetterTagName, xamlNode.PropName, xamlNode.LineNumber, xamlNode.LinePosition); } mode = StyleMode.Setters; _setterPropertyEncountered = true; } else { ThrowException(SRID.StyleUnknownProp, xamlNode.PropName, xamlNode.LineNumber, xamlNode.LinePosition); } } else if ((mode == StyleMode.TriggerBase || mode == StyleMode.Setters) && depth == 2) { mode = StyleMode.Base; } else if (mode == StyleMode.TriggerBase && depth == 3) { if (xamlNode.PropName == XamlStyleSerializer.EventTriggerActions) { mode = StyleMode.TriggerActions; } } _styleModeStack.Push(mode); base.WritePropertyIListStart(xamlNode); }