public async Task GetCampaignMatchDetails_IsSerializable(string guid)
        {
            var query = new GetCampaignMatchDetails()
                .ForMatchId(new Guid(guid));

            var result = await Global.Session.Query(query);

            var serializationUtility = new SerializationUtility<CampaignMatch>();
            serializationUtility.AssertRoundTripSerializationIsPossible(result);
        }
        public async Task GetCompetitiveSkillRankDesignations_IsSerializable()
        {
            var query = new GetCompetitiveSkillRankDesignations()
                .SkipCache();

            var result = await Global.Session.Query(query);

            var serializationUtility = new SerializationUtility<List<CompetitiveSkillRankDesignation>>();
            serializationUtility.AssertRoundTripSerializationIsPossible(result);
        }
        public async Task GetFlexibleStats_IsSerializable()
        {
            var query = new GetFlexibleStats()
                .SkipCache();

            var result = await Global.Session.Query(query);

            var serializationUtility = new SerializationUtility<List<FlexibleStat>>();
            serializationUtility.AssertRoundTripSerializationIsPossible(result);
        }
        public async Task GetCustomServiceRecord_IsSerializable(string gamertag)
        {
            var query = new GetCustomServiceRecord()
                .ForPlayer(gamertag);

            var result = await Global.Session.Query(query);

            var serializationUtility = new SerializationUtility<CustomServiceRecord>();
            serializationUtility.AssertRoundTripSerializationIsPossible(result);
        }
        public async Task GetRequisitionPack_IsSerializable(string guid)
        {
            var query = new GetRequisitionPack()
                .ForRequisitionPackId(new Guid(guid))
                .SkipCache();

            var result = await Global.Session.Query(query);

            var serializationUtility = new SerializationUtility<RequisitionPack>();
            serializationUtility.AssertRoundTripSerializationIsPossible(result);
        }
Exemplo n.º 6
0
        public async Task GetGameVariant_IsSerializable(string guid)
        {
            var query = new GetGameVariant()
                .ForGameVariantId(new Guid(guid))
                .SkipCache();

            var result = await Global.Session.Query(query);

            var serializationUtility = new SerializationUtility<GameVariant>();
            serializationUtility.AssertRoundTripSerializationIsPossible(result);
        }
Exemplo n.º 7
0
        public void Test_NetPayEntityClone()
        {
            var now = DateTime.Now;

            NetPayInfo netpayInfo = new NetPayInfo();

            netpayInfo.ApproveTime       = now;
            netpayInfo.ApproveUserSysNo  = 1;
            netpayInfo.ChannelID         = "channel";
            netpayInfo.CompanyCode       = "8601";
            netpayInfo.ExternalKey       = "externalkey";
            netpayInfo.GiftCardPayAmt    = 1000;
            netpayInfo.MasterSoSysNo     = 100000;
            netpayInfo.Note              = "note";
            netpayInfo.OrderAmt          = 1000;
            netpayInfo.PayAmount         = 1000;
            netpayInfo.PayTypeSysNo      = 1;
            netpayInfo.PointPay          = 1000;
            netpayInfo.PrePayAmt         = 1000;
            netpayInfo.RelatedSoSysNo    = 100000;
            netpayInfo.ReviewedTime      = now;
            netpayInfo.ReviewedUserSysNo = 1;
            netpayInfo.SOSysNo           = 100000;
            netpayInfo.Source            = NetPaySource.Bank;
            netpayInfo.Status            = NetPayStatus.Abandon;
            netpayInfo.SysNo             = 1000;

            var cloneNetPayInfo = SerializationUtility.DeepClone <NetPayInfo>(netpayInfo);

            Assert.AreEqual(now, cloneNetPayInfo.ApproveTime);
            Assert.AreEqual(1, cloneNetPayInfo.ApproveUserSysNo);
            Assert.AreEqual("channel", cloneNetPayInfo.ChannelID);
            Assert.AreEqual("8601", cloneNetPayInfo.CompanyCode);
            Assert.AreEqual("externalkey", cloneNetPayInfo.ExternalKey);
            Assert.AreEqual(1000, cloneNetPayInfo.GiftCardPayAmt);
            Assert.AreEqual(100000, cloneNetPayInfo.MasterSoSysNo);
            Assert.AreEqual("note", cloneNetPayInfo.Note);
            Assert.AreEqual(1000, cloneNetPayInfo.OrderAmt);
            Assert.AreEqual(1000, cloneNetPayInfo.PayAmount);
            Assert.AreEqual(1, cloneNetPayInfo.PayTypeSysNo);
            Assert.AreEqual(1000, cloneNetPayInfo.PointPay);
            Assert.AreEqual(1000, cloneNetPayInfo.PrePayAmt);
            Assert.AreEqual(100000, cloneNetPayInfo.RelatedSoSysNo);
            Assert.AreEqual(now, cloneNetPayInfo.ReviewedTime);
            Assert.AreEqual(1, cloneNetPayInfo.ReviewedUserSysNo);
            Assert.AreEqual(100000, cloneNetPayInfo.SOSysNo);
            Assert.AreEqual(NetPaySource.Bank, cloneNetPayInfo.Source);
            Assert.AreEqual(NetPayStatus.Abandon, cloneNetPayInfo.Status);
            Assert.AreEqual(1000, cloneNetPayInfo.SysNo);
        }
