コード例 #1
0
        public object GetSerializer(Type objectType, Type serializerType)
        {
            if (objectType == typeof(string))
            {
                return(System.Workflow.ComponentModel.Serialization.PrimitiveCodeDomSerializer.Default);
            }
            if (((objectType != null) && TypeProvider.IsAssignable(typeof(ICollection <string>), objectType)) && (!objectType.IsArray && (serializerType == typeof(CodeDomSerializer))))
            {
                PropertyDescriptor descriptor = this.Context[typeof(PropertyDescriptor)] as PropertyDescriptor;
                if (descriptor != null)
                {
                    if (string.Equals(descriptor.Name, "SynchronizationHandles", StringComparison.Ordinal) && TypeProvider.IsAssignable(typeof(Activity), descriptor.ComponentType))
                    {
                        return(new SynchronizationHandlesCodeDomSerializer());
                    }
                }
                else
                {
                    ExpressionContext context = this.Context[typeof(ExpressionContext)] as ExpressionContext;
                    if (((context != null) && (context.Expression is CodePropertyReferenceExpression)) && string.Equals(((CodePropertyReferenceExpression)context.Expression).PropertyName, "SynchronizationHandles", StringComparison.Ordinal))
                    {
                        return(new SynchronizationHandlesCodeDomSerializer());
                    }
                }
            }
            object serializer = this.serializationManager.GetSerializer(objectType, serializerType);

            if (!this.UseUserDefinedSerializer(objectType, serializerType))
            {
                serializer = new SerializableTypeCodeDomSerializer(serializer as CodeDomSerializer);
            }
            return(serializer);
        }
コード例 #2
0
        // work around : PD7's PrimitiveCodeDomSerializer does not handle well strings bigger than 200 characters,
        //       we push our own version to fix it.
        public object GetSerializer(Type objectType, Type serializerType)
        {
            if (objectType == typeof(string))
            {
                return(PrimitiveCodeDomSerializer.Default);
            }
            else if (objectType != null && TypeProvider.IsAssignable(typeof(ICollection <String>), objectType) && !objectType.IsArray && serializerType == typeof(CodeDomSerializer))
            {
                PropertyDescriptor pd = Context[typeof(PropertyDescriptor)] as PropertyDescriptor;
                if (pd != null)
                {
                    if (string.Equals(pd.Name, "SynchronizationHandles", StringComparison.Ordinal) && TypeProvider.IsAssignable(typeof(Activity), pd.ComponentType))
                    {
                        return(new SynchronizationHandlesCodeDomSerializer());
                    }
                }
                else
                {
                    // If property descriptor is not available, we then look at the expression context.
                    ExpressionContext context = Context[typeof(ExpressionContext)] as ExpressionContext;
                    if (context != null && context.Expression is CodePropertyReferenceExpression &&
                        string.Equals(((CodePropertyReferenceExpression)context.Expression).PropertyName, "SynchronizationHandles", StringComparison.Ordinal))
                    {
                        return(new SynchronizationHandlesCodeDomSerializer());
                    }
                }
            }

            object serializer = this.serializationManager.GetSerializer(objectType, serializerType);

            if (!UseUserDefinedSerializer(objectType, serializerType))
            {
                serializer = new SerializableTypeCodeDomSerializer(serializer as CodeDomSerializer);
            }

            return(serializer);
        }
        // work around : PD7's PrimitiveCodeDomSerializer does not handle well strings bigger than 200 characters, 
        //       we push our own version to fix it.
        public object GetSerializer(Type objectType, Type serializerType)
        {
            if (objectType == typeof(string))
            {
                return PrimitiveCodeDomSerializer.Default;
            }
            else if (objectType != null && TypeProvider.IsAssignable(typeof(ICollection<String>), objectType) && !objectType.IsArray && serializerType == typeof(CodeDomSerializer))
            {
                PropertyDescriptor pd = Context[typeof(PropertyDescriptor)] as PropertyDescriptor;
                if (pd != null)
                {
                    if (string.Equals(pd.Name, "SynchronizationHandles", StringComparison.Ordinal) && TypeProvider.IsAssignable(typeof(Activity), pd.ComponentType))
                        return new SynchronizationHandlesCodeDomSerializer();
                }
                else
                {
                    // If property descriptor is not available, we then look at the expression context.
                    ExpressionContext context = Context[typeof(ExpressionContext)] as ExpressionContext;
                    if (context != null && context.Expression is CodePropertyReferenceExpression &&
                        string.Equals(((CodePropertyReferenceExpression)context.Expression).PropertyName, "SynchronizationHandles", StringComparison.Ordinal))
                        return new SynchronizationHandlesCodeDomSerializer();
                }
            }

            object serializer = this.serializationManager.GetSerializer(objectType, serializerType);
            if (!UseUserDefinedSerializer(objectType, serializerType))
                serializer = new SerializableTypeCodeDomSerializer(serializer as CodeDomSerializer);

            return serializer;
        }
 public object GetSerializer(Type objectType, Type serializerType)
 {
     if (objectType == typeof(string))
     {
         return System.Workflow.ComponentModel.Serialization.PrimitiveCodeDomSerializer.Default;
     }
     if (((objectType != null) && TypeProvider.IsAssignable(typeof(ICollection<string>), objectType)) && (!objectType.IsArray && (serializerType == typeof(CodeDomSerializer))))
     {
         PropertyDescriptor descriptor = this.Context[typeof(PropertyDescriptor)] as PropertyDescriptor;
         if (descriptor != null)
         {
             if (string.Equals(descriptor.Name, "SynchronizationHandles", StringComparison.Ordinal) && TypeProvider.IsAssignable(typeof(Activity), descriptor.ComponentType))
             {
                 return new SynchronizationHandlesCodeDomSerializer();
             }
         }
         else
         {
             ExpressionContext context = this.Context[typeof(ExpressionContext)] as ExpressionContext;
             if (((context != null) && (context.Expression is CodePropertyReferenceExpression)) && string.Equals(((CodePropertyReferenceExpression) context.Expression).PropertyName, "SynchronizationHandles", StringComparison.Ordinal))
             {
                 return new SynchronizationHandlesCodeDomSerializer();
             }
         }
     }
     object serializer = this.serializationManager.GetSerializer(objectType, serializerType);
     if (!this.UseUserDefinedSerializer(objectType, serializerType))
     {
         serializer = new SerializableTypeCodeDomSerializer(serializer as CodeDomSerializer);
     }
     return serializer;
 }