示例#1
0
        public bool FullLoader()
        {
            if (!System.IO.File.Exists(System.Windows.Forms.Application.StartupPath + @"\client.lic"))
            {
                //addToFile("STATE FALSE (no file client.lic)\r\n");
                return(false);
            }

            System.IO.TextReader trd = System.IO.File.OpenText("client.lic");
            try
            {
                string dd  = trd.ReadToEnd();
                string spn = this.getSPrivateNumber();

                //addToFile("FullLoader() ReadToEnd: " + dd);
                //addToFile("FullLoader() SPN Value : " + spn);

                //addToFile("client.lic === getSPrivateNumber() ::: " + dd + " === " + spn);
                if (dd == spn)
                {
                    trd.Close();
                    trd.Dispose();

                    //addToFile("STATE TRUE\r\n");
                    return(true);
                }
            }
            catch { }

            trd.Close();
            trd.Dispose();
            //addToFile("STATE FALSE\r\n");
            return(false);
        }
示例#2
0
 public virtual void Load(TextReader r, int size, int readChunkSize)
 {
     if (r == null)
     {
         return;
     }
     if (size <= 0)
     {
         size = InitialBufferSize;
     }
     if (readChunkSize <= 0)
     {
         readChunkSize = ReadBufferSize;
     }
     // System.out.println("load "+size+" in chunks of "+readChunkSize);
     try
     {
         data   = r.ReadToEnd().ToCharArray();
         base.n = data.Length;
     }
     finally
     {
         r.Dispose();
     }
 }
示例#3
0
        private static void LoadOption()
        {
            if (System.IO.File.Exists(FilePathOptions))
            {
                System.IO.TextReader tr = System.IO.File.OpenText(FilePathOptions);
                string line             = string.Empty;

                while (null != (line = tr.ReadLine()))
                {
                    string[] opt = line.Split('=');

                    if ((opt != null) && (opt.Length == 2))
                    {
                        switch (opt[0])
                        {
                        case "SaveOption":
                            try { Configuration.SaveOption = (ESaveOption)Enum.Parse(typeof(ESaveOption), opt[1], true); }
                            catch { }
                            break;

                        default:
                            break;
                        }
                    }
                }

                tr.Close();
                tr.Dispose();
            }
        }
示例#4
0
        public IList <string> ReadStopWords()
        {
            var result = new List <string>();

            System.IO.FileInfo   stopFileInfo = new System.IO.FileInfo(stopFileName);;
            System.IO.TextReader reader       = stopFileInfo.OpenText();;

            try
            {
                while (((System.IO.StreamReader)reader).EndOfStream == false)
                {
                    string word = reader.ReadLine();


                    result.Add(word.Trim());
                }
            }
            catch { } //TODO: Catch überarbeiten
            finally {
                if (reader != null)
                {
                    reader.Dispose();
                }
            }
            return(result);
        }
        internal void PopulateFromReader(object obj, IServiceProvider locator, SelectedSubmission.Result result, HashSet <string> processed, Revenj.Utility.ChunkedMemoryStream cms)
        {
            var str = obj as string;

            Revenj.Utility.BufferedTextReader reader;
            System.IO.TextReader _tr = null;
            if (str != null)
            {
                reader = cms.UseBufferedReader(str);
            }
            else
            {
                _tr    = obj as System.IO.TextReader ?? new System.IO.StringReader(obj.ToString());
                reader = cms.UseBufferedReader(_tr);
            }
            reader.Read(2);

            result.uri        = this.uri;
            result.Submission = this.Submission = _DatabaseCommon.FactoryUseCase1_Submission.SubmissionConverter.CreateFromRecord(reader, 1, locator);
            processed.Add("Submission");
            if (_tr != null)
            {
                _tr.Dispose();
            }
        }
 private void Close()
 {
     if (_OwnStream && _Reader != null)
     {
         _Reader.Close();
         _Reader.Dispose();
     }
     _Reader    = null;
     _OwnStream = false;
 }
示例#7
0
 public IniFile(System.IO.TextReader Stream, IniReadErrorEventHandler IniReadErrorCallback, bool CloseAfterRead = true)
 {
     this.o_Sections     = new ConcurrentDictionary <string, IniSection>();
     this.sFilename      = string.Empty;
     this.tmpStringBuild = new System.Text.StringBuilder();
     this.ReadIniFromTextStream(Stream, IniReadErrorCallback);
     if (CloseAfterRead)
     {
         Stream.Dispose();
     }
 }