Exemplo n.º 8
0
        public void SerializesCustomProperties()
        {
            var originalInnerException = new AssertException("User Message");
            var originalException      = new AfterTestException(originalInnerException);

            var deserializedException = SerializationUtility.SerializeAndDeserialize(originalException);

            var deserializedInnerException = Assert.Single(deserializedException.AfterExceptions);

            Assert.Equal(originalInnerException.Message, deserializedInnerException.Message);
            var deserializedAssertException = Assert.IsType <AssertException>(deserializedInnerException);

            Assert.Equal(originalInnerException.UserMessage, deserializedAssertException.UserMessage);
        }
Exemplo n.º 9
0
        public void SerializationUtilityCanDeserializeConfigurationNode()
        {
            InstrumentationNode instrumentationNode = new InstrumentationNode();

            ApplicationNode.AddNode(instrumentationNode);

            string relativePathToInstrumentationNode = SerializationUtility.CreatePathRelativeToRootNode(instrumentationNode.Path, ApplicationNode.Hierarchy);

            Assert.IsNotNull(relativePathToInstrumentationNode);

            InstrumentationNode deserializedInstance = SerializationUtility.DeserializeFromString(relativePathToInstrumentationNode, typeof(InstrumentationNode), ApplicationNode.Hierarchy) as InstrumentationNode;

            Assert.AreEqual(instrumentationNode, deserializedInstance);
        }
Exemplo n.º 10
0
        public ActionResult AjaxAppForCertification()
        {
            var request = Request.Form["data"];
            var data    = SerializationUtility.JsonDeserialize2 <CertificationInfo>(Request.Form["data"]);

            data.SellerName      = CurrUser.SellerName;
            data.SellerSysNo     = CurrUser.SellerSysNo;
            data.UserID          = CurrUser.UserID;
            data.Status          = "I";
            data.UserDisplayName = CurrUser.UserDisplayName;

            StoreService.SaveCertification(data);
            return(Json(new { Success = true, Message = LanguageHelper.GetText("操作成功") }));
        }
Exemplo n.º 11
0
        object DeserializeObject(DataRow data,
                                 string columnName)
        {
            object byteArrayAsObject = data[columnName];

            if (byteArrayAsObject == DBNull.Value)
            {
                return(null);
            }
            else
            {
                return(SerializationUtility.ToObject((byte[])byteArrayAsObject));
            }
        }
Exemplo n.º 12
0
        public static byte[] ToBytes([NotNull] object target)
        {
                        #if DEV_MODE && PI_ASSERTATIONS
            Debug.Assert(!(target is Object));
                        #endif

                        #if DONT_USE_ODIN_SERIALIZER
            var jsonString = JsonUtility.ToJson(target);
            var bytes      = Encoding.UTF8.GetBytes(jsonString);
            return(bytes);
                        #else
            return(SerializationUtility.SerializeValueWeak(target, DataFormat.Binary));
                        #endif
        }
