Esempio n. 1
0
 public override bool DoLogin()
 {
     Logout(true);
     String loginUrl = "https://www.linkedin.com/secure/login";
     try
     {
         htmlResponse = httpUtils.GetHttpResponse(loginUrl, true);
         this.jsessionid = htmlResponse.Substring(htmlResponse.IndexOf("JSESSIONID=") + "JSESSIONID=".Length);
         this.jsessionid = this.jsessionid.Substring(0, this.jsessionid.IndexOf(";"));
         postString = "session_key=" + UserId + "&session_password="******"&session_login=Sign In&session_login=&session_rikey=invalid key&session_login.x=0&session_login.y=0";
         reffer = loginUrl;
         htmlResponse = httpUtils.GetHttpResponse(loginUrl, true, postString, reffer);
         if (htmlResponse.IndexOf("<input type=\"text\" name=\"session_key\"") == -1)
         {
             IsLoggedIn = true;
             String homePage = htmlResponse.Substring(htmlResponse.IndexOf("window.location.replace('") + "window.location.replace('".Length);
             homePage = homePage.Substring(0, homePage.IndexOf("'"));
             htmlResponse = httpUtils.GetHttpResponse(homePage, true);
         }
         else
         {
             IsLoggedIn = false;
         }
     }
     catch (Exception)
     {
         Logout();
         IsLoggedIn = false;
     }
     return IsLoggedIn;
 }
Esempio n. 2
0
        public Dictionary<string, string> JsonToDictionary(String input, String firstCol)
        {
            //if(input.IndexOf("{"
            //input = input.Replace('\"','');
            /*
            input = input.Substring(input.IndexOf("{" + firstCol) + 1);
            input = input.Substring(0, input.IndexOf("}"));
            */
            /*
            while (input.IndexOf('\\') >= 0)
            {
                int index = input.IndexOf('\\');
                input = input.Substring(0, index) + input.Substring(index + 1);
            }
            */

            input = input.Substring(1);
            input = input.Substring(0,input.Length-1);

            while (input.IndexOf('\"') >= 0)
            {
                int index = input.IndexOf('\"');
                input = input.Substring(0, index) + input.Substring(index + 1);
            }
            /*
            input.Replace(':', '=');
            input.Replace(',', ';');
            */
            return input.TrimEnd(',').Split(',').ToDictionary(item => item.Split(':')[0], item => item.Split(':')[1]);
        }
Esempio n. 3
0
	static String process(String s){
		//analyze parens
		int bidx=s.IndexOf("(");
		while(bidx!=-1){
			int count=1,eidx=bidx+1;
			for(;count!=0;eidx++){
				if(s[eidx]=='(')count++;
				if(s[eidx]==')')count--;
			}
			s=s.Substring(0,bidx)+process(s.Substring(bidx+1,eidx-1-(bidx+1)))+s.Substring(eidx);
			bidx=s.IndexOf("(");
		}

		//calc without parens
		MatchCollection m=muldiv.Matches(s);
		while(m.Count>0){
			if(m[0].Groups[3].Value=="*")
				s=m[0].Groups[1].Value+(int.Parse(m[0].Groups[2].Value)*int.Parse(m[0].Groups[4].Value))+m[0].Groups[5].Value;
			else
				s=m[0].Groups[1].Value+(int.Parse(m[0].Groups[2].Value)/int.Parse(m[0].Groups[4].Value))+m[0].Groups[5].Value;
			m=muldiv.Matches(s);
		}

		m=addsub.Matches(s);
		while(m.Count>0){
			if(m[0].Groups[3].Value=="+")
				s=m[0].Groups[1].Value+(int.Parse(m[0].Groups[2].Value)+int.Parse(m[0].Groups[4].Value))+m[0].Groups[5].Value;
			else
				s=m[0].Groups[1].Value+(int.Parse(m[0].Groups[2].Value)-int.Parse(m[0].Groups[4].Value))+m[0].Groups[5].Value;
			m=addsub.Matches(s);
		}
		return s;
	}
Esempio n. 4
0
        IEnumerable<Shop> GetShops(String html, IEnumerable<City> cities)
        {
            var start = "var myLoadYMapsItemsVar=";
            var end = "};";
            var startIndex = html.IndexOf(start) + start.Length;
            var endIndex = html.IndexOf(end, startIndex) + 1;

            var shopsJsonText = html.Substring(startIndex, endIndex - startIndex);
            var shopsJson = JsonConvert.DeserializeObject<ShopsJson>(shopsJsonText);

            var shops = new List<Shop>();
            var citiesDict = cities.ToDictionary(c => c.Id);
            foreach (var shopJson in shopsJson.items)
            {
                String shirota, dolgota;
                ParseHelper.GetCoordinates(shopJson.gps, out shirota, out dolgota);
                
                var shop = new Shop() 
                {
                    Address = shopJson.name,
                    Dolgota = dolgota,
                    Shirota = shirota,
                    City = citiesDict[shopJson.per_id].Name,
                    TimeWork = shopJson.time
                };

                shops.Add(shop);
            }

            return shops;
        }
        public Wall(String Name, String ModelName, Model SentModel, Vector3 ModelPosition, Vector3 ModelRotation, GraphicsDevice device, Boolean moveable, Boolean pickup, float bounciness, Boolean levitating, String ActionInfo)
            : base(Name, ModelName, SentModel, ModelPosition, ModelRotation, device, moveable, pickup, bounciness, levitating)
        {
            String Dimensions = ActionInfo.Substring(ActionInfo.IndexOf("Wall{") + 5, ActionInfo.IndexOf("}") - ActionInfo.IndexOf("Wall{") - 5);
            this.Length = float.Parse(Dimensions.Substring(Dimensions.IndexOf("Length:") + 7, Dimensions.IndexOf(';', Dimensions.IndexOf("Length:")) - Dimensions.IndexOf("Length:") - 7));
            this.Width = float.Parse(Dimensions.Substring(Dimensions.IndexOf("Width:") + 6, Dimensions.IndexOf(';', Dimensions.IndexOf("Width:")) - Dimensions.IndexOf("Width:") - 6));
            this.Height = float.Parse(Dimensions.Substring(Dimensions.IndexOf("Height:") + 7, Dimensions.IndexOf(';', Dimensions.IndexOf("Height:")) - Dimensions.IndexOf("Height:") - 7));
            int storeSpot = 0;
            try
            {
                wallColor = new Color(
                int.Parse(Dimensions.Substring(storeSpot = (Dimensions.IndexOf("R:", Dimensions.IndexOf("Color(")) + 2), Dimensions.IndexOf(",", Dimensions.IndexOf("R:", Dimensions.IndexOf("Color("))) - storeSpot)),
                int.Parse(Dimensions.Substring(storeSpot = (Dimensions.IndexOf("G:", Dimensions.IndexOf("Color(")) + 2), Dimensions.IndexOf(",", Dimensions.IndexOf("G:", Dimensions.IndexOf("Color("))) - storeSpot)),
                int.Parse(Dimensions.Substring(storeSpot = (Dimensions.IndexOf("B:", Dimensions.IndexOf("Color(")) + 2), Dimensions.IndexOf(",", Dimensions.IndexOf("B:", Dimensions.IndexOf("Color("))) - storeSpot)),
                int.Parse(Dimensions.Substring(storeSpot = (Dimensions.IndexOf("A:", Dimensions.IndexOf("Color(")) + 2), Dimensions.IndexOf(")", Dimensions.IndexOf("A:", Dimensions.IndexOf("Color("))) - storeSpot)));
            }
            catch (Exception e) { }

            //VerticesMasterList.Add(new List<VertexPositionNormalColor>(0));

            this.LastPosition = this.Position;
            this.LastRotation = this.modelRotation;
            this.CalculateBoundingBox();
            this.CalculateBox();

            //Walls should not be moveable or pickupable by default - LIES!!!!
            /*
            this.Moveable = false;
            this.PickUpable = false;
            this.IsLevitating = true;
             */
        }