示例#8
0
 public void Done()
 {
     try
     {
         input.Dispose();
     }
     catch (System.IO.IOException e)
     {
         Console.Error.WriteLine("Caught: " + e + "; ignoring.");
     }
 }
示例#9
0
        internal void ReadUnlockFile(string filePath)
        {
            try
            {
                if (System.IO.File.Exists(filePath))
                {
                    System.IO.TextReader tr = System.IO.File.OpenText(filePath);

                    bool   unlocked = false;
                    string region   = string.Empty;
                    string line     = string.Empty;

                    while (null != (line = tr.ReadLine()))
                    {
                        string[] la = line.Split(new char[] { '\t' }, StringSplitOptions.RemoveEmptyEntries);

                        /* True		<tab>	Oceania East */
                        if (la.Length == 2)
                        {
                            unlocked = bool.Parse(la[0].Trim());
                            region   = la[1].Trim();

                            bool found = false;

                            foreach (var inner in Configuration.UnlockedList)
                            {
                                if (region == inner.Region)
                                {
                                    found = true;
                                }
                            }

                            if (!found)
                            {
                                Configuration.UnlockedList.Add(new UnlockedData()
                                {
                                    Region = region, Unlocked = unlocked
                                });
                            }
                        }
                    }

                    tr.Close();
                    tr.Dispose();
                }
            }
            catch (Exception exc)
            {
                Exception c = exc;                 // to remove compiler warnings
                c.Source = "Composer";
            }
        }
示例#10
0
        static StackObject *Dispose_1(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 1);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            System.IO.TextReader instance_of_this_method = (System.IO.TextReader) typeof(System.IO.TextReader).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            instance_of_this_method.Dispose();

            return(__ret);
        }
示例#11
0
        internal void ReadCollectedFile(string filePath)
        {
            try
            {
                if (System.IO.File.Exists(filePath))
                {
                    System.IO.TextReader tr = System.IO.File.OpenText(filePath);

                    int    collected = 0;
                    string city      = string.Empty;
                    string line      = string.Empty;

                    while (null != (line = tr.ReadLine()))
                    {
                        string[] la = line.Split(new char[] { '\t' }, StringSplitOptions.RemoveEmptyEntries);

                        /* 25	Lodwar, KE */
                        if (la.Length == 2)
                        {
                            collected = int.Parse(la[0].Trim());
                            city      = la[1].Trim();

                            foreach (var item in Configuration.ResourceList)
                            {
                                if (item.City == city)
                                {
                                    item.Collected = collected;
                                }
                            }
                        }
                    }

                    tr.Close();
                    tr.Dispose();
                }
            }
            catch (Exception exc)
            {
                exc.Source = "Composer";                 // to remove compiler warnings
            }
        }
示例#12
0
        public static string ReadToHtml(string htmlPath, System.Collections.Hashtable htReplace)
        {
            try
            {
                System.IO.TextReader reader = System.IO.File.OpenText(AppDomain.CurrentDomain.BaseDirectory + htmlPath);
                string text = reader.ReadToEnd();
                reader.Close();
                reader.Dispose();

                System.Collections.IDictionaryEnumerator ie = htReplace.GetEnumerator();
                while (ie.MoveNext())
                {
                    text = text.Replace(ie.Key.ToString(), ie.Value.ToString());
                }
                return(text);
            }
            catch (Exception)
            {
                return("");
            }
        }
        public double EvalStatement(System.IO.TextReader command, object x)
        {
            if (command == null)
            {
                throw new System.ArgumentNullException("command");
            }

            _reader            = command;
            _x                 = x;
            _strBuilder.Length = 0;
            _parenCount        = 0;
            _current           = (char)0;

            double result = this.EvalStatement();

            _reader.Dispose();
            _x = null;
            _strBuilder.Length = 0;
            _parenCount        = 0;
            _current           = (char)0;

            return(result);
        }
        public double EvalStatement(string command, object x)
        {
            var r = _readerPool.GetInstance();

            r.Reset(command);

            _reader            = r;
            _x                 = x;
            _strBuilder.Length = 0;
            _parenCount        = 0;
            _current           = (char)0;

            double result = this.EvalStatement();

            _reader.Dispose();
            _readerPool.Release(_reader as ReusableStringReader);
            _x = null;
            _strBuilder.Length = 0;
            _parenCount        = 0;
            _current           = (char)0;

            return(result);
        }
