private void Deserialized(StreamingContext context) { if (string.IsNullOrEmpty(_Type)) ReturnType = new MagickType(CreatesInstance ? "voidInstance" : "void"); else ReturnType = new MagickType(CreatesInstance ? "Instance" : _Type); }
private string GetAction(string action, MagickType type) { if (type.IsString) return "UTF8Marshaler.NativeToManaged(" + action + ");"; else return type.ManagedTypeCast + action + ";"; }
private void Deserializated(StreamingContext context) { Type = new MagickType(_Type); }
private void WriteReturn(MagickType type) { if (type.IsVoid) return; if (IsDynamic(type)) WriteLine("return " + type.Managed + ".CreateInstance(result);"); else if (type.IsNativeString) WriteLine("return UTF8Marshaler.NativeToManagedAndRelinquish(result);"); else if (type.IsString) WriteLine("return UTF8Marshaler.NativeToManaged(result);"); else if (type.HasInstance) WriteLine("return " + type.Managed + ".Create(result);"); else WriteLine("return " + type.ManagedTypeCast + "result;"); }
private void WriteCreateStartOut(string name, MagickType type) { WriteLine("using (INativeInstance " + name + "Native = " + type.Managed + ".CreateInstance())"); WriteStartColon(); WriteLine("IntPtr " + name + "NativeOut = " + name + "Native.Instance;"); }
private void WriteCreateStart(string name, MagickType type) { Write("using (INativeInstance " + name + "Native = "); if (type.IsString) Write("UTF8Marshaler"); else Write(type.Managed); WriteLine(".CreateInstance(" + name + "))"); WriteStartColon(); }
private void WriteMarshal(MagickType type) { if (type.IsBool) WriteLine("[return: MarshalAs(UnmanagedType.Bool)]"); }
private void Deserializated(StreamingContext context) => Type = new MagickType(_type);
protected bool IsDynamic(MagickType type) { return(IsDynamic(type.Managed)); }
protected bool NeedsCreate(MagickType type) { if (type.IsString) return true; return IsDynamic(type.Managed); }
protected bool IsDynamic(MagickType type) { return IsDynamic(type.Managed); }