Exemple #1
0
 // Clear all the fields on this instance before it put into the factory cache
 internal void ClearData()
 {
     _contextFlags             = 0;
     _contextData              = null;
     _contextKey               = null;
     _contentProperty          = null;
     _expectedType             = null;
     _expectedTypeId           = 0;
     _createUsingTypeConverter = false;
     _uid  = null;
     _name = null;
 }
 // Clear all the fields on this instance before it put into the factory cache
 internal void ClearData()
 {
     _contextFlags = 0;
     _contextData = null;
     _contextKey = null;
     _contentProperty = null;
     _expectedType = null;
     _expectedTypeId = 0;
     _createUsingTypeConverter = false;
     _uid = null;
     _name = null;
 }
 // simple helper method that removes the flag from the context
 internal void ClearFlag(ReaderFlags flag)
 {
     ContextFlags &= ~flag;
 }
 // simple helper method adds the flag to the context
 internal void SetFlag(ReaderFlags flag)
 {
     ContextFlags |= flag;
 }
 // simple helper method that returns true if the context contains the given flag or flags.
 // If multiple flags are passed in, the context must contain all the flags.
 internal bool CheckFlag(ReaderFlags flag)
 {
     return (ContextFlags & flag) == flag;
 }
Exemple #6
0
 // Token: 0x06002232 RID: 8754 RVA: 0x000AA2C5 File Offset: 0x000A84C5
 internal void ClearFlag(ReaderFlags flag)
 {
     this.ContextFlags &= ~flag;
 }
Exemple #7
0
 // Token: 0x06002231 RID: 8753 RVA: 0x000AA2B5 File Offset: 0x000A84B5
 internal void SetFlag(ReaderFlags flag)
 {
     this.ContextFlags |= flag;
 }
Exemple #8
0
 // Token: 0x06002230 RID: 8752 RVA: 0x000AA2A8 File Offset: 0x000A84A8
 internal bool CheckFlag(ReaderFlags flag)
 {
     return((this.ContextFlags & flag) == flag);
 }
        // Modify the passed flags to set the NeedToAddToTree flag based on the current 
        // context.  This is needed by subparsers in some cases.
        internal static void CheckForTreeAdd(ref ReaderFlags flags, ReaderContextStackData context) 
        {
            // An element doesn't need to be added to a tree if in the context of constructor
            // paramters or deferred content
 
            if (context == null ||
                (context.ContextType != ReaderFlags.ConstructorParams && 
                 context.ContextType != ReaderFlags.RealizeDeferContent)) 
            {
                flags |= ReaderFlags.NeedToAddToTree; 
            }
        }
        // Determine the element type for a baml start record, and either create a new
        // element or mark it for delay creation later.  Update the ReaderFlags to 
        // indicate the type of element created. 
        private void GetElementAndFlags(
                BamlElementStartRecord bamlElementStartRecord, 
                out object element,
                out ReaderFlags flags,
                out Type delayCreatedType,
                out short delayCreatedTypeId) 
        {
            short typeId = bamlElementStartRecord.TypeId; 
            Type elementType = MapTable.GetTypeFromId(typeId); 
            element = null;
 
            delayCreatedType = null;
            delayCreatedTypeId = 0;
            flags = ReaderFlags.Unknown;
 
            if (null != elementType)
            { 
                if (bamlElementStartRecord.CreateUsingTypeConverter || 
                    typeof(MarkupExtension).IsAssignableFrom(elementType))
                { 
                    // CreateUsingTypeConverter means we've decided
                    //  (in XamlRecordReader) that we do not wish to
                    //  create an instance at this time, go to the delay-
                    //  creation state. 
                    // MarkupExtensions will be created later after we have
                    //  parsed the constructor parameters. 
                    delayCreatedType = elementType; 
                    delayCreatedTypeId = typeId;
                } 
                else
                {
                    // Create an instance of the object specified by the
                    //  BeginElement, throw if the creation fails. 
                    element = CreateInstanceFromType(elementType, typeId, false);
                    if (element == null) 
                    { 
                        ThrowException(SRID.ParserNoElementCreate2, elementType.FullName);
                    } 
                }

                flags = GetFlagsFromType(elementType);
            } 
        }
        // Push context data onto the reader context stack 
        internal void PushContext( 
            ReaderFlags contextFlags,
            object      contextData, 
            Type        expectedType,
            short       expectedTypeId,
            bool        createUsingTypeConverter)
        { 
            ReaderContextStackData d;
 
            lock(_stackDataFactoryCache) 
            {
                if (_stackDataFactoryCache.Count == 0) 
                {
                    d = new ReaderContextStackData();
                }
                else 
                {
                    // Get StackData from the factory cache 
                    d = _stackDataFactoryCache[_stackDataFactoryCache.Count-1]; 
                    _stackDataFactoryCache.RemoveAt(_stackDataFactoryCache.Count-1);
                } 
            }

            d.ContextFlags = contextFlags;
            d.ObjectData = contextData; 
            d.ExpectedType = expectedType;
            d.ExpectedTypeId = expectedTypeId; 
            d.CreateUsingTypeConverter = createUsingTypeConverter; 
            ReaderContextStack.Push(d);
            ParserContext.PushScope(); 

            // If the context data is an object that implements INameScope, make it
            // the new Name scope for registering Names
 
            INameScope nameScope = NameScope.NameScopeFromObject(contextData);
 
            if (nameScope != null) 
            {
                ParserContext.NameScopeStack.Push(nameScope); 
            }

        }
 // Push context data onto the reader context stack
 internal void PushContext( 
     ReaderFlags contextFlags, 
     object      contextData,
     Type        expectedType, 
     short       expectedTypeId)
 {
     PushContext( contextFlags, contextData, expectedType, expectedTypeId, false );
 }