示例#15
0
 public virtual void Load( TextReader r, int size, int readChunkSize )
 {
     if ( r == null )
     {
         return;
     }
     if ( size <= 0 )
     {
         size = InitialBufferSize;
     }
     if ( readChunkSize <= 0 )
     {
         readChunkSize = ReadBufferSize;
     }
     // System.out.println("load "+size+" in chunks of "+readChunkSize);
     try
     {
         data = r.ReadToEnd().ToCharArray();
         base.n = data.Length;
     }
     finally
     {
         r.Dispose();
     }
 }
示例#16
0
        protected void FillBuff()
        {
            if (maxNextCharInd == available)
            {
                if (available == bufsize)
                {
                    if (tokenBegin > 2048)
                    {
                        bufpos    = maxNextCharInd = 0;
                        available = tokenBegin;
                    }
                    else if (tokenBegin < 0)
                    {
                        bufpos = maxNextCharInd = 0;
                    }
                    else
                    {
                        ExpandBuff(false);
                    }
                }
                else if (available > tokenBegin)
                {
                    available = bufsize;
                }
                else if ((tokenBegin - available) < 2048)
                {
                    ExpandBuff(true);
                }
                else
                {
                    available = tokenBegin;
                }
            }

            int i;

            try {
                if (stream_closed || (i = inputStream.Read(buffer, maxNextCharInd, available - maxNextCharInd)) <= 0)
                {
                    stream_closed = true;
                        #if PCL || NETSTANDARD1_0 || NETSTANDARD1_1 || NETSTANDARD1_2 || NETSTANDARD1_3 || NETSTANDARD1_4 || NETSTANDARD1_5 || NETSTANDARD1_6 || NETCOREAPP1_0 || NETCOREAPP1_1
                    inputStream.Dispose();
                        #else
                    inputStream.Close();
                        #endif
                    throw new System.IO.IOException();
                }
                else
                {
                    maxNextCharInd += i;
                }
                return;
            }
            catch (System.IO.IOException e) {
                --bufpos;
                backup(0);
                if (tokenBegin == -1)
                {
                    tokenBegin = bufpos;
                }
                throw e;
            }
        }
示例#17
0
        /// <summary>
        /// 将权限值写入菜单的对象中,方便在每个页面打开时取值
        /// </summary>
        /// <param name="server">server context 对象</param>
        /// <param name="functionCodes">当前用户的权限列表</param>
        /// <returns></returns>
        public string initQuery(HttpServerUtility server, List <string> functionCodes)
        {
            string response = string.Empty;

            System.IO.TextReader tr = System.IO.File.OpenText(server.MapPath("./api/init.json"));
            response = tr.ReadToEnd();
            tr.Close();
            tr.Dispose();
            Newtonsoft.Json.Linq.JObject jo = Newtonsoft.Json.Linq.JObject.Parse(response);
            //开始重新生成初始化数据以设置菜单显示
            foreach (Newtonsoft.Json.Linq.JToken jt in jo["menuInfo"])
            {
                Newtonsoft.Json.Linq.JToken jtTag = jt["tag"];
                string tagStr = string.Empty;
                if (jtTag != null)
                {
                    tagStr = jtTag.ToString();
                }
                //第一层菜单
                if (tagStr != string.Empty)
                {
                    //有权限控
                    if (!functionCodes.Contains(tagStr))
                    {
                        jt.Remove();
                        continue;
                    }
                    else
                    {
                        string func = tagStr.Split('_')[0];
                        foreach (string funright in functionCodes)
                        {
                            if (funright.IndexOf(func) > -1)
                            {
                                jt["access"] = jt["access"] + "," + funright.Replace(func + "_", "");
                            }
                        }
                    }
                }
                //开始下一级
                foreach (Newtonsoft.Json.Linq.JToken ch in jt["child"])
                {
                    Newtonsoft.Json.Linq.JToken jtTag1 = ch["tag"];
                    string tagStr1 = string.Empty;
                    if (jtTag1 != null)
                    {
                        tagStr1 = jtTag1.ToString();
                    }
                    //第一层菜单
                    if (tagStr1 != string.Empty)
                    {
                        //有权限控
                        if (!functionCodes.Contains(tagStr1))
                        {
                            ch.Remove();
                            continue;
                        }
                        else
                        {
                            string func = tagStr1.Split('_')[0];
                            foreach (string funright in functionCodes)
                            {
                                if (funright.IndexOf(func) > -1)
                                {
                                    ch["access"] = ch["access"] + "," + funright.Replace(func + "_", "");
                                }
                            }
                        }
                    }
                    //开始下一级
                    foreach (Newtonsoft.Json.Linq.JToken ch1 in ch["child"])
                    {
                        Newtonsoft.Json.Linq.JToken jtTag2 = ch1["tag"];
                        string tagStr2 = string.Empty;
                        if (jtTag2 != null)
                        {
                            tagStr2 = jtTag2.ToString();
                        }
                        //第一层菜单
                        if (tagStr2 != string.Empty)
                        {
                            //有权限控
                            if (!functionCodes.Contains(tagStr2))
                            {
                                ch1.Remove();
                                continue;
                            }
                            else
                            {
                                string func = tagStr2.Split('_')[0];
                                foreach (string funright in functionCodes)
                                {
                                    if (funright.IndexOf(func) > -1)
                                    {
                                        ch1["access"] = ch1["access"] + "," + funright.Replace(func + "_", "");
                                    }
                                }
                            }
                        }
                        //不进行下一级了
                    }
                }
            }
            return(jo.ToString());
        }
