3 writes to _context
System.Xaml (3)
System\Xaml\InfosetObjects\XamlObjectWriter.cs (3)
101
_context
= new ObjectWriterContext(savedContext, settings, rootNameScope, runtime);
105
_context
= new ObjectWriterContext(schemaContext, settings, rootNameScope, runtime);
981
_context
= null;
195 references to _context
System.Xaml (195)
System\Xaml\InfosetObjects\XamlObjectWriter.cs (195)
106
_context
.AddNamespacePrefix(KnownStrings.XmlPrefix, XamlLanguage.Xml1998Namespace);
110
throw
_context
.WithLineInfo(new XamlInternalException());
113
_context
.IsInitializedCallback = this;
115
_deferringWriter = new DeferringWriter(
_context
);
149
Debug.Assert(
_context
.SourceBamlUri is null ||
_context
.BaseUri is null ||
_context
.SourceBamlUri ==
_context
.BaseUri,
151
_afterBeginInitHandler(this, new XamlObjectEventArgs(value,
_context
.BaseUri ??
_context
.SourceBamlUri,
_context
.LineNumber_StartObject,
_context
.LinePosition_StartObject));
236
get { return
_context
.Runtime; }
266
throw
_context
.WithLineInfo(new XamlObjectWriterException(err));
269
XamlMember parentProperty = (
_context
.CurrentType is null &&
_context
.Depth > 1)
270
?
_context
.ParentProperty
271
:
_context
.CurrentProperty; // there is a push frame below making this the parent property.
274
XamlType xamlType = (
_context
.CurrentType is null &&
_context
.Depth > 1)
275
?
_context
.ParentType
276
:
_context
.CurrentType;
282
throw
_context
.WithLineInfo(new XamlObjectWriterException(err));
292
if (
_context
.CurrentType is not null)
294
_context
.PushScope();
297
TryCreateParentInstance(
_context
);
299
_context
.CurrentIsObjectFromMember = true;
301
object parentInstance =
_context
.ParentInstance;
302
_context
.CurrentType = parentProperty.Type;
305
_context
.CurrentInstance = inst ?? throw
_context
.WithLineInfo(new XamlObjectWriterException(SR.Format(SR.GetObjectNull, parentInstance.GetType(), parentProperty.Name)));
308
_context
.CurrentCollection = inst;
328
_context
.LineNumber_StartObject =
_context
.LineNumber;
329
_context
.LinePosition_StartObject =
_context
.LinePosition;
336
throw
_context
.WithLineInfo(new XamlObjectWriterException(err));
342
throw
_context
.WithLineInfo(new XamlObjectWriterException(err));
345
if (
_context
.CurrentType is not null &&
_context
.CurrentProperty is null)
348
_context
.CurrentType.ToString());
349
throw
_context
.WithLineInfo(new XamlObjectWriterException(err));
359
if (
_context
.CurrentType is not null)
361
_context
.PushScope();
364
_context
.CurrentType = xamlType;
371
if ((
_context
.LiveDepth == 1) && (_rootObjectInstance is not null))
374
if (!rootType.CanAssignTo(
_context
.CurrentType))
380
_context
.CurrentInstance = _rootObjectInstance;
381
if (
_context
.CurrentType.IsCollection ||
_context
.CurrentType.IsDictionary)
383
_context
.CurrentCollection = _rootObjectInstance;
386
Logic_BeginInit(
_context
);
401
Debug.Assert(
_context
.CurrentProperty.DeferringLoader is not null);
403
_context
.PushScope();
404
_context
.CurrentInstance = (XamlReader)templateList.GetReader();
415
throw
_context
.WithLineInfo(new XamlObjectWriterException(err));
418
if (
_context
.CurrentType is null)
421
throw
_context
.WithLineInfo(new XamlObjectWriterException(err));
424
if (
_context
.CurrentProperty is not null)
426
string err = SR.Format(SR.OpenPropertyInCurrentFrame_EO,
_context
.CurrentType.ToString(),
427
_context
.CurrentProperty.ToString());
428
throw
_context
.WithLineInfo(new XamlObjectWriterException(err));
433
Debug.Assert(
_context
.LiveDepth > 0);
434
bool hasUnresolvedChildren = HasUnresolvedChildren(
_context
.CurrentInstance);
435
bool isFixupToken =
_context
.CurrentInstance is NameFixupToken;
437
if (!
_context
.CurrentIsObjectFromMember)
443
if (
_context
.CurrentInstance is null)
445
Logic_CreateAndAssignToParentStart(
_context
);
448
XamlType xamlType =
_context
.CurrentType;
449
object instance =
_context
.CurrentInstance;
452
if (
_context
.CurrentType.IsMarkupExtension)
457
Logic_DeferProvideValue(
_context
);
461
ExecutePendingAdds(
_context
.CurrentType,
_context
.CurrentInstance);
462
Logic_EndInit(
_context
);
463
instance =
_context
.CurrentInstance;
464
Logic_AssignProvidedValue(
_context
);
465
if (
_context
.CurrentInstanceRegisteredName is not null)
470
TriggerNameResolution(instance,
_context
.CurrentInstanceRegisteredName);
473
_context
.CurrentInstanceRegisteredName = null;
476
instance =
_context
.CurrentInstance;
483
if (
_context
.LiveDepth > 1)
485
if (!
_context
.CurrentWasAssignedAtCreation)
487
Logic_DoAssignmentToParentProperty(
_context
);
495
if (
_context
.LiveDepth > 1)
497
Logic_AddDependencyForUnresolvedChildren(
_context
, null);
502
ExecutePendingAdds(
_context
.CurrentType,
_context
.CurrentInstance);
503
Logic_EndInit(
_context
);
511
Debug.Assert(
_context
.LiveDepth > 1);
512
Logic_AddDependencyForUnresolvedChildren(
_context
, null);
516
ExecutePendingAdds(
_context
.CurrentType,
_context
.CurrentInstance);
519
if (
_context
.ParentIsPropertyValueSet)
521
throw
_context
.WithLineInfo(new XamlDuplicateMemberException(
522
_context
.ParentProperty,
523
_context
.ParentType));
527
_lastInstance =
_context
.CurrentInstance;
528
string name =
_context
.CurrentInstanceRegisteredName;
530
if (
_context
.LiveDepth == 1)
532
_rootNamescope =
_context
.RootNameScope;
538
_context
.PopScope();
542
_nameFixupGraph.IsOffTheStack(_lastInstance, name,
_context
.LineNumber,
_context
.LinePosition);
564
if (
_context
.LiveDepth == 0 && !_inDispose)
567
_context
.RaiseNameScopeInitializationCompleteEvent();
593
err = SR.Format(SR.TypeHasNoContentProperty,
_context
.CurrentType);
599
else if (
_context
.CurrentProperty is not null)
601
err = SR.Format(SR.OpenPropertyInCurrentFrame_SM,
_context
.CurrentType.ToString(),
602
_context
.CurrentProperty.ToString(),
605
else if (
_context
.CurrentType is null)
612
throw
_context
.WithLineInfo(new XamlObjectWriterException(err));
617
Debug.Assert(
_context
.LiveDepth > 0);
618
_context
.CurrentProperty = property;
622
Logic_DuplicatePropertyCheck(
_context
, property, onParent: false);
626
if (
_context
.CurrentInstance is null)
628
if (!IsConstructionDirective(
_context
.CurrentProperty)
629
&& !IsDirectiveAllowedOnNullInstance(
_context
.CurrentProperty,
_context
.CurrentType))
631
Logic_CreateAndAssignToParentStart(
_context
);
638
_context
.CurrentCollection = new List<PositionalParameterDescriptor>();
646
throw
_context
.WithLineInfo(new XamlObjectWriterException(SR.Format(SR.LateConstructionDirective, property.Name)));
649
if (
_context
.CurrentIsTypeConvertedObject)
655
throw
_context
.WithLineInfo(new XamlObjectWriterException(SR.Format(SR.SettingPropertiesIsNotAllowed, property.Name)));
661
if (property.IsAttachable &&
_context
.CurrentInstance is NameFixupToken)
663
NameFixupToken token = (NameFixupToken)
_context
.CurrentInstance;
664
throw
_context
.WithLineInfo(new XamlObjectWriterException(SR.Format(SR.AttachedPropOnFwdRefTC,
665
property,
_context
.CurrentType, string.Join(", ", token.NeededNames.ToArray()))));
680
_context
.CurrentCollection = Runtime.CreateInstance(property.Type, null);
702
if (
_context
.CurrentType is null)
704
property =
_context
.ParentProperty;
710
property =
_context
.CurrentProperty;
715
string err = (
_context
.CurrentType is not null)
716
? SR.Format(SR.NoPropertyInCurrentFrame_EM,
_context
.CurrentType.ToString())
719
throw
_context
.WithLineInfo(new XamlObjectWriterException(err));
731
_context
.CurrentCtorArgs = ((List<object>)
_context
.CurrentCollection).ToArray();
735
Logic_CreateFromInitializationValue(
_context
);
739
_context
.CurrentCollection = null;
743
Logic_ConvertPositionalParamsToArgs(
_context
);
748
if (
_context
.CurrentType is null)
750
value =
_context
.CurrentInstance;
751
_context
.PopScope();
754
Logic_ValidateXClass(
_context
, value);
756
else if (
_context
.CurrentType is null)
769
object value =
_context
.CurrentInstance;
776
_context
.CurrentInstance = me;
780
Logic_AssignProvidedValue(
_context
);
792
if (property.IsDirective && property == XamlLanguage.Key && !Logic_ShouldConvertKey(
_context
))
795
_context
.ParentKeyIsUnconverted = true;
799
shouldSetValue = Logic_CreatePropertyValueFromValue(
_context
);
805
_lastInstance =
_context
.CurrentInstance;
808
Logic_DoAssignmentToParentProperty(
_context
);
811
_context
.PopScope(); // Value Node Scope
816
_context
.CurrentProperty = null;
817
_context
.CurrentIsPropertyValueSet = false;
832
Debug.Assert(
_context
.CurrentProperty.DeferringLoader is not null);
834
_context
.PushScope();
835
_context
.CurrentInstance = (XamlReader)templateList.GetReader();
843
XamlMember currentProperty =
_context
.CurrentProperty;
846
string err = (
_context
.CurrentType is not null)
847
? SR.Format(SR.NoPropertyInCurrentFrame_V, value,
_context
.CurrentType.ToString())
850
throw
_context
.WithLineInfo(new XamlObjectWriterException(err));
856
_context
.PushScope();
857
_context
.CurrentInstance = value;
878
_context
.CurrentType = XamlLanguage.PositionalParameterDescriptor;
879
_context
.CurrentInstance = new PositionalParameterDescriptor(value, true);
880
Logic_DoAssignmentToParentCollection(
_context
);
881
_context
.PopScope();
885
_context
.CurrentInstance = value;
886
Logic_DoAssignmentToParentCollection(
_context
);
887
_context
.PopScope();
920
throw
_context
.WithLineInfo(new XamlObjectWriterException(err));
923
if (
_context
.CurrentType is not null &&
_context
.CurrentProperty is null)
927
_context
.CurrentType.ToString());
928
throw
_context
.WithLineInfo(new XamlObjectWriterException(err));
932
if (
_context
.CurrentType is not null)
934
_context
.PushScope();
937
_context
.AddNamespacePrefix(namespaceDeclaration.Prefix, namespaceDeclaration.Namespace);
943
while (
_context
.LiveDepth > 0)
945
_context
.PopScope();
951
_context
.PushScope();
961
bool seenStartObject =
_context
.LiveDepth > 1 ||
_context
.CurrentType is not null;
964
while (
_context
.LiveDepth > 0)
966
if (
_context
.CurrentProperty is not null)
1010
return
_context
.RootNameScope;
1031
return
_context
.SchemaContext;
1040
_context
.LineNumber = lineNumber;
1041
_context
.LinePosition = linePosition;
1063
return
_context
.WithLineInfo(ex);
2413
!
_context
.IsOnTheLiveStack(token.TargetContext.CurrentInstance))
2445
if (
_context
.LiveDepth > 0)
2448
if (
_context
.IsOnTheLiveStack(instance))