Beispiel #1
0
        static void Main()
        {
            // "Hello"
            System.String s = "Hello";
            Console.WriteLine(s);
            Console.WriteLine(s.GetHashCode());
            s = s.Insert(2, "mm");
            //s[2] = 'm';
            Console.WriteLine(s);
            Console.WriteLine(s.GetHashCode());
            // "-----------------------------------------------"
            String s2 = new string('-', 20);

            //"Hello-----------------------------------------------"
            s += s2;  //s = s + s2;

            //"5"
            string s4 = 5.ToString();

            //"1 + 2 = 3"
            string s5 = String.Format("{0} + {1} = {2}", 1, 2, 1 + 2);


            // Delay
            Console.ReadKey();
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            //"Hello"
            System.String s = "Hello";
            Console.WriteLine(s);
            Console.WriteLine(s.GetHashCode()); //HashCode - как номер паспорта

            //---------------------
            //Immutable types - типы, которые невозможно изменить. Если мы пытаемся изменить, то у нас создается
            //новый экзампляр этого типа, а старый экземпляр НЕ ИЗМЕНЯЕТСЯ(или погибает в случае s = s + "a";
            s = s.Insert(2, "mmmmm"); //HashCod`ы будут разные т.к string - это immutable type и вместо старой s, теперь уже новая s.
            //s[2] индексаторов нету
            Console.WriteLine(s);
            Console.WriteLine(s.GetHashCode());

            //---------------------
            String s2 = new string('-', 20);

            //Hemmmmmlo------------------------------
            s += s2;

            //"5"
            //На экране есть ЗНАКОМЕСТА (alt + shift) и моно выделять знакоместа с рядов повыше и пониже
            string s4 = 5.ToString(); //по умолчанию ToString(); выводит полное квалифицированное имя класса.

            //"1 + 2 = 3";
            string s5 = String.Format("{0} + {1} = {2}", 1, 2, 1 + 2);


            //Delay
            Console.ReadKey();
        }
Beispiel #3
0
 /// <summary>
 /// Returns a specific Stopwatch if it exists.
 /// </summary>
 /// <param name="identifier">Identifing the used Stopwatch.</param>
 /// <returns>The specified stopwatch.</returns>
 public Stopwatch this[String identifier]
 {
     get
     {
         if (!_stopwatches.ContainsKey(identifier.GetHashCode())) return null;
         return _stopwatches[identifier.GetHashCode()];
     }
     set
     {
         if (value == null) throw new NullReferenceException("Value is null.");
         _stopwatches[identifier.GetHashCode()] = value;
     }
 }
        public override int GetHashCode()
        {
            int result = base.GetHashCode();

            result = 29 * result + _Id.GetHashCode();
            return(result);
        }
Beispiel #5
0
        /// <summary>Returns true if <code>o</code> is equal to this.  If a
        /// {@link SortComparatorSource} (deprecated) or {@link
        /// FieldCache.Parser} was provided, it must properly
        /// implement hashCode (unless a singleton is always
        /// used).
        /// </summary>
        public override int GetHashCode()
        {
            int hash = type ^ 0x346565dd + (reverse ? Boolean.TrueString.GetHashCode() : Boolean.FalseString.GetHashCode()) ^ unchecked ((int)0xaf5998bb);

            if (field != null)
            {
                hash += (field.GetHashCode() ^ unchecked ((int)0xff5685dd));
            }
            if (locale != null)
            {
                hash += (locale.GetHashCode() ^ 0x08150815);
            }
            if (factory != null)
            {
                hash += (factory.GetHashCode() ^ 0x34987555);
            }
            if (comparatorSource != null)
            {
                hash += comparatorSource.GetHashCode();
            }
            if (parser != null)
            {
                hash += (parser.GetHashCode() ^ 0x3aaf56ff);
            }
            return(hash);
        }
 public Activity(String code, String name)
 {
    this.hash = code.GetHashCode();
    this.code = code;
    this.name = name;
    ACTIVITY_POOL.RegisterActivity(this);
 }
Beispiel #7
0
 public static string rfc4122(String seed)
 {
     int oldSeed = Random.seed;
       Random.seed = seed.GetHashCode();
       string uuid = rfc4122();
       Random.seed = oldSeed;
       return uuid;
 }
