object.Equals(object, object)

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

17995 Examples 7

19 View Source File : CelesteNetTCPUDPConnection.cs
License : MIT License
Project Creator : 0x0ade

protected virtual void ReadUDPLoop() {
            try {
                using MemoryStream stream = new();
                using CelesteNetBinaryReader reader = new(Data, UDPQueue.Strings, stream);
                while (UDP != null && IsAlive && !Loopend) {
                    IPEndPoint? remote = null;
                    byte[] raw = UDP.Receive(ref remote);
                    if (UDPRemoteEndPoint != null && !remote.Equals(UDPRemoteEndPoint))
                        continue;

                    stream.Seek(0, SeekOrigin.Begin);
                    stream.Write(raw, 0, raw.Length);

                    stream.Seek(0, SeekOrigin.Begin);
                    Receive(Data.Read(reader));
                }

            } catch (ThreadAbortException) {

            } catch (Exception e) {
                if (!IsAlive)
                    return;

                ReadUDPThread = null;
                lock (UDPErrorLock) {
                    UDPErrorLast = e;
                    if (_OnUDPError != null) {
                        _OnUDPError(this, e, true);
                    } else {
                        Logger.Log(LogLevel.CRI, "tcpudpcon", $"UDP loop error:\n{this}\n{(e is ObjectDisposedException ? "Disposed" : e is SocketException ? e.Message : e.ToString())}");
                        Dispose();
                    }
                }
            }
        }

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

public bool VisitExprDerivedTableQuery(ExprDerivedTableQuery exprDerivedTableQuery, IExpr? parent)
        {
            this.AcceptPar('(', exprDerivedTableQuery.Query, ')', exprDerivedTableQuery);
            exprDerivedTableQuery.Alias.Accept(this, exprDerivedTableQuery);
            if (exprDerivedTableQuery.Columns != null)
            {
                exprDerivedTableQuery.Columns.replacedertNotEmpty("List of columns in a derived table with values literals cannot be empty");
                var selectedColumns = exprDerivedTableQuery.Query.GetOutputColumnNames();

                if (selectedColumns.Count != exprDerivedTableQuery.Columns.Count)
                {
                    throw new SqExpressException("Number of declared columns does not match to number of selected columns in the derived table sub query");
                }

                bool allMatch = true;
                for (int i = 0; i < selectedColumns.Count; i++)
                {
                    if (!string.Equals(selectedColumns[i],
                        ((IExprNamedSelecting) exprDerivedTableQuery.Columns[i]).OutputName))
                    {
                        allMatch = false;
                        break;
                    }
                }
                if (!allMatch)
                {
                    this.AcceptListComaSeparatedPar('(', exprDerivedTableQuery.Columns, ')', exprDerivedTableQuery);
                }
            }

            return true;
        }

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

public bool Equals(ColumnRef? other)
        {
            if (ReferenceEquals(null, other)) return false;
            if (ReferenceEquals(this, other)) return true;
            return this.Table.Equals(other.Table) && string.Equals(this.Name, other.Name, StringComparison.InvariantCultureIgnoreCase);
        }

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

internal string MapSchema(string schemaName)
        {
            if (this.SchemaMap != null)
            {
                for (int i = 0; i < this.SchemaMap.Count; i++)
                {
                    var map = this.SchemaMap[i];

                    if (string.Equals(map.From, schemaName, StringComparison.InvariantCultureIgnoreCase))
                    {
                        schemaName = map.To;
                        break;
                    }
                }
            }

            return schemaName;
        }

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

public bool Equals(ExprAliasGuid? other)
        {
            if (ReferenceEquals(null, other)) return false;
            if (ReferenceEquals(this, other)) return true;
            return this.Id.Equals(other.Id);
        }

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

public bool Equals(ExprColumn? other)
        {
            if (ReferenceEquals(null, other)) return false;
            if (ReferenceEquals(this, other)) return true;
            return Equals(this.Source, other.Source) && Equals(this.ColumnName, other.ColumnName);
        }

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

public bool Equals(ExprDbSchema? other)
        {
            if (ReferenceEquals(null, other)) return false;
            if (ReferenceEquals(this, other)) return true;
            return Equals(this.Database, other.Database) && this.Schema.Equals(other.Schema);
        }

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

public bool Equals(ExprTable? other)
        {
            if (ReferenceEquals(null, other)) return false;
            if (ReferenceEquals(this, other)) return true;
            return Equals(this.Alias, other.Alias) && this.FullName.Equals(other.FullName);
        }

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

public bool Equals(ExprTableFullName? other)
        {
            if (ReferenceEquals(null, other)) return false;
            if (ReferenceEquals(this, other)) return true;
            return Equals(this.DbSchema, other.DbSchema) && this.TableName.Equals(other.TableName);
        }

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

public bool Equals(TableMultiplication other)
        {
            return this.Tables.Equals(other.Tables) && Equals(this.On, other.On);
        }

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

private void EnsureTableNamesAreUnique(List<TableModel> result, string defaultSchema)
        {
            if (result.Count < 2)
            {
                return;
            }

            var dic = result
                .Select((table,origIndex)=>
                {
                    EnsureColumnNamesAreUnique(table);
                    return (table, origIndex);
                })
                //C# clreplaced names is case-sensitive but windows file system is not, so there might be clreplaced overwriting.
                .GroupBy(t => t.table.Name, StringComparer.InvariantCultureIgnoreCase)
                .ToDictionary(t => t.Key, t => t.ToList(), StringComparer.InvariantCultureIgnoreCase);

            foreach (var pair in dic.ToList())
            {
                while (pair.Value.Count > 1)
                {
                    var newName = pair.Key;

                    //Try add schema prefix
                    int? duplicateIndex = null;
                    for (int i = 0; i < pair.Value.Count; i++)
                    {
                        var next = pair.Value[i];
                        if (!string.Equals(next.table.DbName.Schema, defaultSchema, StringComparison.InvariantCultureIgnoreCase))
                        {
                            duplicateIndex = i;
                            break;
                        }
                    }
                    if (duplicateIndex != null)
                    {
                        var duplicate = pair.Value[duplicateIndex.Value];

                        var tableName = duplicate.table.Name;

                        if (!string.IsNullOrEmpty(this._options.TableClreplacedPrefix))
                        {
                            tableName = tableName.Substring(this._options.TableClreplacedPrefix.Length);
                        }

                        newName = this._options.TableClreplacedPrefix + StringHelper.DeSnake(duplicate.table.DbName.Schema) + tableName;
                    }

                    newName = StringHelper.AddNumberUntilUnique(newName, "No", nn => !dic.ContainsKey(nn));

                    duplicateIndex ??= 1;//Second

                    var duplicateRes = pair.Value[duplicateIndex.Value];

                    var newTable = duplicateRes.table.WithNewName(newName);

                    result[duplicateRes.origIndex] = newTable;

                    dic.Add(newTable.Name, new List<(TableModel table, int origIndex)>(1){(newTable, duplicateRes.origIndex)});

                    pair.Value.RemoveAt(duplicateIndex.Value);
                }
            }
        }

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

