System.Guid.GetHashCode()

Here are the examples of the csharp api System.Guid.GetHashCode() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

539 Examples 7

19 View Source File : ExprAliasGuid.cs
License : MIT License
Project Creator : 0x1000000

public override int GetHashCode() => this.Id.GetHashCode();

19 View Source File : BssomGuid.cs
License : MIT License
Project Creator : 1996v

public override int GetHashCode()
        {
            return GetGuid().GetHashCode();
        }

19 View Source File : EnumerableExtensions.cs
License : MIT License
Project Creator : 3DBear

public static IEnumerable<T> Shuffle<T>(this IEnumerable<T> source)
    {
        return source.Shuffle(new Random(Guid.NewGuid().GetHashCode()));
    }

19 View Source File : TLV_0006.cs
License : MIT License
Project Creator : 499116344

public byte[] Get_Tlv(QQUser user)
        {
            if (WSubVer == 0x0002)
            {
                if (user.TXProtocol.BufTgtgt == null)
                {
                    var data = new BinaryWriter(new MemoryStream());
                    data.BeWrite(new Random(Guid.NewGuid().GetHashCode()).Next()); //随机4字节??
                    data.BeWrite(WSubVer); //wSubVer
                    data.BeWrite(user.QQ); //QQ号码
                    data.BeWrite(user.TXProtocol.DwSsoVersion);
                    data.BeWrite(user.TXProtocol.DwServiceId);
                    data.BeWrite(user.TXProtocol.DwClientVer);
                    data.BeWrite((ushort) 0);
                    data.Write(user.TXProtocol.BRememberPwdLogin);
                    data.Write(user.MD51); //密码的一次MD5值,服务器用该MD5值验证用户密码是否正确
                    data.BeWrite(user.TXProtocol.DwServerTime); //登录时间
                    data.Write(new byte[13]); //固定13字节
                    data.Write(Util.IPStringToByteArray(user.TXProtocol.DwClientIP)); //IP地址
                    data.BeWrite(user.TXProtocol.DwIsp); //dwISP
                    data.BeWrite(user.TXProtocol.DwIdc); //dwIDC
                    data.WriteKey(user.TXProtocol.BufComputerIdEx); //机器码
                    data.Write(user.TXProtocol.BufTgtgtKey); //00DD临时密钥(通过验证时客户端用该密钥解密服务端发送回来的数据)

                    user.TXProtocol.BufTgtgt =
                        QQTea.Encrypt(data.BaseStream.ToBytesArray(), user.Md52());
                }
            }
            else
            {
                throw new Exception($"{Name} 无法识别的版本号 {WSubVer}");
            }

            var tlv = new BinaryWriter(new MemoryStream());
            tlv.Write(user.TXProtocol.BufTgtgt);
            FillHead(Command);
            FillBody(tlv.BaseStream.ToBytesArray(), tlv.BaseStream.Length);
            SetLength();
            return GetBuffer();
        }

19 View Source File : Uuid128.cs
License : MIT License
Project Creator : abdullin

public override int GetHashCode()
		{
			return m_packed.GetHashCode();
		}

19 View Source File : PowerPlan.cs
License : MIT License
Project Creator : ABTSoftware

public override int GetHashCode()
        {
            unchecked
            {
                return ((Name != null ? Name.GetHashCode() : 0)*397) ^ Guid.GetHashCode();
            }
        }

19 View Source File : Location.cs
License : Microsoft Public License
Project Creator : achimismaili

public override int GetHashCode()
        {
            return ContentDatabaseId.GetHashCode() ^ Id.GetHashCode();
        }

19 View Source File : VssConnection.cs
License : MIT License
Project Creator : actions

public int GetHashCode(ClientCacheKey obj)
                {
                    return obj.Type.GetHashCode() ^ obj.ServiceIdentifier.GetHashCode();
                }

19 View Source File : OrganizationServiceContextExtensions.cs
License : MIT License
Project Creator : Adoxio

public int GetHashCode(Enreplacedy survey)
			{
				if (survey == null)
				{
					throw new ArgumentNullException("survey");
				}

				return GetId(survey).GetHashCode();
			}

19 View Source File : EntityEqualityComparer.cs
License : MIT License
Project Creator : Adoxio

public int GetHashCode(Enreplacedy key)
		{
			if (key == null)
			{
				throw new ArgumentNullException("key");
			}

			return key.Id.GetHashCode();
		}

19 View Source File : SearchSavedQuery.cs
License : MIT License
Project Creator : Adoxio

public override int GetHashCode()
		{
			return this.SavedQueryId.GetHashCode();
		}

19 View Source File : ModEntry.cs
License : GNU General Public License v3.0
Project Creator : aedenthorn

public override void Entry(IModHelper helper)
        {
            context = this;
            Config = Helper.ReadConfig<ModConfig>();
            if (!Config.EnableMod)
                return;
            Utils.Helper = Helper;
            Utils.Monitor = Monitor;
            Utils.Config = Config;

            HelperEvents.Helper = Helper;
            HelperEvents.Monitor = Monitor;
            HelperEvents.Config = Config;


            myRand = new Random(Guid.NewGuid().GetHashCode());
            Helper.Events.GameLoop.GameLaunched += HelperEvents.GameLoop_GameLaunched;
            Helper.Events.GameLoop.DayStarted += HelperEvents.GameLoop_DayStarted;
            Helper.Events.GameLoop.TimeChanged += HelperEvents.GameLoop_TimeChanged;
        }

19 View Source File : ModEntry.cs
License : GNU General Public License v3.0
Project Creator : aedenthorn

public override void Entry(IModHelper helper)
        {
            context = this;
            Config = Helper.ReadConfig<ModConfig>();
            if (!Config.EnableMod)
                return;

            myRand = new Random(Guid.NewGuid().GetHashCode());

            LoadQuotes();

            if(quotestrings.Length > 0)
            {
                Helper.Events.GameLoop.GameLaunched += GameLoop_GameLaunched;
                Helper.Events.GameLoop.DayStarted += GameLoop_DayStarted;
                if(Config.ClickToDispelQuote || Config.QuoteDurationPerLineMult < 0)
                    Helper.Events.Input.ButtonPressed += Input_ButtonPressed;
            }
        }

