internal XamlObjectWriter(XamlSavedContext savedContext, XamlObjectWriterSettings settings)
 {
     if (savedContext == null)
     {
         throw new ArgumentNullException("savedContext");
     }
     if (savedContext.SchemaContext == null)
     {
         throw new ArgumentException(System.Xaml.SR.Get("SavedContextSchemaContextNull"), "savedContext");
     }
     this.Initialize(savedContext.SchemaContext, savedContext, settings);
 }
 private void AddDependencyForUnresolvedChildren(object childThatHasUnresolvedChildren, XamlMember property, object parentInstance, XamlType parentType, bool parentIsGotten, XamlSavedContext deferredMarkupExtensionContext)
 {
     if (((property != null) && property.IsDirective) && ((parentInstance == null) && (property != XamlLanguage.Key)))
     {
         List<string> result = new List<string>();
         this._nameFixupGraph.GetDependentNames(childThatHasUnresolvedChildren, result);
         string str = string.Join(", ", result.ToArray());
         throw this.WithLineInfo(new XamlObjectWriterException(System.Xaml.SR.Get("TransitiveForwardRefDirectives", new object[] { childThatHasUnresolvedChildren.GetType(), property, str })));
     }
     NameFixupToken token = this.GetTokenForUnresolvedChildren(childThatHasUnresolvedChildren, property, deferredMarkupExtensionContext);
     token.Target.Instance = parentInstance;
     token.Target.InstanceType = parentType;
     token.Target.InstanceWasGotten = parentIsGotten;
     this.PendCurrentFixupToken_SetValue(token);
 }
 private NameFixupToken GetTokenForUnresolvedChildren(object childThatHasUnresolvedChildren, XamlMember property, XamlSavedContext deferredMarkupExtensionContext)
 {
     NameFixupToken token = new NameFixupToken();
     if (deferredMarkupExtensionContext != null)
     {
         token.FixupType = FixupType.MarkupExtensionFirstRun;
         token.SavedContext = deferredMarkupExtensionContext;
     }
     else
     {
         token.FixupType = FixupType.UnresolvedChildren;
     }
     token.ReferencedObject = childThatHasUnresolvedChildren;
     token.Target.Property = property;
     return token;
 }
 private void Initialize(XamlSchemaContext schemaContext, XamlSavedContext savedContext, XamlObjectWriterSettings settings)
 {
     this._inDispose = false;
     if (schemaContext == null)
     {
         throw new ArgumentNullException("schemaContext");
     }
     if ((savedContext != null) && (schemaContext != savedContext.SchemaContext))
     {
         throw new ArgumentException(System.Xaml.SR.Get("SavedContextSchemaContextMismatch"), "schemaContext");
     }
     if (settings != null)
     {
         this._afterBeginInitHandler = settings.AfterBeginInitHandler;
         this._beforePropertiesHandler = settings.BeforePropertiesHandler;
         this._afterPropertiesHandler = settings.AfterPropertiesHandler;
         this._afterEndInitHandler = settings.AfterEndInitHandler;
         this._xamlSetValueHandler = settings.XamlSetValueHandler;
         this._rootObjectInstance = settings.RootObjectInstance;
         this._skipDuplicatePropertyCheck = settings.SkipDuplicatePropertyCheck;
         this._skipProvideValueOnRoot = settings.SkipProvideValueOnRoot;
         this._preferUnconvertedDictionaryKeys = settings.PreferUnconvertedDictionaryKeys;
     }
     INameScope rootNameScope = (settings != null) ? settings.ExternalNameScope : null;
     XamlRuntime runtime = this.CreateRuntime(settings, schemaContext);
     if (savedContext != null)
     {
         this._context = new ObjectWriterContext(savedContext, settings, rootNameScope, runtime);
     }
     else
     {
         if (schemaContext == null)
         {
             throw this.WithLineInfo(new XamlInternalException());
         }
         this._context = new ObjectWriterContext(schemaContext, settings, rootNameScope, runtime);
         this._context.AddNamespacePrefix("xml", "http://www.w3.org/XML/1998/namespace");
     }
     this._context.IsInitializedCallback = this;
     this._deferringWriter = new DeferringWriter(this._context);
     this._rootNamescope = null;
 }
 public XamlObjectWriterFactory(ObjectWriterContext context)
 {
     this._savedContext = context.GetSavedContext(SavedContextType.Template);
     this._parentSettings = context.ServiceProvider_GetSettings();
 }