Beispiel #8
0
        public override int GetHashCode()
        {
            int result;

            result = clauses.GetHashCode();
            result = 29 * result + field.GetHashCode();
            return(result);
        }
 /// <summary>
 /// generates a unique vactionRequestID
 /// </summary>
 /// <param name="EmployeeID"> the EmployeeID of the creator</param>
 /// <returns>vactionRequestID</returns>
 public ulong GenerateID(String EmployeeID)
 {
     DateTime moment = DateTime.Now;
     long timestamp = moment.Ticks - new DateTime(1970, 1, 1).Ticks;
     long iDHash = EmployeeID.GetHashCode();
     ulong vactionRequestID = (ulong)((timestamp & 0x0000FFFFFFFFFFFF) | (iDHash << 48));
     return vactionRequestID;
 }
Beispiel #10
0
        public override int GetHashCode()
        {
            int result;

            result = (_icerik != null?_icerik.GetHashCode():0);
            result = 29 * result + (TipVarmi() ? _tip.GetHashCode() : 0);
            result = 29 * result + (ozelDurumlar != null?ozelDurumlar.GetHashCode():0);
            return(result);
        }
        public StorageKey(Guid uid, String key)
        {
            UID = uid;

            UniqueKey = key;

            FragmentID = key.GetHashCode();

        }
Beispiel #12
0
        //@Override
        public override int GetHashCode()
        {
            int prime  = 31;
            int result = 1;

            result = prime * result + ((field == null) ? 0 : field.GetHashCode());
            result = prime * result + ((text == null) ? 0 : text.GetHashCode());
            return(result);
        }
Beispiel #13
0
        /// <summary>Returns a hash code value for this object.</summary>
        public override int GetHashCode()
        {
            int h = fieldName.GetHashCode();

            h ^= (lowerTerm != null ? lowerTerm.GetHashCode() : unchecked ((int)0xB6ECE882));        // {{Aroush-1.9}} is this OK?!
            h  = (h << 1) | (SupportClass.Number.URShift(h, 31));                                    // rotate to distinguish lower from upper
            h ^= (upperTerm != null ? (upperTerm.GetHashCode()) : unchecked ((int)0x91BEC2C2));      // {{Aroush-1.9}} is this OK?!
            h ^= (includeLower ? unchecked ((int)0xD484B933) : 0) ^ (includeUpper ? 0x6AE423AC : 0); // {{Aroush-1.9}} is this OK?!
            return(h);
        }
Beispiel #14
0
 private Bitmap getCaptchaFromSiDdos(String domen, String sidDdos)
 {
     string localFilename = Directory.GetCurrentDirectory() + @"\" + sidDdos.GetHashCode() + ".jpg";
     using (WebClient client = new WebClient())
     {
         client.DownloadFile(domen + "agent.php?a=code&sid=" + sidDdos, localFilename);
         Bitmap image = new Bitmap(localFilename);
         return image;
     }
 }
        public static Int32 generatePasswordHash(String password)
        {
            Int32 ret;

            /* Implement function */
            ret = password.GetHashCode();
            /* */

            return ret;
        }
Beispiel #16
0
 public Boolean IsExist(String fileName)
 {
     if (String.IsNullOrEmpty(fileName) == true) return false;
     int hash = Math.Abs(fileName.GetHashCode());
     hash = hash % 10000;
     int bucket1 = hash / 100;
     int bucket2 = hash % 100;
     String fullPath = Path.Combine(BaseDir, bucket1.ToString(), bucket2.ToString(), fileName);
     return File.Exists(fullPath);
 }
Beispiel #17
0
        public override int GetHashCode()
        {
            int result;

            result  = clauses.GetHashCode();
            result += slop * 29;
            result += (inOrder?1:0);
            result ^= field.GetHashCode();
            return(result);
        }
        public static Boolean checkPassword(String password, Int32 passwordHash)
        {
            Boolean ret;

            /* Implement function */
            ret = (passwordHash == password.GetHashCode());
            /* */

            return ret;
        }