Exemplo n.º 13
0
 private void HandleObjectPickerEvents()
 {
     if (this.picker.IsReadyToClaim && Event.current.type == EventType.Repaint)
     {
         var      value  = this.picker.ClaimObject();
         object[] values = new object[this.Property.Tree.WeakTargets.Count];
         values[0] = value;
         for (int j = 1; j < values.Length; j++)
         {
             values[j] = SerializationUtility.CreateCopy(value);
         }
         this.resolver.QueueAdd(values);
     }
 }
Exemplo n.º 14
0
        public string GetSuplexSecurity(string userName, string uniqueName)
        {
            SecurityLoadParameters slp = new SecurityLoadParameters()
            {
                ExternalGroupInfo = new ExternalGroupInfo(LdapRoot, true, GlobalExternalGroupsCsv),
                User = this.GetSuplexUser(userName)
            };

            DataSet ds = _splxApi.GetSecurity(uniqueName, slp.User, slp.ExternalGroupInfo);

            SerializationUtility ser = new SerializationUtility();

            return(ser.SerializeSecurityToStringFromDataSet(ds));
        }
        private void SolutionMenuItemCallback(object sender, EventArgs e)
        {
            var runtimeService   = this.container.GetExportedValue <IRuntimeService>();
            var settings         = this.Solution.GetSettings();
            var data             = runtimeService.GetDataGenerationData(settings.Address, settings.DataBase, $"{TagInfo.All}", string.Empty, false, -1);
            var dataSet          = SerializationUtility.Create(data);
            var projectInfoTable = dataSet.Tables[settings.ProjectInfo];

            foreach (var item in this.Solution.GetProjects())
            {
                this.Write(item, settings, projectInfoTable);
            }
            GenerationOutput.WriteLine();
        }
Exemplo n.º 16
0
        static async Task WriteAsync(Settings settings)
        {
            var runtimeService = Container.Get <IRuntimeService>();
            var data           = await runtimeService.GetDataGenerationDataAsync(settings.Address, settings.DataBaseName, "all", null, null);

            var dataSet = SerializationUtility.Create(data);

            var projectInfoTable = dataSet.Tables[settings.ExportName];

            foreach (var item in projectInfoTable.Rows)
            {
                Write(settings.OutputPath, item);
            }
        }
Exemplo n.º 17
0
        public static void Load(string repositoryId = null, string segmentId = null)
        {
            string path = String.Format("{0}/Data/{1}.data", Application.dataPath, repositoryId ?? DefaultRepositoryName);

            if (!File.Exists(path))
            {
                return;
            }

            byte[] bytes     = File.ReadAllBytes(path);
            var    modelData = SerializationUtility.DeserializeValue <ModelData>(bytes, DataFormat.Binary);

            Highscores.AddRange(modelData.Highscores);
        }
Exemplo n.º 18
0
        public static MQMessage ToMessage(this byte[] data)
        {
            MQMessage message;

            if (data == null)
            {
                return(null);
            }
            else
            {
                message = SerializationUtility.BytesToObject <MQMessage>(data);
            }
            return(message);
        }