Esempio n. 6
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="ob"></param>
 /// <param name="fieldPath"></param>
 /// <param name="fieldValue"></param>
 public static void modifyRecursively(Object ob, String fieldPath, String fieldValue)
 {
     if (ob == null)
     {
         return;
     }
     if (!fieldPath.Contains("."))
     {
         modifyValueOfFieldAccordingToTable(ob, fieldPath, fieldValue);
     }
     else
     {
         String prefix = fieldPath.Substring(0, fieldPath.IndexOf('.'));
         Object o;
         o = ob.GetType().GetProperty(prefix, BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public);
         if (o != null)
         {
             PropertyInfo myProp = (PropertyInfo)o;
             Object subObject = myProp.GetValue(ob, null);
             String toPass = fieldPath.Substring(fieldPath.IndexOf('.') + 1);
             modifyRecursively(subObject, toPass, fieldValue);
         }
         else
         {
             o = ob.GetType().GetField(prefix, BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public);
             FieldInfo myField = (FieldInfo)o;
             Object subObject = myField.GetValue(ob);
             String toPass = fieldPath.Substring(fieldPath.IndexOf('.') + 1);
             modifyRecursively(subObject, toPass, fieldValue);
         }
     }
 }
Esempio n. 7
0
        IEnumerable<City> GetCitiesFromPageHtml(String html)
        {
            var startRegionMarker = "<select id=\"filterAddressTown\"";
            var endRegionMarker = "</select>";

            var startIndex = html.IndexOf(startRegionMarker);
            var endIndex = html.IndexOf(endRegionMarker, startIndex) + endRegionMarker.Length;

            var citiesXml = html.Substring(startIndex, endIndex - startIndex);

            var cities = new List<City>();

            var parsed = XDocument.Parse(citiesXml);
            foreach (var elem in parsed.Elements().First().Elements())
            { 
                var city = new City()
                {
                    Id = elem.Attribute("value").Value.Trim(),
                    Name = elem.Value.Trim()
                };

                if (city.Id == "0")
                    continue;

                cities.Add(city);
            }

            return cities;
        }
        public static DateTime W3CDateTimeToDateTime(String w3cDateTime)
        {
            DateTime dt;

            if (w3cDateTime.IndexOf('T') != -1) {
                if (w3cDateTime.IndexOf('Z') != -1) {
                    dt = DateTime.ParseExact(w3cDateTime,
                                             W3CDateTimePatternsUTC,
                                             DateTimeFormatInfo.InvariantInfo,
                                             DateTimeStyles.NoCurrentDateDefault);
                    dt = dt.ToLocalTime();
                } else {
                    dt = DateTime.ParseExact(w3cDateTime,
                                             W3CDateTimePatternsTZ,
                                             DateTimeFormatInfo.InvariantInfo,
                                             DateTimeStyles.NoCurrentDateDefault);
                }
            } else {
                dt = DateTime.ParseExact(w3cDateTime,
                                         W3CDateTimePatternsBasic,
                                         DateTimeFormatInfo.InvariantInfo,
                                         DateTimeStyles.NoCurrentDateDefault);
                dt = dt.ToLocalTime();
            }
            return dt;
        }
 /// <summary>
 /// Constructor with UNC
 /// </summary>
 /// <param name="path">The share name - UNC</param>
 public NetworkShare( String path )
 {
     String hostName = "";
     // check if the UNC is valid
     unc = (String) path.Clone();
     if( path.StartsWith( @"\\" ) )
     {
         path = path.Remove( 0, 2 );
         int i = path.IndexOf( @"\" );
         if( i < 0 )
         {
             goto _abort;
         }
         hostName = path.Substring( 0, path.IndexOf( @"\" ) );
         path = path.Remove( 0, i );
         if( path == null || path.Length < 1 )
         {
             goto _abort;
         }
         // remove the first "\"
         remotePath = (String) path.Remove( 0, 1 );
         if( remotePath == null || remotePath.Length < 1 )
         {
             goto _abort;
         }
         goto _ok;
     }
     _abort:
     throw new Exception( "Invalid UNC path: " + unc );
     _ok:
     {
         host = new NetworkHost( hostName, 0 /* dummy */ );
     }
 }
Esempio n. 10
0
 private String imgtext(String imgs)
 {
     String img = "";
     int ps = imgs.IndexOf("<IMG");
     if (ps >= 0)
     {
         imgs = imgs.Substring(ps);
         ps = imgs.IndexOf(">");
         if (ps >= 0)
         {
             img = imgs.Substring(0, ps + 1);
             ps = img.IndexOf("src=");
             img = img.Substring(ps + 5);
             ps = img.IndexOf(" ");
             if (ps >= 0)
             {
                 img = img.Substring(0, ps - 1);
             }
         }
     }
     if (img.Length > 0)
         if (!img.ToLower().StartsWith("http://"))
         {
             JpSite site = new JpSite();
             img = "http://" + site.host + img;
         }
     return img;
 }
Esempio n. 11
0
		protected override void AddMessage(String message)
		{
			if( message.IndexOf("AFC") == -1 && message.IndexOf("NFC") == -1 )
			{
				base.AddMessage (message);
			}
		}
Esempio n. 12
0
        /// <summary>
        /// 获取指定字符串的第一行内容,其方法是查找\r或\n的位置
        /// 如果只有一个,则直接依据其索引从0开始截取子串即可
        /// 如果找到两个,则取最小的那个作为索此截取子串
        /// 如果没有找到,返回整个字串
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static String getFirstLineOfString(String str)
        {
            if (String.IsNullOrEmpty(str))
            {
                return null;
            }

            int indexOfR = str.IndexOf("\r");
            int indexOfN = str.IndexOf("\n");
            if (indexOfN == -1 && indexOfR == -1)
            {
                return str;
            }

            if (indexOfN != -1 && indexOfR != -1)
            {
                int length = (indexOfN < indexOfR ? indexOfR : indexOfN) - 1;
                return str.Substring(0, length);

            }

            if (indexOfN != -1 && indexOfR == -1)
            {
                return str.Substring(0, indexOfN - 1);

            }

            if (indexOfN == -1 && indexOfR != -1)
            {
                return str.Substring(0, indexOfR - 1);

            }
            return null;
        }
Esempio n. 13
0
 public static Pair<int, int> Between(String str, Pair<int, int> indexes, String header, String footer)
 {
     int head = str.IndexOf(header, indexes.First);
     int foot = str.IndexOf(footer, head);
     int startIndex = head + header.Length;
     return new Pair<int, int>(startIndex, foot);
 }
Esempio n. 14
0
        private static ArrayList CreateSeparatedSite(String site)
        {
            if (site == null || site.Length == 0)
            {
                throw new ArgumentException( Environment.GetResourceString("Argument_InvalidSite" ));
            }
            Contract.EndContractBlock();

            ArrayList list = new ArrayList();
            int braIndex = -1;
            int ketIndex = -1;
            braIndex = site.IndexOf('[');
            if (braIndex == 0)
                ketIndex = site.IndexOf(']', braIndex+1);

            if (ketIndex != -1)
            {
                // Found an IPv6 address. Special case that
                String ipv6Addr = site.Substring(braIndex+1, ketIndex-braIndex-1);
                list.Add(ipv6Addr);
                return list;
            }

            // Regular hostnames or IPv4 addresses
            // We dont need to do this for IPv4 addresses, but it's easier to do it anyway
            String[] separatedArray = site.Split( m_separators );
            
            for (int index = separatedArray.Length-1; index > -1; --index)
            {
                if (separatedArray[index] == null)
                {
                    throw new ArgumentException( Environment.GetResourceString("Argument_InvalidSite" ));
                }
                else if (separatedArray[index].Equals( "" )) 
                {
                    if (index != separatedArray.Length-1) 
                    {
                        throw new ArgumentException( Environment.GetResourceString("Argument_InvalidSite" ));
                    }
                }
                else if (separatedArray[index].Equals( "*" ))
                {
                    if (index != 0)
                    {
                        throw new ArgumentException( Environment.GetResourceString("Argument_InvalidSite" ));
                    }
                    list.Add( separatedArray[index] );
                }
                else if (!AllLegalCharacters( separatedArray[index] ))
                {
                    throw new ArgumentException( Environment.GetResourceString("Argument_InvalidSite" ));
                }
                else
                {
                    list.Add( separatedArray[index] );
                }
            }
            
            return list;
        }
Esempio n. 15
0
        public Pascal(String operation, String filePath, String flags)
        {
            try{
                bool intermediate = flags.IndexOf('i') > 1;
                bool xref = flags.IndexOf('x') > 1;
                source = new Source(new StreamReader(filePath));
                source.AddMessageListener(new SourceMessageListener());

                parser = FrontEndFactory.CreateParser("pascal","top-down",source);
                parser.AddMessageListener(new ParserMessageListener());

                backend = BackendFactory.CreateBackend("compile");
                backend.AddMessageListener(new BackendMessageListener());

                parser.Parse();
                source.close();

                intermediateCode = parser.IntermediateCode;
                symbolTable = Parser.SymbolTable;

                backend.Process(intermediateCode,symbolTable);
            }
            catch(Exception ex){
                Console.WriteLine ("Internal translation error");
                Console.WriteLine (ex.StackTrace);
            }
        }
Esempio n. 16
0
 public ContentType(String mime)
 {
     // this allows us to correctly process ctypes like "text/html; charset=utf-8"
     // todo. investigate the MIME spec and implement this thouroughly
     var sliceAt = mime.IndexOf(";") == -1 ? mime.Length : mime.IndexOf(";");
     Mime = mime.Substring(0, sliceAt); ;
 }
Esempio n. 17
0
        private void GetPic()
        {
            htmlText = ghtml.html(address);

            if (htmlText.IndexOf(@"Фото:", 19) != -1)
            {

                text = htmlText.Substring(htmlText.IndexOf(@"Фото:"));

                Int32 startP = text.IndexOf("SRC", 0);
                if (startP < 300 && startP != -1)
                {
                    startP += 5;

                    //День рождения
                    text = text.Substring(text.IndexOf("Дата рождения"));
                    Int32 startD = text.IndexOf("ms-formbody", 70);
                    tBirthDay.Add(text.Substring(startD + 13, 10));

                    //Дата прихода в Элком+
                    text = text.Substring(text.IndexOf("Дата прихода"));
                    startD = text.IndexOf("ms-formbody", 70);
                    tStartDay.Add(text.Substring(startD + 13, 10));

                    tBirthID.Add(idTemp);

                }

            }
        }
Esempio n. 18
0
        /// <summary>
        /// Get this resource
        /// </summary>
        /// <param name="resource">
        /// A String with SubResources.
        /// If this is simply '/' then return the collection as returned by the get command.
        /// If it's a path like '/elementName' then return the element.
        /// </param>
        public IRestNode getResource(String resource)
        {
            resource = resource.TrimStart('/');
            int param = resource.IndexOf(' ');
            if (param > 0)
            {
                resource = resource.Substring(0, param);
            }
            IRestNode pNode = m_root;
            while (pNode != null && resource.Length > 0)
            {
                int index = resource.IndexOf('/');

                if (index > 0)
                {
                    // test for data
                    String test = resource.Substring(0, index);
                    int end = test.IndexOf(' ');
                    //if (end != -1)
                    //{
                    //    index = end;
                    //}
                    pNode = pNode.OnElement(resource.Substring(0, index));
                    resource = resource.Substring(index, resource.Length - index).TrimStart('/').Trim();
                }
                else
                {
                    pNode.OnElement(resource);
                    return pNode;
                }
            }
            return pNode;
        }
Esempio n. 19
0
        private static readonly String staticPageSeparator = "<hr>"; //---page---

        #endregion Fields

        #region Methods

        private static String getPageSeparator( String content )
        {
            if (content.IndexOf( staticPageSeparator ) > 20) return staticPageSeparator;
            if (content.IndexOf( staticPageSeparator.ToUpper() ) > 20) return staticPageSeparator.ToUpper(); //¾ÀÕýIEµÄbug
            if (content.IndexOf( "<hr />" ) > 20) return "<hr />";
            return null;
        }
Esempio n. 20
0
 private void parse(String message)
 {
     int i = -1;
     int j = message.IndexOf(" :");
     String trailing = "";
     if (message.StartsWith(":"))
     {
         i = message.IndexOf(" ");
         prefix = message.Substring(1, i - 1);
     }
     if (j >= 0)
     {
         trailing = message.Substring(j + 2);
     }
     else
     {
         j = message.Length;
     }
     var commandAndParameters = message.Substring(i + 1, j - i - 1).Split(' ');
     command = commandAndParameters.First();
     if (commandAndParameters.Length > 1)
         parameters = commandAndParameters.Skip(1).ToArray();
     if (!String.IsNullOrEmpty(trailing))
     {
         parameters = parameters.Concat(new string[] { trailing }).ToArray();
     }
 }
        private static void validateRequestUri(String requestUri)
        {
            log.debug(requestUri, "requestUri");

            if ('/' != requestUri[0])
            {

                log.errorFormat("'/' != requestUri.charAt(0); requestUri = '{0}'", requestUri);
                throw HttpErrorHelper.forbidden403FromOriginator(typeof(FileGetRequestHandler));
            }

            if (-1 != requestUri.IndexOf("/."))
            { // UNIX hidden files

                log.errorFormat("-1 != requestUri.indexOf( \"/.\"); requestUri = '{0}'", requestUri);
                throw HttpErrorHelper.forbidden403FromOriginator(typeof(FileGetRequestHandler));

            }

            if (-1 != requestUri.IndexOf(".."))
            { // parent directory

                log.errorFormat("-1 != requestUri.indexOf( \"..\"); requestUri = '{0}'", requestUri);
                throw HttpErrorHelper.forbidden403FromOriginator(typeof(FileGetRequestHandler));

            }
		
        }
Esempio n. 22
0
        public override bool DoLogin()
        {
            Logout(true);
            String homePage = "http://www.myspace.com";
            String loginUrl = "http://login.myspace.com/index.cfm?fuseaction=login.process&MyToken=";
            try
            {
                htmlResponse = httpUtils.GetHttpResponse(homePage, false);
                reffer = homePage;
                String tempStr = "MyToken=";
                int pos = htmlResponse.IndexOf(tempStr);
                myToken = htmlResponse.Substring(pos + tempStr.Length);
                myToken = myToken.Substring(0, myToken.IndexOf("\""));
                loginUrl += myToken;
                postString = "email=" + UserId + "&password="******"&Submit22_x=33&Submit22_y=10";
                htmlResponse = httpUtils.GetHttpResponse(loginUrl, false, postString, reffer);
                if (htmlResponse.IndexOf("<input type=\"text\" name=\"email\"") == -1)
                {
                    // Begin Outer If
                    if (htmlResponse.IndexOf("Member Login") == -1)
                    {
                        // Begin 1st inner if
                        if (htmlResponse.IndexOf("Skip this Advertisement") > 1)
                        {
                            htmlResponse = htmlResponse.Substring(0, htmlResponse.IndexOf("Skip this Advertisement"));
                            tempStr = "<a href=\"";
                            String urlToFetch = htmlResponse.Substring(htmlResponse.IndexOf(tempStr) + tempStr.Length);
                            urlToFetch = urlToFetch.Substring(0, urlToFetch.IndexOf("\""));
                            htmlResponse = httpUtils.GetHttpResponse(urlToFetch, false, "", loginUrl);

                        }
                        //End 1st inner if.

                        // Begin of 2nd inner if
                        if (htmlResponse.IndexOf("You have\n <span><a href=\"") == -1)
                        {
                            htmlResponse = httpUtils.GetHttpResponse("http://home.myspace.com/index.cfm?fuseaction=user", false);

                        }
                        // End of 2nd inner if
                        tempStr = "<span><a href=\"";
                        String fPage = htmlResponse.Substring(htmlResponse.IndexOf(tempStr) + tempStr.Length);
                        fPage = fPage.Substring(0, fPage.IndexOf("\""));

                        IsLoggedIn = true;
                    }
                }
                else
                {
                    IsLoggedIn = false;
                }
            }
            //Outer if close
            // End of outer if
            catch (Exception)
            {
                IsLoggedIn = false;
            }
            return IsLoggedIn;
        }
Esempio n. 23
0
        public const char OD_SET_WATCHING = 'K'; //����

        #endregion Fields

        #region Methods

        //�������յ������ݣ����ض�λ��Ϣ�б�
        public static List<Position> Analyze(String src, bool gprs)
        {
            if(src.IndexOf(HEAD) >= 0)
            {
                while(src.IndexOf(HEAD) != 0)
                    src = src.Substring(src.IndexOf(HEAD));
                if(src.IndexOf(FOOT) <= 0)
                    return null;
                List<Position> list = new List<Position>();

                String[] lines = src.Split(new string[] { HEAD }, StringSplitOptions.RemoveEmptyEntries);
                foreach(String line in lines)
                    if(line != "")
                    {
                        Position pos = null;
                        if(gprs)
                        {
                            pos = GetGPRSPos(line.Substring(0, line.Length - 1));
                        }
                        else
                        {
                            pos = GetSMSPos(line.Substring(0, line.Length - 1));
                        }
                        if(pos != null)
                            list.Add(pos);
                    }
                return list;
            }
            return null;
        }
Esempio n. 24
0
        public static bool CheckParenthesis(String str)
        {
            bool result = true;

            if(str != null)
            {
                int open = 0;
                int closed = 0;

                int i = 0;
                while((i = str.IndexOf('(', i)) >= 0)
                {
                    i++;
                    open++;
                }

                i = 0;
                while((i = str.IndexOf(')', i)) >= 0)
                {
                    i++;
                    closed++;
                }

                result = (open == closed);
            }

            return result;
        }
Esempio n. 25
0
        void PrepareScriptCall(String expression)
        {
            int pos1 = expression.IndexOf("(");
            int pos2 = expression.IndexOf(")");
            _module = "";
            _func = expression.Substring(1, pos1 - 1);
            String[] arr = _func.Split('.');
            if (arr.Length > 2)
                throw new Exception(String.Format("Invalid expression '{0}'", expression));
            if (arr.Length == 2)
            {
                _module = arr[0];
                _func = arr[1];
            }

            String[] args = expression.Substring(pos1 + 1, pos2 - pos1 - 1).Split(',');
            _parameters = new object[args.Length];
            int i = 0;
            foreach (String arg in args)
            {                
                if (IsLazy(arg))
                    _parameters[i] = new Func<object>(() => _valueStack.Evaluate(arg));
                else
                    _parameters[i] = _valueStack.Evaluate(arg);
                i++;
            }
        }
Esempio n. 26
0
 /**
  *
  * @param decl a string from header or meta tag to detect encoding
  * @return encoding String
  */
 public static String GetDeclaredEncoding(String decl)
 {
     if (decl == null)
         return null;
     int idx = decl.IndexOf("encoding");
     if (idx < 0)
         return null;
     int idx1 = decl.IndexOf('"', idx);
     int idx2 = decl.IndexOf('\'', idx);
     if (idx1 == idx2)
         return null;
     if (idx1 < 0 && idx2 > 0 || idx2 > 0 && idx2 < idx1) {
         int idx3 = decl.IndexOf('\'', idx2 + 1);
         if (idx3 < 0)
             return null;
         return decl.Substring(idx2 + 1, idx3 - (idx2 + 1));
     }
     if (idx2 < 0 && idx1 > 0 || idx1 > 0 && idx1 < idx2) {
         int idx3 = decl.IndexOf('"', idx1 + 1);
         if (idx3 < 0)
             return null;
         return decl.Substring(idx1 + 1, idx3 - (idx1 + 1));
     }
     return null;
 }
Esempio n. 27
0
        public void Work()
        {
            while (_stream.CanRead)
            {
                try
                {
                    int bytes_read = _stream.Read(bytemessage, 0, bytemessage.Length);
                    client_message += Encoding.UTF8.GetString(bytemessage, 0, bytes_read);

                    if (client_message.Contains('\n'))
                    {
                        string tmp = client_message.Substring(0, client_message.IndexOf('\n'));
                        client_message = client_message.Remove(0, client_message.IndexOf('\n') + 1);

                        if (dialogue.interpretMessage(tmp))
                        {
                            dialogue = dialogue.getNextDialogue();
                        }

                    }

                }
                catch (Exception e)
                {
                    Console.WriteLine("Exception in Work:"+e.Message);
                    return;
                }

            }
        }
Esempio n. 28
0
 /// <summary>
 /// Gets whether a string matches the IRI production
 /// </summary>
 /// <param name="value">String</param>
 /// <returns></returns>
 public static bool IsIri(String value)
 {
     if (!value.Contains(':')) return false;
     String scheme = value.Substring(0, value.IndexOf(':'));
     String rest = value.Substring(value.IndexOf(':') + 1);
     if (rest.Contains("?"))
     {
         String part = rest.Substring(0, rest.IndexOf('?'));
         String queryAndFragment = rest.Substring(rest.IndexOf('?') + 1);
         String query, fragment;
         if (queryAndFragment.Contains('#'))
         {
             query = queryAndFragment.Substring(0, queryAndFragment.IndexOf('#'));
             fragment = queryAndFragment.Substring(queryAndFragment.IndexOf('#') + 1);
             return IsScheme(scheme) && IsIHierPart(part) && IsIQuery(query) && IsIFragment(fragment);
         }
         else
         {
             query = queryAndFragment;
             return IsScheme(scheme) && IsIHierPart(part) && IsIQuery(query);
         }
     } 
     else if (rest.Contains('#'))
     {
         String part = rest.Substring(0, rest.IndexOf('#'));
         String fragment = rest.Substring(rest.IndexOf('#') + 1);
         return IsScheme(scheme) && IsIHierPart(part) && IsIFragment(fragment);
     }
     else
     {
         return IsScheme(scheme) && IsIHierPart(rest);
     }
 }
Esempio n. 29
0
    void calculate(System.String inp)
    {
        if (inp != null)
        {
            Debug.Log(inp);

            if (inp.Contains("(") && inp.Contains(")"))
            {
                System.Int32 openI  = inp.IndexOf("(");
                System.Int32 Mid    = inp.IndexOf(" ");
                System.Int32 closeI = inp.IndexOf(")");

                System.String PosS = inp.Substring(openI + 1, Mid - openI - 1);
                System.String VelS = inp.Substring(Mid + 1, closeI - Mid - 1);

                System.Int32.TryParse(PosS, out outputI);
                System.Int32.TryParse(VelS, out outputI2);
            }

            //	if (inp.Contains("-"))
            //	{

            //		inp = inp.Remove(inp.IndexOf("-"), 1);

            //		if (inp.Contains("-"))
            //		{
            //			s = inp.Remove(inp.IndexOf("-"), 1);
            //		}

            //		int.TryParse(inp, out outputI);
            //		outputS = outputI.ToString();
            //		int HLen = outputS.Length / 2;
            //		outputS2 = outputS.Substring(0, HLen);
            //		int.TryParse(outputS2, out outputI2);

            //		outputI2 *= -1;



            //		Debug.Log(HLen.ToString() + "   " + inp + " " + outputS + " " + outputS2 + " " + outputI.ToString() + " " + outputI2.ToString());
            //	}
            //	else
            //	{
            //		//Debug.Log(inp);
            //		//int HLen = inp.Length / 2;
            //		//outputS = inp.Substring(HLen - 1, HLen);
            //		int.TryParse(inp, out outputI);
            //		outputS = outputI.ToString();
            //		int HLen = outputS.Length / 2;
            //		outputS2 = outputS.Substring(0, HLen);
            //		int.TryParse(outputS2, out outputI2);


            //		Debug.Log(HLen.ToString() + "   " + inp + " " + outputS + " " + outputS2 + " " + outputI.ToString() + " " + outputI2.ToString());
            //	}

            //	outputF = (float)outputI2 / (float)max;
        }
        Debug.Log(inp);
    }
Esempio n. 30
0
        public WhoLine(IrcLine baseLine)
            : base(baseLine)
        {
            if(baseLine.Numeric != 352)
                throw new ArgumentOutOfRangeException("baseLine", "RPL_WHOREPLY 352 expected");
            if(Parameters.Length < 8)
                throw new ArgumentOutOfRangeException("baseLine", "Need a minimum of 8 parameters");

            UserValue = new UserInfo(Parameters[5], Parameters[2], Parameters[3], Client);
            List<Mode> modes = new List<Mode>();
            int i = 1;

            IsAwayValue = Parameters[6][0] == 'G';
            IsOperValue = Parameters[6][i] == '*';

            if(IsOper)
                i++;

            for(; i < Parameters[6].Length; i++)
            {
                if(Client.Standard.UserPrefixFlags.ContainsKey(Parameters[6][i]))
                {
                    modes.Add(new Mode(Client.Standard.UserPrefixFlags[Parameters[6][i]], FlagArt.Set, User.NickName));
                }
            }

            ModesValue = modes.ToArray();

            RealNameValue = Parameters[7];

            if(!int.TryParse(RealNameValue.Substring(1, RealNameValue.IndexOf(" ")), out HopCountValue))
                throw new ArgumentOutOfRangeException("baseLine", "Invalid hop count, integer expected");

            RealNameValue = RealNameValue.Substring(RealNameValue.IndexOf(" ") + 1);
        }
Esempio n. 31
0
        private void getFlightAbout(String html)
        {
            int iTableStart = html.IndexOf("stage flights", 0);
            int iTableEnd = html.IndexOf("</ul>", iTableStart);
            string strtable = html.Substring(iTableStart, iTableEnd - iTableStart + 5);
            while (true)
            {
                RS_FlightRoute flightAbout = new RS_FlightRoute();
                flightAbout.FlightType = "直达";
                RS_FlightDetail flightDetail = new RS_FlightDetail();
                int startLi = strtable.IndexOf("<li", 0);
                int endLi = strtable.IndexOf("</li", startLi);

                int flightStart = strtable.IndexOf("<p class=\"n\">", 0);
                int flightEnd = strtable.IndexOf("</p>", flightStart);
                String flight = strtable.Substring(flightStart + 13, flightEnd - flightStart - 13);
                for (int i = 0; i < flight.Length; i++)
                {
                    if (flight[i] >= 'A' && flight[i] <= 'Z')
                    {
                        String agency = flight.Substring(0, i);
                        String flightNum = flight.Substring(i);
                        flightDetail.Airline = agency.Trim();
                        flightDetail.FlightNum = flightNum.Trim();
                        break;
                    }
                }
                int timeStart = strtable.IndexOf("<p class=\"i\">", flightEnd);
                int timeEnd = strtable.IndexOf("<br", timeStart);
                String time = strtable.Substring(timeStart + 13, timeEnd - timeStart - 13);
                String TakeOffTime = time.Substring(0, time.IndexOf("-") - 1);
                String ArriveTime = time.Substring(time.IndexOf("-") + 2);
                flightDetail.TakeOffTime = TakeOffTime.Trim(); ;
                flightDetail.ArriveTime = ArriveTime.Trim();
                int portEnd = strtable.IndexOf("</p>", timeEnd);
                String port = strtable.Substring(timeEnd + 6, portEnd - timeEnd - 6).Trim();
                String DPort = port.Substring(0, port.IndexOf("-") - 1);
                String APort = port.Substring(port.IndexOf("-") + 2);
                if (APort.IndexOf("<span") > 0)
                {
                    APort = APort.Substring(0, APort.IndexOf("<span") - 1) + "(经停)";
                }
                flightDetail.DPort = DPort.Trim();
                flightDetail.APort = APort.Trim();

                String agencyUrl = "http://touch.qunar.com/flightDetail.jsp?flightType=oneWay&startCity=" + startCity + "&destCity=" + destCity + "&startDate=" + startDate + "&code=" + flightDetail.FlightNum + "&minPrice=&bd_source=qunar";
                String agencyHtml = getWebHtml(agencyUrl);
                int priceStart = agencyHtml.IndexOf("&yen;", 0);
                int priceEnd = agencyHtml.IndexOf("</em>", priceStart);
                flightDetail.MinPrice = agencyHtml.Substring(priceStart + 5, priceEnd - priceStart - 5);
                flightDetail.AgencyList = getFlightAgency(agencyHtml);

                flightAbout.addDetail(flightDetail);
                flightInfo.addAbout(flightAbout);
                if (strtable.IndexOf("<li", portEnd) > 0)
                    strtable = strtable.Substring(strtable.IndexOf("<li", portEnd));
                else
                    break;
            }
        }
Esempio n. 32
0
    public int distanceBetweenTiles(Tile t1, Tile t2)
    {
        System.String name       = t1.gameObject.name;
        int           commaBreak = name.IndexOf(',');
        int           x1         = System.Convert.ToInt32(name.Substring(4, commaBreak - 4));
        int           y1         = System.Convert.ToInt32(name.Substring(commaBreak + 1, name.Length - 1 - commaBreak));

        name       = t2.gameObject.name;
        commaBreak = name.IndexOf(',');
        int x2 = System.Convert.ToInt32(name.Substring(4, commaBreak - 4));
        int y2 = System.Convert.ToInt32(name.Substring(commaBreak + 1, name.Length - 1 - commaBreak));

        return(distanceBetweenTiles(x1, x2, y1, y2));
    }
Esempio n. 33
0
    public void markMovement(List <Tile.tileType> blockType, int speed, Tile unitTile, Tile currentTile)
    {
        if (speed < 0 || (unitTile != currentTile && blockType.Contains(currentTile.setType)))
        {
            return;
        }

        for (int i = 0; i < 6; i++)
        {
            markMovement(blockType, speed - 1, unitTile, getNeighborByDirection((tileDirections)i, currentTile));
        }
        if (unitTile != currentTile)
        {
            System.String name       = currentTile.gameObject.name;
            int           commaBreak = name.IndexOf(',');
            int           x1         = System.Convert.ToInt32(name.Substring(4, commaBreak - 4));
            int           y1         = System.Convert.ToInt32(name.Substring(commaBreak + 1, name.Length - 1 - commaBreak));

            MeshRenderer    currentMesh   = board[y1, x1].GetComponent <MeshRenderer>();
            int             materialCount = currentMesh.materials.Length;
            List <Material> materialList  = new List <Material>();
            for (int i = 0; i < materialCount; i++)
            {
                if (currentMesh.materials[i].name == "Highlight (Instance)")
                {
                    return;
                }
                materialList.Add(currentMesh.materials[i]);
            }
            materialList.Add(Resources.Load <Material>("Models/Materials/Highlight"));
            currentMesh.materials = materialList.ToArray();
        }
    }
Esempio n. 34
0
    public void claimTile(Tile toClaim, Player owner, int radius)
    {
        System.String name       = toClaim.gameObject.name;
        int           commaBreak = name.IndexOf(',');
        int           x1         = System.Convert.ToInt32(name.Substring(4, commaBreak - 4));
        int           y1         = System.Convert.ToInt32(name.Substring(commaBreak + 1, name.Length - 1 - commaBreak));

        claimTile(y1, x1, owner, radius);
    }
Esempio n. 35
0
    /// <summary>
    /// Returns neighbor based on the direction and the current tile
    /// </summary>
    /// <param name="direction">Direction of neighbor to return</param>
    /// <param name="tile">Current tile</param>
    /// <returns></returns>
    public Tile getNeighborByDirection(tileDirections direction, Tile tile)
    {
        System.String name       = tile.gameObject.name;
        int           commaBreak = name.IndexOf(',');
        int           x1         = System.Convert.ToInt32(name.Substring(4, commaBreak - 4));
        int           y1         = System.Convert.ToInt32(name.Substring(commaBreak + 1, name.Length - 1 - commaBreak));

        return(getNeighborByDirection(direction, y1, x1));
    }
Esempio n. 36
0
    public System.String StripCloneString(System.String s)
    {
        int idx = s.IndexOf("(");

        if (idx == -1)
        {
            return(s);
        }
        return(s.Substring(0, idx));
    }
        /* ----------------------------------	*/

        public static FILE findOnPath(
            char[] pathName, char[] fileName)
        {
            //
            // Use mkStr, to trim space from end of char arrray.
            //
            System.String pName = mkStr(pathName);
            System.String fName = mkStr(fileName);
            System.String nName = "";

            System.String nextDir;
            System.String thisPath = System.Environment.GetEnvironmentVariable(pName);
//
//  System.Console.WriteLine(pName);
//  System.Console.WriteLine(thisPath);
//
            FILE cpf          = new FILE();
            bool found        = false;
            bool pathFinished = false;
            int  length       = thisPath.Length;
            int  nextLength;
            int  nextPathStart;
            int  nextPathEnd = -1;

            while (!found && !pathFinished)
            {
                nextPathStart = nextPathEnd + 1;
                nextPathEnd   = thisPath.IndexOf(GPFiles.GPFiles.pathSep, nextPathStart);
                if (nextPathEnd < 0)
                {
                    nextPathEnd = length;
                }
                nextLength   = nextPathEnd - nextPathStart;
                nextDir      = thisPath.Substring(nextPathStart, nextLength);
                nName        = nextDir + GPFiles.GPFiles.fileSep + fName;
                found        = System.IO.File.Exists(nName);
                pathFinished = nextPathEnd >= length;
            }
            if (found)
            {
                return(open(nName));
            }
            else
            {
                return(null);
            }
        }
Esempio n. 38
0
        public static string BytesToNBNSQuery(byte[] field)
        {
            string nbnsUTF8 = BitConverter.ToString(field);

            nbnsUTF8 = nbnsUTF8.Replace("-00", String.Empty);
            string[] nbnsArray = nbnsUTF8.Split('-');
            string   nbnsQuery = "";

            foreach (string character in nbnsArray)
            {
                nbnsQuery += new System.String(Convert.ToChar(Convert.ToInt16(character, 16)), 1);
            }

            if (nbnsQuery.Contains("CA"))
            {
                nbnsQuery = nbnsQuery.Substring(0, nbnsQuery.IndexOf("CA"));
            }

            int    i = 0;
            string nbnsQuerySubtracted = "";

            do
            {
                byte nbnsQuerySub = (byte)Convert.ToChar(nbnsQuery.Substring(i, 1));
                nbnsQuerySub        -= 65;
                nbnsQuerySubtracted += Convert.ToString(nbnsQuerySub, 16);
                i++;
            }while (i < nbnsQuery.Length);

            i = 0;
            string nbnsQueryHost = "";

            do
            {
                nbnsQueryHost += (Convert.ToChar(Convert.ToInt16(nbnsQuerySubtracted.Substring(i, 2), 16)));
                i             += 2;
            }while (i < nbnsQuerySubtracted.Length - 1);

            if (nbnsQuery.StartsWith("ABAC") && nbnsQuery.EndsWith("AC"))
            {
                nbnsQueryHost = nbnsQueryHost.Substring(2);
                nbnsQueryHost = nbnsQueryHost.Substring(0, nbnsQueryHost.Length - 1);
                nbnsQueryHost = String.Concat("<01><02>", nbnsQueryHost, "<02>");
            }

            return(nbnsQueryHost);
        }
Esempio n. 39
0
        public ECheckContainKey checkContainKeyType(DataProcessParam pDataProcessParam)
        {
            ECheckContainKey nECheckContainKey = ECheckContainKey.ECheckContainKey_NoKey;

            System.Int32 nIndexOfValue = -1;

            nECheckContainKey = ECheckContainKey.ECheckContainKey_NoKey;

            nIndexOfValue = m_strLine.IndexOf(pDataProcessParam.m_strStringSrc);
            if (-1 != nIndexOfValue)
            {
                nECheckContainKey = ECheckContainKey.ECheckContainKey_HaveKey;
                return(nECheckContainKey);
            }

            return(nECheckContainKey);
        }
Esempio n. 40
0
        /// <summary>Replace a string within a string</summary>
        /// <param name="in_sSourceString">The String to modify
        /// </param>
        /// <param name="in_sTokenToReplace">The Token to replace
        /// </param>
        /// <param name="in_sNewToken">The new Token
        /// </param>
        /// <param name="in_nNbTimes">The number of time, the replace operation must be done. -1 means replace all
        /// </param>
        /// <returns> String The new String
        /// </returns>
        /// <exception cref="RuntimeException">where trying to replace by a new token and this new token contains the token to be replaced
        /// </exception>
        static public System.String ReplaceToken(System.String in_sSourceString, System.String in_sTokenToReplace, System.String in_sNewToken, int in_nNbTimes)
        {
            int  nIndex    = 0;
            bool bHasToken = true;

            System.Text.StringBuilder sResult     = new System.Text.StringBuilder(in_sSourceString);
            System.String             sTempString = sResult.ToString();
            int nOldTokenLength = in_sTokenToReplace.Length;
            int nTimes          = 0;

            // To prevent from replace the token with a token containg Token to replace
            if (in_nNbTimes == -1 && in_sNewToken.IndexOf(in_sTokenToReplace) != -1)
            {
                throw new System.SystemException("Can not replace by this new token because it contains token to be replaced");
            }

            while (bHasToken)
            {
                nIndex    = sTempString.IndexOf(in_sTokenToReplace, nIndex);
                bHasToken = (nIndex != -1);

                if (bHasToken)
                {
                    // Control number of times
                    if (in_nNbTimes != -1)
                    {
                        if (nTimes < in_nNbTimes)
                        {
                            nTimes++;
                        }
                        else
                        {
                            // If we already replace the number of times asked then go out
                            break;
                        }
                    }

                    sResult.Replace(sResult.ToString(nIndex, nIndex + nOldTokenLength - nIndex), in_sNewToken, nIndex, nIndex + nOldTokenLength - nIndex);
                    sTempString = sResult.ToString();
                }

                nIndex = 0;
            }

            return(sResult.ToString());
        }
Esempio n. 41
0
        public static URIParsedResult parse(Result result)
        {
            System.String rawText = result.Text;
            if (rawText == null || (!rawText.StartsWith("urlto:") && !rawText.StartsWith("URLTO:")))
            {
                return(null);
            }
            //UPGRADE_WARNING: Method 'java.lang.String.indexOf' was converted to 'System.String.IndexOf' which may throw an exception. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1101'"
            int titleEnd = rawText.IndexOf(':', 6);

            if (titleEnd < 0)
            {
                return(null);
            }
            System.String title = titleEnd <= 6?null:rawText.Substring(6, (titleEnd) - (6));
            System.String uri   = rawText.Substring(titleEnd + 1);
            return(new URIParsedResult(uri, title));
        }
        }//AnalyseFile

        /// <summary>
        /// checkLogFileLine
        /// check one line in log file contain string "[Thrd:"
        /// </summary>
        /// <param name="strLogFileLine"></param>
        /// <returns></returns>
        private Boolean checkLogFileLine(System.String strLogFileLine)
        {
            Boolean nFunRes     = false;
            int     nfindSunStr = -1;

            if (strLogFileLine.Length > 0)
            {
                nfindSunStr = -1;
                nfindSunStr = strLogFileLine.IndexOf(",");
            }

            if (nfindSunStr >= 0)
            {
                nFunRes = true;
            }

            return(nFunRes);
        }
Esempio n. 43
0
    public void SelectUnit(int unitToSelect)
    {
        Destroy(tileMenu.gameObject);
        if (unitToSelect == -1)
        {
            cityOnTile.onSelect();
            return;
        }
        System.String name       = gameObject.name;
        int           commaBreak = name.IndexOf(',');
        int           x          = System.Convert.ToInt32(name.Substring(4, commaBreak - 4));
        int           y          = System.Convert.ToInt32(name.Substring(commaBreak + 1, name.Length - 1 - commaBreak));

        selectedUnit.gameObject.SetActive(false);
        unitsOnTile[unitToSelect].gameObject.SetActive(true);
        selectedUnit = unitsOnTile[unitToSelect];
        selectedUnit.onSelect();
    }
Esempio n. 44
0
        /// <summary> <p>Returns a minimal amount of data from a message string, including only the
        /// data needed to send a response to the remote system.  This includes the
        /// following fields:
        /// <ul><li>field separator</li>
        /// <li>encoding characters</li>
        /// <li>processing ID</li>
        /// <li>message control ID</li></ul>
        /// This method is intended for use when there is an error parsing a message,
        /// (so the Message object is unavailable) but an error message must be sent
        /// back to the remote system including some of the information in the inbound
        /// message.  This method parses only that required information, hopefully
        /// avoiding the condition that caused the original error.</p>
        /// </summary>
        public override Segment getCriticalResponseData(System.String message)
        {
            System.String version      = getVersion(message);
            Segment       criticalData = Parser.makeControlMSH(version, Factory);

            Terser.Set(criticalData, 1, 0, 1, 1, parseLeaf(message, "MSH.1", 0));
            Terser.Set(criticalData, 2, 0, 1, 1, parseLeaf(message, "MSH.2", 0));
            Terser.Set(criticalData, 10, 0, 1, 1, parseLeaf(message, "MSH.10", 0));
            System.String procID = parseLeaf(message, "MSH.11", 0);
            if (procID == null || procID.Length == 0)
            {
                procID = parseLeaf(message, "PT.1", message.IndexOf("MSH.11"));
                //this field is a composite in later versions
            }
            Terser.Set(criticalData, 11, 0, 1, 1, procID);

            return(criticalData);
        }
Esempio n. 45
0
    public override void startMoveUnit()
    {
        System.String        name       = transform.parent.gameObject.name;
        int                  commaBreak = name.IndexOf(',');
        int                  x          = System.Convert.ToInt32(name.Substring(4, commaBreak - 4));
        int                  y          = System.Convert.ToInt32(name.Substring(commaBreak + 1, name.Length - 1 - commaBreak));
        List <Tile.tileType> bannedList = new List <Tile.tileType>();

        bannedList.Add(Tile.tileType.Grass);
        bannedList.Add(Tile.tileType.Ice);
        transform.parent.parent.GetComponent <BoardManager>().markMovement(bannedList, speed, transform.parent.GetComponent <Tile>(), transform.parent.GetComponent <Tile>());
        if (unitMenu != null)
        {
            Destroy(unitMenu.gameObject);
        }
        Camera.main.GetComponent <CameraControllerPC>().changeMode(CameraControllerPC.inputModes.ACTIONTARGET);
        Camera.main.GetComponent <CameraControllerPC>().setActionTarget(new CameraControllerPC.targetSelectMethod(endMoveUnit));
    }
        /// <summary> Finds a message or segment class by name and version.</summary>
        /// <param name="name">the segment or message structure name
        /// </param>
        /// <param name="version">the HL7 version
        /// </param>
        /// <param name="type">'message', 'group', 'segment', or 'datatype'
        /// </param>
        private static System.Type findClass(System.String name, System.String version, System.String type)
        {
            if (NuGenParser.validVersion(version) == false)
            {
                throw new NuGenHL7Exception("The HL7 version " + version + " is not recognized", NuGenHL7Exception.UNSUPPORTED_VERSION_ID);
            }

            //get list of packages to search for the corresponding message class
            System.String[] packages = packageList(version);

            //get subpackage for component type
            System.String types = "message|group|segment|datatype";
            if (types.IndexOf(type) < 0)
            {
                throw new NuGenHL7Exception("Can't find " + name + " for version " + version + " -- type must be " + types + " but is " + type);
            }
            System.String subpackage = type;

            //try to load class from each package
            System.Type compClass = null;
            int         c         = 0;

            while (compClass == null && c < packages.Length)
            {
                try
                {
                    System.String p = packages[c];
                    if (!p.EndsWith("."))
                    {
                        p = p + ".";
                    }
                    System.String classNameToTry = p + subpackage + "." + name;

                    compClass = System.Type.GetType(classNameToTry);
                }
                catch (System.Exception)
                {
                    /* just try next one */
                }
                c++;
            }
            return(compClass);
        }
Esempio n. 47
0
        static StackObject *IndexOf_26(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, 2);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            System.Char @value = (char)ptr_of_this_method->Value;

            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            System.String instance_of_this_method = (System.String) typeof(System.String).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags) 0);
            __intp.Free(ptr_of_this_method);

            var result_of_this_method = instance_of_this_method.IndexOf(@value);

            __ret->ObjectType = ObjectTypes.Integer;
            __ret->Value      = result_of_this_method;
            return(__ret + 1);
        }
 /// <summary>
 /// Add a Parameter to current command object
 /// </summary>
 /// <param name="ParameterName">Parameter Name</param>
 /// <param name="DataType">Parameter Data Type</param>
 /// <param name="Value">Parameter Value</param>
 public void Add_Parameter(System.String ParameterName, MySql.Data.MySqlClient.MySqlDbType DataType, System.Object Value)
 {
     try
     {
         if (ParameterName.IndexOf("@") < 0)
         {
             ParameterName = "@" + ParameterName;
         }
         _MyCommand.Parameters.Add(ParameterName, DataType).Value = Value;
     }
     catch (MySql.Data.MySqlClient.MySqlException SqEx)
     {
         throw new System.Exception(SqEx.Message);
     }
     catch (System.Exception Ex)
     {
         throw new System.Exception(Ex.Message);
     }
 }
