Exemple #1
0
        /// <exclude />
        public static StoreFieldType Deserialize(string serializedData)
        {
            using (TimerProfiler timerProfiler = TimerProfilerFacade.CreateTimerProfiler())
            {
                if (string.IsNullOrEmpty(serializedData))
                {
                    throw new ArgumentNullException("serializedData");
                }

                Dictionary <string, string> dic = StringConversionServices.ParseKeyValueCollection(serializedData);

                if (dic.ContainsKey("PhysicalStoreType") == false)
                {
                    throw new ArgumentException("Wrong serialized format");
                }

                string physicalStoreFieldTypeString           = StringConversionServices.DeserializeValue <string>(dic["PhysicalStoreType"]);
                PhysicalStoreFieldType physicalStoreFieldType = (PhysicalStoreFieldType)Enum.Parse(typeof(PhysicalStoreFieldType), physicalStoreFieldTypeString);

                switch (physicalStoreFieldType)
                {
                case PhysicalStoreFieldType.String:
                    if (dic.ContainsKey("Length") == false)
                    {
                        throw new ArgumentException("Wrong serialized format");
                    }
                    int length = StringConversionServices.DeserializeValueInt(dic["Length"]);
                    return(new StoreFieldType(physicalStoreFieldType, length));

                case PhysicalStoreFieldType.Decimal:
                    if (dic.ContainsKey("Precision") == false)
                    {
                        throw new ArgumentException("Wrong serialized format");
                    }
                    if (dic.ContainsKey("Scale") == false)
                    {
                        throw new ArgumentException("Wrong serialized format");
                    }

                    int precision = StringConversionServices.DeserializeValueInt(dic["Precision"]);
                    int scale     = StringConversionServices.DeserializeValueInt(dic["Scale"]);

                    return(new StoreFieldType(physicalStoreFieldType, precision, scale));

                case PhysicalStoreFieldType.Boolean:
                case PhysicalStoreFieldType.DateTime:
                case PhysicalStoreFieldType.Guid:
                case PhysicalStoreFieldType.Integer:
                case PhysicalStoreFieldType.LargeString:
                case PhysicalStoreFieldType.Long:
                    return(new StoreFieldType(physicalStoreFieldType));
                }

                throw new NotImplementedException();
            }
        }
        public override void OnInitialize(object sender, EventArgs e)
        {
            var pageTeaserInstanceEntityToken = EntityToken as PageTeaserInstanceEntityToken;

            if (pageTeaserInstanceEntityToken != null)
            {
                Teaser = (T)pageTeaserInstanceEntityToken.Teaser;
            }
            else
            {
                var pageTeaserPositionFolderEntityToken = (PageTeaserPositionFolderEntityToken)EntityToken;
                var payload = StringConversionServices.ParseKeyValueCollection(Payload);

                var teaserType      = Type.GetType(StringConversionServices.DeserializeValue <string>(payload["teaserType"]));
                var name            = StringConversionServices.DeserializeValue <string>(payload["name"]);
                var existingTeasers = TeaserFacade.GetPageTeasers(pageTeaserPositionFolderEntityToken.Page).ToList();

                Teaser = (T)DataFacade.BuildNew(teaserType);

                Teaser.Name          = name;
                Teaser.Position      = pageTeaserPositionFolderEntityToken.Id;
                Teaser.LocalOrdering = existingTeasers.Any() ? existingTeasers.Max(t => t.LocalOrdering) + 1 : 1;
            }

            if (BindingExist("Label"))
            {
                return;
            }

            var page = PageManager.GetPageById(new Guid(EntityToken.Source));

            Bindings.Add("Label", Teaser.GetLabel());
            Bindings.Add("Positions", FormHelpers.GetPositions(page.TemplateId));

            Bindings.Add("Name", Teaser.Name);
            Bindings.Add("Position", Teaser.Position);
            Bindings.Add("AdditionalHeader", Teaser.AdditionalHeader);
            Bindings.Add("ShowOnDescendants", Teaser.ShowOnDescendants);
            Bindings.Add("PublishDate", Teaser.PublishDate);
            Bindings.Add("UnpublishDate", Teaser.UnpublishDate);

            LoadBindings();
        }