Exemplo n.º 19
0
        private CacheItem CreateCacheItem(DataRow dataToLoad)
        {
            string key   = (string)dataToLoad["Key"];
            object value = DeserializeValue(dataToLoad);

            CacheItemPriority scavengingPriority = (CacheItemPriority)dataToLoad["ScavengingPriority"];
            object            refreshAction      = DeserializeObject(dataToLoad, "RefreshAction");
            object            expirations        = SerializationUtility.ToObject((byte[])dataToLoad["Expirations"]);
            object            timestamp          = (DateTime)dataToLoad["LastAccessedTime"];

            CacheItem cacheItem = new CacheItem((DateTime)timestamp, key, value, scavengingPriority, (ICacheItemRefreshAction)refreshAction, (ICacheItemExpiration[])expirations);

            return(cacheItem);
        }
        private void SaveCache()
        {
            if (this.WriteToFile && this.EnableCaching)
            {
                try
                {
                    this.approximateSizePerEntry = defaultApproximateSizePerEntry;
                    string   file = Path.Combine(SirenixAssetPaths.OdinTempPath, tempCacheFilename).Replace("\\", "/");
                    FileInfo info = new FileInfo(file);

                    // If there's no entries, delete the old file and don't make a new one.
                    if (this.cache.Count == 0)
                    {
                        if (info.Exists)
                        {
                            this.DeleteCache();
                        }
                    }
                    else
                    {
                        // Create dictionary
                        if (!Directory.Exists(SirenixAssetPaths.OdinTempPath))
                        {
                            Directory.CreateDirectory(SirenixAssetPaths.OdinTempPath);
                        }

                        using (FileStream stream = info.OpenWrite())
                        {
                            List <UnityEngine.Object> unityReferences;
                            SerializationUtility.SerializeValue(this.cache, stream, DataFormat.Binary, out unityReferences);

                            // Log error if any Unity references were serialized.
                            if (unityReferences != null && unityReferences.Count > 0)
                            {
                                Debug.LogError("Cannot reference UnityEngine Objects with PersistentContext.");
                            }
                        }

                        // Update size estimate.
                        this.approximateSizePerEntry = (int)(info.Length / this.EntryCount);
                    }
                }
                catch (Exception ex)
                {
                    Debug.LogError("Exception happened when saving Persistent Context to file.");
                    Debug.LogException(ex);
                }
            }
        }
Exemplo n.º 21
0
        public override FactimeSettings Load()
        {
            if (!File.Exists(GetFileName()))
            {
                base.Save(new FactimeSettings
                {
                    DefaultStart = new TimeSpan(9, 0, 0),
                    DefaultEnd   = new TimeSpan(18, 0, 0),
                    DefaultPreHolidaysCollection = new List <DateTime>(),
                    DefaultHolidaysCollection    = new List <DateTime>()
                });
            }

            return(SerializationUtility.Deserialize <FactimeSettings>(GetFileName()));
        }
Exemplo n.º 22
0
        public void ConfigurationsAreEqualWhenDeserializing()
        {
            var stringConfiguration = CreateConfiguration();

            Serialize(ExternalConfigurationName);

            var stringConfigurationDeserialized = SerializationUtility.DeserializeJson <StringConfiguration>(ExternalConfigurationName);

            foreach (var charSet in stringConfiguration.Characters)
            {
                Assert.AreEqual(charSet.Name, stringConfigurationDeserialized.Characters.First(e => e.Name == charSet.Name).Name);
                Assert.AreEqual(charSet.Characters, stringConfigurationDeserialized.Characters.First(e => e.Characters == charSet.Characters).Characters);
                Assert.AreEqual(charSet.Enabled, stringConfigurationDeserialized.Characters.First(e => e.Enabled == charSet.Enabled).Enabled);
            }
        }
Exemplo n.º 23
0
        public string EncryptCookie <T>(T obj, Dictionary <string, string> parameters)
        {
            string strCookieValue    = string.Empty;
            string strEncCookieValue = string.Empty;
            string strSHA1Sign       = string.Empty;

            strCookieValue = SerializationUtility.JsonSerialize3(obj);

            strEncCookieValue = RC4Encrypt.Encrypt(strCookieValue, parameters["rc4key"], RC4Encrypt.EncoderMode.HexEncoder).Trim();
            strSHA1Sign       = HashEncrypt.SHA1Encrypt(strEncCookieValue + parameters["hashkey"]);
            strEncCookieValue = HttpUtility.UrlEncode(strEncCookieValue);
            strEncCookieValue = strSHA1Sign + strEncCookieValue;

            return(strEncCookieValue);
        }
Exemplo n.º 24
0
        public void DeepCloneTest()
        {
            var user1 = new User(0, "AAA");
            var user2 = new User(1, "BBB");
            var users = new List <User> {
                user1, user2
            };
            var userCollection = new UserCollection(users);

            var cloned = SerializationUtility.DeepClone(userCollection);

            Assert.AreEqual(userCollection, cloned);
            Assert.AreNotSame(userCollection, cloned);
            Assert.AreNotSame(userCollection.Users, cloned.Users);
        }