public override DefaultValue? ParseDefaultValue(string? rawColumnDefaultValue)
        {
            if (string.IsNullOrEmpty(rawColumnDefaultValue))
            {
                return null;
            }

            if (TryGetDefaultValue(rawColumnDefaultValue, IntDefRegEx, DefaultValueType.Integer, out var result))
            {
                return result;
            }
            if (TryGetDefaultValue(rawColumnDefaultValue, StringDefRegEx, DefaultValueType.String, out result))
            {
                return result;
            }

            if (string.Equals(rawColumnDefaultValue, "(getutcdate())", StringComparison.InvariantCultureIgnoreCase))
            {
                return new DefaultValue(DefaultValueType.GetUtcDate, null);
            }
            if (string.Equals(rawColumnDefaultValue, "(NULL)", StringComparison.InvariantCultureIgnoreCase))
            {
                return new DefaultValue(DefaultValueType.Null, null);
            }

            return new DefaultValue(DefaultValueType.Raw, rawColumnDefaultValue);

            static bool TryGetDefaultValue(string value, Regex regex, DefaultValueType defaultValueType, out DefaultValue? result)
            {
                var m = regex.Match(value);
                if (m.Success)
                {
                    result = new DefaultValue(defaultValueType, m.Result("$1"));
                    return true;
                }
                result = null;
                return false;
            }
        }

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

public bool Equals(TableRef? other)
        {
            if (ReferenceEquals(null, other)) return false;
            if (ReferenceEquals(this, other)) return true;
            return string.Equals(this.Schema, other.Schema, StringComparison.InvariantCultureIgnoreCase) && string.Equals(this.Name, other.Name, StringComparison.InvariantCultureIgnoreCase);
        }

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

public static IReadOnlyList<NodeModel> BuildModelRoslyn(string projectFolder)
        {
            List<NodeModel> result = new List<NodeModel>();
				
            var files = Directory.EnumerateFiles(Path.Combine(projectFolder, "Syntax"), "*.cs", SearchOption.AllDirectories);

            files = files.Concat(Directory.EnumerateFiles(projectFolder, "IExpr*.cs"));

            var trees = files.Select(f => CSharpSyntaxTree.ParseText(File.ReadAllText(f))).ToList();
            var cSharpCompilation = CSharpCompilation.Create("Syntax", trees);

            foreach (var tree in trees)
            {
                var semantic = cSharpCompilation.GetSemanticModel(tree);

                foreach (var clreplacedDeclarationSyntax in tree.GetRoot().DescendantNodesAndSelf().OfType<ClreplacedDeclarationSyntax>())
                {
                    var clreplacedSymbol = semantic.GetDeclaredSymbol(clreplacedDeclarationSyntax);
                    
                    var isSuitable = clreplacedSymbol != null 
                                 && !clreplacedSymbol.IsAbstract 
                                 && clreplacedSymbol.DeclaredAccessibility == Accessibility.Public
                                 && IsExpr(clreplacedSymbol) 
                                 && clreplacedSymbol.Name.StartsWith("Expr");
                        
                    if (!isSuitable)
                    {
                        continue;
                    }

                    var properties = GetProperties(clreplacedSymbol);

                    var subNodes = new List<SubNodeModel>();
                    var modelProps = new List<SubNodeModel>();

                    foreach (var constructor in clreplacedSymbol.Constructors)
                    {
                        foreach (var parameter in constructor.Parameters)
                        {
                            INamedTypeSymbol pType = (INamedTypeSymbol)parameter.Type;

                            var correspondingProperty = properties.FirstOrDefault(prop =>
                                string.Equals(prop.Name,
                                    parameter.Name,
                                    StringComparison.CurrentCultureIgnoreCase));

                            if (correspondingProperty == null)
                            {
                                throw new Exception(
                                    $"Could not find a property for the constructor arg: '{parameter.Name}'");
                            }

                            var ta = replacedyzeSymbol(ref pType);

                            var subNodeModel = new SubNodeModel(correspondingProperty.Name,
                                parameter.Name,
                                pType.Name,
                                ta.ListName,
                                ta.IsNullable,
                                ta.HostTypeName);
                            if (ta.Expr)
                            {
                                subNodes.Add(subNodeModel);
                            }
                            else
                            {
                                modelProps.Add(subNodeModel);
                            }

                        }
                    }

                    result.Add(new NodeModel(clreplacedSymbol.Name,
                        modelProps.Count == 0 && subNodes.Count == 0,
                        subNodes,
                        modelProps));
                }
            }

            result.Sort((a, b) => string.CompareOrdinal(a.TypeName, b.TypeName));

            return result;

            bool IsExpr(INamedTypeSymbol symbol)
            {
                if (symbol.Name == "IExpr")
                {
                    return true;
                }
                while (symbol != null)
                {
                    if (symbol.Interfaces.Any(HasA))
                    {
                        return true;
                    }
                    symbol = symbol.BaseType;
                }

                return false;


                bool HasA(INamedTypeSymbol iSym)
                {
                    if (iSym.Name == "IExpr")
                    {
                        return true;
                    }

                    return IsExpr(iSym);
                }
            }

            List<ISymbol> GetProperties(INamedTypeSymbol symbol)
            {
                List<ISymbol> result = new List<ISymbol>();
                while (symbol != null)
                {
                    result.AddRange(symbol.GetMembers().Where(m => m.Kind == SymbolKind.Property));
                    symbol = symbol.BaseType;
                }

                return result;
            }

            Symbolreplacedysis replacedyzeSymbol(ref INamedTypeSymbol typeSymbol)
            {
                string listName = null;
                string hostType = null;
                if (typeSymbol.ContainingType != null)
                {
                    var host = typeSymbol.ContainingType;
                    hostType = host.Name;
                }

                var nullable = typeSymbol.NullableAnnotation == NullableAnnotation.Annotated;

                if (nullable && typeSymbol.Name == "Nullable")
                {
                    typeSymbol = (INamedTypeSymbol)typeSymbol.TypeArguments.Single();
                }

                if (typeSymbol.IsGenericType)
                {
                    if (typeSymbol.Name.Contains("List"))
                    {
                        listName = typeSymbol.Name;
                    }

                    if (typeSymbol.Name == "Nullable")
                    {
                        nullable = true;
                    }

                    typeSymbol = (INamedTypeSymbol)typeSymbol.TypeArguments.Single();
                }

                return new Symbolreplacedysis(nullable, listName, IsExpr(typeSymbol), hostType);
            }
        }

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