Esempio n. 49
0
        /// <summary> Get the text up but not including one of the specified delimiter
        /// characters or the end of line, whichever comes first.
        /// </summary>
        /// <param name="delimiters">A set of delimiter characters.
        /// </param>
        /// <returns> A string, trimmed.
        /// </returns>
        public virtual System.String nextTo(System.String delimiters)
        {
            char c;

            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            for (; ;)
            {
                c = next();
                if (delimiters.IndexOf((System.Char)c) >= 0 || c == 0 || c == '\n' || c == '\r')
                {
                    if (c != 0)
                    {
                        back();
                    }
                    return(sb.ToString().Trim());
                }
                sb.Append(c);
            }
        }
Esempio n. 50
0
        /// <summary> Reads partial atomic charges and add the to the given ChemModel.
        ///
        /// </summary>
        /// <param name="model">Description of the Parameter
        /// </param>
        /// <throws>  CDKException Description of the Exception </throws>
        /// <throws>  IOException  Description of the Exception </throws>
        private void readPartialCharges(IChemModel model)
        {
            //logger.info("Reading partial atomic charges");
            ISetOfMolecules moleculeSet = model.SetOfMolecules;
            IMolecule       molecule    = moleculeSet.getMolecule(0);

            System.String line = input.ReadLine();
            // skip first line after "Total atomic charges"
            while (input.Peek() != -1)
            {
                line = input.ReadLine();
                //logger.debug("Read charge block line: " + line);
                if ((line == null) || (line.IndexOf("Sum of Mulliken charges") >= 0))
                {
                    //logger.debug("End of charge block found");
                    break;
                }
                System.IO.StringReader sr = new System.IO.StringReader(line);
                SupportClass.StreamTokenizerSupport tokenizer = new SupportClass.StreamTokenizerSupport(sr);
                if (tokenizer.NextToken() == SupportClass.StreamTokenizerSupport.TT_NUMBER)
                {
                    //UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
                    int atomCounter = (int)tokenizer.nval;

                    tokenizer.NextToken();
                    // ignore the symbol

                    double charge;
                    if (tokenizer.NextToken() == SupportClass.StreamTokenizerSupport.TT_NUMBER)
                    {
                        charge = tokenizer.nval;
                        //logger.debug("Found charge for atom " + atomCounter + ": " + charge);
                    }
                    else
                    {
                        throw new CDKException("Error while reading charge: expected double.");
                    }
                    IAtom atom = molecule.getAtomAt(atomCounter - 1);
                    atom.setCharge(charge);
                }
            }
        }