Beispiel #19
0
        public String createPic(String base64Code, String format)
        {
            try
            {
                //use standard 3 letter suffix
                if (format == "jpeg")
                {
                    format = "jpg";
                }

                //get hash code of this specific image as its file name, ensuring duplicate image won't be created
                String fileName = base64Code.GetHashCode().ToString();
                fileName = fileName + "." + format;

                //generate full path of the image
                String fileFullPath = storePath + "\\" + fileName;

                //if image doesn't exist, create it
                if (!File.Exists(fileFullPath))
                {
                    byte[] arr = Convert.FromBase64String(base64Code);
                    MemoryStream ms = new MemoryStream(arr, 0, arr.Length);
                    ms.Write(arr, 0, arr.Length);
                    Image image = Image.FromStream(ms, true);

                    switch (format)
                    {
                        case "jpg":
                            image.Save(fileFullPath, ImageFormat.Jpeg);
                            break;
                        case "gif":
                            image.Save(fileFullPath, ImageFormat.Gif);
                            break;
                        case "png":
                            image.Save(fileFullPath, ImageFormat.Png);
                            break;
                        case "bmp":
                            image.Save(fileFullPath, ImageFormat.Bmp);
                            break;
                        default:
                            break;
                    }
                    ms.Close();
                }

                //return file name for replacing the original "src" in _resultXML
                return fileName;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Error");
                return "Error Happened.";
            }
        }
 //@Override
 public override int GetHashCode()
 {
     int prime = 31;
     int result = base.GetHashCode();
     result = prime * result + ((collator == null)?0:collator.GetHashCode());
     result = prime * result + ((field == null)?0:field.GetHashCode());
     result = prime * result + (includeLower?1231:1237);
     result = prime * result + (includeUpper?1231:1237);
     result = prime * result + ((lowerTerm == null)?0:lowerTerm.GetHashCode());
     result = prime * result + ((upperTerm == null)?0:upperTerm.GetHashCode());
     return result;
 }
Beispiel #21
0
        /// <summary>
        /// Function used to authenticate the specified user
        /// </summary>
        /// <param name="userName">user identifier </param>
        /// <param name="password">user password</param>
        /// <returns>User: authenticated, null: not authenticated</returns>
        public User authenticate(String userName, String password)
        {
            User user = null;
            String hashedPassword = password.GetHashCode().ToString("x");
            //validar password

            user = (from u in context.Users
                        where u.UserName == userName
                        && u.Password == hashedPassword
                        select u).FirstOrDefault();

            return user;
        }
Beispiel #22
0
        /// <summary>Returns a hash code value for this object.</summary>
        public override int GetHashCode()
        {
            int h = BitConverter.ToInt32(BitConverter.GetBytes(GetBoost()), 0) ^ fieldName.GetHashCode();

            // hashCode of "" is 0, so don't use that for null...
            h ^= (lowerVal != null ? lowerVal.GetHashCode() : unchecked ((int)0x965a965a));                 // {{Aroush-1.9}} Is this OK?!
            // don't just XOR upperVal with out mixing either it or h, as it will cancel
            // out lowerVal if they are equal.
            h ^= ((h << 17) | (SupportClass.Number.URShift(h, 16)));                                 // a reversible (one to one) 32 bit mapping mix
            h ^= (upperVal != null ? (upperVal.GetHashCode()) : 0x5a695a69);
            h ^= (includeLower ? 0x665599aa : 0) ^ (includeUpper ? unchecked ((int)0x99aa5566) : 0); // {{Aroush-1.9}} Is this OK?!
            return(h);
        }
 public String Build(String[] s)
 {
     if (s[0] != "1" && s[0] != "2" && s[0] != "3" && s[0] != "4" && s[0] != "5" && s[0] != "6" )
     {
         throw new ArgumentException("Protokolltyp " + s[0] + "in param[0] ist nicht definiert!");
     }
     String ret = "";
     for (int i = 0; i < s.Length; i++)
     {
         ret += s[i] + "@@@";
     }
     ret += s.GetHashCode();
     return ret;
 }
Beispiel #24
0
        public override int GetHashCode()
        {
            InitTermBuffer();
            int code = termLength;

            code = code * 31 + startOffset;
            code = code * 31 + endOffset;
            code = code * 31 + flags;
            code = code * 31 + positionIncrement;
            code = code * 31 + type.GetHashCode();
            code = (payload == null ? code : code * 31 + payload.GetHashCode());
            code = code * 31 + ArrayUtil.HashCode(termBuffer, 0, termLength);
            return(code);
        }
Beispiel #25
0
        //public Boolean isAuthorized(String userName, String permissionName)
        //{
        //}
        public void insertUser(String userName, String completeName , String password, long userID )
        {
            var newUser = new User();

            newUser.Id = (int)IdentifierGenerator.NewId();
            newUser.IdSession = SessionManager.getSessionIdentifier();
            newUser.UserName = userName;
            newUser.CompleteName = completeName;
            newUser.Password = password.GetHashCode().ToString("x");
            newUser.IdUserRelation = userID;

            context.Users.Add(newUser);

            context.SaveChanges();
        }
