Merge remote-tracking branch 'remotes/origin/master' into release/1.2.9

This commit is contained in:
Robin 2016-05-24 13:13:48 +02:00
commit 0323705513
276 changed files with 5382 additions and 3666 deletions

View file

@ -43,12 +43,12 @@ namespace Greenshot.Interop {
/// <summary>
/// Type of the COM object, set on constructor after getting the COM reference
/// </summary>
private Type _COMType;
private readonly Type _COMType;
/// <summary>
/// The type of which method calls are intercepted and executed on the COM object.
/// </summary>
private Type _InterceptType;
private readonly Type _InterceptType;
#endregion
[DllImport("ole32.dll")]
@ -214,9 +214,9 @@ namespace Greenshot.Interop {
/// </param>
private COMWrapper(object comObject, Type type)
: base(type) {
this._COMObject = comObject;
this._COMType = comObject.GetType();
this._InterceptType = type;
_COMObject = comObject;
_COMType = comObject.GetType();
_InterceptType = type;
}
#endregion
@ -228,14 +228,14 @@ namespace Greenshot.Interop {
/// sure that the COM object is still cleaned up.
/// </summary>
~COMWrapper() {
this.Dispose(false);
Dispose(false);
}
/// <summary>
/// Cleans up the COM object.
/// </summary>
public void Dispose() {
this.Dispose(true);
Dispose(true);
GC.SuppressFinalize(this);
}
@ -247,17 +247,17 @@ namespace Greenshot.Interop {
/// <see cref="IDisposable"/> interface.
/// </param>
private void Dispose(bool disposing) {
if (disposing && null != this._COMObject) {
if (Marshal.IsComObject(this._COMObject)) {
if (disposing && null != _COMObject) {
if (Marshal.IsComObject(_COMObject)) {
try {
while (Marshal.ReleaseComObject(this._COMObject) > 0);
while (Marshal.ReleaseComObject(_COMObject) > 0);
} catch (Exception) {
//LOG.WarnFormat("Problem releasing {0}", _COMType);
//LOG.Warn("Error: ", ex);
}
}
this._COMObject = null;
_COMObject = null;
}
}
@ -272,7 +272,7 @@ namespace Greenshot.Interop {
/// The full name of the intercepted type.
/// </returns>
public override string ToString() {
return this._InterceptType.FullName;
return _InterceptType.FullName;
}
/// <summary>
@ -282,7 +282,7 @@ namespace Greenshot.Interop {
/// The hash code of the wrapped object.
/// </returns>
public override int GetHashCode() {
return this._COMObject.GetHashCode();
return _COMObject.GetHashCode();
}
/// <summary>
@ -298,7 +298,7 @@ namespace Greenshot.Interop {
if (null != value && RemotingServices.IsTransparentProxy(value)) {
COMWrapper wrapper = RemotingServices.GetRealProxy(value) as COMWrapper;
if (null != wrapper) {
return this._COMObject == wrapper._COMObject;
return _COMObject == wrapper._COMObject;
}
}
@ -469,15 +469,15 @@ namespace Greenshot.Interop {
ParameterInfo parameter;
if ("Dispose" == methodName && 0 == argCount && typeof(void) == returnType) {
this.Dispose();
Dispose();
} else if ("ToString" == methodName && 0 == argCount && typeof(string) == returnType) {
returnValue = this.ToString();
} else if ("GetType" == methodName && 0 == argCount && typeof(System.Type) == returnType) {
returnValue = this._InterceptType;
returnValue = ToString();
} else if ("GetType" == methodName && 0 == argCount && typeof(Type) == returnType) {
returnValue = _InterceptType;
} else if ("GetHashCode" == methodName && 0 == argCount && typeof(int) == returnType) {
returnValue = this.GetHashCode();
returnValue = GetHashCode();
} else if ("Equals" == methodName && 1 == argCount && typeof(bool) == returnType) {
returnValue = this.Equals(callMessage.Args[0]);
returnValue = Equals(callMessage.Args[0]);
} else if (1 == argCount && typeof(void) == returnType && (methodName.StartsWith("add_") || methodName.StartsWith("remove_"))) {
bool removeHandler = methodName.StartsWith("remove_");
methodName = methodName.Substring(removeHandler ? 7 : 4);
@ -487,8 +487,8 @@ namespace Greenshot.Interop {
return new ReturnMessage(new ArgumentNullException("handler"), callMessage);
}
} else {
invokeObject = this._COMObject;
invokeType = this._COMType;
invokeObject = _COMObject;
invokeType = _COMType;
if (methodName.StartsWith("get_")) {
// Property Get
@ -565,7 +565,7 @@ namespace Greenshot.Interop {
if (returnType.IsInterface) {
// Wrap the returned value in an intercepting COM wrapper
if (Marshal.IsComObject(returnValue)) {
returnValue = COMWrapper.Wrap(returnValue, returnType);
returnValue = Wrap(returnValue, returnType);
}
} else if (returnType.IsEnum) {
// Convert to proper Enum type