public async Task Exec(IScenarioContext context)
        {
            bool isPostgres = context.Dialect == SqlDialect.PgSql;
            var table = new TableItAllColumnTypes(isPostgres);
            await context.Database.Statement(table.Script.DropAndCreate());

            var testData = GetTestData(isPostgres);

            await InsertDataInto(table, testData)
                .MapData(Mapping)
                .Exec(context.Database);

            var mapper = new Mapper(new MapperConfiguration(cfg =>
            {
                cfg.AddDataReaderMapping();
                var map = cfg.CreateMap<IDataRecord, AllColumnTypesDto>();

                map
                    .ForMember(nameof(table.ColByteArraySmall), c => c.Ignore())
                    .ForMember(nameof(table.ColByteArrayBig), c => c.Ignore())
                    .ForMember(nameof(table.ColNullableByteArraySmall), c => c.Ignore())
                    .ForMember(nameof(table.ColNullableByteArrayBig), c => c.Ignore())
                    .ForMember(nameof(table.ColNullableFixedSizeByteArray), c => c.Ignore())
                    .ForMember(nameof(table.ColFixedSizeByteArray), c => c.Ignore());

                if (isPostgres)
                {
                    map
                        .ForMember(nameof(table.ColByte), c => c.Ignore())
                        .ForMember(nameof(table.ColNullableByte), c => c.Ignore());
                }
                if (context.Dialect == SqlDialect.MySql)
                {
                    map
                        .ForMember(nameof(table.ColBoolean), c => c.MapFrom((r, dto) => r.GetBoolean(r.GetOrdinal(nameof(table.ColBoolean)))))
                        .ForMember(nameof(table.ColNullableBoolean), c => c.MapFrom((r, dto) => r.IsDBNull(r.GetOrdinal(nameof(table.ColNullableBoolean))) ? (bool?)null : r.GetBoolean(r.GetOrdinal(nameof(table.ColNullableBoolean)))))
                        .ForMember(nameof(table.ColGuid), c => c.MapFrom((r, dto) => r.GetGuid(r.GetOrdinal(nameof(table.ColGuid)))))
                        .ForMember(nameof(table.ColNullableGuid), c=>c.MapFrom((r, dto) => r.IsDBNull(r.GetOrdinal(nameof(table.ColNullableGuid)))? (Guid?)null : r.GetGuid(r.GetOrdinal(nameof(table.ColNullableGuid)))));
                }
            }));

            var expr = Select(table.Columns)
                .From(table).Done();

            context.WriteLine(PgSqlExporter.Default.ToSql(expr));

            var result = await expr
                .QueryList(context.Database, r =>
                {
                    var allColumnTypesDto = mapper.Map<IDataRecord, AllColumnTypesDto>(r);

                    allColumnTypesDto.ColByteArrayBig = StreamToByteArray(table.ColByteArrayBig.GetStream(r));
                    allColumnTypesDto.ColByteArraySmall = table.ColByteArraySmall.Read(r);
                    allColumnTypesDto.ColNullableByteArrayBig = table.ColNullableByteArrayBig.Read(r);
                    allColumnTypesDto.ColNullableByteArraySmall = table.ColNullableByteArraySmall.Read(r);
                    allColumnTypesDto.ColFixedSizeByteArray = table.ColFixedSizeByteArray.Read(r);
                    allColumnTypesDto.ColNullableFixedSizeByteArray = table.ColNullableFixedSizeByteArray.Read(r);

                    return allColumnTypesDto;
                });

            static byte[] StreamToByteArray(Stream stream)
            {
                var buffer = new byte[stream.Length];

                using MemoryStream ms = new MemoryStream(buffer);

                stream.CopyTo(ms);

                var result = buffer;

                stream.Dispose();

                return result;
            }

            for (int i = 0; i < testData.Length; i++)
            {
                if (!Equals(testData[i], result[i]))
                {
                    var props = typeof(AllColumnTypesDto).GetProperties();
                    foreach (var propertyInfo in props)
                    {
                        context.WriteLine($"{propertyInfo.Name}: {propertyInfo.GetValue(testData[i])} - {propertyInfo.GetValue(result[i])}");
                    }

                    throw new Exception("Input and output are not identical!");
                }
            }

            if (context.Dialect == SqlDialect.TSql)
            {
                var data = await Select(AllTypes.GetColumns(table))
                    .From(table)
                    .QueryList(context.Database, (r) => AllTypes.Read(r, table));

                if (data.Count != 2)
                {
                    throw new Exception("Incorrect reading using models");
                }

                await InsertDataInto(table, data).MapData(AllTypes.GetMapping).Exec(context.Database);
            }


            Console.WriteLine("'All Column Type Test' is preplaceded");
        }

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

public bool Equals(AllColumnTypesDto? other)
            {
                if (ReferenceEquals(null, other)) return false;
                if (ReferenceEquals(this, other)) return true;
                return this.ColNullableStringMax == other.ColNullableStringMax &&
                       this.ColString5 == other.ColString5 &&
                       this.ColStringMax == other.ColStringMax &&
                       this.ColNullableStringUnicode == other.ColNullableStringUnicode &&
                       this.ColStringUnicode == other.ColStringUnicode &&
                       Nullable.Equals(this.ColNullableGuid, other.ColNullableGuid) &&
                       this.ColGuid.Equals(other.ColGuid) &&
                       Nullable.Equals(this.ColNullableDateTime, other.ColNullableDateTime) &&
                       this.ColDateTime.Equals(other.ColDateTime) &&
                       Nullable.Equals(this.ColNullableDouble, other.ColNullableDouble) &&
                       this.ColDouble.Equals(other.ColDouble) &&
                       this.ColNullableDecimal == other.ColNullableDecimal &&
                       this.ColDecimal == other.ColDecimal &&
                       this.ColNullableInt64 == other.ColNullableInt64 &&
                       this.ColInt64 == other.ColInt64 &&
                       this.ColNullableInt32 == other.ColNullableInt32 &&
                       this.ColInt32 == other.ColInt32 &&
                       this.ColNullableInt16 == other.ColNullableInt16 &&
                       this.ColInt16 == other.ColInt16 &&
                       this.ColNullableByte == other.ColNullableByte &&
                       this.ColByte == other.ColByte &&
                       this.ColNullableBoolean == other.ColNullableBoolean &&
                       this.ColBoolean == other.ColBoolean &&
                       this.ColXml == other.ColXml &&
                       this.ColNullableXml == other.ColNullableXml &&
                       CompareArrays(this.ColByteArrayBig, other.ColByteArrayBig) &&
                       CompareArrays(this.ColByteArraySmall, other.ColByteArraySmall) &&
                       CompareArrays(this.ColNullableByteArrayBig, other.ColNullableByteArrayBig) &&
                       CompareArrays(this.ColNullableByteArraySmall, other.ColNullableByteArraySmall) &&

                       this.ColNullableFixedSizeString == other.ColNullableFixedSizeString &&
                       this.ColFixedSizeString == other.ColFixedSizeString &&

                       CompareArrays(this.ColNullableFixedSizeByteArray, other.ColNullableFixedSizeByteArray) &&
                       CompareArrays(this.ColFixedSizeByteArray, other.ColFixedSizeByteArray)
                       ;


                static bool CompareArrays(byte[]? arr1, byte[]? arr2)
                {
                    if (arr1 == arr2)
                    {
                        return true;
                    }

                    if (arr1 == null || arr2 == null)
                    {
                        return false;
                    }

                    if (arr1.Length != arr2.Length)
                    {
                        return false;
                    }

                    for (int i = 0; i < arr1.Length; i++)
                    {
                        if (arr1[i] != arr2[i])
                        {
                            return false;
                        }
                    }
                    return true;
                }
            }

19 View Source File : AvifParser.cs
License : MIT License
Project Creator : 0xC0000054