Beispiel #26
0
        public void Resolve(String name, bool ip4Only)
        {
            this.m_name = name;

            int hash = name.GetHashCode();
            if (hash < 0)
                hash = -hash;
            hash = hash % 55536;
            hash += 10000;

            try {
                Address = new IPEndPoint(IPAddress.Loopback, hash);
            } catch (Exception ex) {
                throw new ArgumentException("",ex);
            }
        }
Beispiel #27
0
 public Player(Planet start, String n)
 {
     Random rand = new Random(n.GetHashCode());
     color = new Color(rand.Next(255), rand.Next(255), rand.Next(255));
     if (playerIDs == 0) { color = Color.Purple; }
     if (playerIDs == 1) { color = Color.Orange; }
     if (playerIDs == 2) { color = Color.Green; }
     army = new HashSet<Unit>();
     army.Add(start);
     start.setAffiliation(this);
     startingPlanet = start;
     metal = 1000;
     score = 0;
     name = n;
     id = playerIDs;
     playerIDs++;
 }
Beispiel #28
0
        public ConnectionKey(String username, String password)
        {
            this.username = username;
            this.password = password;

            this.hash = 31;
            if (!String.IsNullOrEmpty(username))
            {
                hash += username.GetHashCode();
            }

            hash *= 31;
            if (!String.IsNullOrEmpty(password))
            {
                hash += password.GetHashCode();
            }
        }
        // download all the attachments of a wit to the local folders
        public void getAttachment(String witId, String fileAssociationId, String fileName, String userProfilepath)
        {
            AccessTokenDao accesstokenDao = new AccessTokenDao();
            String token = accesstokenDao.getAccessToken(Common.userName);

            String url = Resource.endpoint + "wittyparrot/api/attachments/associationId/" + fileAssociationId + "";
            var client = new RestClient();
            client.BaseUrl = new Uri(url);

            var request = new RestRequest();
            request.Method = Method.GET;
            request.Parameters.Clear();
            request.AddParameter("Authorization", "Bearer " + token, ParameterType.HttpHeader);
            request.RequestFormat = DataFormat.Json;

            // execute the request
            IRestResponse response = client.Execute(request);
            if (response.ErrorException != null)
            {
                var statusMessage = RestUtils.getErrorMessage(response.StatusCode);
                MessageBox.Show(statusMessage == "" ? response.StatusDescription : statusMessage);
                var myException = new ApplicationException(response.StatusDescription, response.ErrorException);
                throw myException;
            }

            byte[] r = client.DownloadData(request);
            String fullPath = userProfilepath + "//files//attachments//";
            if (!Directory.Exists(fullPath))
            {
                Directory.CreateDirectory(fullPath);
            }
            // save the file details to docs table
            Docs doc = new Docs();
            doc.docId = fileName.GetHashCode().ToString();
            doc.localPath = fullPath;
            doc.fileName = fileName;
            doc.witId = witId;


            AttachmentDao attachmentDao = new AttachmentDao();
            attachmentDao.saveDocs(doc);

            File.WriteAllBytes(fullPath + fileName, r);
        }
Beispiel #30
0
        internal Value(System.String value, Parameterization p = Parameterization.Value, DataType dataType = null)
            : base(value)
        {
            Original = value;
            _clrType = typeof(System.String);

            if (dataType == null)
            {
                dataType = Mapping.DefaultStringType;
            }

            if (value != null)
            {
                _hashCode = GetCrossTypeHashCode(_clrType, value.GetHashCode());
            }

            Build = (buildContext, buildArgs) =>
            {
                string sql = null;
                if (p != Parameterization.None)
                {
                    sql = value.Parameterize(buildContext, dataType, p);
                }

                if (sql == null)
                {
                    // literal:
                    sql = Mapping.Build(value, dataType);

                    // if node contains concatenator than all string values should be escaped twice
                    if (buildContext.Current.IsQuery)
                    {
                        if (buildContext.Current.Query.Master.IsConcatenated)
                        {
                            sql = Filter.Escape(sql);
                        }
                    }
                }

                return(sql);
            };
        }
Beispiel #31
0
        public List<object> Evaluate(String expression)
        {
            if (expression.Equals("")) return null;

            List<Statement> statement;
            var hashcode = expression.GetHashCode();

            if (_cache.ContainsKey(hashcode))
            {
                statement = _cache[hashcode];
            }
            else
            {
                var tokens = Tokenizer(expression);
                statement = Statementizer(tokens);
                _cache.Add(hashcode, statement);
            }

            return ExecuteStatements(statement);
        }
