public object Deserialize(string serializedObject) { Dictionary <string, string> serializationData = StringConversionServices.ParseKeyValueCollection(serializedObject); if (serializationData.ContainsKey("_IsNew_") == false) { throw new ArgumentException("serializedObject is of wrong format"); } IData data = null; bool isNew = StringConversionServices.DeserializeValueBool(serializationData["_IsNew_"]); if (isNew) { if (serializationData.ContainsKey("_Type_") == false) { throw new ArgumentException("serializedObject is of wrong format"); } string typeString = StringConversionServices.DeserializeValueString(serializationData["_Type_"]); Type interfaceType = TypeManager.GetType(typeString); data = DataFacade.BuildNew(interfaceType); } else { if (serializationData.ContainsKey("_DataSourceId_") == false) { throw new ArgumentException("serializedObject is of wrong format"); } string dataSourceIdString = StringConversionServices.DeserializeValueString(serializationData["_DataSourceId_"]); DataSourceId dataSourceId = DataSourceId.Deserialize(dataSourceIdString); data = DataFacade.GetDataFromDataSourceId(dataSourceId); if (data == null) { throw new DataSerilizationException(string.Format("Failed to get the '{0}' with the given data source '{1}', data might have been deleted sinse this serialized data was created", dataSourceId.InterfaceType, dataSourceId)); } } Type dataType = data.DataSourceId.InterfaceType; DeserializePropertiesFromInterface(serializationData, dataType, false, data); foreach (var inheritedInterface in dataType.GetInterfaces()) { if (inheritedInterface == typeof(IData)) { continue; // DataSourceId is already deserialized so we're skipping it here } DeserializePropertiesFromInterface(serializationData, inheritedInterface, true, data); } return(data); }
public static ActionToken Deserialize(string serializedData) { Dictionary <string, string> dic = StringConversionServices.ParseKeyValueCollection(serializedData); string name = StringConversionServices.DeserializeValueString(dic["Name"]); bool isWidget = StringConversionServices.DeserializeValueBool(dic["IsWidget"]); return(new FunctionInfoActionToken(name, isWidget)); }
/// <exclude /> public object Deserialize(string serializedObject) { Dictionary <string, string> dic = StringConversionServices.ParseKeyValueCollection(serializedObject); string zipFilename = StringConversionServices.DeserializeValueString(dic["ZipFileName"]); string packageInstallDirectory = StringConversionServices.DeserializeValueString(dic["PackageInstallDirectory"]); bool hasBeenValidated = StringConversionServices.DeserializeValueBool(dic["HasBeenValidated"]); string originalPackageInstallDirectory = null; string serializedValue; if (dic.TryGetValue("OriginalPackageInstallDirectory", out serializedValue)) { originalPackageInstallDirectory = StringConversionServices.DeserializeValueString(serializedValue); } if (C1File.Exists(zipFilename)) { XElement installContent; XmlHelper.LoadInstallXml(zipFilename, out installContent); PackageInformation packageInformation; PackageManager.ValidatePackageInformation(installContent, out packageInformation); string packageZipFilename = Path.Combine(packageInstallDirectory, Path.GetFileName(zipFilename)); C1File.Copy(zipFilename, packageZipFilename, true); var packageInstaller = new PackageInstaller(new PackageInstallerUninstallerFactory(), packageZipFilename, packageInstallDirectory, TempDirectoryFacade.CreateTempDirectory(), packageInformation); var packageManagerInstallProcess = new PackageManagerInstallProcess( packageInstaller, packageInformation.SystemLockingType, zipFilename, packageInstallDirectory, packageInformation.Name, packageInformation.Version, packageInformation.Id, originalPackageInstallDirectory); if (hasBeenValidated) { packageManagerInstallProcess.Validate(); } return(packageManagerInstallProcess); } return(new PackageManagerInstallProcess(new List <PackageFragmentValidationResult>(), null));; }
public static ActionToken Deserialize(string serializedData) { Dictionary <string, string> dic = StringConversionServices.ParseKeyValueCollection(serializedData); return(new CustomUrlActionNodeActionToken ( StringConversionServices.DeserializeValueString(dic["Url"]), StringConversionServices.DeserializeValueBool(dic["External"]), StringConversionServices.DeserializeValueString(dic["ViewType"]), StringConversionServices.DeserializeValueString(dic["ViewLabel"]), StringConversionServices.DeserializeValueString(dic["ViewToolTip"]), StringConversionServices.DeserializeValueString(dic["SerializedActionNode"]), StringConversionServices.DeserializeValueString(dic["PermissionTypes"]).DesrializePermissionTypes().ToList() )); }
public object Deserialize(string serializedObject) { if (serializedObject == null) { throw new ArgumentNullException("serializedObject"); } Dictionary <string, string> dic = StringConversionServices.ParseKeyValueCollection(serializedObject); UploadedFile uploadedFile = new UploadedFile(); if (dic.ContainsKey("HasFile") == false) { throw new InvalidOperationException("Not correct serialized format"); } uploadedFile.HasFile = StringConversionServices.DeserializeValueBool(dic["HasFile"]); if (dic.ContainsKey("FileName")) { uploadedFile.FileName = StringConversionServices.DeserializeValueString(dic["FileName"]); } if (dic.ContainsKey("ContentType")) { uploadedFile.ContentType = StringConversionServices.DeserializeValueString(dic["ContentType"]); } if (dic.ContainsKey("ContentLength") == false) { throw new InvalidOperationException("Not correct serialized format"); } uploadedFile.ContentLength = StringConversionServices.DeserializeValueInt(dic["ContentLength"]); if (dic.ContainsKey("FileStream")) { byte[] bytes = StringConversionServices.DeserializeValueArray <byte>(dic["FileStream"]); uploadedFile.FileStream = new MemoryStream(bytes); } return(uploadedFile); }
/// <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); if (!dic.ContainsKey("_GroupName_") || !dic.ContainsKey("_IsLocalInstalled_") || !dic.ContainsKey("_CanBeUninstalled_")) { throw new ArgumentException("serializedEntityToken is of wrong format"); } string groupName = StringConversionServices.DeserializeValueString(dic["_GroupName_"]); bool isLocalInstalled = StringConversionServices.DeserializeValueBool(dic["_IsLocalInstalled_"]); bool canBeUninstalled = StringConversionServices.DeserializeValueBool(dic["_CanBeUninstalled_"]); return(new PackageElementProviderInstalledPackageItemEntityToken(new Guid(id), groupName, isLocalInstalled, canBeUninstalled)); }
/// <exclude /> public static ActionToken Deserialize(string serialiedWorkflowActionToken) { Dictionary <string, string> dic = StringConversionServices.ParseKeyValueCollection(serialiedWorkflowActionToken); if ((dic.ContainsKey("_WorkflowType_") == false) || (dic.ContainsKey("_Payload_") == false) || (dic.ContainsKey("_ExtraPayload_") == false) || (dic.ContainsKey("_Ignore_") == false) || (dic.ContainsKey("_PermissionTypes_") == false)) { throw new ArgumentException("The serialiedWorkflowActionToken is not a serialized WorkflowActionToken", "serialiedWorkflowActionToken"); } string serializedType = StringConversionServices.DeserializeValueString(dic["_WorkflowType_"]); Type type = TypeManager.GetType(serializedType); string permissionTypesString = StringConversionServices.DeserializeValueString(dic["_PermissionTypes_"]); WorkflowActionToken workflowActionToken = new WorkflowActionToken(type, permissionTypesString.DesrializePermissionTypes()); string payload = StringConversionServices.DeserializeValueString(dic["_Payload_"]); workflowActionToken.Payload = payload; string extraPayload = StringConversionServices.DeserializeValueString(dic["_ExtraPayload_"]); workflowActionToken.ExtraPayload = extraPayload; bool ignoreEntityTokenLocking = StringConversionServices.DeserializeValueBool(dic["_Ignore_"]); workflowActionToken.DoIgnoreEntityTokenLocking = ignoreEntityTokenLocking; if (dic.ContainsKey("_EventHandleFilterType_")) { string serializedFilterType = StringConversionServices.DeserializeValueString(dic["_EventHandleFilterType_"]); workflowActionToken.EventHandleFilterType = TypeManager.GetType(serializedFilterType); } return(workflowActionToken); }
/// <exclude /> public static ActionToken Deserialize(string serializedData) { Dictionary <string, string> dic = StringConversionServices.ParseKeyValueCollection(serializedData); if (!dic.ContainsKey("_ActionIdentifier_") || !dic.ContainsKey("_PermissionTypes_")) { throw new ArgumentException($"The {nameof(serializedData)} is not a serialized {nameof(ProxyDataActionToken)}", nameof(serializedData)); } string serializedType = StringConversionServices.DeserializeValueString(dic["_ActionIdentifier_"]); string permissionTypesString = StringConversionServices.DeserializeValueString(dic["_PermissionTypes_"]); bool doIgnoreEntityTokenLocking = StringConversionServices.DeserializeValueBool(dic["_DoIgnoreEntityTokenLocking_"]); var result = new ProxyDataActionToken(ActionIdentifier.Deserialize(serializedType), permissionTypesString.DesrializePermissionTypes()) { DoIgnoreEntityTokenLocking = doIgnoreEntityTokenLocking }; return(result); }
public static RandomStringSettings Deserialize(Dictionary <string, string> values) { return(new RandomStringSettings( StringConversionServices.DeserializeValueInt(values["Length"]), StringConversionServices.DeserializeValueBool(values["CheckCollisions"]))); }
/// <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); } } }