Exemplo n.º 25
0
        public override void StoreProgram(IUdonProgram udonProgram)
        {
            if (this == null)
            {
                return;
            }

            byte[] serializedProgramBytes = SerializationUtility.SerializeValue(udonProgram, DEFAULT_SERIALIZATION_DATA_FORMAT, out programUnityEngineObjects);
            serializedProgramBytesString = Convert.ToBase64String(serializedProgramBytes);
            serializationDataFormat      = DEFAULT_SERIALIZATION_DATA_FORMAT;

            #if UNITY_EDITOR
            UnityEditor.EditorUtility.SetDirty(this);
            #endif
        }
Exemplo n.º 26
0
        public static ValueTask <int> WritePacketAsync(IByteHandler byteHandler, int sequenceNumber, ArraySegment <byte> contents, IOBehavior ioBehavior)
        {
            var bufferLength = contents.Count + 4;
            var buffer       = ArrayPool <byte> .Shared.Rent(bufferLength);

            SerializationUtility.WriteUInt32((uint)contents.Count, buffer, 0, 3);
            buffer[3] = (byte)sequenceNumber;
            Buffer.BlockCopy(contents.Array, contents.Offset, buffer, 4, contents.Count);
            return(byteHandler.WriteBytesAsync(new ArraySegment <byte>(buffer, 0, bufferLength), ioBehavior)
                   .ContinueWith(x =>
            {
                ArrayPool <byte> .Shared.Return(buffer);
                return default(ValueTask <int>);
            }));
        }
Exemplo n.º 27
0
 public void Serialize(CompactWriter writer)
 {
     Address.WriteAddress(writer, _address);
     writer.WriteObject(_subgroupName);
     CacheStatistics.WriteCacheStatistics(writer, _stats);
     writer.Write(_status.Data);
     DataAffinity.WriteDataAffinity(writer, _dataAffinity);
     writer.WriteObject(_connectedClients);
     writer.Write(_isInproc);
     Address.WriteAddress(writer, _rendererAddress);
     writer.WriteObject(_nodeGuid);
     writer.Write(_statsReplicationCounter);
     writer.Write((byte)CacheNodeStatus);
     SerializationUtility.SerializeDictionary(_localConnectedClientsInfo, writer);
 }
Exemplo n.º 28
0
        public static ShoppingCart GetShoppingCartByCustomer(int userSysNo)
        {
            ShoppingCart shoppingCart = GetShoppingCartFromCookieOrCreateNew();

            if (shoppingCart == null)
            {
                shoppingCart = new ShoppingCart();
            }
            string key = CookieHelper.GetCookie <string>(MY_SHOPPINGCART_SIGN_KEY);

            if (String.IsNullOrEmpty(key))
            {
                key = Guid.NewGuid().ToString("N");
                CookieHelper.SaveCookie <string>(MY_SHOPPINGCART_SIGN_KEY, key);
            }
            shoppingCart.ShoppingCartID = key;
            if (userSysNo > 0)
            {
                //获取数据库最新数据购物车
                ShoppingCartPersistent shoppingCartPersistent = ShoppingPersistentDA.GetShoppingCartByCustomer(userSysNo);
                ShoppingCart           newShoppingCart        = new ShoppingCart();
                if (shoppingCartPersistent != null && !string.IsNullOrEmpty(shoppingCartPersistent.ShoppingCart))
                {
                    newShoppingCart = SerializationUtility.JsonDeserialize2 <ShoppingCart>(shoppingCartPersistent.ShoppingCart);
                }
                //判断购物车是否发生变化
                if (newShoppingCart.ShoppingCartID != shoppingCart.ShoppingCartID)
                {
                    newShoppingCart.ShoppingCartID = shoppingCart.ShoppingCartID;
                    //合并购物车
                    MergeShoppingCart(shoppingCart, newShoppingCart);
                }
                //写入DB
                ShoppingPersistentDA.SaveShoppingCart(new ShoppingCartPersistent()
                {
                    CustomerSysNo    = userSysNo,
                    ShoppingCart     = SerializationUtility.JsonSerialize2(shoppingCart),
                    ShoppingCartMini = ""
                });
            }
            else
            {
                shoppingCart = GetShoppingCartFromCookie();
            }
            //写入Cookie
            CookieHelper.SaveCookie <ShoppingCart>(MY_SHOPPINGCART_COOKIE_NAME, shoppingCart);
            return(shoppingCart);
        }
        public IStorageFile CreateFile(string path, DateTime?lastWriteTime = null)
        {
            EnsurePathIsRelative(path);

            if (Container.BlobExists(String.Concat(_root, path)))
            {
                // MAB delete the file if it already exists
                DeleteFile(path);
                //throw new ArgumentException("File " + path + " already exists");
            }

            // create all folder entries in the hierarchy
            int lastIndex;
            var localPath = path;

            while ((lastIndex = localPath.LastIndexOf('/')) > 0)
            {
                localPath = localPath.Substring(0, lastIndex);
                var folder = Container.GetBlockBlobReference(String.Concat(_root, Combine(localPath, FolderEntry)));
                folder.OpenWrite().Dispose();
            }

            var blob        = Container.GetBlockBlobReference(String.Concat(_root, path));
            var contentType = GetContentType(path);

            if (!String.IsNullOrWhiteSpace(contentType))
            {
                blob.Properties.ContentType = contentType;

                if (IsCacheable(contentType))
                {
                    blob.Properties.CacheControl = "max-age=1800, public";
                }
            }

            blob.Metadata.Add("UploadedFromNode", SerializationUtility.GetLocalhostFqdn());
            if (lastWriteTime.HasValue)
            {
                blob.Metadata.Add("LastWriteTime", SerializationUtility.ToUniversalString(lastWriteTime));
            }

            using (var memoryStream = new MemoryStream(new byte[0]))
            {
                blob.UploadFromStream(memoryStream);
            }

            return(new AzureBlobFileStorage(blob, _absoluteRoot));
        }