public ItemLocationEntry TryGetXmpLocation(uint itemId)
        {
            foreach (IItemReferenceEntry item in GetMatchingReferences(itemId, ReferenceTypes.ContentDescription))
            {
                IItemInfoEntry entry = TryGereplacedemInfoEntry(item.FromItemId);

                if (entry != null && entry.ItemType == ItemInfoEntryTypes.Mime)
                {
                    MimeItemInfoEntryBox mimeItemInfo = (MimeItemInfoEntryBox)entry;
                    string contentType = mimeItemInfo.ContentType.Value;

                    if (string.Equals(contentType, XmpItemInfoEntry.XmpContentType, StringComparison.Ordinal))
                    {
                        return TryGereplacedemLocation(item.FromItemId);
                    }
                }
            }

            return null;
        }

19 View Source File : AvifParser.cs
License : MIT License
Project Creator : 0xC0000054

private bool IsAlphaChannelItem(uint itemId)
        {
            AuxiliaryTypePropertyBox auxiliaryTypeBox = TryGetreplacedociatedItemProperty<AuxiliaryTypePropertyBox>(itemId);

            if (auxiliaryTypeBox != null)
            {
                string auxType = auxiliaryTypeBox.AuxType.Value;

                if (string.Equals(auxType, AlphaChannelNames.AVIF, StringComparison.Ordinal) ||
                    string.Equals(auxType, AlphaChannelNames.HEVC, StringComparison.Ordinal))
                {
                    return true;
                }
            }

            return false;
        }

19 View Source File : HeifImageHandle.cs
License : GNU Lesser General Public License v3.0
Project Creator : 0xC0000054

public IReadOnlyList<HeifItemId> GetMetadataBlockIds(string type = null, string contentType = null)
        {
            VerifyNotDisposed();

            int count = LibHeifNative.heif_image_handle_get_number_of_metadata_blocks(this.imageHandle, type);

            if (count == 0)
            {
                return Array.Empty<HeifItemId>();
            }

            var ids = new HeifItemId[count];

            unsafe
            {
                fixed (HeifItemId* ptr = ids)
                {
                    int filledCount = LibHeifNative.heif_image_handle_get_list_of_metadata_block_IDs(this.imageHandle,
                                                                                                     type,
                                                                                                     ptr,
                                                                                                     count);
                    if (filledCount != count)
                    {
                        ExceptionUtil.ThrowHeifException(Resources.CannotGetAllMetadataBlockIds);
                    }
                }
            }

            // The type must be defined in order to filter by content type.
            if (type != null && contentType != null)
            {
                var matchingItems = new List<HeifItemId>();

                for (int i = 0; i < ids.Length; i++)
                {
                    var id = ids[i];
                    var metadataContentType = LibHeifNative.heif_image_handle_get_metadata_content_type(this.imageHandle, id);

                    if (contentType.Equals(metadataContentType.GetStringValue(), StringComparison.Ordinal))
                    {
                        matchingItems.Add(id);
                    }
                }

                return matchingItems;
            }
            else
            {
                return ids;
            }
        }

19 View Source File : MetadataProvider.cs
License : MIT License
Project Creator : 0xd4d

public ModuleDef? GetModule(string? filename) {
			if (string2.IsNullOrEmpty(filename))
				return null;
			lock (lockObj) {
				foreach (var module in modules) {
					if (StringComparer.OrdinalIgnoreCase.Equals(module.Location, filename))
						return module;
				}
				var mod = ModuleDefMD.Load(filename);
				modules.Add(mod);
				return mod;
			}
		}

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

static (int bitness, DisasmInfo[] methods, KnownSymbols knownSymbols) GetMethodsToDisreplacedemble(int pid, string moduleName, MemberFilter typeFilter, MemberFilter methodFilter, bool heapSearch) {
			var methods = new List<DisasmInfo>();
			var knownSymbols = new KnownSymbols();
			int bitness;
			using (var dataTarget = DataTarget.AttachToProcess(pid, 0, AttachFlag.Preplacedive)) {
				if (dataTarget.ClrVersions.Count == 0)
					throw new ApplicationException("Couldn't find CLR/CoreCLR");
				if (dataTarget.ClrVersions.Count > 1)
					throw new ApplicationException("Found more than one CLR/CoreCLR");
				var clrInfo = dataTarget.ClrVersions[0];
				var clrRuntime = clrInfo.CreateRuntime(clrInfo.LocalMatchingDac);
				bitness = clrRuntime.PointerSize * 8;

				// Per https://github.com/microsoft/clrmd/issues/303
				dataTarget.DataReader.Flush();

				var module = clrRuntime.Modules.FirstOrDefault(a =>
					StringComparer.OrdinalIgnoreCase.Equals(a.Name, moduleName) ||
					StringComparer.OrdinalIgnoreCase.Equals(Path.GetFileNameWithoutExtension(a.Name), moduleName) ||
					StringComparer.OrdinalIgnoreCase.Equals(a.FileName, moduleName));
				if (module is null)
					throw new ApplicationException($"Couldn't find module '{moduleName}'");

				module.Runtime.Flush();

				foreach (var type in EnumerateTypes(module, heapSearch)) {
					if (!typeFilter.IsMatch(type.Name, type.MetadataToken))
						continue;
					foreach (var method in type.Methods) {
						if (!IsSameType(method.Type, type))
							continue;
						if (method.CompilationType == MethodCompilationType.None)
							continue;
						if (!methodFilter.IsMatch(method.Name, method.MetadataToken))
							continue;
						var disasmInfo = CreateDisasmInfo(dataTarget, method);
						DecodeInstructions(knownSymbols, clrRuntime, disasmInfo);
						methods.Add(disasmInfo);
					}
				}
			}
			return (bitness, methods.ToArray(), knownSymbols);
		}

19 View Source File : PublicFile.cs
License : Apache License 2.0
Project Creator : 0xFireball

public bool CheckPreplacedword(string preplaced)
        {
            var cryptoHelper = new AuthCryptoHelper(Crypto.Conf);
            var inputPreplaced = cryptoHelper.CalculateUserPreplacedwordHash(preplaced, Crypto.Salt);
            return StructuralComparisons.StructuralEqualityComparer.Equals(inputPreplaced, Crypto.Key);
        }

19 View Source File : WebUserManager.cs
License : Apache License 2.0
Project Creator : 0xFireball

public async Task<bool> CheckPreplacedwordAsync(string preplacedword, RegisteredUser user)
        {
            var ret = false;
            var lockEntry = ServerContext.ServiceTable.GetOrCreate(user.Username).UserLock;
            await lockEntry.WithConcurrentReadAsync(Task.Run(() =>
            {
                //Calculate hash and compare
                var cryptoHelper = new AuthCryptoHelper(user.Crypto.Conf);
                var pwKey =
                    cryptoHelper.CalculateUserPreplacedwordHash(preplacedword, user.Crypto.Salt);
                ret = StructuralComparisons.StructuralEqualityComparer.Equals(pwKey, user.Crypto.Key);
            }));
            return ret;
        }

19 View Source File : SourceCodeProvider.cs
License : MIT License
Project Creator : 0xd4d