Esempio n. 51
0
        public static GeoParsedResult parse(Result result)
        {
            System.String rawText = result.Text;
            if (rawText == null || (!rawText.StartsWith("geo:") && !rawText.StartsWith("GEO:")))
            {
                return(null);
            }
            // Drop geo, query portion
            //UPGRADE_WARNING: Method 'java.lang.String.indexOf' was converted to 'System.String.IndexOf' which may throw an exception. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1101'"
            int queryStart = rawText.IndexOf('?', 4);

            System.String geoURIWithoutQuery = queryStart < 0?rawText.Substring(4):rawText.Substring(4, (queryStart) - (4));
            int           latitudeEnd        = geoURIWithoutQuery.IndexOf(',');

            if (latitudeEnd < 0)
            {
                return(null);
            }
            //UPGRADE_WARNING: Method 'java.lang.String.indexOf' was converted to 'System.String.IndexOf' which may throw an exception. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1101'"
            int    longitudeEnd = geoURIWithoutQuery.IndexOf(',', latitudeEnd + 1);
            double latitude, longitude, altitude;

            try
            {
                latitude = System.Double.Parse(geoURIWithoutQuery.Substring(0, (latitudeEnd) - (0)));
                if (longitudeEnd < 0)
                {
                    longitude = System.Double.Parse(geoURIWithoutQuery.Substring(latitudeEnd + 1));
                    altitude  = 0.0;
                }
                else
                {
                    longitude = System.Double.Parse(geoURIWithoutQuery.Substring(latitudeEnd + 1, (longitudeEnd) - (latitudeEnd + 1)));
                    altitude  = System.Double.Parse(geoURIWithoutQuery.Substring(longitudeEnd + 1));
                }
            }
            catch (System.FormatException)
            {
                return(null);
            }
            return(new GeoParsedResult(rawText.StartsWith("GEO:")?"geo:" + rawText.Substring(4):rawText, latitude, longitude, altitude));
        }
