Example #1
0
 private static string ConvertValue(String value)
 {
     Dictionary<String, String> replacements = new Dictionary<string, string>();
     replacements.Add("&sp;", " ");
     replacements.Add("&1uc;", "{-|}");
     replacements.Add("&amp;", "&");
     replacements.Add("&bs;", "{# BackSpace}");
     replacements.Add("&cr;", "{# Return}");
     replacements.Add("&uc;", "{MODE:CAPS}");
     replacements.Add("&lc;", "{MODE:LOWER}");
     replacements.Add("&dw;", "{# Control_L(BackSpace)}");
     replacements.Add("\\", "\\\\");
     replacements.Add("\"", "\\\"");
     foreach (string key in replacements.Keys.OrderByDescending(_k=>_k.Length))
     {
         value = value.Replace(key, replacements[key]);
     }
     if (value.Contains("&+i;"))
     {
         value = String.Format("{0}{{^}}", value.Replace("&+i;", ""));
     }
     if (value.Contains("&rb;"))
     {
         value = String.Format("{{^}}{0}", value.Replace("&rb;", ""));
     }
     return value.Trim();
 }
        public static String getLatFromAddress2(String s)
        {
            s = s.Replace("Suite", "");
            s = s.Replace("suite", "");
            s = s.Replace("Apt", "");
            s = s.Replace("apt", "");

            //Instance class use (Geocode)  (Can be made from static/instance class)
            var geocodeRequest = new GeocodingRequest
                                     {
                                         Address = s,
                                     };
            var geocodingEngine = new GeocodingEngine();

            GeocodingResponse geocode = geocodingEngine.GetGeocode(geocodeRequest);
            Result match1 = null;
            try
            {
                match1 = geocode.Results.First();
            }
            catch (Exception)
            {
                return "notfound";
            }
            Double lat = match1.Geometry.Location.Latitude;

            return lat.ToString();
        }
Example #3
0
        /// <summary>
        /// 修改已有的文件名。
        /// </summary>
        /// <param name="oldWjm">旧文件名</param>
        /// <param name="newWjm">新文件名</param>
        /// <returns>是否修改成功</returns>
        public bool changeGYBGPMWjm(String oldWjm, String newWjm)
        {
            if (null == oldWjm || null == newWjm)
            {
                return false;
            }

            String dwjm = newWjm.Replace(".PDF", ".DOC");

            IDictionary<String, Object> para = new Dictionary<String, Object>();
            para.Add("oldwjm", oldWjm);
            para.Add("newwjm", newWjm);
            para.Add("dwjm", dwjm);

            bool result = true;
            try
            {
                sqlMapper.Update("ChangeGYBG_PM_wjm", para);
                //修改PDF文件名
                OperationFile.ReNameFile(oldWjm, newWjm);
                //修改DOC文件名
                oldWjm=oldWjm.Replace(".PDF", ".DOC");
                newWjm=newWjm.Replace(".PDF", ".DOC");
                OperationFile.ReNameFile(oldWjm, newWjm);

            }
            catch
            {
                result = false;
            }
            return result;
        }
Example #4
0
 public static string encryptBase64Url(String text)
 {
     text = text.Replace("+","-");
     text = text.Replace("/","_");
     text = text.Replace("=","$");
     return text;
 }
Example #5
0
            public List<String> publisher_update_task( String api, String topic, List<string> pub_uris) 
            {
                XmlRpcValue l = new XmlRpcValue();
                l.Set(0, api);
                l.Set(1, "");
                //XmlRpcValue ll = new XmlRpcValue();
                //l.Set(0, ll);
                for(int i = 0; i < pub_uris.Count; i++)
                {
                    XmlRpcValue ll = new XmlRpcValue(pub_uris[i]);
                    l.Set(i + 1, ll);
                }


                XmlRpcValue args = new XmlRpcValue();
                args.Set(0, "master");
                args.Set(1, topic);
                args.Set(2, l);
                       XmlRpcValue result = new XmlRpcValue(new XmlRpcValue(), new XmlRpcValue(), new XmlRpcValue(new XmlRpcValue())),
                        payload = new XmlRpcValue();

                 Ros_CSharp.master.host = api.Replace("http://","").Replace("/","").Split(':')[0];
                 Ros_CSharp.master.port =  int.Parse( api.Replace("http://", "").Replace("/", "").Split(':')[1]);
                 Ros_CSharp.master.execute("publisherUpdate", args, result, payload, false );
                
                return new List<string>(new []{"http://ERIC:1337"});
            }