Beispiel #32
0
        // @Override
        public override System.String Intern(System.String s)
        {
            int h = s.GetHashCode();
            // In the future, it may be worth augmenting the string hash
            // if the lower bits need better distribution.
            int slot = h & (cache.Length - 1);

            Entry first      = this.cache[slot];
            Entry nextToLast = null;

            int chainLength = 0;

            for (Entry e = first; e != null; e = e.next)
            {
                if (e.hash == h && (ReferenceEquals(e.str, s) || String.CompareOrdinal(e.str, s) == 0))
                {
                    // if (e.str == s || (e.hash == h && e.str.compareTo(s)==0)) {
                    return(e.str);
                }

                chainLength++;
                if (e.next != null)
                {
                    nextToLast = e;
                }
            }

            // insertion-order cache: add new entry at head

#if !NETSTANDARD1_6
            s = String.Intern(s);
#endif

            this.cache[slot] = new Entry(s, h, first);
            if (chainLength >= maxChainLength)
            {
                // prune last entry
                nextToLast.next = null;
            }
            return(s);
        }
Beispiel #33
0
    public static string GetSaveLocation(String filename)
    {
      // TODO: Generate directory structure from filename with hashing and random
      // TODO: Check that filename doesn't already exists there, if it does, rehash

      //string tmpDir = ConfigurationManager.AppSettings.Get("TempDirectory");
      string filesBaseDir = ConfigurationManager.AppSettings.Get("FilesBaseDir");
      uint fileDirectories = 1;
      UInt32.TryParse(ConfigurationManager.AppSettings.Get("NumOfDirectoriesForFiles"), out fileDirectories);

      ulong subdir = ((ulong) filename.GetHashCode()) % fileDirectories;

      string targetDir = filesBaseDir + System.IO.Path.DirectorySeparatorChar + subdir.ToString();
      if (!System.IO.Directory.Exists(targetDir))
      {
        System.IO.Directory.CreateDirectory(targetDir);
      }

      return targetDir + System.IO.Path.DirectorySeparatorChar + filename + "." + DateTime.Now.ToString("yyyyddmmHHmm");

    }
Beispiel #34
0
        public byte[] ReadFile(String fileName)
        {
            if (String.IsNullOrEmpty(fileName) == true)
            {
                throw new ArgumentNullException("fileName");
            }

            int hash = Math.Abs(fileName.GetHashCode());
            hash = hash % 10000;
            int bucket1 = hash / 100;
            int bucket2 = hash % 100;

            String fullPath = Path.Combine(BaseDir, bucket1.ToString(), bucket2.ToString(), fileName);
            if (File.Exists(fullPath))
            {
                return File.ReadAllBytes(fullPath);
            }
            else
            {
                return null;
            }
        }
Beispiel #35
0
        public void Write(String fileName, byte[] data)
        {
            if (String.IsNullOrEmpty(fileName) == true)
            {
                throw new ArgumentNullException("fileName");
            }

            if (data == null)
            {
                throw new ArgumentNullException("data");
            }

            int hash = Math.Abs(fileName.GetHashCode());
            hash = hash % 10000;
            int bucket1 = hash / 100;
            int bucket2 = hash % 100;
            String path1 = Path.Combine(BaseDir, bucket1.ToString());
            String path2 = Path.Combine(BaseDir, bucket1.ToString(),bucket2.ToString());
            if (Directory.Exists(path1) == false)
            {
                lock (SyncRoot)
                {
                    Directory.CreateDirectory(path1);
                }
            }

            if (Directory.Exists(path2) == false)
            {
                lock (SyncRoot)
                {
                    Directory.CreateDirectory(path2);
                }
            }

            String fullPath = Path.Combine(BaseDir, bucket1.ToString(), bucket2.ToString(), fileName);
            File.WriteAllBytes(fullPath, data);
        }
Beispiel #36
0
 public override int GetHashCode()
 {
     return(name.GetHashCode() | (namespace_Renamed == null?0:namespace_Renamed.GetHashCode()));
 }
 public override int GetHashCode()
 {
     return(readerKey.GetHashCode() * fieldName.GetHashCode());
 }
 internal RedisCacheKey(String key)
 {    
     Key = key;
     StateKey = String.Format("{0}_STATE", Key);
     Hash = key.GetHashCode();
 }    
