3 writes to _context
System.Xaml (3)
System\Xaml\InfosetObjects\XamlObjectWriter.cs (3)
100
_context
= new ObjectWriterContext(savedContext, settings, rootNameScope, runtime);
104
_context
= new ObjectWriterContext(schemaContext, settings, rootNameScope, runtime);
980
_context
= null;
195 references to _context
System.Xaml (195)
System\Xaml\InfosetObjects\XamlObjectWriter.cs (195)
105
_context
.AddNamespacePrefix(KnownStrings.XmlPrefix, XamlLanguage.Xml1998Namespace);
109
throw
_context
.WithLineInfo(new XamlInternalException());
112
_context
.IsInitializedCallback = this;
114
_deferringWriter = new DeferringWriter(
_context
);
148
Debug.Assert(
_context
.SourceBamlUri is null ||
_context
.BaseUri is null ||
_context
.SourceBamlUri ==
_context
.BaseUri,
150
_afterBeginInitHandler(this, new XamlObjectEventArgs(value,
_context
.BaseUri ??
_context
.SourceBamlUri,
_context
.LineNumber_StartObject,
_context
.LinePosition_StartObject));
235
get { return
_context
.Runtime; }
265
throw
_context
.WithLineInfo(new XamlObjectWriterException(err));
268
XamlMember parentProperty = (
_context
.CurrentType is null &&
_context
.Depth > 1)
269
?
_context
.ParentProperty
270
:
_context
.CurrentProperty; // there is a push frame below making this the parent property.
273
XamlType xamlType = (
_context
.CurrentType is null &&
_context
.Depth > 1)
274
?
_context
.ParentType
275
:
_context
.CurrentType;
281
throw
_context
.WithLineInfo(new XamlObjectWriterException(err));
291
if (
_context
.CurrentType is not null)
293
_context
.PushScope();
296
TryCreateParentInstance(
_context
);
298
_context
.CurrentIsObjectFromMember = true;
300
object parentInstance =
_context
.ParentInstance;
301
_context
.CurrentType = parentProperty.Type;
304
_context
.CurrentInstance = inst ?? throw
_context
.WithLineInfo(new XamlObjectWriterException(SR.Format(SR.GetObjectNull, parentInstance.GetType(), parentProperty.Name)));
307
_context
.CurrentCollection = inst;
327
_context
.LineNumber_StartObject =
_context
.LineNumber;
328
_context
.LinePosition_StartObject =
_context
.LinePosition;
335
throw
_context
.WithLineInfo(new XamlObjectWriterException(err));
341
throw
_context
.WithLineInfo(new XamlObjectWriterException(err));
344
if (
_context
.CurrentType is not null &&
_context
.CurrentProperty is null)
347
_context
.CurrentType.ToString());
348
throw
_context
.WithLineInfo(new XamlObjectWriterException(err));
358
if (
_context
.CurrentType is not null)
360
_context
.PushScope();
363
_context
.CurrentType = xamlType;
370
if ((
_context
.LiveDepth == 1) && (_rootObjectInstance is not null))
373
if (!rootType.CanAssignTo(
_context
.CurrentType))
379
_context
.CurrentInstance = _rootObjectInstance;
380
if (
_context
.CurrentType.IsCollection ||
_context
.CurrentType.IsDictionary)
382
_context
.CurrentCollection = _rootObjectInstance;
385
Logic_BeginInit(
_context
);
400
Debug.Assert(
_context
.CurrentProperty.DeferringLoader is not null);
402
_context
.PushScope();
403
_context
.CurrentInstance = (XamlReader)templateList.GetReader();
414
throw
_context
.WithLineInfo(new XamlObjectWriterException(err));
417
if (
_context
.CurrentType is null)
420
throw
_context
.WithLineInfo(new XamlObjectWriterException(err));
423
if (
_context
.CurrentProperty is not null)
425
string err = SR.Format(SR.OpenPropertyInCurrentFrame_EO,
_context
.CurrentType.ToString(),
426
_context
.CurrentProperty.ToString());
427
throw
_context
.WithLineInfo(new XamlObjectWriterException(err));
432
Debug.Assert(
_context
.LiveDepth > 0);
433
bool hasUnresolvedChildren = HasUnresolvedChildren(
_context
.CurrentInstance);
434
bool isFixupToken =
_context
.CurrentInstance is NameFixupToken;
436
if (!
_context
.CurrentIsObjectFromMember)
442
if (
_context
.CurrentInstance is null)
444
Logic_CreateAndAssignToParentStart(
_context
);
447
XamlType xamlType =
_context
.CurrentType;
448
object instance =
_context
.CurrentInstance;
451
if (
_context
.CurrentType.IsMarkupExtension)
456
Logic_DeferProvideValue(
_context
);
460
ExecutePendingAdds(
_context
.CurrentType,
_context
.CurrentInstance);
461
Logic_EndInit(
_context
);
462
instance =
_context
.CurrentInstance;
463
Logic_AssignProvidedValue(
_context
);
464
if (
_context
.CurrentInstanceRegisteredName is not null)
469
TriggerNameResolution(instance,
_context
.CurrentInstanceRegisteredName);
472
_context
.CurrentInstanceRegisteredName = null;
475
instance =
_context
.CurrentInstance;
482
if (
_context
.LiveDepth > 1)
484
if (!
_context
.CurrentWasAssignedAtCreation)
486
Logic_DoAssignmentToParentProperty(
_context
);
494
if (
_context
.LiveDepth > 1)
496
Logic_AddDependencyForUnresolvedChildren(
_context
, null);
501
ExecutePendingAdds(
_context
.CurrentType,
_context
.CurrentInstance);
502
Logic_EndInit(
_context
);
510
Debug.Assert(
_context
.LiveDepth > 1);
511
Logic_AddDependencyForUnresolvedChildren(
_context
, null);
515
ExecutePendingAdds(
_context
.CurrentType,
_context
.CurrentInstance);
518
if (
_context
.ParentIsPropertyValueSet)
520
throw
_context
.WithLineInfo(new XamlDuplicateMemberException(
521
_context
.ParentProperty,
522
_context
.ParentType));
526
_lastInstance =
_context
.CurrentInstance;
527
string name =
_context
.CurrentInstanceRegisteredName;
529
if (
_context
.LiveDepth == 1)
531
_rootNamescope =
_context
.RootNameScope;
537
_context
.PopScope();
541
_nameFixupGraph.IsOffTheStack(_lastInstance, name,
_context
.LineNumber,
_context
.LinePosition);
563
if (
_context
.LiveDepth == 0 && !_inDispose)
566
_context
.RaiseNameScopeInitializationCompleteEvent();
592
err = SR.Format(SR.TypeHasNoContentProperty,
_context
.CurrentType);
598
else if (
_context
.CurrentProperty is not null)
600
err = SR.Format(SR.OpenPropertyInCurrentFrame_SM,
_context
.CurrentType.ToString(),
601
_context
.CurrentProperty.ToString(),
604
else if (
_context
.CurrentType is null)
611
throw
_context
.WithLineInfo(new XamlObjectWriterException(err));
616
Debug.Assert(
_context
.LiveDepth > 0);
617
_context
.CurrentProperty = property;
621
Logic_DuplicatePropertyCheck(
_context
, property, onParent: false);
625
if (
_context
.CurrentInstance is null)
627
if (!IsConstructionDirective(
_context
.CurrentProperty)
628
&& !IsDirectiveAllowedOnNullInstance(
_context
.CurrentProperty,
_context
.CurrentType))
630
Logic_CreateAndAssignToParentStart(
_context
);
637
_context
.CurrentCollection = new List<PositionalParameterDescriptor>();
645
throw
_context
.WithLineInfo(new XamlObjectWriterException(SR.Format(SR.LateConstructionDirective, property.Name)));
648
if (
_context
.CurrentIsTypeConvertedObject)
654
throw
_context
.WithLineInfo(new XamlObjectWriterException(SR.Format(SR.SettingPropertiesIsNotAllowed, property.Name)));
660
if (property.IsAttachable &&
_context
.CurrentInstance is NameFixupToken)
662
NameFixupToken token = (NameFixupToken)
_context
.CurrentInstance;
663
throw
_context
.WithLineInfo(new XamlObjectWriterException(SR.Format(SR.AttachedPropOnFwdRefTC,
664
property,
_context
.CurrentType, string.Join(", ", token.NeededNames.ToArray()))));
679
_context
.CurrentCollection = Runtime.CreateInstance(property.Type, null);
701
if (
_context
.CurrentType is null)
703
property =
_context
.ParentProperty;
709
property =
_context
.CurrentProperty;
714
string err = (
_context
.CurrentType is not null)
715
? SR.Format(SR.NoPropertyInCurrentFrame_EM,
_context
.CurrentType.ToString())
718
throw
_context
.WithLineInfo(new XamlObjectWriterException(err));
730
_context
.CurrentCtorArgs = ((List<object>)
_context
.CurrentCollection).ToArray();
734
Logic_CreateFromInitializationValue(
_context
);
738
_context
.CurrentCollection = null;
742
Logic_ConvertPositionalParamsToArgs(
_context
);
747
if (
_context
.CurrentType is null)
749
value =
_context
.CurrentInstance;
750
_context
.PopScope();
753
Logic_ValidateXClass(
_context
, value);
755
else if (
_context
.CurrentType is null)
768
object value =
_context
.CurrentInstance;
775
_context
.CurrentInstance = me;
779
Logic_AssignProvidedValue(
_context
);
791
if (property.IsDirective && property == XamlLanguage.Key && !Logic_ShouldConvertKey(
_context
))
794
_context
.ParentKeyIsUnconverted = true;
798
shouldSetValue = Logic_CreatePropertyValueFromValue(
_context
);
804
_lastInstance =
_context
.CurrentInstance;
807
Logic_DoAssignmentToParentProperty(
_context
);
810
_context
.PopScope(); // Value Node Scope
815
_context
.CurrentProperty = null;
816
_context
.CurrentIsPropertyValueSet = false;
831
Debug.Assert(
_context
.CurrentProperty.DeferringLoader is not null);
833
_context
.PushScope();
834
_context
.CurrentInstance = (XamlReader)templateList.GetReader();
842
XamlMember currentProperty =
_context
.CurrentProperty;
845
string err = (
_context
.CurrentType is not null)
846
? SR.Format(SR.NoPropertyInCurrentFrame_V, value,
_context
.CurrentType.ToString())
849
throw
_context
.WithLineInfo(new XamlObjectWriterException(err));
855
_context
.PushScope();
856
_context
.CurrentInstance = value;
877
_context
.CurrentType = XamlLanguage.PositionalParameterDescriptor;
878
_context
.CurrentInstance = new PositionalParameterDescriptor(value, true);
879
Logic_DoAssignmentToParentCollection(
_context
);
880
_context
.PopScope();
884
_context
.CurrentInstance = value;
885
Logic_DoAssignmentToParentCollection(
_context
);
886
_context
.PopScope();
919
throw
_context
.WithLineInfo(new XamlObjectWriterException(err));
922
if (
_context
.CurrentType is not null &&
_context
.CurrentProperty is null)
926
_context
.CurrentType.ToString());
927
throw
_context
.WithLineInfo(new XamlObjectWriterException(err));
931
if (
_context
.CurrentType is not null)
933
_context
.PushScope();
936
_context
.AddNamespacePrefix(namespaceDeclaration.Prefix, namespaceDeclaration.Namespace);
942
while (
_context
.LiveDepth > 0)
944
_context
.PopScope();
950
_context
.PushScope();
960
bool seenStartObject =
_context
.LiveDepth > 1 ||
_context
.CurrentType is not null;
963
while (
_context
.LiveDepth > 0)
965
if (
_context
.CurrentProperty is not null)
1009
return
_context
.RootNameScope;
1030
return
_context
.SchemaContext;
1039
_context
.LineNumber = lineNumber;
1040
_context
.LinePosition = linePosition;
1062
return
_context
.WithLineInfo(ex);
2412
!
_context
.IsOnTheLiveStack(token.TargetContext.CurrentInstance))
2444
if (
_context
.LiveDepth > 0)
2447
if (
_context
.IsOnTheLiveStack(instance))