MethodDef? GetMetadataMethod(DisasmInfo method) {
			if (!StringComparer.OrdinalIgnoreCase.Equals(lastModule?.Location, method.ModuleFilename)) {
				lastModule = metadataProvider.GetModule(method.ModuleFilename);
				lastMethod = null;
			}
			if (lastModule?.PdbState is null)
				return null;
			if (lastMethod?.MDToken.Raw != method.MethodToken)
				lastMethod = lastModule?.ResolveToken(method.MethodToken) as MethodDef;
			return lastMethod;
		}

19 View Source File : AdditionalTiers.cs
License : GNU General Public License v3.0
Project Creator : 1330-Studios

public override void OnApplicationStart() {
            var asmTypes = replacedembly.GetTypes();
            var ttypes = new Stack<SType>();
            for (int i = 0; i < asmTypes.Length; i++)
                if (typeof(TowerTask).IsreplacedignableFrom(asmTypes[i]) && !typeof(TowerTask).FullName.Equals(asmTypes[i].FullName))
                    ttypes.Push(asmTypes[i]);
            List<TowerTask> tts = new();
            foreach (var type in ttypes) {
                var tt = (TowerTask)Activator.CreateInstance(type);
                if (((long)tt.tower) != -1)
                    tts.Add(tt);
            }
            Towers = tts.ToArray();

            if (!MelonPreferences.HasEntry("Additional Tier Addon Config", "Tier 6 required pop count multiplier")) {
                MelonPreferences.CreateCategory("Additional Tier Addon Config", "Additional Tier Addon Config");
                MelonPreferences.CreateEntry("Additional Tier Addon Config", "Tier 6 required pop count multiplier", (float)1);
                MelonPreferences.CreateEntry("Additional Tier Addon Config", "Display Format", ADisplay.style);
            }

            Globals.Load();

            HarmonyInstance.Patch(Method(typeof(Tower), nameof(Tower.Hilight)), postfix: new HarmonyMethod(Method(typeof(HighlightManager), nameof(HighlightManager.Highlight))));
            HarmonyInstance.Patch(Method(typeof(Tower), nameof(Tower.UnHighlight)), postfix: new HarmonyMethod(Method(typeof(HighlightManager), nameof(HighlightManager.UnHighlight))));

            MelonLogger.Msg(ConsoleColor.Red, "Additional Tier Addon Loaded!");
            CacheBuilder.Build();
            DisplayFactory.Build();
        }

19 View Source File : Assets.cs
License : GNU General Public License v3.0
Project Creator : 1330-Studios

