public static string UriAppendQuery(
     [DekiScriptParam("base uri")] XUri uri,
     [DekiScriptParam("query parameters to append")] Hashtable args
     )
 {
     foreach (DictionaryEntry entry in args)
     {
         string value = SysUtil.ChangeType <string>(entry.Value);
         if (value != null)
         {
             uri = uri.With((string)entry.Key, value);
         }
     }
     return(uri.ToString());
 }
Exemplo n.º 2
0
 public bool TryGetValue(DekiScriptLiteral index, out DekiScriptLiteral value)
 {
     if (index == null)
     {
         throw new ArgumentNullException("index");
     }
     if ((index.ScriptType == DekiScriptType.NUM) || (index.ScriptType == DekiScriptType.STR))
     {
         return(TryGetValue(SysUtil.ChangeType <string>(index.NativeValue), out value));
     }
     else
     {
         throw new DekiScriptBadTypeException(Location.None, index.ScriptType, new[] { DekiScriptType.NUM, DekiScriptType.STR });
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// 生成二维码地址(扫码支付模式一)
        /// </summary>
        /// <param name="product_id"></param>
        /// <returns></returns>
        public string CreateScanCode(string product_id)
        {
            var dics = new SortedDictionary <string, object>
            {
                ["time_stamp"] = DateTime.Now.ToLocalSeconds().ToString(),
                ["nonce_str"]  = SysUtil.GenerateNonceStr(),
                ["product_id"] = product_id,
                ["appid"]      = ApiConfig.AppId,
                ["mch_id"]     = ApiConfig.MchId
            };
            var encStr = GetSignContent(dics);
            var sign   = GetSign(encStr);

            return(string.Concat("weixin://wxpay/bizpayurl?", encStr, "&sign=", sign));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Try to get an item from the queue.
        /// </summary>
        /// <param name="item">Storage location for the item to be removed.</param>
        /// <returns><see langword="True"/> if the dequeue succeeded.</returns>
        public bool TryDequeue(out T item)
        {
            // TODO (arnec): should convert return to enum to indicate contention vs. empty queue

            // loop until we successfully dequeue a node or the queue is empty
            while (true)
            {
                // capture the current state of the queue
                SingleLinkNode <T> curHead     = _head;
                SingleLinkNode <T> curHeadNext = curHead.Next;
                SingleLinkNode <T> curTail     = _tail;

                // check if the current head and tail are equal
                if (ReferenceEquals(curHead, curTail))
                {
                    // check if the current head has a non-empty Next reference
                    if (curHeadNext == null)
                    {
                        // unable to find an item in the queue
                        item = default(T);
                        return(false);
                    }

                    // tail reference was not properly updated in an earlier attempt, update it now (see note above)
                    SysUtil.CAS(ref _tail, curTail, curHeadNext);
                }
                else if (curHeadNext == null)
                {
                    // head and tail differ, but we have no next, i.e. contention changed the queue before we
                    // captured its state
                    item = default(T);
                    return(false);
                }
                else
                {
                    // try to replace the current head with the current head's Next reference
                    if (SysUtil.CAS(ref _head, curHead, curHeadNext))
                    {
                        // we have successfully retrieved the head of the queue
                        item = curHeadNext.Item;

                        // clear out the Item field so the GC can reclaim the memory
                        curHeadNext.Item = default(T);
                        return(true);
                    }
                }
            }
        }
Exemplo n.º 5
0
 public DekiScriptLiteral this[DekiScriptLiteral index] {
     get {
         if (index == null)
         {
             return(DekiScriptNil.Value);
         }
         if (index.ScriptType == DekiScriptType.NUM)
         {
             return(this[SysUtil.ChangeType <int>(index.NativeValue)]);
         }
         else
         {
             return(DekiScriptNil.Value);
         }
     }
 }
Exemplo n.º 6
0
        /// <summary>
        /// Try to pop an item from the top of the stack
        /// </summary>
        /// <param name="item">Storage location for the item to be removed.</param>
        /// <returns><see langword="True"/> if the pop succeeded.</returns>
        public bool TryPop(out T item)
        {
            SingleLinkNode <T> node;

            do
            {
                node = _head;
                if (node == null)
                {
                    item = default(T);
                    return(false);
                }
            } while(!SysUtil.CAS(ref _head, node, node.Next));
            item = node.Item;
            return(true);
        }
Exemplo n.º 7
0
        public T EnvAt <T>(string path)
        {
            if (path == null)
            {
                throw new ArgumentNullException("path");
            }
            DekiScriptMap env = DreamContext.Current.GetState <DekiScriptMap>();

            if (env == null)
            {
                return(default(T));
            }
            DekiScriptLiteral value = env.GetAt(path);

            return(SysUtil.ChangeType <T>(value.NativeValue));
        }
Exemplo n.º 8
0
        void OnSnapshotBeginComparing(PackedMemorySnapshot snapshot)
        {
            string filename = string.Format("{0}/{1}-{2}.memsnap",
                                            Application.persistentDataPath,
                                            SysUtil.FormatDateAsFileNameString(DateTime.Now),
                                            SysUtil.FormatTimeAsFileNameString(DateTime.Now));

            System.Runtime.Serialization.Formatters.Binary.BinaryFormatter bf = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
            using (Stream stream = File.Open(filename, FileMode.Create))
            {
                bf.Serialize(stream, snapshot);
            }

            _compBeginFilename     = filename;
            _isRequestingCompBegin = false;
        }
Exemplo n.º 9
0
 public override bool LeftTetris()
 {
     if (m_oNextTetris == null)
     {
         return(false);
     }
     if (base.LeftTetris())
     {
         GameProto.PlayerRequestMove oRequest = new GameProto.PlayerRequestMove();
         oRequest.EDirection = GameProto.EMoveDirection.EmdLeft;
         oRequest.FTick      = m_fTick;
         SysUtil.SendMessage(GameControler.Instance().proSession, oRequest, "GameProto.PlayerRequestMove");
         return(true);
     }
     return(false);
 }
Exemplo n.º 10
0
 public override bool RightRotation()
 {
     if (m_oNextTetris == null)
     {
         return(false);
     }
     if (base.RightRotation())
     {
         GameProto.PlayerRequestRotation oRequest = new GameProto.PlayerRequestRotation();
         oRequest.EDirection = GameProto.ERotationDirection.ErdRight;
         oRequest.FTick      = m_fTick;
         SysUtil.SendMessage(GameControler.Instance().proSession, oRequest, "GameProto.PlayerRequestRotation");
         return(true);
     }
     return(false);
 }
Exemplo n.º 11
0
        private void Recv()
        {
            Logger.Log("sock recv thread start...");
            while (!close && !interrupted)
            {
                try
                {
                    long interval = DateTime.Now.Ticks;

                    if (sock == null)
                    {
                        Logger.LogWarning("sock is null by not close");
                        break;
                    }
                    else if (!Connected)
                    {
                        Logger.LogWarning("sock disconnected by not close");
                        break;
                    }
                    else
                    {
                        OnRecv();
                    }

                    interval = System.DateTime.Now.Ticks - interval;
                    int sleep = 10 - (int)SysUtil.TickToMilliSec(interval);
                    if (sleep > 0)
                    {
                        Thread.Sleep(sleep);
                    }
                }
                catch (System.Exception ex)
                {
                    if (!(ex is System.Threading.ThreadAbortException))
                    {
                        Logger.LogError(ex);
                    }
                    else
                    {
                        Logger.Log("recv thread abort");
                    }
                    interrupted = true;
                }
            }
            interrupted = true;
            Logger.Log("sock recv thread end normally");
        }
Exemplo n.º 12
0
 /// <summary>
 /// Abre o armazenamento da memória mapeada.
 /// </summary>
 /// <param name="fileName"></param>
 /// <param name="viewCount"></param>
 /// <param name="viewSize"></param>
 /// <param name="initialSizeMB"></param>
 public void OpenMemoryMappedStore(string fileName, uint viewCount, uint viewSize, uint initialSizeMB)
 {
     try
     {
         _fileName      = fileName;
         _viewCount     = viewCount;
         _viewSize      = SysUtil.AllignViewSize(viewSize);
         _initialSizeMB = initialSizeMB;
         _mmf           = MmfFile.Create(_fileName, (ulong)(_initialSizeMB * 0x100000), false);
         _viewManager   = new ViewManager(_mmf, _viewSize);
         _viewManager.CreateInitialViews(_viewCount);
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemplo n.º 13
0
    public void OnPlayerRequestGameTest(byte[] pBuf)
    {
        GameProto.PlayerRequestGameTest oTest = GameProto.PlayerRequestGameTest.Parser.ParseFrom(pBuf);
        if (oTest == null)
        {
            SampleDebuger.LogYellow("OnTest error parse");
            return;
        }

        SampleDebuger.Log(oTest.SzTest.ToString());

        oTest.SzTest = String.Format("{0}, {1}, {2}, {3}, {4}, {5}",
                                     "sessionobject.cs", 106, "SessionObject::OnRecv", dw1++,
                                     ToString(), DateTime.Now.ToLocalTime().ToString());

        SysUtil.SendMessage(m_pSession, oTest, "GameProto.PlayerRequestGameTest");
    }
Exemplo n.º 14
0
        /// <summary>
        /// Get delegate for enqueuing messages asynchronously to named queue.
        /// </summary>
        /// <param name="queueName">Queue name.</param>
        /// <returns>Delegate for enqueuing message asynchronously.</returns>
        public Action <string> GetEnqueueMessageCallback(SqsQueueName queueName)
        {
repeat:
            SqsQueueDelayedSendClient queue;
            var directory = _directory;

            if (!directory.TryGetValue(queueName.Value, out queue))
            {
                var newDirectory = new Dictionary <string, SqsQueueDelayedSendClient>(directory);
                newDirectory[queueName.Value] = queue = new SqsQueueDelayedSendClient(_client, queueName, _timerFactory);
                if (!SysUtil.CAS(ref _directory, directory, newDirectory))
                {
                    goto repeat;
                }
            }
            return(queue.EnqueueMessage);
        }
Exemplo n.º 15
0
 public DeviceInfo GetLocalInfo()
 {
     try
     {
         return(new DeviceInfo()
         {
             IP = SysUtil.GetLocalIP(),
             DeviceName = this.DeviceName,
             NickName = this.NickName
         });
     }
     catch (Exception e)
     {
         Logging.Error(e);
     }
     return(null);
 }
Exemplo n.º 16
0
        /// <summary>
        /// Retrieve an output/return value from the finished command.
        /// </summary>
        /// <typeparam name="T">Returned value type</typeparam>
        /// <param name="key">Name of returned parameter (provided previously using 'WithOutput()' or 'WithInOut()' or 'WithReturn()'</param>
        /// <param name="def">Value to return if returned value is null or DbNull</param>
        /// <returns>Converted value</returns>
        public T At <T>(string key, T def)
        {
            object value = ((IDataParameter)_command.Parameters[_factory.ParameterChar + key]).Value;

            if (value == null)
            {
                return(def);
            }
            if (value is DBNull)
            {
                return(def);
            }
            if (value is T)
            {
                return((T)value);
            }
            return((T)SysUtil.ChangeType(value, typeof(T)));
        }
Exemplo n.º 17
0
        public static IList <ServiceBE> GetServicesByQuery(DreamContext context, out uint totalCount, out uint queryCount)
        {
            ServiceType   filterType = context.GetParam("type", ServiceType.UNDEFINED);
            uint          limit, offset;
            SortDirection sortDir;
            string        sortFieldString;

            Utils.GetOffsetAndCountFromRequest(context, 100, out limit, out offset, out sortDir, out sortFieldString);

            // Attempt to read the sort field.  If a parsing error occurs, default to undefined.
            ServicesSortField sortField = ServicesSortField.UNDEFINED;

            if (!String.IsNullOrEmpty(sortFieldString))
            {
                try { sortField = SysUtil.ChangeType <ServicesSortField>(sortFieldString); } catch { }
            }
            return(DbUtils.CurrentSession.Services_GetByQuery(filterType == ServiceType.UNDEFINED ? null : filterType.ToString(), sortDir, sortField, offset, limit, out totalCount, out queryCount));
        }
Exemplo n.º 18
0
        public static AssetDesc CreateDesc(string assetPath)
        {
            string unixStyle = SysUtil.ToUnixPath(SysUtil.TrimHeadTailSeparators(assetPath));
            string filename  = Path.GetFileNameWithoutExtension(unixStyle);
            string ext       = Path.GetExtension(unixStyle);

            if (string.IsNullOrEmpty(filename))
            {
                Logging.Instance.Log("CreateDesc() failed (invalid asset path): {0}.", assetPath);
                return(null);
            }

            string fullpath = Path.Combine(GState.AssetRoot, SysUtil.ToWindowsPath(unixStyle));

            if (!File.Exists(fullpath))
            {
                Logging.Instance.Log("CreateDesc() failed (file not found): {0}.", assetPath);
                return(null);
            }

            string digest = SysUtil.GetFileMD5AsString(fullpath);

            if (string.IsNullOrEmpty(digest))
            {
                Logging.Instance.Log("CreateDesc() failed (md5 calculating failed): {0}.", fullpath);
                return(null);
            }

            AssetType type = AssetType.Unknown;

            if (ext.ToLower() == "png")
            {
                type = AssetType.PNG;
            }

            AssetDesc desc = new AssetDesc();

            desc.LinkTime = DateTime.Now;
            desc.Name     = filename + "_" + desc.LinkTime.ToString("yyyyMMdd_HHmmss");
            desc.Type     = type;
            desc.Path     = unixStyle;
            desc.Digest   = digest;
            return(desc);
        }
Exemplo n.º 19
0
        //--- Class Methods ---

        /// <summary>
        /// Add a named callback to the clock.
        /// </summary>
        /// <param name="name">Unique key for the callback.</param>
        /// <param name="callback">Callback action.</param>
        public static void AddCallback(string name, ClockCallback callback)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException("name", "name cannot be null or empty");
            }
            if (callback == null)
            {
                throw new ArgumentNullException("callback");
            }

            // add callback
#if LOCKFREEE
            var newNode = new SingleLinkNode <NamedClockCallback>(new NamedClockCallback(name, callback));
            do
            {
                newNode.Next = _head;
            } while(!SysUtil.CAS(ref _head, newNode.Next, newNode));
#else
            lock (_syncRoot) {
                int index;

                // check if there is an empty slot in the callbacks array
                for (index = 0; index < _callbacks.Length; ++index)
                {
                    if (_callbacks[index].Value == null)
                    {
                        _callbacks[index] = new NamedClockCallback(name, callback);
                        return;
                    }
                }

                // make room to add a new thread by doubling the array size and copying over the existing entries
                var newArray = new NamedClockCallback[2 * _callbacks.Length];
                Array.Copy(_callbacks, newArray, _callbacks.Length);

                // assign new thread
                newArray[index] = new NamedClockCallback(name, callback);

                // update instance field
                _callbacks = newArray;
            }
#endif
        }
Exemplo n.º 20
0
 public void Open()
 {
     if (this._enableTracking)
     {
         Debug.LogFormat("[ResourceTracker] info: {0} ", new object[1]
         {
             (object)"already enabled, ignored."
         });
     }
     else
     {
         try
         {
             string str = Path.Combine(Application.get_persistentDataPath(), "mem_logs");
             if (!Directory.Exists(str))
             {
                 Directory.CreateDirectory(str);
             }
             DateTime now      = DateTime.Now;
             string   path2    = string.Format("{0}_{1}_alloc.txt", (object)SysUtil.FormatDateAsFileNameString(now), (object)SysUtil.FormatTimeAsFileNameString(now));
             string   fileName = Path.Combine(str, path2);
             this._logWriter           = new System.IO.FileInfo(fileName).CreateText();
             this._logWriter.AutoFlush = true;
             this._enableTracking      = true;
             Debug.LogFormat("[ResourceTracker] tracking enabled: {0} ", new object[1]
             {
                 (object)fileName
             });
         }
         catch (Exception ex)
         {
             Debug.LogErrorFormat("[ResourceTracker] Open() failed, error: {0} ", new object[1]
             {
                 (object)ex.Message
             });
             if (this._logWriter != null)
             {
                 this._logWriter.Close();
                 this._logWriter = (StreamWriter)null;
             }
             this._enableTracking = false;
         }
     }
 }
Exemplo n.º 21
0
        public static Hashtable ListCombine(
            [DekiScriptParam("list of keys")] ArrayList keys,
            [DekiScriptParam("list of values")] ArrayList values
            )
        {
            Hashtable result = new Hashtable(StringComparer.OrdinalIgnoreCase);

            for (int i = 0; i < Math.Min(keys.Count, values.Count); ++i)
            {
                try {
                    string key = SysUtil.ChangeType <string>(keys[i]);
                    if (!string.IsNullOrEmpty(key))
                    {
                        result[key] = values[i];
                    }
                } catch { }
            }
            return(result);
        }
Exemplo n.º 22
0
        private void Tile_Clicked(object sender, EventArgs e)
        {
            MetroTileItem ti = sender as MetroTileItem;

            if (ti == null)
            {
                return;
            }

            ti.Checked = true;
            if (m_selectedTile != null)
            {
                m_selectedTile.Checked = false;
            }

            m_selectedTile  = ti;
            m_selectedAsset = SysUtil.GetRelativePath((string)ti.Tag, m_assetRoot);
            SysPost.InvokeMulticast(this, AssetSelected);
        }
Exemplo n.º 23
0
        public static Size GetImageSize(string assetPath)
        {
            string fullpath = Path.Combine(GState.AssetRoot, SysUtil.ToWindowsPath(assetPath));

            if (!File.Exists(fullpath))
            {
                Logging.Instance.Log("CreateDesc() failed (file not found): {0}.", assetPath);
                return(Size.Empty);
            }

            try
            {
                return(Image.FromFile(fullpath).Size);
            }
            catch (Exception)
            {
                return(Const.ZERO_SIZE);
            }
        }
Exemplo n.º 24
0
        private ArrayList AtXPathList(XDoc doc, string xpath, Hashtable namespaces, bool asXml)
        {
            XDoc node;

            if (namespaces != null)
            {
                // initialize a namespace manager
                XmlNamespaceManager nsm = new XmlNamespaceManager(SysUtil.NameTable);
                foreach (DictionaryEntry ns in namespaces)
                {
                    nsm.AddNamespace((string)ns.Key, SysUtil.ChangeType <string>(ns.Value));
                }
                node = doc.AtPath(xpath, nsm);
            }
            else
            {
                // use default namespace manager
                node = doc[xpath];
            }

            // iterate over all matches
            ArrayList result = new ArrayList();

            foreach (XDoc item in node)
            {
                if (asXml)
                {
                    if (item.AsXmlNode.NodeType == XmlNodeType.Attribute)
                    {
                        result.Add(((XmlAttribute)item.AsXmlNode).OwnerElement.OuterXml);
                    }
                    else
                    {
                        result.Add(item.AsXmlNode.OuterXml);
                    }
                }
                else
                {
                    result.Add(item.AsText);
                }
            }
            return(result);
        }
Exemplo n.º 25
0
        public IList <ulong> Tags_GetPageIds(uint tagid)
        {
            List <ulong> ids = new List <ulong>();

            // Note that joining on pages is necessary to ensure that the page hasn't been deleted
            Catalog.NewQuery(@" /* Tags_GetPages */
SELECT tag_map.tagmap_page_id FROM pages
JOIN tag_map
    ON page_id = tagmap_page_id
WHERE tagmap_tag_id = ?TAGID;")
            .With("TAGID", tagid)
            .Execute(delegate(IDataReader dr) {
                while (dr.Read())
                {
                    ids.Add(SysUtil.ChangeType <ulong>(dr[0]));
                }
            });
            return(ids);
        }
Exemplo n.º 26
0
        public static TextureRenderInfo BuildSingleTexture(Gwen.Renderer.Tao renderer, string url)
        {
            if (!ResProtocol.IsSingleTexture(url))
            {
                return(null);
            }

            AssetDesc desc = Scene.Instance.GetAssetDesc(url);

            if (desc == null)
            {
                return(null);
            }

            string fullpath = Path.Combine(GState.AssetRoot, SysUtil.ToWindowsPath(desc.Path));

            if (!File.Exists(fullpath))
            {
                return(null);
            }

            Gwen.Texture t;
            t = new Gwen.Texture(renderer);
            if (t == null)
            {
                return(null);
            }

            t.Load(fullpath);
            if (t.Failed)
            {
                return(null);
            }

            TextureRenderInfo tri = new TextureRenderInfo();

            tri.u1      = 0;
            tri.v1      = 0;
            tri.u2      = 1;
            tri.v2      = 1;
            tri.texture = t;
            return(tri);
        }
Exemplo n.º 27
0
        /// <summary>
        /// Maps the file to the memory of the process.
        /// </summary>
        public void OpenMemoryMappedStore(string fileName, uint viewCount, uint viewSize, uint initialSizeMB)
        {
            try
            {
                _fileName      = fileName;
                _viewCount     = viewCount;
                _viewSize      = (uint)SysUtil.AllignViewSize(viewSize);
                _initialSizeMB = initialSizeMB;

                _mmf         = MmfFile.Create(_fileName, _initialSizeMB * StorageProviderBase.MB, false);
                _viewManager = new ViewManager(_mmf, _viewSize);
                _viewManager.CreateInitialViews(_viewCount);
            }
            catch (Exception e)
            {
                //Console.WriteLine("MmfStorage.OpenMemoryMappedStore" + "Error:" + e);
                throw;
            }
        }
Exemplo n.º 28
0
        private void btn_OpenA_Click(object sender, EventArgs e)
        {
            DialogResult result = openFileDialog1.ShowDialog();

            if (result == DialogResult.OK)
            {
                webBrowser1.Navigate("about:blank");
                tbd_filename1.Text = openFileDialog1.FileName;
                string sFilePath = openFileDialog1.FileName;

                if (SysUtil.GetFileExt(sFilePath) == ".doc")
                {
                    WordHelp helper = new WordHelp();
                    helper.Open(sFilePath);
                    string htmlFilePath = System.Windows.Forms.Application.StartupPath + "/TEMP/temp_" + DateTime.Now.Ticks + ".html";
                    helper.SaveAsHtml(htmlFilePath);

                    helper.Quit();
                    this.labelItem1.Text = "转换中";
                    Thread.Sleep(3000);

                    this.labelItem1.Text = "转换完毕";
                    // webBrowser1.Navigate(System.Windows.Forms.Application.StartupPath + "/ckeditor/samples/editor.html");

                    StreamReader reader = new StreamReader(htmlFilePath, Encoding.GetEncoding("gb2312"), true);


                    string html = reader.ReadToEnd();

                    html = html.Substring(html.IndexOf("punctuation'>"), html.Length - html.IndexOf("punctuation'>"));
                    html = html.Substring(13, html.IndexOf("</body>") - 12);

                    webBrowser1.Navigate(this.getEditorHTML(html));
                }
                else if (SysUtil.GetFileExt(sFilePath) == ".html")
                {
                    webBrowser1.Navigate(sFilePath);
                }

                a_isOpen = true;
            }
        }
        public static string UriBuild(
            [DekiScriptParam("base uri")] XUri uri,
            [DekiScriptParam("path segments to append (must a string or list of strings)", true)] object path,
            [DekiScriptParam("query parameters to append", true)] Hashtable args
            )
        {
            if (path is string)
            {
                uri = uri.AtPath((string)path);
            }
            else if (path is ArrayList)
            {
                foreach (string segment in (ArrayList)path)
                {
                    uri = uri.At(XUri.EncodeSegment(segment));
                }
            }
            if (args != null)
            {
                foreach (DictionaryEntry entry in args)
                {
                    string key = (string)entry.Key;

                    // remove existing parameter
                    uri = uri.WithoutParams(key);

                    // check if entry is a list of values
                    if (entry.Value is ArrayList)
                    {
                        foreach (var value in (ArrayList)entry.Value)
                        {
                            uri = uri.With(key, SysUtil.ChangeType <string>(value));
                        }
                    }
                    else if (entry.Value != null)
                    {
                        uri = uri.With(key, SysUtil.ChangeType <string>(entry.Value));
                    }
                }
            }
            return(uri.ToString());
        }
Exemplo n.º 30
0
    public void Open()
    {
        if (_enableTracking)
        {
            UnityEngine.Debug.LogFormat("[ResourceTracker] info: {0} ", "already enabled, ignored.");
            return;
        }

        try
        {
            string logDir = Path.Combine(Application.persistentDataPath, "mem_logs");
            if (!Directory.Exists(logDir))
            {
                Directory.CreateDirectory(logDir);
            }

            DateTime dt = DateTime.Now;

            string logFile = string.Format("{0}_{1}_alloc.txt", SysUtil.FormatDateAsFileNameString(dt), SysUtil.FormatTimeAsFileNameString(dt));
            string logPath = Path.Combine(logDir, logFile);

            _logWriter           = new FileInfo(logPath).CreateText();
            _logWriter.AutoFlush = true;
            _logPath             = logPath;

            _enableTracking = true;
            UnityEngine.Debug.LogFormat("[ResourceTracker] tracking enabled: {0} ", logPath);
        }
        catch (Exception ex)
        {
            UnityEngine.Debug.LogErrorFormat("[ResourceTracker] Open() failed, error: {0} ", ex.Message);

            if (_logWriter != null)
            {
                _logWriter.Close();
                _logWriter = null;
            }

            _enableTracking = false;
            _logPath        = "";
        }
    }