Beispiel #39
0
 public int hashUrl(String urlName)
 {
     return urlName.GetHashCode();
 }
        public override int GetHashCode()
        {		
			
			return _name == null ? -1 : _name.GetHashCode();
		}
Beispiel #41
0
 /*(non-Javadoc) <see cref="java.lang.Object.hashCode() */
 public override int GetHashCode()
 {
     return(field.GetHashCode() + CachedFieldSourceHashCode());
 }
 private int CalculateHash(String key)
 {
     uint result = (uint)key.GetHashCode();
     return (int) Math.Abs(result % _tablesize);
 }
 public override int GetHashCode()
 {
     return(term != null?term.GetHashCode():0);
 }
Beispiel #44
0
 /// <summary>Composes a hashcode based on the field and type. </summary>
 public override int GetHashCode()
 {
     return(field.GetHashCode() ^ (custom == null?0:custom.GetHashCode()));
 }
Beispiel #45
0
        /// <summary>
        /// A Function which attempts to reduce a Uri to a QName and issues a Temporary Namespace if required
        /// </summary>
        /// <param name="uri">The Uri to attempt to reduce</param>
        /// <param name="qname">The value to output the QName to if possible</param>
        /// <param name="tempNamespace">The Temporary Namespace issued (if any)</param>
        /// <returns></returns>
        /// <remarks>
        /// <para>
        /// This function will always returns a possible QName for the URI if the format of the URI permits it.  It doesn't guarentee that the QName will be valid for the syntax it is being written to - it is up to implementers of writers to validate the QNames returned.
        /// </para>
        /// <para>
        /// Where necessary a Temporary Namespace will be issued and the <paramref name="tempNamespace">tempNamespace</paramref> parameter will be set to the prefix of the new temporary namespace
        /// </para>
        /// </remarks>
        public bool ReduceToQName(String uri, out String qname, out String tempNamespace)
        {
            tempNamespace = String.Empty;

            //See if we've cached this mapping
            QNameMapping mapping = new QNameMapping(uri);
            if (this._mapping.Contains(uri.GetHashCode(), mapping))
            {
                qname = this._mapping[uri.GetHashCode()].QName;
                return true;
            }

            //Try and find a Namespace URI that is the prefix of the URI
            foreach (Uri u in this._uris.Values)
            {
                String baseuri = u.ToString();

                //Does the Uri start with the Base Uri
                if (uri.StartsWith(baseuri))
                {
                    //Remove the Base Uri from the front of the Uri
                    qname = uri.Substring(baseuri.Length);
                    //Add the Prefix back onto the front plus the colon to give a QName
                    if (this._prefixes.ContainsKey(u.GetEnhancedHashCode()))
                    {
                        qname = this._prefixes[u.GetEnhancedHashCode()] + ":" + qname;
                        if (qname.Equals(":")) continue;
                        if (qname.Contains("/") || qname.Contains("#")) continue;
                        //Cache the Mapping
                        mapping.QName = qname;
                        this.AddToCache(uri.GetHashCode(), mapping);
                        return true;
                    }
                }
            }

            //Try and issue a Temporary Namespace
            String nsUri, nsPrefix;
            if (uri.Contains('#'))
            {
                nsUri = uri.Substring(0, uri.LastIndexOf('#') + 1);
                nsPrefix = this.GetNextTemporaryNamespacePrefix();
            }
            else if (uri.LastIndexOf('/') > 8)
            {
                nsUri = uri.Substring(0, uri.LastIndexOf('/') + 1);
                nsPrefix = this.GetNextTemporaryNamespacePrefix();
            }
            else
            {

                //Failed to find a Reduction and unable to issue a Temporary Namespace
                qname = String.Empty;
                return false;
            }

            //Add to Namespace Map
            this.AddNamespace(nsPrefix, UriFactory.Create(nsUri));

            //Cache mapping and return
            mapping.QName = nsPrefix + ":" + uri.Replace(nsUri, String.Empty);
            this.AddToCache(uri.GetHashCode(), mapping);
            qname = mapping.QName;
            tempNamespace = nsPrefix;
            return true;
        }
		internal RandomFieldComparator(int numHits, String field)
		{
			values = new int[numHits];
			random = new Random(field.GetHashCode());
		}
Beispiel #47
0
 /// <summary>
 /// Override has code
 /// </summary>
 /// <returns></returns>
 public override int GetHashCode()
 {
     return(name.GetHashCode() + 700 * rep);
 }
