internal void ApplyCacheEntry(IDesignerSerializationManager manager, ComponentCache.Entry entry)
        {
            SerializationResourceManager resourceManager = this.GetResourceManager(manager);

            if (entry.Metadata != null)
            {
                foreach (ComponentCache.ResourceEntry entry2 in entry.Metadata)
                {
                    resourceManager.SetMetadata(manager, entry2.Name, entry2.Value, entry2.ShouldSerializeValue, true);
                }
            }
            if (entry.Resources != null)
            {
                foreach (ComponentCache.ResourceEntry entry3 in entry.Resources)
                {
                    manager.Context.Push(entry3.PropertyDescriptor);
                    manager.Context.Push(entry3.ExpressionContext);
                    try
                    {
                        resourceManager.SetValue(manager, entry3.Name, entry3.Value, entry3.ForceInvariant, entry3.ShouldSerializeValue, entry3.EnsureInvariant, true);
                    }
                    finally
                    {
                        manager.Context.Pop();
                        manager.Context.Pop();
                    }
                }
            }
        }
 private object Serialize(IDesignerSerializationManager manager, object value, bool forceInvariant, bool shouldSerializeInvariant, bool ensureInvariant)
 {
     using (CodeDomSerializerBase.TraceScope("ResourceCodeDomSerializer::Serialize"))
     {
         bool   flag;
         string str3;
         SerializationResourceManager resourceManager = this.GetResourceManager(manager);
         CodeStatementCollection      statements      = (CodeStatementCollection)manager.Context[typeof(CodeStatementCollection)];
         if (!forceInvariant)
         {
             if (!resourceManager.DeclarationAdded)
             {
                 resourceManager.DeclarationAdded = true;
                 RootContext context = manager.Context[typeof(RootContext)] as RootContext;
                 if (statements != null)
                 {
                     CodeExpression[] expressionArray;
                     if (context != null)
                     {
                         string name = manager.GetName(context.Value);
                         expressionArray = new CodeExpression[] { new CodeTypeOfExpression(name) };
                     }
                     else
                     {
                         expressionArray = new CodeExpression[] { new CodePrimitiveExpression(this.ResourceManagerName) };
                     }
                     CodeExpression initExpression = new CodeObjectCreateExpression(typeof(ComponentResourceManager), expressionArray);
                     statements.Add(new CodeVariableDeclarationStatement(typeof(ComponentResourceManager), this.ResourceManagerName, initExpression));
                     base.SetExpression(manager, resourceManager, new CodeVariableReferenceExpression(this.ResourceManagerName));
                     resourceManager.ExpressionAdded = true;
                 }
             }
             else if (!resourceManager.ExpressionAdded)
             {
                 if (base.GetExpression(manager, resourceManager) == null)
                 {
                     base.SetExpression(manager, resourceManager, new CodeVariableReferenceExpression(this.ResourceManagerName));
                 }
                 resourceManager.ExpressionAdded = true;
             }
         }
         ExpressionContext tree = (ExpressionContext)manager.Context[typeof(ExpressionContext)];
         string            str2 = resourceManager.SetValue(manager, tree, value, forceInvariant, shouldSerializeInvariant, ensureInvariant, false);
         if ((value is string) || ((tree != null) && (tree.ExpressionType == typeof(string))))
         {
             flag = false;
             str3 = "GetString";
         }
         else
         {
             flag = true;
             str3 = "GetObject";
         }
         CodeMethodInvokeExpression expression = new CodeMethodInvokeExpression {
             Method = new CodeMethodReferenceExpression(new CodeVariableReferenceExpression(this.ResourceManagerName), str3)
         };
         expression.Parameters.Add(new CodePrimitiveExpression(str2));
         if (flag)
         {
             System.Type castType = this.GetCastType(manager, value);
             if (castType != null)
             {
                 return(new CodeCastExpression(castType, expression));
             }
             return(expression);
         }
         return(expression);
     }
 }