Пример #1
0
 public T GetData <T>(ESBMessageSerializerType serializerType = ESBMessageSerializerType.Xml)
 {
     if (Content == null)
     {
         return(default(T));
     }
     if (serializerType == ESBMessageSerializerType.BinaryBase64)
     {
         return(SerializationUtility.BinaryDeserialize <T>(Content));
     }
     if (serializerType == ESBMessageSerializerType.Json)
     {
         return(SerializationUtility.JsonDeserialize <T>(Content));
     }
     return(SerializationUtility.XmlDeserialize <T>(Content));
 }
Пример #2
0
        private static string GetObjectValueAsKey(object obj)
        {
            Type type = obj.GetType();

            if (s_IdentityType.IsAssignableFrom(type))
            {
                return(Invoker.PropertyGet(s_IdentityType, obj, "SysNo", false, true).ToString());
            }
            else if (CanAsKey(type))
            {
                return(obj.ToString());
            }
            else
            {
                return(SerializationUtility.BinarySerialize(obj));
            }
        }
Пример #3
0
        internal static void LoadResouce(string cacheKey, string filePath)
        {
            cacheKey = cacheKey.ToUpper();
            MessageResource res = SerializationUtility.LoadFromXml <MessageResource>(filePath);

            lock (s_SyncObj)
            {
                if (s_MessageResDictionary.ContainsKey(cacheKey))
                {
                    s_MessageResDictionary[cacheKey] = res;
                }
                else
                {
                    s_MessageResDictionary.Add(cacheKey, res);
                }
            }
        }
Пример #4
0
        private static WebPrinterConfigData GetData()
        {
            WebPrinterConfigData data = MemoryCache.Default.Get(CACHE_KEY) as WebPrinterConfigData;

            if (data == null)
            {
                lock (s_SyncObj)
                {
                    data = MemoryCache.Default.Get(CACHE_KEY) as WebPrinterConfigData;
                    if (data == null)
                    {
                        string path = GetConfigFilePath();
                        if (File.Exists(path))
                        {
                            data = SerializationUtility.LoadFromXml <WebPrinterConfigData>(path);
                        }
                        else
                        {
                            data = new WebPrinterConfigData
                            {
                                HandlerRegister = new HandlerRegister
                                {
                                    Handlers = new List <WebPrintHandlerSetting>(0)
                                },
                                PrinterSetting = new WebPrinterSetting
                                {
                                    Printers = new List <WebPrinter>(0)
                                }
                            };
                        }
                        CacheItemPolicy policy = new CacheItemPolicy();
                        policy.ChangeMonitors.Add(new HostFileChangeMonitor(new List <string> {
                            path
                        }));
                        policy.AbsoluteExpiration = new DateTimeOffset(2999, 12, 31, 23, 59, 59, TimeSpan.Zero);
                        MemoryCache.Default.Set(CACHE_KEY, data, policy);
                    }
                }
            }
            return(data);
        }