Esempio n. 52
0
        /// <summary>   Populates the given Segment object with data from the given XML Element. </summary>
        /// <summary>   for the given Segment, or if there is an error while setting individual field
        ///             values. </summary>
        ///
        /// <param name="segmentObject">    The segment object. </param>
        /// <param name="segmentElement">   Element describing the segment. </param>

        public virtual void Parse(ISegment segmentObject, System.Xml.XmlElement segmentElement)
        {
            SupportClass.HashSetSupport done = new SupportClass.HashSetSupport();

            //        for (int i = 1; i <= segmentObject.NumFields(); i++) {
            //            String elementName = makeElementName(segmentObject, i);
            //            done.add(elementName);
            //            parseReps(segmentObject, segmentElement, elementName, i);
            //        }

            System.Xml.XmlNodeList all = segmentElement.ChildNodes;
            for (int i = 0; i < all.Count; i++)
            {
                System.String elementName = all.Item(i).Name;
                if (System.Convert.ToInt16(all.Item(i).NodeType) == (short)System.Xml.XmlNodeType.Element &&
                    !done.Contains(elementName))
                {
                    done.Add(elementName);

                    int index = elementName.IndexOf('.');
                    if (index >= 0 && elementName.Length > index)
                    {
                        //properly formatted element
                        System.String fieldNumString = elementName.Substring(index + 1);
                        int           fieldNum       = System.Int32.Parse(fieldNumString);
                        this.ParseReps(segmentObject, segmentElement, elementName, fieldNum);
                    }
                    else
                    {
                        log.Debug(
                            "Child of segment " + segmentObject.GetStructureName() + " doesn't look like a field: "
                            + elementName);
                    }
                }
            }

            //set data type of OBX-5
            if (segmentObject.GetType().FullName.IndexOf("OBX") >= 0)
            {
                Varies.fixOBX5(segmentObject, this.Factory);
            }
        }