Example #6
0
        public static String GetLogicalTag(String templateText)
        {
            String pattern = @"[\[][\%][\?][^[email protected]].*?[\%][\]]";
            Regex regex = new Regex(pattern);
            MatchCollection matchCollection = regex.Matches(templateText);

            bool flags = false;

            pattern = @"(\[\%\?\%\])";
            regex = new Regex(pattern);
            MatchCollection fix = regex.Matches(templateText);
            if (fix.Count != 0)
                flags = true;

            foreach (Match item in matchCollection)
            {
                if (flags)
                {
                    String temp = item.Value.Trim(new Char[] { '[', '%', '?', ']' });

                    templateText = templateText.Replace(item.Value, " if( " + temp + " ) {");

                    templateText = templateText.Replace("[%?%]", " } ");
                }
                else
                {
                    String temp = item.Value.Trim(new Char[] { '[', '%', '?', ']' });

                    templateText = templateText.Replace(item.Value, " if( " + temp + " ) ");
                }
            }

            return templateText;
        }
Example #7
0
 /// <summary>
 /// Processes the internal argruments in a string.
 /// </summary>
 public static String ProcessArguments(String data)
 {
     data = data.Replace("$(Quote)", "\"");
     data = data.Replace("$(AppDir)", PathHelper.GetExeDirectory());
     data = Environment.ExpandEnvironmentVariables(data);
     return data;
 }
Example #8
0
        private String modifycatorString(int inAccuracy, String dataString, int inputStringFormat)
        {
            if (dataString.Length > inAccuracy)
                    dataString = dataString.Substring(0, inAccuracy);

            dataString = dataString.Replace('E', 'e');
            dataString = dataString.Replace('.', ',');

            if (dataString.IndexOf(',') == 0)
            dataString = "0" + dataString;

            if ((dataString[0] != '-') && (dataString[0] != '+'))
                dataString = "+" + dataString;

            if (dataString.IndexOf(',') == -1)
            if (dataString.IndexOf('e') != -1)
                    dataString = dataString.Substring(0, dataString.IndexOf('e')) + ",0" + dataString.Substring(dataString.IndexOf('e'));
            else
                    dataString = dataString + ",0";

            if ((dataString[dataString.IndexOf('e') + 1] != '+')&&
                (dataString[dataString.IndexOf('e') + 1] != '-'))
                dataString = dataString.Replace("e", "e+");

            if (dataString.IndexOf('e') == -1)
                dataString = dataString + "e+0";

            return dataString;
        }
Example #9
0
 public static string decryptBase64Url(String base64Url)
 {
     base64Url = base64Url.Replace("-", "+");
     base64Url = base64Url.Replace("_", "/");
     base64Url = base64Url.Replace("$", "=");
     return base64Url;
 }
Example #10
0
 /// <summary>
 /// Creates a new CSS range token.
 /// </summary>
 /// <param name="range">The selected range string.</param>
 /// <param name="position">The token's position.</param>
 public CssRangeToken(String range, TextPosition position)
     : base(CssTokenType.Range, range, position)
 {
     _start = range.Replace(Symbols.QuestionMark, '0');
     _end = range.Replace(Symbols.QuestionMark, 'F');
     _range = GetRange();
 }
Example #11
0
 public static Dictionary<String, String> JsonObjectToDictionaryList(String StringDataIn)
 {
     Dictionary<String, String> Json = new Dictionary<string, string>();
     StringDataIn = StringDataIn.Replace("{", "");//Beginn of Object
     StringDataIn = StringDataIn.Replace("}", "");//End of Object
     return JsonObjectToDictionary(StringDataIn);
 }
        public GetSystemFlags(String CurrentFlags)
        {
            InitializeComponent();

            foreach (EnumFlags EFlags in Enum.GetValues(typeof(EnumFlags)))
            {
                _ValueFlags.Add(EFlags.ToString());
            }

            for (int i = 0; i < _ValueFlags.Count; i++)
            {
                listBox_Flags.Items.Add(_ValueFlags[i].ToString());
            }

            // Parse current flags
            CurrentFlags = CurrentFlags.Replace("(", "");
            CurrentFlags = CurrentFlags.Replace(")", "");
            CurrentFlags = CurrentFlags.Replace(" ", "");

            string[] ParsedString = CurrentFlags.Split(new char[]{'+'});
            for (int i = 0; i < ParsedString.Length; i++)
            {
                listBox_Flags.SelectedItems.Add(ParsedString[i]);
            }
        }
Example #13
0
 public String EscapeForXMLandHTML(String myString)
 {
     myString = myString.Replace("<", "&lt;");
     myString = myString.Replace(">", "&gt;");
     myString = myString.Replace("&", "&amp;");
     return myString;
 }
