Exemple #1
0
        public static object Unstage(StageItem item, Type targetType)
        {
            if (item is StageNull)
            {
                return(null);
            }
            IStager stager = SerializationMaster.GetStager(targetType);

            if (stager != null)
            {
                return(stager.UnstageValue(item, targetType));
            }
            StageValue stageValue = item as StageValue;

            if (stageValue == null)
            {
                StageElement stageElement = item as StageElement;
                if (stageElement == null)
                {
                    throw new SerializationException(string.Concat("Unable to unstage, the element is not supported: ", targetType.Name));
                }
                return(SerializationMaster.ReflectIn(stageElement));
            }
            IValueConverter converter = SerializationMaster.GetConverter(targetType);

            if (converter == null)
            {
                throw new SerializationException(string.Concat("Unable to unstage, no converter or stager was found for type: ", targetType.Name));
            }
            return(converter.FromString(stageValue.@value, targetType));
        }