示例#18
0
 public virtual void Dispose()
 {
     backingReader.Dispose();
 }
示例#19
0
        internal void ReadResourceFile(string filePath)
        {
            try
            {
                if (System.IO.File.Exists(filePath))
                {
                    System.IO.TextReader tr = System.IO.File.OpenText(filePath);
                    string key    = string.Empty;
                    int    amount = 0;
                    string city   = string.Empty;
                    string region = string.Empty;
                    string line   = string.Empty;

                    while (null != (line = tr.ReadLine()))
                    {
                        string[] la = line.Split(new char[] { '\t' }, StringSplitOptions.RemoveEmptyEntries);

                        /*
                         *      Acai
                         *      Amount Needed   City                Region
                         *      25				Lodwar, KE          Africa East
                         *      50				Moundou, TD         Africa East
                         *      150				Antofagasta, CL     S. America Lower
                         *      1				Bogota, CO          S. America Upper
                         *      1,225		Total Amount
                         */
                        if (la.Length == 1)                           // Resource
                        {
                            key    = la[0].Trim();
                            city   = string.Empty;
                            region = string.Empty;
                            amount = 0;
                        }
                        else if (la.Length == 2)                           // summarize
                        {
                            key    = string.Empty;
                            city   = string.Empty;
                            region = string.Empty;
                            amount = 0;
                        }
                        else if (la.Length == 3)                           // Resource info
                        {
                            if (la[0].Contains("Amount"))
                            {
                            }
                            else
                            {
                                amount = int.Parse(la[0].Trim());
                                city   = la[1].Trim();
                                region = la[2].Trim();

                                if (amount == 1)
                                {
                                    amount = 1000;
                                }
                            }
                        }
                        else                         // maybe empty line
                        {
                            key    = string.Empty;
                            city   = string.Empty;
                            region = string.Empty;
                            amount = 0;
                        }

                        if (key != string.Empty && amount != 0)
                        {
                            ResourceData ld = new ResourceData
                            {
                                City     = city,
                                Amount   = amount,
                                Region   = region,
                                Resource = key
                            };

                            //ObservableCollection<ResourceData> list = null;

                            //if ( Configuration.ResourceDictionary.TryGetValue(key, out list) )
                            //{
                            //}
                            //else
                            //{
                            //	list = new ObservableCollection<ResourceData>();
                            //	Configuration.ResourceDictionary.Add(key, list);
                            //}

                            //list.Add(ld);

                            Configuration.ResourceList.Add(ld);
                        }
                    }

                    tr.Close();
                    tr.Dispose();
                }
            }
            catch (Exception exc)
            {
                exc.Source = "Composer";                 // to remove compiler warnings
            }
        }