Example #14
0
 private String escapeAscii(String text)
 {
     text = text.Replace("\x0a", "\\n");
     text = text.Replace("\x0d", "\\r");
     text = text.Replace("\xa0", "\\u00a0");
     return text;
 }
        public static String adaptarTexto(String txt)
        {
            if (txt.Substring(0, 2).Equals("rt"))
            {
                txt = txt.Substring(2);
            }

            if (txt != null && !txt.Equals(""))
            {

                char[] acentuados = new char[] { 'ç', 'á', 'à', 'ã', 'â', 'ä', 'é', 'è', 'ê', 'ë', 'í', 'ì', 'î', 'ï', 'ó', 'ò', 'õ', 'ô', 'ö', 'ú', 'ù', 'û', 'ü' };
                char[] naoAcentuados = new char[] { 'c', 'a', 'a', 'a', 'a', 'a', 'e', 'e', 'e', 'e', 'i', 'i', 'i', 'i', 'o', 'o', 'o', 'o', 'o', 'u', 'u', 'u', 'u' };

                for (int i = 0; i < acentuados.Length; i++)
                {
                    txt = txt.Replace(acentuados[i], naoAcentuados[i]);
                }

            }

            txt = txt.Replace("rt ", "#rt ");
            txt = txt.Replace("retweet", "#rt");
            txt = txt.Replace("de um #rt", "de #rt");

            txt = removerPontuacao(txt);
            txt = adaptarPreco(txt);

            return txt;
        }
        //Method to eliminate Hyperlinks from numbers
        public static String cleanString(String s)
        {
            s.Trim();
            s = s.Replace("hyperlink", "");
            s = s.Replace(" ", "");
            //finds the last index where ' occurs
            int end = s.LastIndexOf("\"");
            int num = s.Length;

            int n = s.Length - end;

            char[] a = s.ToCharArray();
            char[] b = new char[256];

            int j = 0;
            for (int i = end + 1; i < s.Length; i++)
            {

                b[j] = a[i];
                j++;
            }

            string str = new string(b);
            return str;
        }
        public Boolean VerificaRut(String rut)
        {
            bool validacion = false;
            try
            {
                rut = rut.ToUpper();
                rut = rut.Replace(".", "");
                rut = rut.Replace("-", "");
                int rutAux = int.Parse(rut.Substring(0, rut.Length - 1));

                char dv = char.Parse(rut.Substring(rut.Length - 1, 1));

                int m = 0, s = 1;
                for (; rutAux != 0; rutAux /= 10)
                {
                    s = (s + rutAux % 10 * (9 - m++ % 6)) % 11;
                }
                if (dv == (char)(s != 0 ? s + 47 : 75))
                {
                    validacion = true;
                }
            }
            catch (Exception)
            {
            }
            return validacion;
        }
Example #18
0
 public static byte[] ConvertFromBase64String(String dataStr)
 {
     dataStr = dataStr.Replace("$", "/");
     dataStr = dataStr.Replace("#", "+");
     byte[] data = Convert.FromBase64String(dataStr);
     return data;
 }
Example #19
0
 /// <summary>
 ///   Generates a valid DotNet name.
 /// </summary>
 /// <param name = "prefix">The prefix.</param>
 /// <param name = "value">The value.</param>
 /// <returns>A valid DotNet name.</returns>
 public static String GenerateDotNetName(String prefix, String value)
 {
     value = value.Replace('-', ' ');
     value = value.Replace('&', ' ');
     String[] parts = value.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
     return parts.Aggregate(prefix, (s, part) => s += (part.Substring(0, 1).ToUpper() + part.Substring(1)));
 }
        /// <summary>
        /// Converts an XMLstring to an array of GBaseElement (Name and Type) structures
        /// </summary>
        /// <param name="XMLString">An XML string of the form: field..type..field..type...</param>
        /// <returns>An array of GBaseElement that is the parsed, passed XMLstring</returns>
        public GBaseElement[] FieldsToGBaseElementArray(String XMLString)
        {
            Stack<GBaseElement> _elements = new Stack<GBaseElement>();                      // Initially use a stack to hold the elements
            XMLString = XMLString.Replace("\t", "").Replace("\r", "").Replace("\n",  "");   // Replace the tabs, newllines, and returns in the string

            // Loop until break is hit
            while (true)
            {
                _GBaseElement.Name = XMLString.Substring(XMLString.IndexOf("Name=\"") + 6,      // Set the name to be the string between "Name=\"" and the next "
                                                         XMLString.IndexOf("\"", XMLString.IndexOf("Name=\"") + 6) - (XMLString.IndexOf("Name=\"") + 6)).ToLower();

                                                                                                // Set the Type to be the string between <Type> and </Type>
                _GBaseElement.Type = GetXMLBetweenTags("Type", XMLString).ToLower();

                _elements.Push(_GBaseElement);  // Push the newly generated object into _elements

                XMLString = XMLString.Substring(XMLString.IndexOf("</Field>") + 8,              // Get rid of the portion of the string that has been evaluated
                                                XMLString.Length - (XMLString.IndexOf("</Field>") + 8));

                if (XMLString.Replace(" ", "").Length == 0)     // Get rid of any left over spaces (sometimes they presist) and see if there is no more to look over
                    break;
            }

            return _elements.ToArray();     // Return the stack as an array
        }