Beispiel #48
0
 public override int GetHashCode(String obj)
 {
     return(obj.GetHashCode());
 }
 public override int GetHashCode()
 {
     return(_uri == null ? -1 : _uri.GetHashCode());
 }
Beispiel #50
0
 /*(non-Javadoc) @see java.lang.Object#hashCode() */
 public override int GetHashCode()
 {
     return(hcode + field.GetHashCode());
 }
 public override int GetHashCode()
 {
     return(dir.GetHashCode() + name.GetHashCode());
 }
Beispiel #52
0
        public static bool addNewUser(String username, String password, String name, String email)
        {
            try
            {
                OracleConnection oc = new OracleConnection(strConnectionString);
                OracleDataAdapter da = new OracleDataAdapter();

                da.InsertCommand = new OracleCommand("INSERT INTO USERS VALUES(:LOGIN, :PASSWORD, :NAME, :EMAIL)", oc);
                da.InsertCommand.Parameters.Add("LOGIN", OracleDbType.Varchar2).Value = username;
                da.InsertCommand.Parameters.Add("PASSWORD", OracleDbType.Varchar2).Value = password.GetHashCode().ToString();
                da.InsertCommand.Parameters.Add("NAME", OracleDbType.Varchar2).Value = name;
                da.InsertCommand.Parameters.Add("EMAIL", OracleDbType.Varchar2).Value = email;
                oc.Open();
                da.InsertCommand.ExecuteNonQuery();
                oc.Close();
                return true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return false;
            }
        }
Beispiel #53
0
 public override int GetHashCode()
 {
     return(type.GetHashCode());
 }
Beispiel #54
0
        public override DocumentsWriter.DocWriter ProcessDocument()
        {
            consumer.StartDocument();
            fieldsWriter.StartDocument();

            Document doc = docState.doc;

            System.Diagnostics.Debug.Assert(docFieldProcessor.docWriter.writer.TestPoint("DocumentsWriter.ThreadState.init start"));

            fieldCount = 0;

            int thisFieldGen = fieldGen++;

            System.Collections.Generic.IList <IFieldable> docFields = doc.GetFields();
            int numDocFields = docFields.Count;

            // Absorb any new fields first seen in this document.
            // Also absorb any changes to fields we had already
            // seen before (eg suddenly turning on norms or
            // vectors, etc.):

            for (int i = 0; i < numDocFields; i++)
            {
                IFieldable    field     = docFields[i];
                System.String fieldName = field.Name;

                // Make sure we have a PerField allocated
                int hashPos = fieldName.GetHashCode() & hashMask;
                DocFieldProcessorPerField fp = fieldHash[hashPos];
                while (fp != null && !fp.fieldInfo.name.Equals(fieldName))
                {
                    fp = fp.next;
                }

                if (fp == null)
                {
                    // TODO FI: we need to genericize the "flags" that a
                    // field holds, and, how these flags are merged; it
                    // needs to be more "pluggable" such that if I want
                    // to have a new "thing" my Fields can do, I can
                    // easily add it
                    FieldInfo fi = fieldInfos.Add(fieldName, field.IsIndexed, field.IsTermVectorStored,
                                                  field.IsStorePositionWithTermVector, field.IsStoreOffsetWithTermVector,
                                                  field.OmitNorms, false, field.OmitTermFreqAndPositions);

                    fp                 = new DocFieldProcessorPerField(this, fi);
                    fp.next            = fieldHash[hashPos];
                    fieldHash[hashPos] = fp;
                    totalFieldCount++;

                    if (totalFieldCount >= fieldHash.Length / 2)
                    {
                        Rehash();
                    }
                }
                else
                {
                    fp.fieldInfo.Update(field.IsIndexed, field.IsTermVectorStored,
                                        field.IsStorePositionWithTermVector, field.IsStoreOffsetWithTermVector,
                                        field.OmitNorms, false, field.OmitTermFreqAndPositions);
                }

                if (thisFieldGen != fp.lastGen)
                {
                    // First time we're seeing this field for this doc
                    fp.fieldCount = 0;

                    if (fieldCount == fields.Length)
                    {
                        int newSize = fields.Length * 2;
                        DocFieldProcessorPerField[] newArray = new DocFieldProcessorPerField[newSize];
                        Array.Copy(fields, 0, newArray, 0, fieldCount);
                        fields = newArray;
                    }

                    fields[fieldCount++] = fp;
                    fp.lastGen           = thisFieldGen;
                }

                if (fp.fieldCount == fp.fields.Length)
                {
                    IFieldable[] newArray = new IFieldable[fp.fields.Length * 2];
                    Array.Copy(fp.fields, 0, newArray, 0, fp.fieldCount);
                    fp.fields = newArray;
                }

                fp.fields[fp.fieldCount++] = field;
                if (field.IsStored)
                {
                    fieldsWriter.AddField(field, fp.fieldInfo);
                }
            }

            // If we are writing vectors then we must visit
            // fields in sorted order so they are written in
            // sorted order.  TODO: we actually only need to
            // sort the subset of fields that have vectors
            // enabled; we could save [small amount of] CPU
            // here.
            QuickSort(fields, 0, fieldCount - 1);

            for (int i = 0; i < fieldCount; i++)
            {
                fields[i].consumer.ProcessFields(fields[i].fields, fields[i].fieldCount);
            }

            if (docState.maxTermPrefix != null && docState.infoStream != null)
            {
                docState.infoStream.WriteLine("WARNING: document contains at least one immense term (longer than the max length " + DocumentsWriter.MAX_TERM_LENGTH + "), all of which were skipped.  Please correct the analyzer to not produce such terms.  The prefix of the first immense term is: '" + docState.maxTermPrefix + "...'");
                docState.maxTermPrefix = null;
            }

            DocumentsWriter.DocWriter one = fieldsWriter.FinishDocument();
            DocumentsWriter.DocWriter two = consumer.FinishDocument();
            if (one == null)
            {
                return(two);
            }
            else if (two == null)
            {
                return(one);
            }
            else
            {
                PerDoc both = GetPerDoc();
                both.docID = docState.docID;
                System.Diagnostics.Debug.Assert(one.docID == docState.docID);
                System.Diagnostics.Debug.Assert(two.docID == docState.docID);
                both.one = one;
                both.two = two;
                return(both);
            }
        }