Esempio n. 53
0
        public ECheckContainKey checkContainKeyType()
        {
            ECheckContainKey nECheckContainKey = ECheckContainKey.ECheckContainKey_NoKey;

            System.Int32 nIndexOfValue = -1;

            nECheckContainKey = ECheckContainKey.ECheckContainKey_NoKey;


            nIndexOfValue = m_strLine.IndexOf(m_strKey);
            if (-1 != nIndexOfValue)
            {
                //find key ok
                nECheckContainKey = ECheckContainKey.ECheckContainKey_ContainKey;
                return(nECheckContainKey);
            }


            return(nECheckContainKey);
        }
Esempio n. 54
0
		// enhanced to not re-process substituted text
		public static System.String processArguments(System.String text, System.String[] args, int currentArg)
		{
			System.String working = text;
			if (working.IndexOf("${") != - 1 && args.Length > currentArg)
			{
				int index = extractNextIndex(working, args);
				if (index == - 1)
				{
					index = currentArg;
					currentArg++;
				}
				System.String value_Renamed = args[index];
				System.String[] replaced = replaceFirstValue(working, value_Renamed);
				return replaced[0] + processArguments(replaced[1], args, currentArg);
			}
			else
			{
				return working;
			}
		}
Esempio n. 55
0
        /// <summary> Populates the given Segment object with data from the given XML Element.</summary>
        /// <throws>  HL7Exception if the XML Element does not have the correct name and structure </throws>
        /// <summary>      for the given Segment, or if there is an error while setting individual field values.
        /// </summary>
        public virtual void  parse(Segment segmentObject, System.Xml.XmlElement segmentElement)
        {
            //UPGRADE_TODO: Class 'java.util.HashSet' was converted to 'SupportClass.HashSetSupport' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilHashSet'"
            SupportClass.HashSetSupport done = new SupportClass.HashSetSupport();

            //        for (int i = 1; i <= segmentObject.numFields(); i++) {
            //            String elementName = makeElementName(segmentObject, i);
            //            done.add(elementName);
            //            parseReps(segmentObject, segmentElement, elementName, i);
            //        }

            //UPGRADE_TODO: Method 'org.w3c.dom.Node.getChildNodes' was converted to 'System.Xml.XmlNode.ChildNodes' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
            System.Xml.XmlNodeList all = segmentElement.ChildNodes;
            for (int i = 0; i < all.Count; i++)
            {
                System.String elementName = all.Item(i).Name;
                if (System.Convert.ToInt16(all.Item(i).NodeType) == (short)System.Xml.XmlNodeType.Element && !done.Contains(elementName))
                {
                    done.Add(elementName);

                    int index = elementName.IndexOf('.');
                    if (index >= 0 && elementName.Length > index)
                    {
                        //properly formatted element
                        System.String fieldNumString = elementName.Substring(index + 1);
                        int           fieldNum       = System.Int32.Parse(fieldNumString);
                        parseReps(segmentObject, segmentElement, elementName, fieldNum);
                    }
                    else
                    {
                        log.debug("Child of segment " + segmentObject.getStructureName() + " doesn't look like a field: " + elementName);
                    }
                }
            }

            //set data type of OBX-5
            if (segmentObject.GetType().FullName.IndexOf("OBX") >= 0)
            {
                Varies.fixOBX5(segmentObject, Factory);
            }
        }
        /// <summary>
        /// getInstrumentIDFromOneLine
        /// eg. get "3320" from one line in one line
        /// </summary>
        /// <param name="strLogFileLine"></param>
        /// <returns></returns>
        private System.String getInstrumentIDFromOneLine(System.String strLineInFile)
        {
            System.String strInstrumentID = "";
            int           nfindSunStr     = -1;


            //3320,****
            if (strLineInFile.Length > 0)
            {
                nfindSunStr = -1;
                nfindSunStr = strLineInFile.IndexOf(",");
            }
            if (nfindSunStr > 0)
            {
                //3320,****
                strInstrumentID = strLineInFile.Substring(0, nfindSunStr);
                nfindSunStr     = -1;
            }

            return(strInstrumentID);
        }//AnalyseFile