Exemplo n.º 30
0
        public override void GetResponseUserInfo(PartnerBackContext context)
        {
            //第一步,获取AccessToken
            NameValueCollection postData = new NameValueCollection();

            postData.Add("client_id", context.PassportInfo.Parnter.AppID);
            postData.Add("client_secret", context.PassportInfo.Parnter.AppSecret);
            postData.Add("grant_type", "authorization_code");
            postData.Add("code", context.ResponseParam["code"]);
            postData.Add("redirect_uri", SpecialUrlEncode(BuildActionUrl(context.PassportInfo.Base.BaseUrl, context.PassportInfo.Parnter.LoginBackUrl)));
            string responseData = HttpPostRequest(context.PassportInfo.Parnter.AccessTokenUrl
                                                  , BuildStringFromNameValueCollection(postData)
                                                  , "application/x-www-form-urlencoded"
                                                  , context.PassportInfo.Parnter.Encoding);

            //Debug模式下记录相关信息至日志
            if (context.PassportInfo.Parnter.Debug.Equals("1"))
            {
                Logger.WriteLog(string.Format("获取AccessToken响应数据:{0}", responseData), "PassportSinaWeibo", "GetAccessToken");
            }

            SinaWeiboAccessToken returnData = SerializationUtility.JsonDeserialize <SinaWeiboAccessToken>(responseData);

            if (returnData == null)
            {
                throw new BusinessException("登录失败!");
            }

            //第二步,获取用户信息
            string requestParam = string.Format("access_token={0}&uid={1}",
                                                returnData.access_token,
                                                returnData.uid
                                                );

            responseData = HttpGetRequest(string.Format("{0}?{1}", context.PassportInfo.Parnter.GetUserInfoUrl, requestParam)
                                          , context.PassportInfo.Parnter.Encoding);

            //Debug模式下记录相关信息至日志
            if (context.PassportInfo.Parnter.Debug.Equals("1"))
            {
                Logger.WriteLog(string.Format("获取User响应数据:{0}", responseData), "PassportSinaWeibo", "GetUserInfo");
            }
            SinaWeiboUserInfo userInfo = SerializationUtility.JsonDeserialize <SinaWeiboUserInfo>(responseData);

            context.CustomerID    = string.Format("SinaWeibo_{0}", userInfo.id);
            context.CustomerName  = userInfo.screen_name;
            context.CustomerSouce = Enums.CustomerSourceType.Sina;
        }