Beispiel #55
0
        public static bool updatePassword(String username, String password)
        {
            try
            {
                OracleConnection oc = new OracleConnection(strConnectionString);
                OracleDataAdapter da = new OracleDataAdapter();

                da.UpdateCommand = new OracleCommand("UPDATE USERS SET PASSWORD = :PASSWORD WHERE LOGIN = :LOGIN", oc);
                da.UpdateCommand.Parameters.Add("PASSWORD", OracleDbType.Varchar2).Value = password.GetHashCode().ToString();
                da.UpdateCommand.Parameters.Add("LOGIN", OracleDbType.Varchar2).Value = username;
                oc.Open();
                da.UpdateCommand.ExecuteNonQuery();
                oc.Close();
                return true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return false;
            }
        }
Beispiel #56
0
 /// <summary>Combines the hashCode() of the field and the text. </summary>
 public override int GetHashCode()
 {
     return(field.GetHashCode() + text.GetHashCode());
 }
 /// <summary>
 /// Create new credentials
 /// </summary>
 /// <param name="myLogin">The login string</param>
 /// <param name="myPassword">The password</param>
 public ServiceUserPasswordCredentials(String myLogin, String myPassword)
 {
     _login = myLogin;
     _passwordHash = myPassword.GetHashCode();
 }
Beispiel #58
0
 /// <summary>Composes a hashcode based on the field and type. </summary>
 public override int GetHashCode()
 {
     return(field.GetHashCode() ^ type ^ (custom == null?0:custom.GetHashCode()) ^ (locale == null?0:locale.GetHashCode()));
 }
Beispiel #59
0
 private int getBucketIndex(String value)
 {
     int hashCode = value.GetHashCode() & 0x7fffffff;
     int bucketIndex = hashCode % bucketListCapacity;
     int increment = (bucketIndex > 1) ? bucketIndex : 1;
     int i = bucketListCapacity;
     while (0 < i--)
     {
         int stringIndex = buckets[bucketIndex];
         if (stringIndex == 0) return bucketIndex;
         if (String.CompareOrdinal(value, stringList[stringIndex - 1]) == 0) return bucketIndex;
         bucketIndex = (bucketIndex + increment) % bucketListCapacity; // Probe.
     }
     throw new InvalidOperationException("Failed to locate a bucket.");
 }
Beispiel #60
0
 /// <inheritdoc/>
 public override int GetHashCode() => Name.GetHashCode(S.StringComparison.Ordinal);