Esempio n. 57
0
        public static System.String ExtractChar(System.String AValue, System.String AGroup)
        {
            System.String sTemp;
            System.Int32  nTemp;
            System.Int32  nCount = 0;
            sTemp = System.String.Empty;

            if (AValue != null)
            {
                nCount = AValue.Length;
            }

            for (nTemp = 0; nTemp < nCount; nTemp++)
            {
                if (AGroup.IndexOf(AValue[nTemp]) >= 0)
                {
                    sTemp = sTemp + AValue[nTemp];
                }
            }
            return(sTemp);
        }
        /// <summary> Transforms a string that represents a URI into something more proper, by adding or canonicalizing
        /// the protocol.
        /// </summary>
        private static System.String massageURI(System.String uri)
        {
            int protocolEnd = uri.IndexOf(':');

            if (protocolEnd < 0)
            {
                // No protocol, assume http
                uri = "http://" + uri;
            }
            else if (isColonFollowedByPortNumber(uri, protocolEnd))
            {
                // Found a colon, but it looks like it is after the host, so the protocol is still missing
                uri = "http://" + uri;
            }
            else
            {
                // Lowercase protocol to avoid problems
                uri = uri.Substring(0, (protocolEnd) - (0)).ToLower() + uri.Substring(protocolEnd);
            }
            return(uri);
        }