Example #21
0
 public Address(String sourceAddressCode)
 {
     if (sourceAddressCode.StartsWith(LexicalSymbols.LabelAddress))
     {
         this.IsLabelledAddress = true;
         this.AddressLabel = sourceAddressCode.Replace(LexicalSymbols.LabelAddress, String.Empty);
     }
     else if (sourceAddressCode.StartsWith(LexicalSymbols.BinaryAddress))
     {
         this.BinaryAddress = int.Parse(sourceAddressCode.Replace(LexicalSymbols.BinaryAddress, String.Empty));
         this.SourceAddress = BinaryToSource(this.BinaryAddress);
     }
     else
     {
         this.SourceAddress = int.Parse(sourceAddressCode);
         if (this.SourceAddress >= 0)
         {
             this.BinaryAddress = SourceToBinary(this.SourceAddress);
         }
         else
         {
             this.BinaryAddress = this.SourceAddress;
         }
     }
 }
Example #22
0
 public void gotAT(String newATCommand)
 {
     newATCommand = newATCommand.Replace("\r", "");
     newATCommand = newATCommand.Replace("\n", "");
     Console.WriteLine("adding:" + newATCommand);
     slots[actSlot].settingStrings.Add(newATCommand);
 }
Example #23
0
 private static string TidyUpArtist(String artist)
 {
     artist = artist.Replace("&&", "&amp;");
     artist = artist.Replace("\"", "&quot;");
     artist = artist.Replace("<", "&lt;");
     artist = artist.Replace(">", "&gt;");
     return artist;
 }
Example #24
0
 /// <summary>
 /// Returns a string where all "wrong" directory separator chars are replaced by the ones used by the system 
 /// </summary>
 /// <param name="path">The original path string potentially with wrong chars</param>
 /// <returns>The corrected path string</returns>
 static String FixDirectorySeparators(String path)
 {
     if(Path.DirectorySeparatorChar != '\\')
         path = path.Replace('\\', Path.DirectorySeparatorChar);
     if(Path.DirectorySeparatorChar != '/')
         path = path.Replace('/', Path.DirectorySeparatorChar);
     return path;
 }
Example #25
0
 private static String replaceSpecialChart(String sourceData)
 {
     sourceData = sourceData.Replace("\r\n", "<br>");
     sourceData = sourceData.Replace("\n", "<br>");
     sourceData = sourceData.Replace(@"\", @"\\");
     sourceData = sourceData.Replace("'", "\\'");
     return sourceData;
 }
Example #26
0
        public String BuildAbsoluteUrl(String rootUrl)
        {
            if (String.IsNullOrWhiteSpace(rootUrl)) throw new ArgumentNullException("rootUrl");

            return (String.Equals(rootUrl, ArcGIS.ServiceModel.PortalGateway.AGOPortalUrl, StringComparison.OrdinalIgnoreCase))
                ? (DontForceHttps ? rootUrl : rootUrl.Replace("http://", "https://")) + RelativeUrl.Replace("tokens/", "")
                : (DontForceHttps ? rootUrl : rootUrl.Replace("http://", "https://")) + RelativeUrl;
        }
Example #27
0
 public virtual void RefractorString(ref String s)
 {
     s = s.Replace("~(", "bitnot(");
     s = s.Replace(" && ", " and ");
     s = s.Replace(" || ", " or ");
     s = s.Replace("!", "not ");
     s = s.Replace("nop", "nop()");
 }
Example #28
0
 private static String ReplaceWithFilePaths( String strFileData,  String appDir, String binDir, String strOriginUrl){
     strFileData = strFileData.Replace("$AppDir$", appDir);
     strFileData = strFileData.Replace("$AppDirUrl$", MakeFileUrl(appDir));
     strFileData = strFileData.Replace("$CodeGen$", MakeFileUrl(binDir));
     if (strOriginUrl != null)
         strFileData = strFileData.Replace("$OriginUrl$", strOriginUrl);
     return strFileData ;
 }
Example #29
0
 String EscapeForHtml(String str)
 {
     str = str.Replace("'", "&#39;");
     str = str.Replace("\"", "&quot;");
     str = str.Replace("\n", " ");
     str = str.Replace("<", "&lt;");
     str = str.Replace(">", "&gt;");
     return str;
 }
Example #30
0
    public String Purge(String text)
    {
        text= text.Replace("&nbsp;"," ");

        text = text.Replace("\r\n", " ");
        text = text.Replace("  ", " ");

        return text;
    }