[HarmonyPrefix]
            public static bool Prefix(Factory __instance, string objectId, Il2CppSystem.Action<UnityDisplayNode> onComplete) {
                var replacedets = ShaderBundle.LoadAllreplacedets();

                using (var enumerator = allreplacedetsKnown.GetEnumerator()) {
                    while (enumerator.MoveNext()) {
                        var curreplacedet = enumerator.Current;
                        if (objectId.Equals(curreplacedet.CustomreplacedetName)) {
                            UnityDisplayNode udn = null;
                            __instance.FindAndSetupPrototypeAsync(curreplacedet.BTDreplacedetName,
                                new Action<UnityDisplayNode>(
                                    btdUdn => {
                                        var instance = Object.Instantiate(btdUdn, __instance.PrototypeRoot);
                                        instance.name = objectId + "(Clone)";
                                        if (curreplacedet.RendererType == RendererType.SPRITERENDERER)
                                            instance.isSprite = true;
                                        instance.RecalculateGenericRenderers();

                                        Type rendererType = null;
                                        switch (curreplacedet.RendererType) {
                                            case RendererType.MESHRENDERER:
                                                rendererType = Il2CppType.Of<MeshRenderer>();
                                                break;
                                            case RendererType.SPRITERENDERER:
                                                rendererType = Il2CppType.Of<SpriteRenderer>();
                                                break;
                                            case RendererType.SKINNEDMESHRENDERER:
                                                rendererType = Il2CppType.Of<SkinnedMeshRenderer>();
                                                break;
                                            case RendererType.PARTICLESYSTEMRENDERER:
                                                rendererType = Il2CppType.Of<ParticleSystemRenderer>();
                                                break;
                                        }

                                        if (rendererType == null && curreplacedet.RendererType != RendererType.SKINNEDANDUNSKINNEDMESHRENDERER)
                                            throw new NullReferenceException("rendererType is still null, don't leave things unset.");

                                        for (var i = 0; i < instance.genericRenderers.Length; i++) {
                                            if (instance.genericRenderers[i].GetIl2CppType() == rendererType) {
                                                if (curreplacedet.RendererType != RendererType.SPRITERENDERER && curreplacedet.RendererType != RendererType.SKINNEDANDUNSKINNEDMESHRENDERER && curreplacedet.RendererType != RendererType.PARTICLESYSTEMRENDERER) {
                                                    var renderer = instance.genericRenderers[i].Cast<Renderer>();
                                                    if (!SpecialShaderIndicies.ContainsKey(objectId))
                                                        renderer.material.shader = replacedets.First(a => a.name.StartsWith("Unlit/CelShading")).Cast<Shader>();
                                                    else
                                                        renderer.material.shader = replacedets.First(SpecialShaderIndicies[objectId]).Cast<Shader>();
                                                    renderer.material.SetColor("_OutlineColor", Color.black);
                                                    renderer.material.mainTexture = CacheBuilder.Get(objectId);
                                                } else if (curreplacedet.RendererType == RendererType.SPRITERENDERER) {
                                                    var spriteRenderer = instance.genericRenderers[i].Cast<SpriteRenderer>();
                                                    if (SpriteCreation.ContainsKey(objectId))
                                                        spriteRenderer.sprite = SpriteCreation[objectId](objectId);
                                                    else
                                                        spriteRenderer.sprite = SpriteBuilder.createProjectile(CacheBuilder.Get(objectId));
                                                    if (Types.ContainsKey(objectId)) {
                                                        spriteRenderer.gameObject.AddComponent(Types[objectId]);
                                                    }
                                                }
                                            } else if (curreplacedet.RendererType == RendererType.SKINNEDANDUNSKINNEDMESHRENDERER) {
                                                if (instance.genericRenderers[i].GetIl2CppType() == Il2CppType.Of<SkinnedMeshRenderer>()) {
                                                    var skinnedRenderer = instance.genericRenderers[i].Cast<SkinnedMeshRenderer>();
                                                    if (!SpecialShaderIndicies.ContainsKey(objectId))
                                                        skinnedRenderer.material.shader = replacedets.First(a => a.name.StartsWith("Unlit/CelShading")).Cast<Shader>();
                                                    else
                                                        skinnedRenderer.material.shader = replacedets.First(SpecialShaderIndicies[objectId]).Cast<Shader>();
                                                    skinnedRenderer.material.SetColor("_OutlineColor", Color.black);
                                                    skinnedRenderer.material.mainTexture = CacheBuilder.Get(objectId);

                                                } else if (instance.genericRenderers[i].GetIl2CppType() == Il2CppType.Of<MeshRenderer>()) {
                                                    var meshRenderer = instance.genericRenderers[i].Cast<MeshRenderer>();
                                                    if (!SpecialShaderIndicies.ContainsKey(objectId))
                                                        meshRenderer.material.shader = replacedets.First(a => a.name.StartsWith("Unlit/CelShading")).Cast<Shader>();
                                                    else
                                                        meshRenderer.material.shader = replacedets.First(SpecialShaderIndicies[objectId]).Cast<Shader>();
                                                    meshRenderer.material.SetColor("_OutlineColor", Color.black);
                                                    meshRenderer.material.mainTexture = CacheBuilder.Get(objectId);
                                                }
                                            }
                                        }


                                        if (Actions.ContainsKey(objectId))
                                            Actions[objectId](instance);

                                        udn = instance;
                                        onComplete.Invoke(udn);
                                    }));
                            return false;
                        }
                    }
                }

                if (objectId.Equals("UpgradedText")) {
                    UnityDisplayNode udn = null;
                    __instance.FindAndSetupPrototypeAsync("3dcdbc19136c60846ab944ada06695c0",
                        new Action<UnityDisplayNode>(oudn => {
                            var nudn = Object.Instantiate(oudn, __instance.PrototypeRoot);
                            nudn.name = objectId + "(Clone)";
                            nudn.isSprite = true;
                            nudn.RecalculateGenericRenderers();
                            var nktmp = nudn.GetComponentInChildren<NK_TextMeshPro>();
                            nktmp.m_fontColorGradient = new(Color.red, Color.red, new(255, 255, 0), Color.white);
                            nktmp.capitalize = false;
                            udn = nudn;
                            onComplete.Invoke(udn);
                        }));
                    return false;
                }

19 View Source File : BigFoot.cs
License : GNU General Public License v3.0
Project Creator : 1330-Studios

[HarmonyPrefix]
            public static bool Prefix(MapLoader __instance, string map, Il2CppSystem.Action<MapModel> loadedCallback) {
                if (map.Equals(Name)) {
                    __instance.currentMapName = map;
                    var mapModel = new MapModel(map, new AreaModel[] {
                            new("Whole", AreaWhole, 0, AreaType.land),
                            new("Track", AreaTrack, 0, AreaType.track),
                            new("Land1", AreaLand1, 0, AreaType.land),
                            new("Water", AreaWellWater, 0, AreaType.water),
                            new("Tree1", AreaTree1, 15, AreaType.unplaceable, isBlocker: true),
                            new("Tree2", AreaTree2, 15, AreaType.unplaceable, isBlocker: true),
                            new("Tree3", AreaTree3, 15, AreaType.unplaceable, isBlocker: true),
                            new("Tree4", AreaTree4, 15, AreaType.unplaceable, isBlocker: true)
                        }, new BlockerModel[0], new CoopAreaLayoutModel[] {
                            new(new CoopAreaModel[] {new(0, AreaWhole, new())}, AreaLayoutType.FREE_FOR_ALL,
                                new CoopAreaWhiteLineModel[0])
                        },
                        new PathModel[] {
                            new("Path1", Path1, true, false, new(-1000, -1000, -1000), new(-1000, -1000, -1000), null,
                                null),
                        }, new RemoveableModel[0], new MapGizmoModel[0], 0
                        , new("", new("", new string[] { "Path1" }), new("", new string[] { "Path1" }))
                        , new MapEventModel[0], 1);
                    loadedCallback.Invoke(mapModel);

                    SceneManager.LoadScene(map, new LoadSceneParameters {
                        loadSceneMode = LoadSceneMode.Additive,
                        localPhysicsMode = LocalPhysicsMode.None
                    });

                    return false;
                }

19 View Source File : Dumper.cs
License : MIT License
Project Creator : 13xforever

private List<DiscInfo.DiscInfo> GetValidationInfo()
        {
            var discInfoList = new List<DiscInfo.DiscInfo>();
            foreach (var discKeyInfo in allMatchingKeys.Where(ki => ki.KeyType == KeyType.Ird))
            {
                var ird = IrdParser.Parse(File.ReadAllBytes(discKeyInfo.FullPath));
                if (!DiscVersion.Equals(ird.GameVersion))
                    continue;

                discInfoList.Add(ird.ToDiscInfo());
            }
            return discInfoList;
        }

19 View Source File : Assets.cs
License : GNU General Public License v3.0
Project Creator : 1330-Studios

[HarmonyPrefix]
            public static bool Prefix(Factory __instance, string objectId, Il2CppSystem.Action<UnityDisplayNode> onComplete) {
                using (var enumerator = allreplacedetsKnown.GetEnumerator()) {
                    while (enumerator.MoveNext()) {
                        replacedetInfo curreplacedet = enumerator.Current;
                        if (objectId.Equals(curreplacedet.CustomreplacedetName)) {
                            GameObject obj = Object.Instantiate(new GameObject(objectId + "(Clone)"), __instance.PrototypeRoot);
                            var sr = obj.AddComponent<SpriteRenderer>();
                            sr.sprite = SpriteBuilder.createBloon(CacheBuilder.Get(objectId));
                            var udn = obj.AddComponent<UnityDisplayNode>();
                            udn.transform.position = new(-3000, 0);
                            onComplete.Invoke(udn);
                            return false;
                        }
                    }
                }
                return true;
            }

19 View Source File : Daffodils.cs
License : GNU General Public License v3.0
Project Creator : 1330-Studios

[HarmonyPrefix]
            public static bool Prefix(MapLoader __instance, string map, Il2CppSystem.Action<MapModel> loadedCallback) {
                if (map.Equals(Name)) {
                    __instance.currentMapName = map;
                    var mapModel = new MapModel(map, new AreaModel[] {
                            new("Whole", AreaWhole, 0, AreaType.land),
                            new("Track", AreaTrack, 0, AreaType.track),
                            new("Water", AreaWellWater, 0, AreaType.water),
                            new("Land1", AreaLand1, 0, AreaType.land),
                            new("Land2", AreaLand2, 0, AreaType.land),
                            new("Tree1", AreaTree1, 15, AreaType.unplaceable, isBlocker: true),
                            new("Tree2", AreaTree2, 15, AreaType.unplaceable, isBlocker: true),
                            new("Tree3", AreaTree3, 15, AreaType.unplaceable, isBlocker: true),
                            new("Tree4", AreaTree4, 15, AreaType.unplaceable, isBlocker: true)
                        }, new BlockerModel[0], new CoopAreaLayoutModel[] {
                            new(new CoopAreaModel[] {new(0, AreaWhole, new())}, AreaLayoutType.FREE_FOR_ALL,
                                new CoopAreaWhiteLineModel[0])
                        },
                        new PathModel[] {
                            new("Path1", Path1, true, false, new(-1000, -1000, -1000), new(-1000, -1000, -1000), null, null),
                        }, new RemoveableModel[0], new MapGizmoModel[0], 0
                        , new("", new("", new string[] { "Path1" }), new("", new string[] { "Path1" }))
                        , new MapEventModel[0], 1);
                    loadedCallback.Invoke(mapModel);

                    SceneManager.LoadScene(map, new LoadSceneParameters {
                        loadSceneMode = LoadSceneMode.Additive,
                        localPhysicsMode = LocalPhysicsMode.None
                    });

                    return false;
                }

19 View Source File : Shipwreck.cs
License : GNU General Public License v3.0
Project Creator : 1330-Studios

[HarmonyPrefix]
            public static bool Prefix(MapLoader __instance, string map, Il2CppSystem.Action<MapModel> loadedCallback) {
                if (map.Equals(Name)) {
                    __instance.currentMapName = map;

                    PointInfo[] Path2 = Path1.Reversed();
                    var mapModel = new MapModel(map, new AreaModel[] {
                            new("Whole", AreaWhole, 0, AreaType.water),
                            new("UP1", AreaUp1, 0, AreaType.unplaceable),
                            new("UP2", AreaUp2, 0, AreaType.unplaceable),
                            new("UP3", AreaUp3, 0, AreaType.unplaceable),
                            new("UP4", AreaUp4, 0, AreaType.unplaceable),
                            new("Crate", AreaCrate, 0, AreaType.land),
                            new("Barrel", AreaBarrel, 0, AreaType.land),
                            new("Rock1", AreaSRock, 0, AreaType.land),
                            new("Rock2", AreaMRock, 0, AreaType.land),
                            new("Rock3", AreaLRock, 0, AreaType.land),
                            new("Rock4", AreaTRock1, 0, AreaType.land),
                            new("Rock5", AreaTRock2, 0, AreaType.land),
                            new("WatchTower", AreaWatchTowerTop, 0, AreaType.land),
                            new("LeftShip", AreaLeftShip, 0, AreaType.land),
                            new("RightShip", AreaRightShip, 0, AreaType.land),
                            new("Straight1", AreaStraight1, 0, AreaType.track)
                    }, new BlockerModel[0], new CoopAreaLayoutModel[]
                        {
                            new(new CoopAreaModel[] {new(0, AreaWhole, new())}, AreaLayoutType.FREE_FOR_ALL, new CoopAreaWhiteLineModel[0])
                        },
                        new PathModel[] {
                            new("Path1", Path1, true, false, new(-1000, -1000, -1000), new(-1000, -1000, -1000), null, null),
                            new("Path2", Path2, true, false, new(-1000, -1000, -1000), new(-1000, -1000, -1000), null, null)
                    }, new RemoveableModel[0], new MapGizmoModel[0], 0
                    , new("", new("", new string[] { "Path1", "Path2" }), new("", new string[] { "Path1", "Path2" }))
                    , new MapEventModel[0], 1);
                    loadedCallback.Invoke(mapModel);

                    SceneManager.LoadScene(map, new LoadSceneParameters {
                        loadSceneMode = LoadSceneMode.Additive,
                        localPhysicsMode = LocalPhysicsMode.None
                    });

                    return false;
                }

19 View Source File : Captcha.cs
License : MIT License
Project Creator : 1992w

public bool Validate(string captchaId, string code)
        {
            var val = _storage.Get(captchaId);
            var comparisonType = _options.CurrentValue.IgnoreCase ? StringComparison.CurrentCultureIgnoreCase : StringComparison.CurrentCulture;
            var result = string.Equals(val, code, comparisonType);
            if (result)
            {
                _storage.Remove(captchaId);
            }

            return result;
        }

19 View Source File : CircularBuffer.cs
License : MIT License
Project Creator : 1iveowl

public int IndexOf(T item)
        {
            for (var i = 0; i < Count; ++i)
                if (Equals(item, this[i]))
                    return i;
            return -1;
        }

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

[Fact]
        public void CompositedResolverAllowPrivateTest()
        {
            var val = new _PrivateMembersClreplaced().Init();
            var buf = BssomSerializer.Serialize(val, BssomSerializerOptions.DefaultAllowPrivate);
            var val2 = BssomSerializer.Deserialize<_PrivateMembersClreplaced>(buf, BssomSerializerOptions.DefaultAllowPrivate);
            val.Equals(val2).IsTrue();
        }

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

[Fact]
        public void Map1Deserialize_CompositedResolverAllowPrivateTest()
        {
            var val = new Dictionary<string, int>() {
                {"A1",1 },
                {"B1",2 },
                {"C1",3 },
                {"D1",4 },
                {"E1",5 },
            };
            var buf = BssomSerializer.Serialize(val);
            var val2 = BssomSerializer.Deserialize<_PrivateMembersClreplaced>(buf, BssomSerializerOptions.DefaultAllowPrivate);
            _PrivateMembersClreplaced.Create(1, 2, 3, 4, 5).Equals(val2).IsTrue();

        }

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

[Fact]
        public void ExpentdTypeTest()
        {
            var val = new _sub().Init();
            var buf = BssomSerializer.Serialize(val, BssomSerializerOptions.DefaultAllowPrivate);
            var val2 = BssomSerializer.Deserialize<_sub>(buf, BssomSerializerOptions.DefaultAllowPrivate);
            val.Equals(val2).IsTrue();

        }

19 View Source File : DataChangedBehavior.cs
License : MIT License
Project Creator : 1iveowl

private static bool Compare(object leftOperand, ComparisonCondition operatorType, object rightOperand)
        {
            if (leftOperand != null && rightOperand != null)
            {
                rightOperand = TypeConverterHelper.Convert(rightOperand.ToString(), leftOperand.GetType().FullName);
            }

            var leftComparableOperand = leftOperand as IComparable;
            var rightComparableOperand = rightOperand as IComparable;

            if ((leftComparableOperand != null) && (rightComparableOperand != null))
            {
                return EvaluateComparable(leftComparableOperand, operatorType, rightComparableOperand);
            }

            switch (operatorType)
            {
                case ComparisonCondition.Equal:
                    return object.Equals(leftOperand, rightOperand);
                case ComparisonCondition.NotEqual:
                    return !object.Equals(leftOperand, rightOperand);
                case ComparisonCondition.LessThan:
                case ComparisonCondition.LessThanOrEqual:
                case ComparisonCondition.GreaterThan:
                case ComparisonCondition.GreaterThanOrEqual:
                {
                    switch (leftComparableOperand)
                    {
                        case null when rightComparableOperand == null:
                            throw new ArgumentException("Invalid operands");
                        case null:
                            throw new ArgumentException("Invalid left operand");
                        default:
                            throw new ArgumentException("Invalid right operand");
                    }
                }
                default:
                    return false;
            }
        }

19 View Source File : AddServer5Form.cs
License : GNU General Public License v3.0
Project Creator : 2dust

private void SetHeaderType()
        {
            cmbHeaderType.Items.Clear();

            string network = cmbNetwork.Text;
            if (Utils.IsNullOrEmpty(network))
            {
                cmbHeaderType.Items.Add(Global.None);
                return;
            }

            if (network.Equals(Global.DefaultNetwork))
            {
                cmbHeaderType.Items.Add(Global.None);
                cmbHeaderType.Items.Add(Global.TcpHeaderHttp);
            }
            else if (network.Equals("kcp") || network.Equals("quic"))
            {
                cmbHeaderType.Items.Add(Global.None);
                cmbHeaderType.Items.Add("srtp");
                cmbHeaderType.Items.Add("utp");
                cmbHeaderType.Items.Add("wechat-video");
                cmbHeaderType.Items.Add("dtls");
                cmbHeaderType.Items.Add("wireguard");
            }
            else if (network.Equals("grpc"))
            {
                cmbHeaderType.Items.Add(Global.GrpcgunMode);
                cmbHeaderType.Items.Add(Global.GrpcmultiMode);
            }
            else
            {
                cmbHeaderType.Items.Add(Global.None);
            }
            cmbHeaderType.SelectedIndex = 0;
        }

19 View Source File : LAbstract.cs
License : MIT License
Project Creator : 3F

protected Projecreplacedem GetProjecreplacedem(string line, string solutionDir)
        {
            var pItem = new Projecreplacedem(line, solutionDir);

            if(pItem.pGuid == null) {
                LSender.Send(this, $"The Guid is null or empty for line :: '{line}'", Message.Level.Error);
                return default(Projecreplacedem);
            }

            if(String.Equals(Guids.SLN_FOLDER, pItem.pType, StringComparison.OrdinalIgnoreCase)) {
                LSender.Send(this, $"{pItem.name} has been ignored as solution-folder :: '{line}'", Message.Level.Debug);
                return default(Projecreplacedem);
            }

            return pItem;
        }

19 View Source File : LProjectSolutionItems.cs
License : MIT License
Project Creator : 3F

public override bool Positioned(ISvc svc, RawText line)
        {
            var pItem = new Projecreplacedem(line.trimmed, svc.Sln.SolutionDir);

            if(pItem.pGuid == null 
                || !String.Equals(Guids.SLN_FOLDER, pItem.pType, StringComparison.OrdinalIgnoreCase))
            {
                return false;
            }

            LSender.Send(this, $"Found solution-folder: '{pItem.name}'", Message.Level.Info);

            var folderItems = new List<RawText>();
            while((line = svc.ReadLine(this)) != null && (line != "EndProject"))
            {
                if(!line.trimmed.StartsWith("ProjectSection(SolutionItems) = preProject", StringComparison.Ordinal)) {
                    continue;
                }

                for(line = svc.ReadLine(this); line != null; line = svc.ReadLine(this))
                {
                    if(line.trimmed.StartsWith("EndProjectSection", StringComparison.Ordinal)) {
                        break;
                    }

                    var item = line.trimmed.Before('=');
                    if(item == null)
                    {
                        LSender.Send(
                            this, 
                            $"Ignored incorrect item for '{pItem.name}':{pItem.pGuid} - '{line}'", 
                            Message.Level.Warn
                        );
                        continue;
                    }

                    item = item.TrimEnd();
                    LSender.Send(this, $"Found item: '{item}'", Message.Level.Info);

                    folderItems.Add(new RawText(item, svc.CurrentEncoding));
                }
            }

            if(svc.Sln.SolutionFolderList == null) {
                svc.Sln.SolutionFolderList = new List<SolutionFolder>();
            }

            svc.Sln.SolutionFolderList.Add(new SolutionFolder(pItem, folderItems));
            return true;
        }

19 View Source File : ConfigItem.cs
License : MIT License
Project Creator : 3F

public bool IsEqualByRule(string config, string platform, bool icase = false)
        {
            var cmp = icase ? StringComparison.InvariantCultureIgnoreCase 
                            : StringComparison.InvariantCulture;

            return string.Equals(ConfigurationByRule, Rule?.Configuration(config), cmp)
                && string.Equals(PlatformByRule, Rule?.Platform(platform), cmp);
        }

19 View Source File : XProject.cs
License : MIT License
Project Creator : 3F

public IEnumerable<ImportElement> GetImports(string project, string label, bool eq = false)
        {
            var ret = GetImports();
            var cmp = StringComparison.InvariantCultureIgnoreCase;

            if(project != null) {
                if(eq) {
                    ret = ret.Where(i => project.Equals(i.project, cmp));
                }
                else {
                    ret = ret.Where(i => i.project != null && i.project.EndsWith(project, cmp));
                }
            }

            if(label != null) {
                ret = ret.Where(i => label.Equals(i.label, cmp));
            }

            return ret;
        }

19 View Source File : BasicList.cs
License : MIT License
Project Creator : 404Lcc

internal bool Contains(object value)
        {
            foreach (object obj in this)
            {
                if (object.Equals(obj, value)) return true;
            }
            return false;
        }

19 View Source File : DefaultValueDecorator.cs
License : MIT License
Project Creator : 404Lcc

public override void Write(object value, ProtoWriter dest)
        {
            if (!object.Equals(value, defaultValue))
            {
                Tail.Write(value, dest);
            }
        }

19 View Source File : EnumSerializer.cs
License : MIT License
Project Creator : 404Lcc

public void Write(object value, ProtoWriter dest)
        {
            if (map == null)
            {
                ProtoWriter.WriteInt32(EnumToWire(value), dest);
            }
            else
            {
                for (int i = 0; i < map.Length; i++)
                {
                    if (object.Equals(map[i].TypedValue, value))
                    {
                        ProtoWriter.WriteInt32(map[i].WireValue, dest);
                        return;
                    }
                }
                ProtoWriter.ThrowEnumException(dest, value);
            }
        }

19 View Source File : Maybe.cs
License : Apache License 2.0
Project Creator : 42skillz

public override bool Equals(object obj)
        {
            var other = obj as Maybe<T>;
            if (other == null)
                return false;
 
            return object.Equals(this.Item, other.Item);
        }

19 View Source File : DoubleClickButton.cs
License : MIT License
Project Creator : 404Lcc

public override void OnPointerDown(PointerEventData eventData)
        {
            base.OnPointerDown(eventData);
            if (_first.Equals(default))
            {
                _first = DateTime.Now;
            }
            else
            {
                _second = DateTime.Now;
            }
        }

19 View Source File : DoubleClickButton.cs
License : MIT License
Project Creator : 404Lcc

public override void OnPointerUp(PointerEventData eventData)
        {
            base.OnPointerUp(eventData);
            //在第二次鼠标抬起时触发,时差小于600ms
            if (!_first.Equals(default) && !_second.Equals(default))
            {
                TimeSpan time = _second - _first;
                float milliseconds = time.Seconds * 1000 + time.Milliseconds;
                if (milliseconds < 600)
                {
                    Press();
                }
                else
                {
                    ResetTime();
                }
            }
        }

19 View Source File : LongClickButton.cs
License : MIT License
Project Creator : 404Lcc

public override void OnPointerDown(PointerEventData eventData)
        {
            base.OnPointerDown(eventData);
            if (_first.Equals(default))
            {
                _first = DateTime.Now;
            }
        }

19 View Source File : LongClickButton.cs
License : MIT License
Project Creator : 404Lcc

public override void OnPointerUp(PointerEventData eventData)
        {
            base.OnPointerUp(eventData);
            //在鼠标抬起时触发,时差大于200ms
            if (!_first.Equals(default))
            {
                _second = DateTime.Now;
            }
            if (!_first.Equals(default) && !_second.Equals(default))
            {
                TimeSpan time = _second - _first;
                float milliseconds = time.Seconds * 1000 + time.Milliseconds;
                if (milliseconds > 200)
                {
                    Press();
                }
                else
                {
                    ResetTime();
                }
            }
        }

See More Examples