Esempio n. 59
0
        /// <summary>
        /// Add a Parameter to current command object
        /// </summary>
        /// <param name="ParameterName">Parameter Name</param>
        /// <param name="Value">Parameter Value</param>
        public void Add_Parameter_WithValue(System.String ParameterName, System.Object Value)
        {
            try
            {
                if (ParameterName.IndexOf("@") < 0)
                {
                    ParameterName = "@" + ParameterName;
                }
                //var _value = Convert.ChangeType(Value, Value.GetType());

                _MyCommand.Parameters.AddWithValue(ParameterName, Value);
            }
            catch (MySql.Data.MySqlClient.MySqlException SqEx)
            {
                throw new System.Exception(SqEx.Message);
            }
            catch (System.Exception Ex)
            {
                throw new System.Exception(Ex.Message);
            }
        }
Esempio n. 60
0
        static void RunCase(int CaseNum, System.IO.TextReader TR, System.IO.TextWriter TW)
        {
            char[] Splits = new char[] { ' ', '\t', '\n', '\r' };
            int    L      = System.Convert.ToInt32(TR.ReadLine());

            System.String TreeStr = "";
            for (int i = 0; i < L; i++)
            {
                TreeStr += TR.ReadLine();
            }
            int  Start = TreeStr.IndexOf('(');
            int  End   = TreeStr.LastIndexOf(')');
            Node N     = new Node(TreeStr.Substring(Start + 1, End - Start - 1));

            System.String Result = "Case #" + (CaseNum + 1) + ":";
            int           A      = System.Convert.ToInt32(TR.ReadLine());

            for (int i = 0; i < A; i++)
            {
                System.String   AStr    = TR.ReadLine();
                System.String[] Strs    = AStr.Split(Splits, StringSplitOptions.RemoveEmptyEntries);
                int             NumChar = System.Convert.ToInt32(Strs[1]);
                System.String[] Chars   = new System.String[NumChar];
                for (int j = 0; j < NumChar; j++)
                {
                    Chars[j] = Strs[j + 2];
                }
                Result += "\n" + N.Eval(Chars).ToString("0.0000000");
            }


            if (TW == null)
            {
                System.Console.WriteLine(Result);
            }
            else
            {
                TW.WriteLine(Result);
            }
        }