19 View Source File : Main.cs
License : MIT License
Project Creator : AhmedMinegames

private void ObfuscasteCode(string ToProtect)
        {
            ModuleContext ModuleCont = ModuleDefMD.CreateModuleContext();
            ModuleDefMD FileModule = ModuleDefMD.Load(ToProtect, ModuleCont);
            replacedemblyDef replacedembly1 = FileModule.replacedembly;

            if (checkBox7.Checked)
            {
                foreach (var tDef in FileModule.Types)
                {
                    if (tDef == FileModule.GlobalType) continue;
                    foreach (var mDef in tDef.Methods)
                    {
                        if (mDef.Name.StartsWith("get_") || mDef.Name.StartsWith("set_")) continue;
                        if (!mDef.HasBody || mDef.IsConstructor) continue;
                        mDef.Body.SimplifyBranches();
                        mDef.Body.SimplifyMacros(mDef.Parameters);
                        var blocks = GetMethod(mDef);
                        var ret = new List<Block>();
                        foreach (var group in blocks)
                        {
                            Random rnd = new Random();
                            ret.Insert(rnd.Next(0, ret.Count), group);
                        }
                        blocks = ret;
                        mDef.Body.Instructions.Clear();
                        var local = new Local(mDef.Module.CorLibTypes.Int32);
                        mDef.Body.Variables.Add(local);
                        var target = Instruction.Create(OpCodes.Nop);
                        var instr = Instruction.Create(OpCodes.Br, target);
                        var instructions = new List<Instruction> { Instruction.Create(OpCodes.Ldc_I4, 0) };
                        foreach (var instruction in instructions)
                            mDef.Body.Instructions.Add(instruction);
                        mDef.Body.Instructions.Add(Instruction.Create(OpCodes.Stloc, local));
                        mDef.Body.Instructions.Add(Instruction.Create(OpCodes.Br, instr));
                        mDef.Body.Instructions.Add(target);
                        foreach (var block in blocks.Where(block => block != blocks.Single(x => x.Number == blocks.Count - 1)))
                        {
                            mDef.Body.Instructions.Add(Instruction.Create(OpCodes.Ldloc, local));
                            var instructions1 = new List<Instruction> { Instruction.Create(OpCodes.Ldc_I4, block.Number) };
                            foreach (var instruction in instructions1)
                                mDef.Body.Instructions.Add(instruction);
                            mDef.Body.Instructions.Add(Instruction.Create(OpCodes.Ceq));
                            var instruction4 = Instruction.Create(OpCodes.Nop);
                            mDef.Body.Instructions.Add(Instruction.Create(OpCodes.Brfalse, instruction4));

                            foreach (var instruction in block.Instructions)
                                mDef.Body.Instructions.Add(instruction);

                            var instructions2 = new List<Instruction> { Instruction.Create(OpCodes.Ldc_I4, block.Number + 1) };
                            foreach (var instruction in instructions2)
                                mDef.Body.Instructions.Add(instruction);

                            mDef.Body.Instructions.Add(Instruction.Create(OpCodes.Stloc, local));
                            mDef.Body.Instructions.Add(instruction4);
                        }
                        mDef.Body.Instructions.Add(Instruction.Create(OpCodes.Ldloc, local));
                        var instructions3 = new List<Instruction> { Instruction.Create(OpCodes.Ldc_I4, blocks.Count - 1) };
                        foreach (var instruction in instructions3)
                            mDef.Body.Instructions.Add(instruction);
                        mDef.Body.Instructions.Add(Instruction.Create(OpCodes.Ceq));
                        mDef.Body.Instructions.Add(Instruction.Create(OpCodes.Brfalse, instr));
                        mDef.Body.Instructions.Add(Instruction.Create(OpCodes.Br, blocks.Single(x => x.Number == blocks.Count - 1).Instructions[0]));
                        mDef.Body.Instructions.Add(instr);

                        foreach (var lastBlock in blocks.Single(x => x.Number == blocks.Count - 1).Instructions)
                            mDef.Body.Instructions.Add(lastBlock);
                    }
                }
            }

            if (checkBox2.Checked)
            {
                for (int i = 200; i < 300; i++)
                {
                    InterfaceImpl Interface = new InterfaceImplUser(FileModule.GlobalType);
                    TypeDef typedef = new TypeDefUser("", $"Form{i.ToString()}", FileModule.CorLibTypes.GetTypeRef("System", "Attribute"));
                    InterfaceImpl interface1 = new InterfaceImplUser(typedef);
                    FileModule.Types.Add(typedef);
                    typedef.Interfaces.Add(interface1);
                    typedef.Interfaces.Add(Interface);
                }
            }

            string[] FakeObfuscastionsAttributes = { "ConfusedByAttribute", "YanoAttribute", "NetGuard", "DotfuscatorAttribute", "BabelAttribute", "ObfuscatedByGoliath", "dotNetProtector" };
            if (checkBox5.Checked)
            {
                for (int i = 0; i < FakeObfuscastionsAttributes.Length; i++)
                {
                    var FakeObfuscastionsAttribute = new TypeDefUser(FakeObfuscastionsAttributes[i], FileModule.CorLibTypes.Object.TypeDefOrRef);
                    FileModule.Types.Add(FakeObfuscastionsAttribute);
                }
            }

            if (checkBox8.Checked)
            {
                foreach (TypeDef type in FileModule.Types)
                {
                    FileModule.Name = RandomName(12);
                    if (type.IsGlobalModuleType || type.IsRuntimeSpecialName || type.IsSpecialName || type.IsWindowsRuntime || type.IsInterface)
                    {
                        continue;
                    }
                    else
                    {
                        for (int i = 200; i < 300; i++)
                        {
                            foreach (PropertyDef property in type.Properties)
                            {
                                if (property.IsRuntimeSpecialName) continue;
                                property.Name = RandomName(20) + i + RandomName(10) + i;
                            }
                            foreach (FieldDef fields in type.Fields)
                            {
                                fields.Name = RandomName(20) + i + RandomName(10) + i;
                            }
                            foreach (EventDef eventdef in type.Events)
                            {
                                eventdef.Name = RandomName(20) + i + RandomName(10) + i;
                            }
                            foreach (MethodDef method in type.Methods)
                            {
                                if (method.IsConstructor || method.IsRuntimeSpecialName || method.IsRuntime || method.IsStaticConstructor || method.IsVirtual) continue;
                                method.Name = RandomName(20) + i + RandomName(10) + i;
                            }
                            foreach(MethodDef method in type.Methods)
                            {
                                foreach(Parameter RenameParameters in method.Parameters)
                                {
                                    RenameParameters.Name = RandomName(10);
                                }
                            }
                        }
                    }
                    foreach (ModuleDefMD module in FileModule.replacedembly.Modules)
                    {
                        module.Name = RandomName(13);
                        module.replacedembly.Name = RandomName(14);
                    }
                }

                foreach (TypeDef type in FileModule.Types)
                {
                    foreach (MethodDef GetMethods in type.Methods)
                    {
                        for (int i = 200; i < 300; i++)
                        {
                            if (GetMethods.IsConstructor || GetMethods.IsRuntimeSpecialName || GetMethods.IsRuntime || GetMethods.IsStaticConstructor) continue;
                            GetMethods.Name = RandomName(15) + i;
                        }
                    }
                }
            }

            if (checkBox6.Checked)
            {
                for (int i = 0; i < 200; i++)
                {
                    var Junk = new TypeDefUser(RandomName(10) + i + RandomName(10) + i + RandomName(10) + i, FileModule.CorLibTypes.Object.TypeDefOrRef);
                    FileModule.Types.Add(Junk);
                }

                for (int i = 0; i < 200; i++)
                {
                    var Junk = new TypeDefUser("<" + RandomName(10) + i + RandomName(10) + i + RandomName(10) + i + ">", FileModule.CorLibTypes.Object.TypeDefOrRef);
                    var Junk2 = new TypeDefUser(RandomName(11) + i + RandomName(11) + i + RandomName(11) + i, FileModule.CorLibTypes.Object.TypeDefOrRef);
                    FileModule.Types.Add(Junk);
                    FileModule.Types.Add(Junk2);
                }

                for (int i = 0; i < 200; i++)
                {
                    var Junk = new TypeDefUser("<" + RandomName(10) + i + RandomName(10) + i + RandomName(10) + i + ">", FileModule.CorLibTypes.Object.Namespace);
                    var Junk2 = new TypeDefUser(RandomName(11) + i + RandomName(11) + i + RandomName(11) + i, FileModule.CorLibTypes.Object.Namespace);
                    FileModule.Types.Add(Junk);
                    FileModule.Types.Add(Junk2);
                }
            }

            if (checkBox1.Checked)
            {
                foreach (TypeDef type in FileModule.Types)
                {
                    foreach (MethodDef method in type.Methods)
                    {
                        if (method.Body == null) continue;
                        method.Body.SimplifyBranches();
                        for (int i = 0; i < method.Body.Instructions.Count; i++)
                        {
                            if (method.Body.Instructions[i].OpCode == OpCodes.Ldstr)
                            {
                                string EncodedString = method.Body.Instructions[i].Operand.ToString();
                                string InsertEncodedString = Convert.ToBase64String(UTF8Encoding.UTF8.GetBytes(EncodedString));
                                method.Body.Instructions[i].OpCode = OpCodes.Nop;
                                method.Body.Instructions.Insert(i + 1, new Instruction(OpCodes.Call, FileModule.Import(typeof(Encoding).GetMethod("get_UTF8", new Type[] { }))));
                                method.Body.Instructions.Insert(i + 2, new Instruction(OpCodes.Ldstr, InsertEncodedString));
                                method.Body.Instructions.Insert(i + 3, new Instruction(OpCodes.Call, FileModule.Import(typeof(Convert).GetMethod("FromBase64String", new Type[] { typeof(string) }))));
                                method.Body.Instructions.Insert(i + 4, new Instruction(OpCodes.Callvirt, FileModule.Import(typeof(Encoding).GetMethod("GetString", new Type[] { typeof(byte[]) }))));
                                i += 4;
                            }
                        }
                    }
                }
            }

            if (checkBox10.Checked)
            {
                foreach (var type in FileModule.GetTypes())
                {
                    if (type.IsGlobalModuleType) continue;
                    foreach (var method in type.Methods)
                    {
                        if (!method.HasBody) continue;
                        {
                            for (var i = 0; i < method.Body.Instructions.Count; i++)
                            {
                                if (!method.Body.Instructions[i].IsLdcI4()) continue;
                                var numorig = new Random(Guid.NewGuid().GetHashCode()).Next();
                                var div = new Random(Guid.NewGuid().GetHashCode()).Next();
                                var num = numorig ^ div;
                                var nop = OpCodes.Nop.ToInstruction();
                                var local = new Local(method.Module.ImportAsTypeSig(typeof(int)));
                                method.Body.Variables.Add(local);
                                method.Body.Instructions.Insert(i + 1, OpCodes.Stloc.ToInstruction(local));
                                method.Body.Instructions.Insert(i + 2, Instruction.Create(OpCodes.Ldc_I4, method.Body.Instructions[i].GetLdcI4Value() - sizeof(float)));
                                method.Body.Instructions.Insert(i + 3, Instruction.Create(OpCodes.Ldc_I4, num));
                                method.Body.Instructions.Insert(i + 4, Instruction.Create(OpCodes.Ldc_I4, div));
                                method.Body.Instructions.Insert(i + 5, Instruction.Create(OpCodes.Xor));
                                method.Body.Instructions.Insert(i + 6, Instruction.Create(OpCodes.Ldc_I4, numorig));
                                method.Body.Instructions.Insert(i + 7, Instruction.Create(OpCodes.Bne_Un, nop));
                                method.Body.Instructions.Insert(i + 8, Instruction.Create(OpCodes.Ldc_I4, 2));
                                method.Body.Instructions.Insert(i + 9, OpCodes.Stloc.ToInstruction(local));
                                method.Body.Instructions.Insert(i + 10, Instruction.Create(OpCodes.Sizeof, method.Module.Import(typeof(float))));
                                method.Body.Instructions.Insert(i + 11, Instruction.Create(OpCodes.Add));
                                method.Body.Instructions.Insert(i + 12, nop);
                                i += 12;
                            }
                            method.Body.SimplifyBranches();
                        }
                    }
                }
            }

            if (checkBox11.Checked)
            {
                foreach (ModuleDef module in FileModule.replacedembly.Modules)
                {
                    TypeRef attrRef = FileModule.CorLibTypes.GetTypeRef("System.Runtime.CompilerServices", "SuppressIldasmAttribute");
                    var ctorRef = new MemberRefUser(module, ".ctor", MethodSig.CreateInstance(module.CorLibTypes.Void), attrRef);
                    var attr = new CustomAttribute(ctorRef);
                    module.CustomAttributes.Add(attr);
                }
            }

            if (checkBox13.Checked)
            {
                // later
            }

            if (File.Exists(Environment.CurrentDirectory + @"\Obfuscasted.exe") == false)
            {
                File.Copy(ToProtect, Environment.CurrentDirectory + @"\Obfuscasted.exe");
                FileModule.Write(Environment.CurrentDirectory + @"\Obfuscasted.exe");
                if (checkBox12.Checked)
                {
                    string RandomreplacedemblyName = RandomName(12);
                    PackAndEncrypt(Environment.CurrentDirectory + @"\Obfuscasted.exe", Environment.CurrentDirectory + @"\" + RandomreplacedemblyName + ".tmp");
                    File.Delete(Environment.CurrentDirectory + @"\Obfuscasted.exe");
                    File.Move(Environment.CurrentDirectory + @"\" + RandomreplacedemblyName + ".tmp", Environment.CurrentDirectory + @"\Obfuscasted.exe");
                }
            }
            else
            {
                MessageBox.Show("Please Delete or move the file: " + Environment.CurrentDirectory + @"\Obfuscasted.exe" + " first to Obfuscaste your file", "Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
            }
        }

19 View Source File : UserAppAuthManager.cs
License : MIT License
Project Creator : AiursoftWeb

private async Task<OAuthPack> GeneratePack(GatewayUser user, string appId)
        {
            var pack = new OAuthPack
            {
                Code = Math.Abs(Guid.NewGuid().GetHashCode()),
                UserId = user.Id,
                ApplyAppId = appId
            };
            await _dbContext.OAuthPack.AddAsync(pack);
            await _dbContext.SaveChangesAsync();
            return pack;
        }

19 View Source File : Position.cs
License : MIT License
Project Creator : AiursoftWeb

public override int GetHashCode()
        {
            return _hash.GetHashCode();
        }

19 View Source File : ValidateCodeCreater.cs
License : MIT License
Project Creator : albyho

public string CreateValidationCode(int codeLength)
        {
            var chars = "1234567890qwertyuipasdfghjklzxcvbnm";
            var rand = new Random(Guid.NewGuid().GetHashCode());

            string result = null;
            for (int i = 0; i < codeLength; i++)
            {
                var r = rand.Next(chars.Length);

                result = string.Concat(result, chars[r]);
            }

            return result;
        }

19 View Source File : ValidateCodeCreater.cs
License : MIT License
Project Creator : albyho

public byte[] CreateValidationCodeGraphic()
        {
            var rand = new Random(Guid.NewGuid().GetHashCode());

            var randAngle = 40;
            var mapWidth = ValidationCode.Length * 18;
            var mapHeight = 28;

            using (var bitmap = new SKBitmap(mapWidth, mapHeight))
            {
                using (var canvas = new SKCanvas(bitmap))
                {
                    canvas.Clear(SKColors.AliceBlue);

                    var paint = new SKPaint() { Color = SKColors.LightGray, };
                    for (int i = 0; i < 50; i++)
                    {
                        int x = rand.Next(0, bitmap.Width);
                        int y = rand.Next(0, bitmap.Height);

                        canvas.DrawRect(new SKRect(x, y, x + 1, y + 1), paint);
                    }

                    var chars = ValidationCode.ToCharArray();
                    var colors = new[] { SKColors.Black, SKColors.Red, SKColors.DarkBlue, SKColors.Green, SKColors.Orange, SKColors.Brown, SKColors.DarkCyan, SKColors.Purple };
                    var fonts = new[]
                    {
                        SKTypeface.FromFamilyName("Verdana"),
                        SKTypeface.FromFamilyName("Microsoft Sans Serif"),
                        SKTypeface.FromFamilyName("Comic Sans MS"),
                        SKTypeface.FromFamilyName("Arial")
                    };

                    canvas.Translate(-4, 0);

                    for (int i = 0; i < chars.Length; i++)
                    {
                        int colorIndex = rand.Next(colors.Length);
                        int fontIndex = rand.Next(fonts.Length);

                        var fontColor = colors[colorIndex];
                        var foneSize = rand.Next(18, 25);
                        float angle = rand.Next(-randAngle, randAngle);

                        SKPoint point = new SKPoint(16, 28 / 2 + 4);

                        canvas.Translate(point);
                        canvas.RotateDegrees(angle);

                        var textPaint = new SKPaint()
                        {
                            TextAlign = SKTextAlign.Center,
                            Color = fontColor,
                            TextSize = foneSize,
                            IsVerticalText = true,
                            IsAntialias = true,
                            Typeface = fonts[fontIndex],

                            //IsAntialias = rand.Next(1) == 1 ? true : false,
                            //FakeBoldText = true,
                            //FilterQuality = SKFilterQuality.High,
                            //HintingLevel = SKPaintHinting.Full,

                            //IsEmbeddedBitmapText = true,                    
                            //LcdRenderText = true,
                            //Style = SKPaintStyle.StrokeAndFill,
                            //TextEncoding = SKTextEncoding.Utf8,
                        };

                        canvas.DrawText(chars[i].ToString(), new SKPoint(0, 0), textPaint);
                        canvas.RotateDegrees(-angle);
                        canvas.Translate(0, -point.Y);
                    }

                    using (var image = SKImage.FromBitmap(bitmap))
                    {
                        using (var ms = new MemoryStream())
                        {
                            image.Encode(SKEncodedImageFormat.Png, 90).SaveTo(ms);
                            return ms.ToArray();
                        }
                    }
                }
            }
        }

19 View Source File : Entity.cs
License : MIT License
Project Creator : alexandrebeato

public override int GetHashCode()
        {
            return (GetType().GetHashCode() * 451) + Id.GetHashCode();
        }

19 View Source File : PatreonPageCrawler.cs
License : MIT License
Project Creator : AlexCSDev

public async Task<List<ICrawledUrl>> Crawl(ICrawlTargetInfo crawlTargetInfo, string downloadDirectory)
        {
            PatreonCrawlTargetInfo patreonCrawlTargetInfo = (PatreonCrawlTargetInfo)crawlTargetInfo;
            if (patreonCrawlTargetInfo.Id < 1)
                throw new ArgumentException("Campaign ID cannot be less than 1");
            if (string.IsNullOrEmpty(patreonCrawlTargetInfo.Name))
                throw new ArgumentException("Campaign name cannot be null or empty");
            if(string.IsNullOrWhiteSpace(downloadDirectory))
                throw new ArgumentException("Download directory cannot be empty");

            _logger.Debug($"Starting crawling campaign {patreonCrawlTargetInfo.Name}");
            List<ICrawledUrl> crawledUrls = new List<ICrawledUrl>();
            Random rnd = new Random(Guid.NewGuid().GetHashCode());

            if (_patreonDownloaderSettings.SaveAvatarAndCover)
            {
                _logger.Debug("Adding avatar and cover...");
                if(!string.IsNullOrWhiteSpace(patreonCrawlTargetInfo.AvatarUrl))
                    crawledUrls.Add(new PatreonCrawledUrl { PostId = "0", Url = patreonCrawlTargetInfo.AvatarUrl, UrlType = PatreonCrawledUrlType.AvatarFile });
                if (!string.IsNullOrWhiteSpace(patreonCrawlTargetInfo.CoverUrl))
                    crawledUrls.Add(new PatreonCrawledUrl { PostId = "0", Url = patreonCrawlTargetInfo.CoverUrl, UrlType = PatreonCrawledUrlType.CoverFile });
            }

            string nextPage = CrawlStartUrl + $"&filter[campaign_id]={patreonCrawlTargetInfo.Id}";

            int page = 0;
            while (!string.IsNullOrEmpty(nextPage))
            {
                page++;
                _logger.Debug($"Page #{page}: {nextPage}");
                string json = await _webDownloader.DownloadString(nextPage);

                if(_patreonDownloaderSettings.SaveJson)
                    await File.WriteAllTextAsync(Path.Combine(downloadDirectory, $"page_{page}.json"),
                        json);

                ParsingResult result = await ParsePage(json, downloadDirectory);

                if(result.CrawledUrls.Count > 0)
                    crawledUrls.AddRange(result.CrawledUrls);

                nextPage = result.NextPage;

                await Task.Delay(500 * rnd.Next(1, 3)); //0.5 - 1 second delay
            }

            _logger.Debug("Finished crawl");

            return crawledUrls;
        }

19 View Source File : VectorReader.cs
License : MIT License
Project Creator : altimesh

public static float[] GetRandomVector(int size)
        {
            float[] res = new float[size];
            Random rand = new Random(Guid.NewGuid().GetHashCode());
            for (int i = 0; i < size; ++i)
            {
                res[i] = rand.NextFloat();
            }
            return res;
        }

19 View Source File : SimpleWalker.cs
License : MIT License
Project Creator : altimesh

[IntrinsicFunction("clock")]
        public static int clock()
        {
            return Guid.NewGuid().GetHashCode();
        }

19 View Source File : Program.cs
License : MIT License
Project Creator : altimesh

static void Main(string[] args)
        {
            float4[] callResult_net = new float4[OPT_N/4];
            float4[] putResult_net = new float4[OPT_N/4];
            float4[] stockPrice_net = new float4[OPT_N/4];
            float4[] optionStrike_net = new float4[OPT_N/4];
            float4[] optionYears_net = new float4[OPT_N/4];

            float4[] callResult_cuda = new float4[OPT_N/4];
            float4[] putResult_cuda = new float4[OPT_N/4];
            
            Random rand = new Random(Guid.NewGuid().GetHashCode());
            for (int i = 0; i < OPT_N/4; ++i)
            {
                callResult_net[i] = new float4(0.0f, 0.0f, 0.0f, 0.0f);
                putResult_net[i] = new float4(-1.0f, -1.0f, -1.0f, -1.0f) ;
                callResult_cuda[i] = new float4(0.0f, 0.0f, 0.0f, 0.0f);
                putResult_cuda[i] = new float4(-1.0f, -1.0f, -1.0f, -1.0f);
                stockPrice_net[i] = rand.NextFloat4(5.0f, 30.0f);
                optionStrike_net[i] = rand.NextFloat4(1.0f, 100.0f);
                optionYears_net[i] = rand.NextFloat4(0.25f, 10f);
            }

            cudaDeviceProp prop;
            cuda.GetDeviceProperties(out prop, 0);
            HybRunner runner = HybRunner.Cuda().SetDistrib(8 * prop.multiProcessorCount, 256);
            dynamic wrapper = runner.Wrap(new Program());
            
            for (int i = 0; i < NUM_ITERATIONS; ++i)
            {
                wrapper.BlackScholes(callResult_cuda,
                             putResult_cuda,
                             stockPrice_net,
                             optionStrike_net,
                             optionYears_net,
                             0, OPT_N/4);
            }

            Parallel.For(0, OPT_N/4, (opt) =>
            {
                BlackScholes(callResult_net,
                                putResult_net,
                                stockPrice_net,
                                optionStrike_net,
                                optionYears_net,
                                opt,
                                opt + 1);
            });

            WriteCalculationError(callResult_net, callResult_cuda, putResult_net, putResult_cuda);

        }

19 View Source File : Program.cs
License : MIT License
Project Creator : altimesh

static void Main(string[] args)
        {
            float[] callResult_net = new float[OPT_N];
            float[] putResult_net = new float[OPT_N];
            float[] stockPrice_net = new float[OPT_N];
            float[] optionStrike_net = new float[OPT_N];
            float[] optionYears_net = new float[OPT_N];

            float[] callResult_cuda = new float[OPT_N];
            float[] putResult_cuda = new float[OPT_N];
            
            Random rand = new Random(Guid.NewGuid().GetHashCode());
            for (int i = 0; i < OPT_N; ++i)
            {
                callResult_net[i] = 0.0f;
                callResult_cuda[i] = 0.0f;
                putResult_net[i] = -1.0f;
                putResult_cuda[i] = -1.0f;
                stockPrice_net[i] = (float)rand.NextDouble() * 25.0f + 5.0f;
                optionStrike_net[i] = (float)rand.NextDouble() * 99.0f + 1.0f;
                optionYears_net[i] = (float)rand.NextDouble() * 9.75f + 0.25f;
            }

            cudaDeviceProp prop;
            cuda.GetDeviceProperties(out prop, 0);
            HybRunner runner = HybRunner.Cuda("BlackScholes_CUDA.dll").SetDistrib(8 * prop.multiProcessorCount, 256);
            dynamic wrapper = runner.Wrap(new Program());
            
            for (int i = 0; i < NUM_ITERATIONS; ++i)
            {
                wrapper.BlackScholes(callResult_cuda,
                             putResult_cuda,
                             stockPrice_net,
                             optionStrike_net,
                             optionYears_net,
                             0, OPT_N);
            }

            for (int i = 0; i < NUM_ITERATIONS; ++i)
            {
                Parallel.For(0, OPT_N, (opt) =>
                {
                    BlackScholes(callResult_net,
                                 putResult_net,
                                 stockPrice_net,
                                 optionStrike_net,
                                 optionYears_net,
                                 opt,
                                 opt + 1);
                });
            }

            float maxCallError = 0.0F;
            float maxPutError = 0.0F;
            float callL2Error = 0.0F;
            float putL2Error = 0.0F;
            float callL1Error = 0.0F;
            float putL1Error = 0.0F;
            for (int i = 0; i < OPT_N; ++i)
            {
                float callError = Math.Abs(callResult_net[i] - callResult_cuda[i]);
                float putError = Math.Abs(putResult_net[i] - putResult_cuda[i]);
                callL2Error += callError * callError;
                putL2Error += putError * putError;
                callL1Error += callError;
                putL1Error += putError;
                maxCallError = maxCallError > callError ? maxCallError : callError;
                maxPutError = maxPutError > putError ? maxPutError : putError;
            }

            callL1Error /= (float)OPT_N;
            putL1Error /= (float)OPT_N;
            callL2Error = Sqrtf(callL2Error) / (float)OPT_N;
            putL2Error = Sqrtf(putL2Error) / (float)OPT_N;

            Console.WriteLine("CALL ERRORS : Linf : {0:G17}, L2 : {1:G17}, L1: {2:G17}", maxCallError, callL2Error, callL1Error);
            Console.WriteLine("PUT ERRORS  : Linf : {0:G17}, L2 : {1:G17}, L1: {2:G17}", maxPutError, putL2Error, putL1Error);
        }

19 View Source File : Program.cs
License : MIT License
Project Creator : altimesh

static void Main(string[] args)
        {
            float4[] callResult_net = new float4[OPT_N/4];
            float4[] putResult_net = new float4[OPT_N/4];
            float4[] stockPrice_net = new float4[OPT_N/4];
            float4[] optionStrike_net = new float4[OPT_N/4];
            float4[] optionYears_net = new float4[OPT_N/4];

            float4[] callResult_cuda = new float4[OPT_N/4];
            float4[] putResult_cuda = new float4[OPT_N/4];
            
            Random rand = new Random(Guid.NewGuid().GetHashCode());
            for (int i = 0; i < OPT_N/4; ++i)
            {
                callResult_net[i] = new float4(0.0f, 0.0f, 0.0f, 0.0f);
                putResult_net[i] = new float4(-1.0f, -1.0f, -1.0f, -1.0f) ;
                callResult_cuda[i] = new float4(0.0f, 0.0f, 0.0f, 0.0f);
                putResult_cuda[i] = new float4(-1.0f, -1.0f, -1.0f, -1.0f);
                stockPrice_net[i] = rand.NextFloat4(5.0f, 30.0f);
                optionStrike_net[i] = rand.NextFloat4(1.0f, 100.0f);
                optionYears_net[i] = rand.NextFloat4(0.25f, 10f);
            }

            cudaDeviceProp prop;
            cuda.GetDeviceProperties(out prop, 0);
            HybRunner runner = HybRunner.Cuda("BlackScholesFloat4_CUDA.dll").SetDistrib(8 * prop.multiProcessorCount, 256);
            dynamic wrapper = runner.Wrap(new Program());
            
            for (int i = 0; i < NUM_ITERATIONS; ++i)
            {
                wrapper.BlackScholes(callResult_cuda,
                             putResult_cuda,
                             stockPrice_net,
                             optionStrike_net,
                             optionYears_net,
                             0, OPT_N/4);
            }
            for (int i = 0; i < NUM_ITERATIONS; ++i)
            {
                Parallel.For(0, OPT_N/4, (opt) =>
                {
                    BlackScholes(callResult_net,
                                 putResult_net,
                                 stockPrice_net,
                                 optionStrike_net,
                                 optionYears_net,
                                 opt,
                                 opt + 1);
                });
            }

            WriteCalculationError(callResult_net, callResult_cuda, putResult_net, putResult_cuda);

        }

19 View Source File : Program.cs
License : MIT License
Project Creator : altimesh

static void Main(string[] args)
        {
            float[] callResult_net = new float[OPT_N];
            float[] putResult_net = new float[OPT_N];
            float[] stockPrice_net = new float[OPT_N];
            float[] optionStrike_net = new float[OPT_N];
            float[] optionYears_net = new float[OPT_N];

            float[] callResult_cuda = new float[OPT_N];
            float[] putResult_cuda = new float[OPT_N];
            
            Random rand = new Random(Guid.NewGuid().GetHashCode());
            for (int i = 0; i < OPT_N; ++i)
            {
                callResult_net[i] = 0.0f;
                callResult_cuda[i] = 0.0f;
                putResult_net[i] = -1.0f;
                putResult_cuda[i] = -1.0f;
                stockPrice_net[i] = (float)rand.NextDouble() * 25.0f + 5.0f;
                optionStrike_net[i] = (float)rand.NextDouble() * 99.0f + 1.0f;
                optionYears_net[i] = (float)rand.NextDouble() * 9.75f + 0.25f;
            }

            cudaDeviceProp prop;
            cuda.GetDeviceProperties(out prop, 0);
            HybRunner runner = HybRunner.Cuda().SetDistrib(8 * prop.multiProcessorCount, 256);
            dynamic wrapper = runner.Wrap(new Program());
            
            for (int i = 0; i < NUM_ITERATIONS; ++i)
            {
                wrapper.BlackScholes(callResult_cuda,
                             putResult_cuda,
                             stockPrice_net,
                             optionStrike_net,
                             optionYears_net,
                             0, OPT_N);
            }
            
            Parallel.For(0, OPT_N, (opt) =>
            {
                BlackScholes(callResult_net,
                                putResult_net,
                                stockPrice_net,
                                optionStrike_net,
                                optionYears_net,
                                opt,
                                opt + 1);
            });

            float maxCallError = 0.0F;
            float maxPutError = 0.0F;
            float callL2Error = 0.0F;
            float putL2Error = 0.0F;
            float callL1Error = 0.0F;
            float putL1Error = 0.0F;
            for (int i = 0; i < OPT_N; ++i)
            {
                float callError = Math.Abs(callResult_net[i] - callResult_cuda[i]);
                float putError = Math.Abs(putResult_net[i] - putResult_cuda[i]);
                callL2Error += callError * callError;
                putL2Error += putError * putError;
                callL1Error += callError;
                putL1Error += putError;
                maxCallError = maxCallError > callError ? maxCallError : callError;
                maxPutError = maxPutError > putError ? maxPutError : putError;
            }

            callL1Error /= (float)OPT_N;
            putL1Error /= (float)OPT_N;
            callL2Error = Sqrtf(callL2Error) / (float)OPT_N;
            putL2Error = Sqrtf(putL2Error) / (float)OPT_N;

            Console.WriteLine("CALL ERRORS : Linf : {0:G17}, L2 : {1:G17}, L1: {2:G17}", maxCallError, callL2Error, callL1Error);
            Console.WriteLine("PUT ERRORS  : Linf : {0:G17}, L2 : {1:G17}, L1: {2:G17}", maxPutError, putL2Error, putL1Error);
        }

19 View Source File : AggregateMember.cs
License : MIT License
Project Creator : amolines

public override int GetHashCode()
        {
            return Id.GetHashCode() ^ 31;
        }

19 View Source File : CreateConferenceRequestHandler.cs
License : Apache License 2.0
Project Creator : Anapher

private static string GenerateId()
        {
            var guid = Guid.NewGuid();
            var id = Math.Abs(guid.GetHashCode());

            return new Hashids("Strive").Encode(id);
        }

19 View Source File : GuidId.cs
License : MIT License
Project Creator : andrewlock

public override int GetHashCode() => Value.GetHashCode();

19 View Source File : Entity.cs
License : MIT License
Project Creator : Andyhacool

public override int GetHashCode()
        {
            return (GetType().GetHashCode() * 907) + Id.GetHashCode();
        }

19 View Source File : ShortGuid.cs
License : MIT License
Project Creator : AnkiTools

public override int GetHashCode()
        {
            return _guid.GetHashCode();
        }

19 View Source File : ReferenceCollectorEditor.cs
License : MIT License
Project Creator : AnotherEnd15

public override void OnInspectorGUI()
	{
        //使ReferenceCollector支持撤销操作,还有Redo,不过没有在这里使用
        Undo.RecordObject(referenceCollector, "Changed Settings");
		var dataProperty = serializedObject.FindProperty("data");
        //开始水平布局,如果是比较新版本学习U3D的,可能不知道这东西,这个是老GUI系统的知识,除了用在编辑器里,还可以用在生成的游戏中
		GUILayout.BeginHorizontal();
        //下面几个if都是点击按钮就会返回true调用里面的东西
		if (GUILayout.Button("添加引用"))
		{
            //添加新的元素,具体的函数注释
            // Guid.NewGuid().GetHashCode().ToString() 就是新建后默认的key
            AddReference(dataProperty, Guid.NewGuid().GetHashCode().ToString(), null);
		}
		if (GUILayout.Button("全部删除"))
		{
			dataProperty.ClearArray();
		}
		if (GUILayout.Button("删除空引用"))
		{
			DelNullReference();
		}
		if (GUILayout.Button("排序"))
		{
			referenceCollector.Sort();
		}
		EditorGUILayout.EndHorizontal();
		EditorGUILayout.BeginHorizontal();
        //可以在编辑器中对searchKey进行赋值,只要输入对应的Key值,就可以点后面的删除按钮删除相对应的元素
        searchKey = EditorGUILayout.TextField(searchKey);
        //添加的可以用于选中Object的框,这里的object也是(UnityEngine.Object
        //第三个参数为是否只能引用scene中的Object
        EditorGUILayout.ObjectField(heroPrefab, typeof (Object), false);
		if (GUILayout.Button("删除"))
		{
			referenceCollector.Remove(searchKey);
			heroPrefab = null;
		}
		GUILayout.EndHorizontal();
		EditorGUILayout.Space();

		var delList = new List<int>();
        SerializedProperty property;
        //遍历ReferenceCollector中data list的所有元素,显示在编辑器中
        for (int i = referenceCollector.data.Count - 1; i >= 0; i--)
		{
			GUILayout.BeginHorizontal();
            //这里的知识点在ReferenceCollector中有说
            property = dataProperty.GetArrayElementAtIndex(i).FindPropertyRelative("key");
            EditorGUILayout.TextField(property.stringValue, GUILayout.Width(150));
            property = dataProperty.GetArrayElementAtIndex(i).FindPropertyRelative("gameObject");
            property.objectReferenceValue = EditorGUILayout.ObjectField(property.objectReferenceValue, typeof(Object), true);
			if (GUILayout.Button("X"))
			{
                //将元素添加进删除list
				delList.Add(i);
			}
			GUILayout.EndHorizontal();
		}
		var eventType = Event.current.type;
        //在Inspector 窗口上创建区域,向区域拖拽资源对象,获取到拖拽到区域的对象
        if (eventType == EventType.DragUpdated || eventType == EventType.DragPerform)
		{
			// Show a copy icon on the drag
			DragAndDrop.visualMode = DragAndDropVisualMode.Copy;

			if (eventType == EventType.DragPerform)
			{
				DragAndDrop.AcceptDrag();
				foreach (var o in DragAndDrop.objectReferences)
				{
					AddReference(dataProperty, o.name, o);
				}
			}

			Event.current.Use();
		}

        //遍历删除list,将其删除掉
		foreach (var i in delList)
		{
			dataProperty.DeleteArrayElementAtIndex(i);
		}
		serializedObject.ApplyModifiedProperties();
		serializedObject.UpdateIfRequiredOrScript();
	}

19 View Source File : C3Addon.cs
License : GNU General Public License v3.0
Project Creator : armandoalonso

public override int GetHashCode()
        {
            return Id.GetHashCode();
        }

19 View Source File : UserAccountClaim.cs
License : Apache License 2.0
Project Creator : aruss

public override int GetHashCode()
        {
            return this.Id.GetHashCode();
        }

19 View Source File : Program.cs
License : GNU General Public License v3.0
Project Creator : asimmon

public static void Main(string[] args)
        {
            var parsedArgs = ProgramArguments.Parse(args);
            if (parsedArgs.ShowHelp)
            {
                parsedArgs.WriteHelp(Console.Out);
                return;
            }

            var configuration = GetRequestedConfiguration(parsedArgs.ConfigurationPath);
            configuration.Seed = parsedArgs.Seed ?? Math.Abs(Guid.NewGuid().GetHashCode());

            for (var iter = 1; iter <= parsedArgs.RepeatCount; iter++)
            {
                var outputFile = GetOutputFile(parsedArgs.OutputPath, iter);
                var opts = new WorkerOptions(parsedArgs, iter, outputFile, configuration);

                using var worker = new Worker(opts);
                worker.Work();
            }
        }

19 View Source File : TextTemplatingSession.cs
License : MIT License
Project Creator : atifaziz

public override int GetHashCode ()
        {
            return Id.GetHashCode ();
        }

19 View Source File : Program.cs
License : Apache License 2.0
Project Creator : aws-samples

private static List<DeviceData> GetDeviceData()
        {
            var dataList = new List<DeviceData>();

            var url = Path.GetRandomFileName();
            for (var i = 0; i < _deviceCount; i++)
            {
                var rnd = new Random(Guid.NewGuid().GetHashCode());

                var data = new DeviceData
                {
                    DeviceId = string.Format("Device{0}", i),
                    Temperature = rnd.Next(0, 40),
                    Humidity = rnd.Next(0, 100)
                };

                dataList.Add(data);
            }
            return dataList;
        }

19 View Source File : ObjectStoreDaemon.cs
License : MIT License
Project Creator : azist

private Bucket getBucket(Guid key)
    {
      var idx = (key.GetHashCode() & CoreConsts.ABS_HASH_MASK) % m_BucketCount;
      return m_Buckets[idx];
    }

19 View Source File : Query.cs
License : MIT License
Project Creator : azist

public override int GetHashCode() => m_Idenreplacedy.GetHashCode();

19 View Source File : ObjectStoreEntry.cs
License : MIT License
Project Creator : azist

public override int GetHashCode() => Key.GetHashCode();

19 View Source File : IndexingPrimitives.cs
License : MIT License
Project Creator : azist

public override int GetHashCode() => Value.GetHashCode() ^ Bookmark.GetHashCode();

19 View Source File : LockSession.cs
License : MIT License
Project Creator : azist

public override int GetHashCode()
    {
      return ID.GetHashCode() ^ Host.GetHashCodeOrdSenseCase();
    }

19 View Source File : PropertyKey.cs
License : MIT License
Project Creator : Bassman2

public override int GetHashCode()
        {
            return this.fmtid.GetHashCode() ^ this.pid.GetHashCode();
        }

19 View Source File : SerializedGUID.cs
License : MIT License
Project Creator : Baste-RainGames

public override int GetHashCode()
        {
            return guid.GetHashCode();
        }

19 View Source File : Models.cs
License : MIT License
Project Creator : BlazorPlus

public void GenerateSecureKeyAndHash(out byte[] sourceKeyIV, out byte[] encryptedkeyandiv, out byte[] sourcekeyhash)
		{
			Random r = new Random(Guid.NewGuid().GetHashCode());
			byte[] keyandiv = new byte[32];//key=24,iv=8
			r.NextBytes(keyandiv);
			EncryptSourceKey(keyandiv, out encryptedkeyandiv, out sourcekeyhash);
			sourceKeyIV = keyandiv;
		}

19 View Source File : ProfileFileInfo.cs
License : GNU General Public License v3.0
Project Creator : BornToBeRoot

public override int GetHashCode()
        {
            return ID.GetHashCode();            
        }

19 View Source File : RandomSeed.cs
License : MIT License
Project Creator : CatLib

public static int Guid()
        {
            return Environment.TickCount ^ System.Guid.NewGuid().GetHashCode();
        }

19 View Source File : BaseEntity.cs
License : MIT License
Project Creator : chinabeacon

public override int GetHashCode()
        {
            if (Equals(Id, default(int)))
                return base.GetHashCode();
            return Id.GetHashCode();
        }

19 View Source File : Node.cs
License : MIT License
Project Creator : chris-gong

public override int GetHashCode()
        {
            return Guid.GetHashCode();
        }

19 View Source File : PropertyKey.cs
License : GNU General Public License v3.0
Project Creator : CitizensReactor

public override int GetHashCode()
        {
            return formatId.GetHashCode() ^ propertyId;
        }

See More Examples