Exemple #3
0
        /// <exclude />
        public static EntityToken Deserialize(string serializedEntityToken)
        {
            string type, source, id;
            Dictionary <string, string> dic;

            DoDeserialize(serializedEntityToken, out type, out source, out id, out dic);

            var entityToken = new DataGroupingProviderHelperEntityToken(type);

            if (dic.ContainsKey("Payload"))
            {
                entityToken._payload = dic["Payload"];
            }

            entityToken.GroupingValues = new Dictionary <string, object>();

            Type dataType = TypeManager.GetType(type);

            List <PropertyInfo> propertyInfos = dataType.GetPropertiesRecursively();

            foreach (var kvp in dic)
            {
                PropertyInfo propertyInfo = propertyInfos.Where(f => f.Name == kvp.Key).SingleOrDefault();

                if (propertyInfo == null)
                {
                    continue;
                }

                object value = null;
                if (kvp.Value != _magicNullValue)
                {
                    value = StringConversionServices.DeserializeValue(kvp.Value, propertyInfo.PropertyType);
                }


                entityToken.GroupingValues.Add(kvp.Key, value);
            }

            return(entityToken);
        }
Exemple #4
0
        /// <exclude />
        public static EntityToken Deserialize(string serializedEntityToken)
        {
            string type, source, id;
            Dictionary <string, string> dic;

            DoDeserialize(serializedEntityToken, out type, out source, out id, out dic);

            TreeDataFieldGroupingElementEntityToken entityToken = new TreeDataFieldGroupingElementEntityToken(id, source, type, dic);

            if (dic.ContainsKey("_ReferenceType_"))
            {
                string typeString = StringConversionServices.DeserializeValueString(dic["_ReferenceType_"]);

                entityToken.ChildGeneratingDataElementsReferenceType = TypeManager.GetType(typeString);
            }

            if (dic.ContainsKey("_ReferenceValueType_"))
            {
                Type referenceValueType = StringConversionServices.DeserializeValueType(dic["_ReferenceValueType_"]);
                entityToken.ChildGeneratingDataElementsReferenceValue = StringConversionServices.DeserializeValue(dic["_ReferenceValue_"], referenceValueType);
            }

            return(entityToken);
        }
Exemple #5
0
        /// <exclude />
        public static DefaultValue Deserialize(string serializedData)
        {
            Verify.ArgumentNotNullOrEmpty(serializedData, "serializedData");

            using (TimerProfilerFacade.CreateTimerProfiler())
            {
                Dictionary <string, string> dic = StringConversionServices.ParseKeyValueCollection(serializedData);

                Verify.That(dic.ContainsKey("ValueType"), "Wrong serialized format");

                string valueTypeString = StringConversionServices.DeserializeValue <string>(dic["ValueType"]);
                var    valueType       = (DefaultValueType)Enum.Parse(typeof(DefaultValueType), valueTypeString);

                bool hasValue = dic.ContainsKey("Value");

                switch (valueType)
                {
                case DefaultValueType.Boolean:
                    Verify.That(hasValue, "Wrong serialized format");
                    bool boolValue = StringConversionServices.DeserializeValueBool(dic["Value"]);
                    return(DefaultValue.Boolean(boolValue));

                case DefaultValueType.DateTime:
                    Verify.That(hasValue, "Wrong serialized format");
                    DateTime dateTimeValue = StringConversionServices.DeserializeValueDateTime(dic["Value"]);
                    return(DefaultValue.DateTime(dateTimeValue));

                case DefaultValueType.DateTimeNow:
                    return(DefaultValue.Now);

                case DefaultValueType.Decimal:
                    Verify.That(hasValue, "Wrong serialized format");
                    decimal decimalValue = StringConversionServices.DeserializeValueDecimal(dic["Value"]);
                    return(DefaultValue.Decimal(decimalValue));

                case DefaultValueType.Guid:
                    Verify.That(hasValue, "Wrong serialized format");
                    Guid guidValue = StringConversionServices.DeserializeValueGuid(dic["Value"]);
                    return(DefaultValue.Guid(guidValue));

                case DefaultValueType.Integer:
                    Verify.That(hasValue, "Wrong serialized format");
                    int intValue = StringConversionServices.DeserializeValueInt(dic["Value"]);
                    return(DefaultValue.Integer(intValue));

                case DefaultValueType.NewGuid:
                    return(DefaultValue.NewGuid);

                case DefaultValueType.String:
                    string stringValue = null;
                    if (hasValue)
                    {
                        stringValue = StringConversionServices.DeserializeValueString(dic["Value"]);
                    }
                    return(DefaultValue.String(stringValue));

                case DefaultValueType.RandomString:
                    var settings = RandomStringSettings.Deserialize(dic);

                    return(new DefaultValue(settings));

                default:
                    throw new NotImplementedException("DefaultValueType = " + valueType);
                }
            }
        }