3 writes to _context
System.Xaml (3)
System\Xaml\InfosetObjects\XamlObjectWriter.cs (3)
103
_context
= new ObjectWriterContext(savedContext, settings, rootNameScope, runtime);
107
_context
= new ObjectWriterContext(schemaContext, settings, rootNameScope, runtime);
955
_context
= null;
195 references to _context
System.Xaml (195)
System\Xaml\InfosetObjects\XamlObjectWriter.cs (195)
108
_context
.AddNamespacePrefix(KnownStrings.XmlPrefix, XamlLanguage.Xml1998Namespace);
112
throw
_context
.WithLineInfo(new XamlInternalException());
114
_context
.IsInitializedCallback = this;
116
_deferringWriter = new DeferringWriter(
_context
);
148
Debug.Assert(
_context
.SourceBamlUri == null ||
_context
.BaseUri == null ||
_context
.SourceBamlUri ==
_context
.BaseUri,
150
_afterBeginInitHandler(this, new XamlObjectEventArgs(value,
_context
.BaseUri ??
_context
.SourceBamlUri,
_context
.LineNumber_StartObject,
_context
.LinePosition_StartObject));
232
get { return
_context
.Runtime; }
262
throw
_context
.WithLineInfo(new XamlObjectWriterException(err));
264
XamlMember parentProperty = (
_context
.CurrentType == null &&
_context
.Depth > 1)
265
?
_context
.ParentProperty
266
:
_context
.CurrentProperty; // there is a push frame below making this the parent property.
269
XamlType xamlType = (
_context
.CurrentType == null &&
_context
.Depth > 1)
270
?
_context
.ParentType
271
:
_context
.CurrentType;
277
throw
_context
.WithLineInfo(new XamlObjectWriterException(err));
287
if (
_context
.CurrentType != null)
289
_context
.PushScope();
292
TryCreateParentInstance(
_context
);
294
_context
.CurrentIsObjectFromMember = true;
296
object parentInstance =
_context
.ParentInstance;
297
_context
.CurrentType = parentProperty.Type;
300
_context
.CurrentInstance = inst ?? throw
_context
.WithLineInfo(new XamlObjectWriterException(SR.Format(SR.GetObjectNull, parentInstance.GetType(), parentProperty.Name)));
303
_context
.CurrentCollection = inst;
323
_context
.LineNumber_StartObject =
_context
.LineNumber;
324
_context
.LinePosition_StartObject =
_context
.LinePosition;
331
throw
_context
.WithLineInfo(new XamlObjectWriterException(err));
336
throw
_context
.WithLineInfo(new XamlObjectWriterException(err));
339
if (
_context
.CurrentType != null &&
_context
.CurrentProperty == null)
342
_context
.CurrentType.ToString());
343
throw
_context
.WithLineInfo(new XamlObjectWriterException(err));
353
if (
_context
.CurrentType != null)
355
_context
.PushScope();
358
_context
.CurrentType = xamlType;
365
if ((
_context
.LiveDepth == 1) && (_rootObjectInstance != null))
368
if (!rootType.CanAssignTo(
_context
.CurrentType))
373
_context
.CurrentInstance = _rootObjectInstance;
374
if (
_context
.CurrentType.IsCollection ||
_context
.CurrentType.IsDictionary)
376
_context
.CurrentCollection = _rootObjectInstance;
378
Logic_BeginInit(
_context
);
394
Debug.Assert(
_context
.CurrentProperty.DeferringLoader != null);
396
_context
.PushScope();
397
_context
.CurrentInstance = (XamlReader)templateList.GetReader();
407
throw
_context
.WithLineInfo(new XamlObjectWriterException(err));
409
if (
_context
.CurrentType == null)
412
throw
_context
.WithLineInfo(new XamlObjectWriterException(err));
414
if (
_context
.CurrentProperty != null)
416
string err = SR.Format(SR.OpenPropertyInCurrentFrame_EO,
_context
.CurrentType.ToString(),
417
_context
.CurrentProperty.ToString());
418
throw
_context
.WithLineInfo(new XamlObjectWriterException(err));
423
Debug.Assert(
_context
.LiveDepth > 0);
424
bool hasUnresolvedChildren = HasUnresolvedChildren(
_context
.CurrentInstance);
425
bool isFixupToken =
_context
.CurrentInstance is NameFixupToken;
427
if (!
_context
.CurrentIsObjectFromMember)
433
if (
_context
.CurrentInstance == null)
435
Logic_CreateAndAssignToParentStart(
_context
);
438
XamlType xamlType =
_context
.CurrentType;
439
object instance =
_context
.CurrentInstance;
442
if (
_context
.CurrentType.IsMarkupExtension)
447
Logic_DeferProvideValue(
_context
);
451
ExecutePendingAdds(
_context
.CurrentType,
_context
.CurrentInstance);
452
Logic_EndInit(
_context
);
453
instance =
_context
.CurrentInstance;
454
Logic_AssignProvidedValue(
_context
);
455
if (
_context
.CurrentInstanceRegisteredName != null)
460
TriggerNameResolution(instance,
_context
.CurrentInstanceRegisteredName);
462
_context
.CurrentInstanceRegisteredName = null;
464
instance =
_context
.CurrentInstance;
471
if (
_context
.LiveDepth > 1)
473
if (!
_context
.CurrentWasAssignedAtCreation)
475
Logic_DoAssignmentToParentProperty(
_context
);
483
if (
_context
.LiveDepth > 1)
485
Logic_AddDependencyForUnresolvedChildren(
_context
, null);
490
ExecutePendingAdds(
_context
.CurrentType,
_context
.CurrentInstance);
491
Logic_EndInit(
_context
);
499
Debug.Assert(
_context
.LiveDepth > 1);
500
Logic_AddDependencyForUnresolvedChildren(
_context
, null);
504
ExecutePendingAdds(
_context
.CurrentType,
_context
.CurrentInstance);
507
if (
_context
.ParentIsPropertyValueSet)
509
throw
_context
.WithLineInfo(new XamlDuplicateMemberException(
510
_context
.ParentProperty,
511
_context
.ParentType));
514
_lastInstance =
_context
.CurrentInstance;
515
string name =
_context
.CurrentInstanceRegisteredName;
517
if (
_context
.LiveDepth == 1)
519
_rootNamescope =
_context
.RootNameScope;
525
_context
.PopScope();
529
_nameFixupGraph.IsOffTheStack(_lastInstance, name,
_context
.LineNumber,
_context
.LinePosition);
551
if (
_context
.LiveDepth == 0 && !_inDispose)
554
_context
.RaiseNameScopeInitializationCompleteEvent();
580
err = SR.Format(SR.TypeHasNoContentProperty,
_context
.CurrentType);
586
else if (
_context
.CurrentProperty != null)
588
err = SR.Format(SR.OpenPropertyInCurrentFrame_SM,
_context
.CurrentType.ToString(),
589
_context
.CurrentProperty.ToString(),
592
else if (
_context
.CurrentType == null)
599
throw
_context
.WithLineInfo(new XamlObjectWriterException(err));
604
Debug.Assert(
_context
.LiveDepth > 0);
605
_context
.CurrentProperty = property;
609
Logic_DuplicatePropertyCheck(
_context
, property, false /*onParent*/);
613
if (
_context
.CurrentInstance == null)
615
if (!IsConstructionDirective(
_context
.CurrentProperty)
616
&& !IsDirectiveAllowedOnNullInstance(
_context
.CurrentProperty,
_context
.CurrentType))
618
Logic_CreateAndAssignToParentStart(
_context
);
625
_context
.CurrentCollection = new List<PositionalParameterDescriptor>();
633
throw
_context
.WithLineInfo(new XamlObjectWriterException(SR.Format(SR.LateConstructionDirective, property.Name)));
636
if (
_context
.CurrentIsTypeConvertedObject)
642
throw
_context
.WithLineInfo(new XamlObjectWriterException(SR.Format(SR.SettingPropertiesIsNotAllowed, property.Name)));
647
if (property.IsAttachable &&
_context
.CurrentInstance is NameFixupToken)
649
NameFixupToken token = (NameFixupToken)
_context
.CurrentInstance;
650
throw
_context
.WithLineInfo(new XamlObjectWriterException(SR.Format(SR.AttachedPropOnFwdRefTC,
651
property,
_context
.CurrentType, string.Join(", ", token.NeededNames.ToArray()))));
665
_context
.CurrentCollection = Runtime.CreateInstance(property.Type, null);
687
if (
_context
.CurrentType == null)
689
property =
_context
.ParentProperty;
694
property =
_context
.CurrentProperty;
699
string err = (
_context
.CurrentType != null)
700
? SR.Format(SR.NoPropertyInCurrentFrame_EM,
_context
.CurrentType.ToString())
703
throw
_context
.WithLineInfo(new XamlObjectWriterException(err));
715
_context
.CurrentCtorArgs = ((List<object>)
_context
.CurrentCollection).ToArray();
719
Logic_CreateFromInitializationValue(
_context
);
723
_context
.CurrentCollection = null;
727
Logic_ConvertPositionalParamsToArgs(
_context
);
732
if (
_context
.CurrentType == null)
734
value =
_context
.CurrentInstance;
735
_context
.PopScope();
737
Logic_ValidateXClass(
_context
, value);
739
else if (
_context
.CurrentType == null)
752
object value =
_context
.CurrentInstance;
760
_context
.CurrentInstance = me;
764
Logic_AssignProvidedValue(
_context
);
775
if (property.IsDirective && property == XamlLanguage.Key && !Logic_ShouldConvertKey(
_context
))
778
_context
.ParentKeyIsUnconverted = true;
782
shouldSetValue = Logic_CreatePropertyValueFromValue(
_context
);
787
_lastInstance =
_context
.CurrentInstance;
790
Logic_DoAssignmentToParentProperty(
_context
);
792
_context
.PopScope(); // Value Node Scope
797
_context
.CurrentProperty = null;
798
_context
.CurrentIsPropertyValueSet = false;
813
Debug.Assert(
_context
.CurrentProperty.DeferringLoader != null);
815
_context
.PushScope();
816
_context
.CurrentInstance = (XamlReader)templateList.GetReader();
823
XamlMember currentProperty =
_context
.CurrentProperty;
826
string err = (
_context
.CurrentType != null)
827
? SR.Format(SR.NoPropertyInCurrentFrame_V, value,
_context
.CurrentType.ToString())
830
throw
_context
.WithLineInfo(new XamlObjectWriterException(err));
836
_context
.PushScope();
837
_context
.CurrentInstance = value;
858
_context
.CurrentType = XamlLanguage.PositionalParameterDescriptor;
859
_context
.CurrentInstance = new PositionalParameterDescriptor(value, true);
860
Logic_DoAssignmentToParentCollection(
_context
);
861
_context
.PopScope();
865
_context
.CurrentInstance = value;
866
Logic_DoAssignmentToParentCollection(
_context
);
867
_context
.PopScope();
899
throw
_context
.WithLineInfo(new XamlObjectWriterException(err));
901
if (
_context
.CurrentType != null &&
_context
.CurrentProperty == null)
905
_context
.CurrentType.ToString());
906
throw
_context
.WithLineInfo(new XamlObjectWriterException(err));
910
if (
_context
.CurrentType != null)
912
_context
.PushScope();
914
_context
.AddNamespacePrefix(namespaceDeclaration.Prefix, namespaceDeclaration.Namespace);
920
while (
_context
.LiveDepth > 0)
922
_context
.PopScope();
927
_context
.PushScope();
937
bool seenStartObject =
_context
.LiveDepth > 1 ||
_context
.CurrentType != null;
940
while (
_context
.LiveDepth > 0)
942
if (
_context
.CurrentProperty != null)
984
return
_context
.RootNameScope;
1005
return
_context
.SchemaContext;
1014
_context
.LineNumber = lineNumber;
1015
_context
.LinePosition = linePosition;
1037
return
_context
.WithLineInfo(ex);
2344
!
_context
.IsOnTheLiveStack(token.TargetContext.CurrentInstance))
2375
if (
_context
.LiveDepth > 0)
2378
if (
_context
.IsOnTheLiveStack(instance))