Exemplo n.º 31
0
        public void GuardarBloque(string rutaArchivo, DataFormat tipoFormato)
        {
            var bytes = SerializationUtility.SerializeValue(this, tipoFormato);

            if (tipoFormato == DataFormat.JSON)
            {
                string ruta       = rutaArchivo + "/" + "Bloque_" + posicion.x + "_" + posicion.y + "_" + posicion.z + ".json";
                var    jsonString = System.Text.Encoding.UTF8.GetString(bytes);
                File.WriteAllText(ruta, jsonString);
            }
            else
            {
                string ruta = rutaArchivo + "/" + "Bloque_" + posicion.x + "_" + posicion.y + "_" + posicion.z + ".jcc";
                File.WriteAllBytes(ruta, bytes);
            }
        }
Exemplo n.º 32
0
        protected virtual object ReadField(IsolatedStorageFileStream fileStream, bool encrypted)
        {
            if (fileStream.Length == 0)
            {
                return(null);
            }
            byte[] fieldBytes = new byte[fileStream.Length];
            fileStream.Read(fieldBytes, 0, fieldBytes.Length);
            if (encrypted)
            {
                fieldBytes = DecryptValue(fieldBytes);
            }
            object fieldValue = SerializationUtility.ToObject(fieldBytes);

            return(fieldValue);
        }
Exemplo n.º 33
0
        public ActionResult AjaxSavePurchaseOrder()
        {
            if (string.IsNullOrWhiteSpace(Request["Data"]))
            {
                throw new BusinessException("采购单信息为空");
            }
            PurchaseOrderInfo poInfo = SerializationUtility.JsonDeserialize2 <PurchaseOrderInfo>(Request["Data"]);

            SetUserInfo(poInfo);
            poInfo.VendorInfo = new VendorBasicInfo()
            {
                VendorID = UserAuthHelper.GetCurrentUser().SellerSysNo.ToString()
            };
            poInfo = ProductPurchaseService.CreatePO(poInfo);
            return(Json(poInfo));
        }
Exemplo n.º 34
0
        public static StorePage QueryStorePageByPageName(string pageName, int sellerSysNo)
        {
            var page = StoreDA.QueryStorePageByPageName(pageName, sellerSysNo);

            if (page != null)
            {
                var value = page.DataValue;
                if (!string.IsNullOrEmpty(value))
                {
                    var result = SerializationUtility.JsonDeserialize2 <StorePage>(value);
                    result.SysNo = page.SysNo;
                    return(result);
                }
            }
            return(null);
        }
Exemplo n.º 35
0
        public void IsSerializableTest1()
        {
            try
            {
                Type testType = null;
                SerializationUtility.IsSerializable(testType);
                Assert.Fail("Null type should cause a NullReferenceException.");
            }
            catch (NullReferenceException)
            {
            }

            Assert.IsFalse(SerializationUtility.IsSerializable(typeof(NotSerializable)), "Type is marked as not serializable");
            Assert.IsFalse(SerializationUtility.IsSerializable(typeof(AlsoNotSerializable)), "Type's base type is marked as not serializable");
            Assert.IsTrue(SerializationUtility.IsSerializable(typeof(Serializable)), "Type is serializable");
        }
Exemplo n.º 36
0
    /*
     * private IEnumerable<Type> GetAllTypes()
     * {
     *  List<Type> l_types = new List<Type>();
     *  if(ExecutedEvents != null)
     *  {
     *      for(int i = 0; i < ExecutedEvents.Count; i++)
     *      {
     *          EventEntry l_eventEntry = (EventEntry) ExecutedEvents[i];
     *          if (!l_types.Contains(l_eventEntry.ExecutedEvent.GetType()))
     *          {
     *              l_types.Add(l_eventEntry.ExecutedEvent.GetType());
     *          }
     *      }
     *  }
     *  return l_types;
     * }
     */

    protected override void OnEnable()
    {
        base.OnEnable();
        ExecutedEvents = new List <object>();


        EventQueue.OnEventExecuted = (AEvent p_event) =>
        {
            EventEntry l_eventEntry = new EventEntry()
            {
                ExecutionTime = DateTime.Now.ToString("hh:mm:ss.fff tt"),
                ExecutedEvent = (AEvent)SerializationUtility.CreateCopy(p_event)
            };
            ExecutedEvents.Add(l_eventEntry);
        };
    }
Exemplo n.º 37
0
        public void SaveUserSession(UserEntity user)
        {
            var serializationUtility = new SerializationUtility();

            var userJson = serializationUtility.Serialize<UserEntity>(user);

            //如果已经存在用户信息,那么就更新
            if (ApplicationData.Current.LocalSettings.Values.ContainsKey(LoginService.USERKEY))
            {
                ApplicationData.Current.LocalSettings.Values[LoginService.USERKEY] = userJson;
            }
            else
            {
                ApplicationData.Current.LocalSettings.Values.Add(LoginService.USERKEY, userJson);
            }

            //调用登录状态委托
            if (LoginService.LoginIn != default(LoginInEventHandler))
            {
                LoginService.LoginIn(null, new LoginEventArgs() { IsLoginIn = true, User = user });
            }
        }
Exemplo n.º 38
0
        public UserEntity GetUserSession()
        {
            var serializationUtility = new SerializationUtility();

            object userJson = string.Empty;

            ApplicationData.Current.LocalSettings.Values.TryGetValue(LoginService.USERKEY, out userJson);

            return serializationUtility.DeSerialize<UserEntity>(userJson == default(object) ? string.Empty : userJson.ToString());
        }
Exemplo n.º 39
0
        public async Task GetSpartanImage_IsSerializable(string gamertag)
        {
            var query = new GetSpartanImage()
                .ForPlayer(gamertag);

            var result = await Global.Session.Query(query);

            var serializationUtility = new SerializationUtility<GetImage>();
            serializationUtility.AssertRoundTripSerializationIsPossible(result);
        }
        private async void DownloadProgress(DownloadOperation downloadOperation)
        {
            double percent = 0;
            if (downloadOperation.Progress.TotalBytesToReceive > 0)
            {
                percent = downloadOperation.Progress.BytesReceived * 100 / downloadOperation.Progress.TotalBytesToReceive;
            }

            var currentDownloadCoursePeriods = this.Course.CoursePeriods.Single<CoursePeriodEntity>(coursePeriods => coursePeriods.ID == this.ActivelyDownload.Single<KeyValuePair<Guid, DownloadOperation>>(activelyDownload => activelyDownload.Value == downloadOperation).Key);

            //只有当进度为100%时,才开始缓存文件信息
            if (percent >= 100)
            {
                #region 缓存视频信息
                var downloadedLessonDataEntityContainer = ApplicationData.Current.LocalSettings.CreateContainer(App.Settings.DownloadedLessonDataEntityContainerName, ApplicationDataCreateDisposition.Always);

                var serializeUtility = new SerializationUtility();

                //如果本地已经存在这个Key,那么表示缓存过视频,那么就需要更新视频信息及视频流
                if (downloadedLessonDataEntityContainer.Values.ContainsKey(currentDownloadCoursePeriods.ID.ToString()))
                {
                    //更新视频基本信息
                    downloadedLessonDataEntityContainer.Values[currentDownloadCoursePeriods.ID.ToString()] = serializeUtility.Serialize<CoursePeriodEntity>(currentDownloadCoursePeriods);
                }
                //如果本地不存在这个Key,那么就表示没有缓存过视频,就需要录入视频信息及视频流
                else
                {
                    //录入视频基本信息
                    downloadedLessonDataEntityContainer.Values.Add(currentDownloadCoursePeriods.ID.ToString(), serializeUtility.Serialize<CoursePeriodEntity>(currentDownloadCoursePeriods));
                }
                #endregion
            }
            await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, new Windows.UI.Core.DispatchedHandler(() =>
             {
                 currentDownloadCoursePeriods.IsDownloading = true;
                 currentDownloadCoursePeriods.DownloadProgress = percent;
             }));
        }