Simplified usages and removed unnecessary casts

This commit is contained in:
Joshua Askharoun
2021-02-21 22:59:09 -06:00
parent c920dff448
commit 91b30a963f
533 changed files with 6257 additions and 6257 deletions
+5 -5
View File
@@ -19,19 +19,19 @@ namespace Microsoft.Zune
IntPtr instanceHandle = IntPtr.Zero; IntPtr instanceHandle = IntPtr.Zero;
try try
{ {
instanceHandle = MemoryFonts.LoadLibraryEx(resourceDllName, IntPtr.Zero, 2U); instanceHandle = LoadLibraryEx(resourceDllName, IntPtr.Zero, 2U);
if (instanceHandle == IntPtr.Zero) if (instanceHandle == IntPtr.Zero)
return false; return false;
IntPtr resource = MemoryFonts.FindResource(instanceHandle, fontResourceName, (IntPtr)10); IntPtr resource = FindResource(instanceHandle, fontResourceName, (IntPtr)10);
if (resource == IntPtr.Zero) if (resource == IntPtr.Zero)
return false; return false;
IntPtr resourceHandle = MemoryFonts.LoadResource(instanceHandle, resource); IntPtr resourceHandle = LoadResource(instanceHandle, resource);
return !(resourceHandle == IntPtr.Zero) && !(MemoryFonts.AddFontMemResourceEx(MemoryFonts.LockResource(resourceHandle), MemoryFonts.SizeofResource(instanceHandle, resource), IntPtr.Zero, out uint _) == IntPtr.Zero); return !(resourceHandle == IntPtr.Zero) && !(AddFontMemResourceEx(LockResource(resourceHandle), SizeofResource(instanceHandle, resource), IntPtr.Zero, out uint _) == IntPtr.Zero);
} }
finally finally
{ {
if (instanceHandle != IntPtr.Zero) if (instanceHandle != IntPtr.Zero)
MemoryFonts.FreeLibrary(instanceHandle); FreeLibrary(instanceHandle);
} }
} }
+68 -68
View File
@@ -14,7 +14,7 @@ namespace Microsoft.Zune.PerfTrace
internal class EtwTraceProvider internal class EtwTraceProvider
{ {
private const ushort _version = 0; private const ushort _version = 0;
private EtwTraceProvider.EtwProc _etwProc; private EtwProc _etwProc;
private ulong _registrationHandle; private ulong _registrationHandle;
private ulong _traceHandle; private ulong _traceHandle;
private byte _level; private byte _level;
@@ -23,7 +23,7 @@ namespace Microsoft.Zune.PerfTrace
internal EtwTraceProvider(Guid controlGuid, string regPath) internal EtwTraceProvider(Guid controlGuid, string regPath)
{ {
this._level = (byte)0; this._level = 0;
this._flags = 0U; this._flags = 0U;
this._enabled = false; this._enabled = false;
this._traceHandle = 0UL; this._traceHandle = 0UL;
@@ -46,8 +46,8 @@ namespace Microsoft.Zune.PerfTrace
~EtwTraceProvider() ~EtwTraceProvider()
{ {
EtwTraceProvider.UnregisterTraceGuids(this._registrationHandle); UnregisterTraceGuids(this._registrationHandle);
GC.KeepAlive((object)this._etwProc); GC.KeepAlive(_etwProc);
} }
internal uint Flags => this._flags; internal uint Flags => this._flags;
@@ -64,24 +64,24 @@ namespace Microsoft.Zune.PerfTrace
{ {
try try
{ {
EtwTraceProvider.BaseEvent* baseEventPtr = (EtwTraceProvider.BaseEvent*)byteBuffer; BaseEvent* baseEventPtr = (BaseEvent*)byteBuffer;
switch (requestCode) switch (requestCode)
{ {
case 4: case 4:
this._traceHandle = baseEventPtr->HistoricalContext; this._traceHandle = baseEventPtr->HistoricalContext;
this._flags = (uint)EtwTraceProvider.GetTraceEnableFlags(baseEventPtr->HistoricalContext); this._flags = (uint)GetTraceEnableFlags(baseEventPtr->HistoricalContext);
this._level = EtwTraceProvider.GetTraceEnableLevel(baseEventPtr->HistoricalContext); this._level = GetTraceEnableLevel(baseEventPtr->HistoricalContext);
if (this._flags == 0U && this._level == (byte)0) if (this._flags == 0U && this._level == 0)
{ {
this._flags = uint.MaxValue; this._flags = uint.MaxValue;
this._level = (byte)4; this._level = 4;
} }
this._enabled = true; this._enabled = true;
break; break;
case 5: case 5:
this._enabled = false; this._enabled = false;
this._traceHandle = 0UL; this._traceHandle = 0UL;
this._level = (byte)0; this._level = 0;
this._flags = 0U; this._flags = 0U;
break; break;
default: default:
@@ -106,17 +106,17 @@ namespace Microsoft.Zune.PerfTrace
private unsafe uint Register(Guid controlGuid) private unsafe uint Register(Guid controlGuid)
{ {
EtwTraceProvider.TraceGuidRegistration guidReg = new EtwTraceProvider.TraceGuidRegistration(); TraceGuidRegistration guidReg = new TraceGuidRegistration();
Guid guid = new Guid(3029687280U, (ushort)15089, (ushort)18240, (byte)180, (byte)117, (byte)153, (byte)5, (byte)93, (byte)63, (byte)233, (byte)170); Guid guid = new Guid(3029687280U, 15089, 18240, 180, 117, 153, 5, 93, 63, 233, 170);
this._etwProc = new EtwTraceProvider.EtwProc(this.ControllerChangeCallback); this._etwProc = new EtwProc(this.ControllerChangeCallback);
guidReg.Guid = &guid; guidReg.Guid = &guid;
guidReg.RegHandle = (void*)null; guidReg.RegHandle = null;
return EtwTraceProvider.RegisterTraceGuids(this._etwProc, (void*)null, ref controlGuid, 1U, ref guidReg, (string)null, (string)null, out this._registrationHandle); return RegisterTraceGuids(this._etwProc, null, ref controlGuid, 1U, ref guidReg, null, null, out this._registrationHandle);
} }
internal void TraceEvent(byte level, Guid eventGuid, byte eventType) => this.TraceEvent(level, eventGuid, eventType, (object)null, (object)null); internal void TraceEvent(byte level, Guid eventGuid, byte eventType) => this.TraceEvent(level, eventGuid, eventType, null, null);
internal void TraceEvent(byte level, Guid eventGuid, byte eventType, object data0) => this.TraceEvent(level, eventGuid, eventType, data0, (object)null); internal void TraceEvent(byte level, Guid eventGuid, byte eventType, object data0) => this.TraceEvent(level, eventGuid, eventType, data0, null);
internal void TraceEvent( internal void TraceEvent(
byte level, byte level,
@@ -125,7 +125,7 @@ namespace Microsoft.Zune.PerfTrace
object data0, object data0,
object data1) object data1)
{ {
int num = (int)this.TraceEvent(level, eventGuid, eventType, data0, data1, (object)null, (object)null, (object)null, (object)null, (object)null, (object)null, (object)null); int num = (int)this.TraceEvent(level, eventGuid, eventType, data0, data1, null, null, null, null, null, null, null);
} }
internal void TraceEvent( internal void TraceEvent(
@@ -136,7 +136,7 @@ namespace Microsoft.Zune.PerfTrace
object data1, object data1,
object data2) object data2)
{ {
int num = (int)this.TraceEvent(level, eventGuid, eventType, data0, data1, data2, (object)null, (object)null, (object)null, (object)null, (object)null, (object)null); int num = (int)this.TraceEvent(level, eventGuid, eventType, data0, data1, data2, null, null, null, null, null, null);
} }
internal void TraceEvent( internal void TraceEvent(
@@ -148,7 +148,7 @@ namespace Microsoft.Zune.PerfTrace
object data2, object data2,
object data3) object data3)
{ {
int num = (int)this.TraceEvent(level, eventGuid, eventType, data0, data1, data2, data3, (object)null, (object)null, (object)null, (object)null, (object)null); int num = (int)this.TraceEvent(level, eventGuid, eventType, data0, data1, data2, data3, null, null, null, null, null);
} }
internal void TraceEvent( internal void TraceEvent(
@@ -161,7 +161,7 @@ namespace Microsoft.Zune.PerfTrace
object data3, object data3,
object data4) object data4)
{ {
int num = (int)this.TraceEvent(level, eventGuid, eventType, data0, data1, data2, data3, data4, (object)null, (object)null, (object)null, (object)null); int num = (int)this.TraceEvent(level, eventGuid, eventType, data0, data1, data2, data3, data4, null, null, null, null);
} }
internal void TraceEvent( internal void TraceEvent(
@@ -175,7 +175,7 @@ namespace Microsoft.Zune.PerfTrace
object data4, object data4,
object data5) object data5)
{ {
int num = (int)this.TraceEvent(level, eventGuid, eventType, data0, data1, data2, data3, data4, data5, (object)null, (object)null, (object)null); int num = (int)this.TraceEvent(level, eventGuid, eventType, data0, data1, data2, data3, data4, data5, null, null, null);
} }
internal void TraceEvent( internal void TraceEvent(
@@ -190,7 +190,7 @@ namespace Microsoft.Zune.PerfTrace
object data5, object data5,
object data6) object data6)
{ {
int num = (int)this.TraceEvent(level, eventGuid, eventType, data0, data1, data2, data3, data4, data5, data6, (object)null, (object)null); int num = (int)this.TraceEvent(level, eventGuid, eventType, data0, data1, data2, data3, data4, data5, data6, null, null);
} }
internal void TraceEvent( internal void TraceEvent(
@@ -206,7 +206,7 @@ namespace Microsoft.Zune.PerfTrace
object data6, object data6,
object data7) object data7)
{ {
int num = (int)this.TraceEvent(level, eventGuid, eventType, data0, data1, data2, data3, data4, data5, data6, data7, (object)null); int num = (int)this.TraceEvent(level, eventGuid, eventType, data0, data1, data2, data3, data4, data5, data6, data7, null);
} }
internal unsafe uint TraceEvent( internal unsafe uint TraceEvent(
@@ -239,24 +239,24 @@ namespace Microsoft.Zune.PerfTrace
string str8 = str1; string str8 = str1;
string str9 = str1; string str9 = str1;
string str10 = str1; string str10 = str1;
EtwTraceProvider.BaseEvent baseEvent; BaseEvent baseEvent;
baseEvent.ClientContext = 0U; baseEvent.ClientContext = 0U;
baseEvent.Flags = 1179648U; baseEvent.Flags = 1179648U;
baseEvent.Guid = eventGuid; baseEvent.Guid = eventGuid;
baseEvent.EventType = evtype; baseEvent.EventType = evtype;
baseEvent.Level = level; baseEvent.Level = level;
baseEvent.Version = (ushort)0; baseEvent.Version = 0;
if (data0 != null) if (data0 != null)
{ {
++num2; ++num2;
EtwTraceProvider.MofField* mofField = (EtwTraceProvider.MofField*)( & baseEvent.UserData + num3++ * sizeof(EtwTraceProvider.MofField)); MofField* mofField = &baseEvent.UserData + num3++ * sizeof(MofField);
if ((str10 = this.ProcessOneObject(data0, mofField, ptr, ref offSet)) != null) if ((str10 = this.ProcessOneObject(data0, mofField, ptr, ref offSet)) != null)
num1 |= 1; num1 |= 1;
} }
if (data1 != null) if (data1 != null)
{ {
++num2; ++num2;
EtwTraceProvider.MofField* mofField = (EtwTraceProvider.MofField*)( & baseEvent.UserData + num3++ * sizeof(EtwTraceProvider.MofField)); MofField* mofField = &baseEvent.UserData + num3++ * sizeof(MofField);
ptr = chPtr1 + offSet; ptr = chPtr1 + offSet;
if ((str9 = this.ProcessOneObject(data1, mofField, ptr, ref offSet)) != null) if ((str9 = this.ProcessOneObject(data1, mofField, ptr, ref offSet)) != null)
num1 |= 2; num1 |= 2;
@@ -264,7 +264,7 @@ namespace Microsoft.Zune.PerfTrace
if (data2 != null) if (data2 != null)
{ {
++num2; ++num2;
EtwTraceProvider.MofField* mofField = (EtwTraceProvider.MofField*)( & baseEvent.UserData + num3++ * sizeof(EtwTraceProvider.MofField)); MofField* mofField = &baseEvent.UserData + num3++ * sizeof(MofField);
ptr = chPtr1 + offSet; ptr = chPtr1 + offSet;
if ((str8 = this.ProcessOneObject(data2, mofField, ptr, ref offSet)) != null) if ((str8 = this.ProcessOneObject(data2, mofField, ptr, ref offSet)) != null)
num1 |= 4; num1 |= 4;
@@ -272,7 +272,7 @@ namespace Microsoft.Zune.PerfTrace
if (data3 != null) if (data3 != null)
{ {
++num2; ++num2;
EtwTraceProvider.MofField* mofField = (EtwTraceProvider.MofField*)( & baseEvent.UserData + num3++ * sizeof(EtwTraceProvider.MofField)); MofField* mofField = &baseEvent.UserData + num3++ * sizeof(MofField);
ptr = chPtr1 + offSet; ptr = chPtr1 + offSet;
if ((str7 = this.ProcessOneObject(data3, mofField, ptr, ref offSet)) != null) if ((str7 = this.ProcessOneObject(data3, mofField, ptr, ref offSet)) != null)
num1 |= 8; num1 |= 8;
@@ -280,7 +280,7 @@ namespace Microsoft.Zune.PerfTrace
if (data4 != null) if (data4 != null)
{ {
++num2; ++num2;
EtwTraceProvider.MofField* mofField = (EtwTraceProvider.MofField*)( & baseEvent.UserData + num3++ * sizeof(EtwTraceProvider.MofField)); MofField* mofField = &baseEvent.UserData + num3++ * sizeof(MofField);
ptr = chPtr1 + offSet; ptr = chPtr1 + offSet;
if ((str6 = this.ProcessOneObject(data4, mofField, ptr, ref offSet)) != null) if ((str6 = this.ProcessOneObject(data4, mofField, ptr, ref offSet)) != null)
num1 |= 16; num1 |= 16;
@@ -288,7 +288,7 @@ namespace Microsoft.Zune.PerfTrace
if (data5 != null) if (data5 != null)
{ {
++num2; ++num2;
EtwTraceProvider.MofField* mofField = (EtwTraceProvider.MofField*)( & baseEvent.UserData + num3++ * sizeof(EtwTraceProvider.MofField)); MofField* mofField = &baseEvent.UserData + num3++ * sizeof(MofField);
ptr = chPtr1 + offSet; ptr = chPtr1 + offSet;
if ((str5 = this.ProcessOneObject(data5, mofField, ptr, ref offSet)) != null) if ((str5 = this.ProcessOneObject(data5, mofField, ptr, ref offSet)) != null)
num1 |= 32; num1 |= 32;
@@ -296,7 +296,7 @@ namespace Microsoft.Zune.PerfTrace
if (data6 != null) if (data6 != null)
{ {
++num2; ++num2;
EtwTraceProvider.MofField* mofField = (EtwTraceProvider.MofField*)( & baseEvent.UserData + num3++ * sizeof(EtwTraceProvider.MofField)); MofField* mofField = &baseEvent.UserData + num3++ * sizeof(MofField);
ptr = chPtr1 + offSet; ptr = chPtr1 + offSet;
if ((str4 = this.ProcessOneObject(data6, mofField, ptr, ref offSet)) != null) if ((str4 = this.ProcessOneObject(data6, mofField, ptr, ref offSet)) != null)
num1 |= 64; num1 |= 64;
@@ -304,7 +304,7 @@ namespace Microsoft.Zune.PerfTrace
if (data7 != null) if (data7 != null)
{ {
++num2; ++num2;
EtwTraceProvider.MofField* mofField = (EtwTraceProvider.MofField*)( & baseEvent.UserData + num3++ * sizeof(EtwTraceProvider.MofField)); MofField* mofField = &baseEvent.UserData + num3++ * sizeof(MofField);
ptr = chPtr1 + offSet; ptr = chPtr1 + offSet;
if ((str3 = this.ProcessOneObject(data7, mofField, ptr, ref offSet)) != null) if ((str3 = this.ProcessOneObject(data7, mofField, ptr, ref offSet)) != null)
num1 |= 128; num1 |= 128;
@@ -312,7 +312,7 @@ namespace Microsoft.Zune.PerfTrace
if (data8 != null) if (data8 != null)
{ {
uint num4 = num2 + 1U; uint num4 = num2 + 1U;
EtwTraceProvider.MofField* mofField = (EtwTraceProvider.MofField*)( & baseEvent.UserData + num3++ * sizeof(EtwTraceProvider.MofField)); MofField* mofField = &baseEvent.UserData + num3++ * sizeof(MofField);
ptr = chPtr1 + offSet; ptr = chPtr1 + offSet;
if ((str2 = this.ProcessOneObject(data8, mofField, ptr, ref offSet)) != null) if ((str2 = this.ProcessOneObject(data8, mofField, ptr, ref offSet)) != null)
num1 |= 256; num1 |= 256;
@@ -334,65 +334,65 @@ namespace Microsoft.Zune.PerfTrace
if ((num1 & 1) != 0) if ((num1 & 1) != 0)
{ {
(&baseEvent.UserData)[index1].DataLength = (uint)((str10.Length + 1) * 2); (&baseEvent.UserData)[index1].DataLength = (uint)((str10.Length + 1) * 2);
(&baseEvent.UserData)[index1].DataPointer = (void*)chPtr2; (&baseEvent.UserData)[index1].DataPointer = chPtr2;
} }
int index2 = index1 + 1; int index2 = index1 + 1;
if ((num1 & 2) != 0) if ((num1 & 2) != 0)
{ {
(&baseEvent.UserData)[index2].DataLength = (uint)((str9.Length + 1) * 2); (&baseEvent.UserData)[index2].DataLength = (uint)((str9.Length + 1) * 2);
(&baseEvent.UserData)[index2].DataPointer = (void*)chPtr3; (&baseEvent.UserData)[index2].DataPointer = chPtr3;
} }
int index3 = index2 + 1; int index3 = index2 + 1;
if ((num1 & 4) != 0) if ((num1 & 4) != 0)
{ {
(&baseEvent.UserData)[index3].DataLength = (uint)((str8.Length + 1) * 2); (&baseEvent.UserData)[index3].DataLength = (uint)((str8.Length + 1) * 2);
(&baseEvent.UserData)[index3].DataPointer = (void*)chPtr4; (&baseEvent.UserData)[index3].DataPointer = chPtr4;
} }
int index4 = index3 + 1; int index4 = index3 + 1;
if ((num1 & 8) != 0) if ((num1 & 8) != 0)
{ {
(&baseEvent.UserData)[index4].DataLength = (uint)((str7.Length + 1) * 2); (&baseEvent.UserData)[index4].DataLength = (uint)((str7.Length + 1) * 2);
(&baseEvent.UserData)[index4].DataPointer = (void*)chPtr5; (&baseEvent.UserData)[index4].DataPointer = chPtr5;
} }
int index5 = index4 + 1; int index5 = index4 + 1;
if ((num1 & 16) != 0) if ((num1 & 16) != 0)
{ {
(&baseEvent.UserData)[index5].DataLength = (uint)((str6.Length + 1) * 2); (&baseEvent.UserData)[index5].DataLength = (uint)((str6.Length + 1) * 2);
(&baseEvent.UserData)[index5].DataPointer = (void*)chPtr6; (&baseEvent.UserData)[index5].DataPointer = chPtr6;
} }
int index6 = index5 + 1; int index6 = index5 + 1;
if ((num1 & 32) != 0) if ((num1 & 32) != 0)
{ {
(&baseEvent.UserData)[index6].DataLength = (uint)((str5.Length + 1) * 2); (&baseEvent.UserData)[index6].DataLength = (uint)((str5.Length + 1) * 2);
(&baseEvent.UserData)[index6].DataPointer = (void*)chPtr7; (&baseEvent.UserData)[index6].DataPointer = chPtr7;
} }
int index7 = index6 + 1; int index7 = index6 + 1;
if ((num1 & 64) != 0) if ((num1 & 64) != 0)
{ {
(&baseEvent.UserData)[index7].DataLength = (uint)((str4.Length + 1) * 2); (&baseEvent.UserData)[index7].DataLength = (uint)((str4.Length + 1) * 2);
(&baseEvent.UserData)[index7].DataPointer = (void*)chPtr8; (&baseEvent.UserData)[index7].DataPointer = chPtr8;
} }
int index8 = index7 + 1; int index8 = index7 + 1;
if ((num1 & 128) != 0) if ((num1 & 128) != 0)
{ {
(&baseEvent.UserData)[index8].DataLength = (uint)((str3.Length + 1) * 2); (&baseEvent.UserData)[index8].DataLength = (uint)((str3.Length + 1) * 2);
(&baseEvent.UserData)[index8].DataPointer = (void*)chPtr9; (&baseEvent.UserData)[index8].DataPointer = chPtr9;
} }
int index9 = index8 + 1; int index9 = index8 + 1;
if ((num1 & 256) != 0) if ((num1 & 256) != 0)
{ {
(&baseEvent.UserData)[index9].DataLength = (uint)((str2.Length + 1) * 2); (&baseEvent.UserData)[index9].DataLength = (uint)((str2.Length + 1) * 2);
(&baseEvent.UserData)[index9].DataPointer = (void*)chPtr10; (&baseEvent.UserData)[index9].DataPointer = chPtr10;
} }
baseEvent.BufferSize = (uint)(48 + num3 * sizeof(EtwTraceProvider.MofField)); baseEvent.BufferSize = (uint)(48 + num3 * sizeof(MofField));
num5 = EtwTraceProvider.TraceEvent(this._traceHandle, (char*)&baseEvent); num5 = TraceEvent(this._traceHandle, (char*)&baseEvent);
} }
return num5; return num5;
} }
private unsafe string ProcessOneObject( private unsafe string ProcessOneObject(
object data, object data,
EtwTraceProvider.MofField* mofField, MofField* mofField,
char* ptr, char* ptr,
ref uint offSet) ref uint offSet)
{ {
@@ -401,116 +401,116 @@ namespace Microsoft.Zune.PerfTrace
private unsafe string EncodeObject( private unsafe string EncodeObject(
object data, object data,
EtwTraceProvider.MofField* mofField, MofField* mofField,
char* ptr, char* ptr,
ref uint offSet) ref uint offSet)
{ {
if (data == null) if (data == null)
{ {
mofField->DataLength = 0U; mofField->DataLength = 0U;
mofField->DataPointer = (void*)null; mofField->DataPointer = null;
return (string)null; return null;
} }
Type type = data.GetType(); Type type = data.GetType();
if (type.IsEnum) if (type.IsEnum)
data = Convert.ChangeType(data, Enum.GetUnderlyingType(type), (IFormatProvider)CultureInfo.InvariantCulture); data = Convert.ChangeType(data, Enum.GetUnderlyingType(type), CultureInfo.InvariantCulture);
switch (data) switch (data)
{ {
case sbyte num: case sbyte num:
mofField->DataLength = 1U; mofField->DataLength = 1U;
sbyte* numPtr1 = (sbyte*)ptr; sbyte* numPtr1 = (sbyte*)ptr;
*numPtr1 = num; *numPtr1 = num;
mofField->DataPointer = (void*)numPtr1; mofField->DataPointer = numPtr1;
++offSet; ++offSet;
break; break;
case byte num: case byte num:
mofField->DataLength = 1U; mofField->DataLength = 1U;
byte* numPtr2 = (byte*)ptr; byte* numPtr2 = (byte*)ptr;
*numPtr2 = num; *numPtr2 = num;
mofField->DataPointer = (void*)numPtr2; mofField->DataPointer = numPtr2;
++offSet; ++offSet;
break; break;
case short num: case short num:
mofField->DataLength = 2U; mofField->DataLength = 2U;
short* numPtr3 = (short*)ptr; short* numPtr3 = (short*)ptr;
*numPtr3 = num; *numPtr3 = num;
mofField->DataPointer = (void*)numPtr3; mofField->DataPointer = numPtr3;
offSet += 2U; offSet += 2U;
break; break;
case ushort num: case ushort num:
mofField->DataLength = 2U; mofField->DataLength = 2U;
ushort* numPtr4 = (ushort*)ptr; ushort* numPtr4 = (ushort*)ptr;
*numPtr4 = num; *numPtr4 = num;
mofField->DataPointer = (void*)numPtr4; mofField->DataPointer = numPtr4;
offSet += 2U; offSet += 2U;
break; break;
case int num: case int num:
mofField->DataLength = 4U; mofField->DataLength = 4U;
int* numPtr5 = (int*)ptr; int* numPtr5 = (int*)ptr;
*numPtr5 = num; *numPtr5 = num;
mofField->DataPointer = (void*)numPtr5; mofField->DataPointer = numPtr5;
offSet += 4U; offSet += 4U;
break; break;
case uint num: case uint num:
mofField->DataLength = 4U; mofField->DataLength = 4U;
uint* numPtr6 = (uint*)ptr; uint* numPtr6 = (uint*)ptr;
*numPtr6 = num; *numPtr6 = num;
mofField->DataPointer = (void*)numPtr6; mofField->DataPointer = numPtr6;
offSet += 4U; offSet += 4U;
break; break;
case long num: case long num:
mofField->DataLength = 8U; mofField->DataLength = 8U;
long* numPtr7 = (long*)ptr; long* numPtr7 = (long*)ptr;
*numPtr7 = num; *numPtr7 = num;
mofField->DataPointer = (void*)numPtr7; mofField->DataPointer = numPtr7;
offSet += 8U; offSet += 8U;
break; break;
case ulong num: case ulong num:
mofField->DataLength = 8U; mofField->DataLength = 8U;
ulong* numPtr8 = (ulong*)ptr; ulong* numPtr8 = (ulong*)ptr;
*numPtr8 = num; *numPtr8 = num;
mofField->DataPointer = (void*)numPtr8; mofField->DataPointer = numPtr8;
offSet += 8U; offSet += 8U;
break; break;
case char ch: case char ch:
mofField->DataLength = 2U; mofField->DataLength = 2U;
char* chPtr = ptr; char* chPtr = ptr;
*chPtr = ch; *chPtr = ch;
mofField->DataPointer = (void*)chPtr; mofField->DataPointer = chPtr;
offSet += 2U; offSet += 2U;
break; break;
case float num: case float num:
mofField->DataLength = 4U; mofField->DataLength = 4U;
float* numPtr9 = (float*)ptr; float* numPtr9 = (float*)ptr;
*numPtr9 = num; *numPtr9 = num;
mofField->DataPointer = (void*)numPtr9; mofField->DataPointer = numPtr9;
offSet += 4U; offSet += 4U;
break; break;
case double num: case double num:
mofField->DataLength = 8U; mofField->DataLength = 8U;
double* numPtr10 = (double*)ptr; double* numPtr10 = (double*)ptr;
*numPtr10 = num; *numPtr10 = num;
mofField->DataPointer = (void*)numPtr10; mofField->DataPointer = numPtr10;
offSet += 8U; offSet += 8U;
break; break;
case bool flag: case bool flag:
mofField->DataLength = 1U; mofField->DataLength = 1U;
bool* flagPtr = (bool*)ptr; bool* flagPtr = (bool*)ptr;
*flagPtr = flag; *flagPtr = flag;
mofField->DataPointer = (void*)flagPtr; mofField->DataPointer = flagPtr;
++offSet; ++offSet;
break; break;
case Decimal num: case Decimal num:
mofField->DataLength = 16U; mofField->DataLength = 16U;
Decimal* numPtr11 = (Decimal*)ptr; Decimal* numPtr11 = (Decimal*)ptr;
*numPtr11 = num; *numPtr11 = num;
mofField->DataPointer = (void*)numPtr11; mofField->DataPointer = numPtr11;
offSet += 16U; offSet += 16U;
break; break;
default: default:
return data.ToString(); return data.ToString();
} }
return (string)null; return null;
} }
[DllImport("advapi32", CharSet = CharSet.Unicode)] [DllImport("advapi32", CharSet = CharSet.Unicode)]
@@ -521,11 +521,11 @@ namespace Microsoft.Zune.PerfTrace
[DllImport("advapi32", EntryPoint = "RegisterTraceGuidsW", CharSet = CharSet.Unicode)] [DllImport("advapi32", EntryPoint = "RegisterTraceGuidsW", CharSet = CharSet.Unicode)]
internal static extern unsafe uint RegisterTraceGuids( internal static extern unsafe uint RegisterTraceGuids(
[In] EtwTraceProvider.EtwProc cbFunc, [In] EtwProc cbFunc,
[In] void* context, [In] void* context,
[In] ref Guid controlGuid, [In] ref Guid controlGuid,
[In] uint guidCount, [In] uint guidCount,
ref EtwTraceProvider.TraceGuidRegistration guidReg, ref TraceGuidRegistration guidReg,
[In] string mofImagePath, [In] string mofImagePath,
[In] string mofResourceName, [In] string mofResourceName,
out ulong regHandle); out ulong regHandle);
@@ -587,7 +587,7 @@ namespace Microsoft.Zune.PerfTrace
[FieldOffset(44)] [FieldOffset(44)]
internal uint Flags; internal uint Flags;
[FieldOffset(48)] [FieldOffset(48)]
internal EtwTraceProvider.MofField UserData; internal MofField UserData;
} }
internal unsafe delegate uint EtwProc( internal unsafe delegate uint EtwProc(
+15 -15
View File
@@ -11,43 +11,43 @@ namespace Microsoft.Zune.PerfTrace
public sealed class PerfTrace public sealed class PerfTrace
{ {
private static readonly EtwTraceProvider _EventProvider; private static readonly EtwTraceProvider _EventProvider;
internal static readonly Guid ZUNE_ETW_CONTROL_GUID = new Guid(1496399467U, (ushort)53017, (ushort)20072, (byte)142, (byte)243, (byte)135, (byte)107, (byte)12, (byte)8, (byte)232, (byte)1); internal static readonly Guid ZUNE_ETW_CONTROL_GUID = new Guid(1496399467U, 53017, 20072, 142, 243, 135, 107, 12, 8, 232, 1);
internal static readonly Guid PERFTRACE_LAUNCHEVENT_GUID = new Guid(1815200785, (short)23272, (short)18087, (byte)190, (byte)166, (byte)76, (byte)236, (byte)117, (byte)51, (byte)196, (byte)218); internal static readonly Guid PERFTRACE_LAUNCHEVENT_GUID = new Guid(1815200785, 23272, 18087, 190, 166, 76, 236, 117, 51, 196, 218);
internal static readonly Guid PerftraceUICollectionGuid = new Guid(235915657U, (ushort)37778, (ushort)18043, (byte)146, (byte)252, (byte)128, (byte)212, (byte)193, (byte)153, (byte)154, (byte)151); internal static readonly Guid PerftraceUICollectionGuid = new Guid(235915657U, 37778, 18043, 146, 252, 128, 212, 193, 153, 154, 151);
private PerfTrace() private PerfTrace()
{ {
} }
static PerfTrace() => Microsoft.Zune.PerfTrace.PerfTrace._EventProvider = new EtwTraceProvider(Microsoft.Zune.PerfTrace.PerfTrace.ZUNE_ETW_CONTROL_GUID, "SOFTWARE\\Microsoft\\Zune"); static PerfTrace() => _EventProvider = new EtwTraceProvider(ZUNE_ETW_CONTROL_GUID, "SOFTWARE\\Microsoft\\Zune");
internal static bool IsEnabled( internal static bool IsEnabled(
EtwTraceProvider provider, EtwTraceProvider provider,
Microsoft.Zune.PerfTrace.PerfTrace.Flags flag, Flags flag,
Microsoft.Zune.PerfTrace.PerfTrace.Level level) Level level)
{ {
return (uint)level <= (uint)provider.Level && provider.IsEnabled && (flag & (Microsoft.Zune.PerfTrace.PerfTrace.Flags)provider.Flags) > ~Microsoft.Zune.PerfTrace.PerfTrace.Flags.All; return (uint)level <= provider.Level && provider.IsEnabled && (flag & (Flags)provider.Flags) > ~Flags.All;
} }
internal static bool IsEnabled(Microsoft.Zune.PerfTrace.PerfTrace.Flags flags, Microsoft.Zune.PerfTrace.PerfTrace.Level level) => Microsoft.Zune.PerfTrace.PerfTrace.IsEnabled(Microsoft.Zune.PerfTrace.PerfTrace._EventProvider, flags, level); internal static bool IsEnabled(Flags flags, Level level) => IsEnabled(_EventProvider, flags, level);
internal static bool IsEnabled(Microsoft.Zune.PerfTrace.PerfTrace.Flags flags) => Microsoft.Zune.PerfTrace.PerfTrace.IsEnabled(Microsoft.Zune.PerfTrace.PerfTrace._EventProvider, flags, Microsoft.Zune.PerfTrace.PerfTrace.Level.Normal); internal static bool IsEnabled(Flags flags) => IsEnabled(_EventProvider, flags, Level.Normal);
public static void PERFTRACE_LAUNCHEVENT(Microsoft.Zune.PerfTrace.PerfTrace.LAUNCH_EVENT launchEvent, uint data) public static void PERFTRACE_LAUNCHEVENT(LAUNCH_EVENT launchEvent, uint data)
{ {
if (!Microsoft.Zune.PerfTrace.PerfTrace.IsEnabled(Microsoft.Zune.PerfTrace.PerfTrace.Flags.Launch, Microsoft.Zune.PerfTrace.PerfTrace.Level.Normal)) if (!IsEnabled(Flags.Launch, Level.Normal))
return; return;
Microsoft.Zune.PerfTrace.PerfTrace._EventProvider.TraceEvent((byte)4, Microsoft.Zune.PerfTrace.PerfTrace.PERFTRACE_LAUNCHEVENT_GUID, (byte)launchEvent, (object)data); _EventProvider.TraceEvent(4, PERFTRACE_LAUNCHEVENT_GUID, (byte)launchEvent, data);
} }
public static void TraceUICollectionEvent(UICollectionEvent traceEvent, string eventDetail) public static void TraceUICollectionEvent(UICollectionEvent traceEvent, string eventDetail)
{ {
if (!Microsoft.Zune.PerfTrace.PerfTrace.IsEnabled(Microsoft.Zune.PerfTrace.PerfTrace.Flags.Collection, Microsoft.Zune.PerfTrace.PerfTrace.Level.Normal)) if (!IsEnabled(Flags.Collection, Level.Normal))
return; return;
Microsoft.Zune.PerfTrace.PerfTrace._EventProvider.TraceEvent((byte)4, Microsoft.Zune.PerfTrace.PerfTrace.PerftraceUICollectionGuid, (byte)traceEvent, (object)eventDetail); _EventProvider.TraceEvent(4, PerftraceUICollectionGuid, (byte)traceEvent, eventDetail);
} }
[System.Flags] [Flags]
internal enum Flags : uint internal enum Flags : uint
{ {
DB_Mutex = 1, DB_Mutex = 1,
@@ -15,12 +15,12 @@ namespace Microsoft.Zune.Shell
{ {
private List<DataProviderQuery> _currentQueries = new List<DataProviderQuery>(); private List<DataProviderQuery> _currentQueries = new List<DataProviderQuery>();
internal static void Register() => Application.RegisterDataProvider("Aggregate", new DataProviderQueryFactory(AggregateDataProviderQuery.ConstructAggregateDataProviderQuery)); internal static void Register() => Application.RegisterDataProvider("Aggregate", new DataProviderQueryFactory(ConstructAggregateDataProviderQuery));
internal static DataProviderQuery ConstructAggregateDataProviderQuery( internal static DataProviderQuery ConstructAggregateDataProviderQuery(
object queryTypeCookie) object queryTypeCookie)
{ {
return (DataProviderQuery)new AggregateDataProviderQuery(queryTypeCookie); return new AggregateDataProviderQuery(queryTypeCookie);
} }
protected AggregateDataProviderQuery(object queryTypeCookie) protected AggregateDataProviderQuery(object queryTypeCookie)
@@ -36,12 +36,12 @@ namespace Microsoft.Zune.Shell
private void InitializeCurrentQueries() private void InitializeCurrentQueries()
{ {
this.Result = (object)null; this.Result = null;
this.UnsubscribeFromCurrentQueries(); this.UnsubscribeFromCurrentQueries();
this._currentQueries.Clear(); this._currentQueries.Clear();
if (this.GetProperty("Queries") is IList property) if (this.GetProperty("Queries") is IList property)
{ {
foreach (object obj in (IEnumerable)property) foreach (object obj in property)
{ {
if (obj is DataProviderQuery dataProviderQuery) if (obj is DataProviderQuery dataProviderQuery)
this._currentQueries.Add(dataProviderQuery); this._currentQueries.Add(dataProviderQuery);
@@ -94,7 +94,7 @@ namespace Microsoft.Zune.Shell
ArrayList arrayList = new ArrayList(); ArrayList arrayList = new ArrayList();
foreach (DataProviderQuery currentQuery in this._currentQueries) foreach (DataProviderQuery currentQuery in this._currentQueries)
arrayList.Add(currentQuery.Result); arrayList.Add(currentQuery.Result);
this.Result = (object)arrayList; this.Result = arrayList;
this.Status = flag ? DataProviderQueryStatus.Error : DataProviderQueryStatus.Complete; this.Status = flag ? DataProviderQueryStatus.Error : DataProviderQueryStatus.Complete;
} }
else else
+1 -1
View File
@@ -30,7 +30,7 @@ namespace Microsoft.Zune.Shell
{ {
if (string.IsNullOrEmpty(arArg)) if (string.IsNullOrEmpty(arArg))
throw new ArgumentException(nameof(arArgs)); throw new ArgumentException(nameof(arArgs));
string str = (string)null; string str = null;
string name; string name;
if (arArg[0] == '-' || arArg[0] == '/') if (arArg[0] == '-' || arArg[0] == '/')
name = arArg.Substring(1, arArg.Length - 1); name = arArg.Substring(1, arArg.Length - 1);
@@ -25,7 +25,7 @@ namespace Microsoft.Zune.Shell
{ {
int dueTime = 30000; int dueTime = 30000;
this._onCompleteHandler = onCompleteHandler; this._onCompleteHandler = onCompleteHandler;
this._failsafeTimer = new System.Threading.Timer(new TimerCallback(this.FailsafeCallback), (object)null, dueTime, -1); this._failsafeTimer = new System.Threading.Timer(new TimerCallback(this.FailsafeCallback), null, dueTime, -1);
} }
} }
+6 -6
View File
@@ -15,20 +15,20 @@ namespace Microsoft.Zune.Shell
[ComDefaultInterface(typeof(ILaunchZuneShell))] [ComDefaultInterface(typeof(ILaunchZuneShell))]
public sealed class LaunchZuneShell : ILaunchZuneShell public sealed class LaunchZuneShell : ILaunchZuneShell
{ {
private static LaunchZuneShell.LaunchDelegate s_launch; private static LaunchDelegate s_launch;
private static string s_args; private static string s_args;
private static IntPtr s_hWndSplashScreen; private static IntPtr s_hWndSplashScreen;
[STAThread] [STAThread]
public IntPtr GetLaunchDelegate(string args, IntPtr hWndSplashScreen) public IntPtr GetLaunchDelegate(string args, IntPtr hWndSplashScreen)
{ {
LaunchZuneShell.s_args = args; s_args = args;
LaunchZuneShell.s_hWndSplashScreen = hWndSplashScreen; s_hWndSplashScreen = hWndSplashScreen;
LaunchZuneShell.s_launch = new LaunchZuneShell.LaunchDelegate(this.LaunchZuneShellHelper); s_launch = new LaunchDelegate(this.LaunchZuneShellHelper);
return Marshal.GetFunctionPointerForDelegate((Delegate)LaunchZuneShell.s_launch); return Marshal.GetFunctionPointerForDelegate(s_launch);
} }
private int LaunchZuneShellHelper() => ZuneApplication.Launch(LaunchZuneShell.s_args, LaunchZuneShell.s_hWndSplashScreen); private int LaunchZuneShellHelper() => ZuneApplication.Launch(s_args, s_hWndSplashScreen);
public IntPtr GetRenderWindow() => ZuneApplication.GetRenderWindow(); public IntPtr GetRenderWindow() => ZuneApplication.GetRenderWindow();
+6 -6
View File
@@ -18,7 +18,7 @@ namespace Microsoft.Zune.Shell
public static Hashtable Startup(string[] args, string defaultCommandLineSwitch) public static Hashtable Startup(string[] args, string defaultCommandLineSwitch)
{ {
WindowSize windowSize = new WindowSize(1012, 693); WindowSize windowSize = new WindowSize(1012, 693);
string str = (string)null; string str = null;
bool flag1 = false; bool flag1 = false;
bool flag2 = false; bool flag2 = false;
Hashtable hashtable = new Hashtable(); Hashtable hashtable = new Hashtable();
@@ -43,7 +43,7 @@ namespace Microsoft.Zune.Shell
case "size": case "size":
try try
{ {
windowSize = StandAlone.ParseSize(commandLineArgument.Value); windowSize = ParseSize(commandLineArgument.Value);
break; break;
} }
catch (FormatException ex) catch (FormatException ex)
@@ -71,7 +71,7 @@ namespace Microsoft.Zune.Shell
break; break;
} }
default: default:
hashtable[(object)commandLineArgument.Name] = (object)commandLineArgument.Value; hashtable[commandLineArgument.Name] = commandLineArgument.Value;
break; break;
} }
} }
@@ -96,7 +96,7 @@ namespace Microsoft.Zune.Shell
Application.AnimationsEnabled = ClientConfiguration.GeneralSettings.AnimationsEnabled; Application.AnimationsEnabled = ClientConfiguration.GeneralSettings.AnimationsEnabled;
Application.Initialize(); Application.Initialize();
Application.Window.InitialClientSize = windowSize; Application.Window.InitialClientSize = windowSize;
object obj = Registry.GetValue(ZuneUI.Shell.SettingsRegistryPath, "WindowPosition", (object)null); object obj = Registry.GetValue(ZuneUI.Shell.SettingsRegistryPath, "WindowPosition", null);
if (obj != null) if (obj != null)
{ {
if (obj is string) if (obj is string)
@@ -118,7 +118,7 @@ namespace Microsoft.Zune.Shell
Application.Window.ShowWindowFrame = flag1; Application.Window.ShowWindowFrame = flag1;
Application.Window.SetBackgroundColor(ZuneUI.Shell.WindowColorFromRGB(ClientConfiguration.Shell.BackgroundColor)); Application.Window.SetBackgroundColor(ZuneUI.Shell.WindowColorFromRGB(ClientConfiguration.Shell.BackgroundColor));
if (!flag2) if (!flag2)
Application.DeferredInvoke((DeferredInvokeHandler)delegate Application.DeferredInvoke(delegate
{ {
Windowing.ForceSetForegroundWindow(Application.Window.Handle); Windowing.ForceSetForegroundWindow(Application.Window.Handle);
}, DeferredInvokePriority.Low); }, DeferredInvokePriority.Low);
@@ -143,7 +143,7 @@ namespace Microsoft.Zune.Shell
Application.Run(initialLoadComplete); Application.Run(initialLoadComplete);
if (TaskbarPlayer.Instance.ToolbarVisible) if (TaskbarPlayer.Instance.ToolbarVisible)
return; return;
Registry.SetValue(ZuneUI.Shell.SettingsRegistryPath, "WindowPosition", (object)Application.Window.GetSavedPosition(true)); Registry.SetValue(ZuneUI.Shell.SettingsRegistryPath, "WindowPosition", Application.Window.GetSavedPosition(true));
} }
public static void Shutdown() => Application.Shutdown(); public static void Shutdown() => Application.Shutdown();
+9 -9
View File
@@ -16,9 +16,9 @@ namespace Microsoft.Zune.Shell
{ {
get get
{ {
if (TraceSwitches.collectionSwitch == null) if (collectionSwitch == null)
TraceSwitches.collectionSwitch = new ZuneTraceSwitch("Collection", "Collection page traces"); collectionSwitch = new ZuneTraceSwitch("Collection", "Collection page traces");
return TraceSwitches.collectionSwitch; return collectionSwitch;
} }
} }
@@ -26,9 +26,9 @@ namespace Microsoft.Zune.Shell
{ {
get get
{ {
if (TraceSwitches.shellSwitch == null) if (shellSwitch == null)
TraceSwitches.shellSwitch = new ZuneTraceSwitch("Shell", "Shell traces"); shellSwitch = new ZuneTraceSwitch("Shell", "Shell traces");
return TraceSwitches.shellSwitch; return shellSwitch;
} }
} }
@@ -36,9 +36,9 @@ namespace Microsoft.Zune.Shell
{ {
get get
{ {
if (TraceSwitches.dataProviderSwitch == null) if (dataProviderSwitch == null)
TraceSwitches.dataProviderSwitch = new ZuneTraceSwitch("DataProvider", "Data provider traces"); dataProviderSwitch = new ZuneTraceSwitch("DataProvider", "Data provider traces");
return TraceSwitches.dataProviderSwitch; return dataProviderSwitch;
} }
} }
} }
+8 -8
View File
@@ -13,9 +13,9 @@ namespace Microsoft.Zune.Shell
{ {
private bool _inCompactMode; private bool _inCompactMode;
private bool _shutdown; private bool _shutdown;
private ViewTimeLogger.LogHelper _compactModeLog = new ViewTimeLogger.LogHelper(SQMDataId.CompactModeViewTime); private LogHelper _compactModeLog = new LogHelper(SQMDataId.CompactModeViewTime);
private ViewTimeLogger.LogHelper _mixViewLog = new ViewTimeLogger.LogHelper(SQMDataId.MixViewTime); private LogHelper _mixViewLog = new LogHelper(SQMDataId.MixViewTime);
private ViewTimeLogger.LogHelper _collectionViewLog; private LogHelper _collectionViewLog;
private static ViewTimeLogger _viewTimeLogger; private static ViewTimeLogger _viewTimeLogger;
private ViewTimeLogger() private ViewTimeLogger()
@@ -35,9 +35,9 @@ namespace Microsoft.Zune.Shell
{ {
get get
{ {
if (ViewTimeLogger._viewTimeLogger == null) if (_viewTimeLogger == null)
ViewTimeLogger._viewTimeLogger = new ViewTimeLogger(); _viewTimeLogger = new ViewTimeLogger();
return ViewTimeLogger._viewTimeLogger; return _viewTimeLogger;
} }
} }
@@ -46,11 +46,11 @@ namespace Microsoft.Zune.Shell
if (this._collectionViewLog != null && viewSQMId != this._collectionViewLog.LogId) if (this._collectionViewLog != null && viewSQMId != this._collectionViewLog.LogId)
{ {
this._collectionViewLog.Stop(); this._collectionViewLog.Stop();
this._collectionViewLog = (ViewTimeLogger.LogHelper)null; this._collectionViewLog = null;
} }
if (viewSQMId == SQMDataId.Invalid || this._collectionViewLog != null) if (viewSQMId == SQMDataId.Invalid || this._collectionViewLog != null)
return; return;
this._collectionViewLog = new ViewTimeLogger.LogHelper(viewSQMId); this._collectionViewLog = new LogHelper(viewSQMId);
if (this._inCompactMode) if (this._inCompactMode)
return; return;
this._collectionViewLog.Start(); this._collectionViewLog.Start();
+126 -126
View File
@@ -46,15 +46,15 @@ namespace Microsoft.Zune.Shell
public static double ZuneCurrentSettingsVersion => 2.0; public static double ZuneCurrentSettingsVersion => 2.0;
public static void SetDesktopLockState(bool locked) => ZuneApplication._desktopLocked = locked; public static void SetDesktopLockState(bool locked) => _desktopLocked = locked;
public static bool IsDesktopLocked => ZuneApplication._desktopLocked; public static bool IsDesktopLocked => _desktopLocked;
public static string DefaultCommandLineParameterSwitch => "PlayMedia"; public static string DefaultCommandLineParameterSwitch => "PlayMedia";
public static ZuneLibrary ZuneLibrary => ZuneApplication._zuneLibrary; public static ZuneLibrary ZuneLibrary => _zuneLibrary;
public static Microsoft.Zune.Service.Service Service => Microsoft.Zune.Service.Service.Instance; public static Service.Service Service => Zune.Service.Service.Instance;
public static event EventHandler Closing; public static event EventHandler Closing;
@@ -78,7 +78,7 @@ namespace Microsoft.Zune.Shell
internal static IntPtr GetRenderWindow() => Application.Window.Handle; internal static IntPtr GetRenderWindow() => Application.Window.Handle;
public static void PageLoadComplete() => ZuneApplication._initializationFailsafe.Complete(); public static void PageLoadComplete() => _initializationFailsafe.Complete();
private static void CorePhase3Ready(int hr, bool fSuc) private static void CorePhase3Ready(int hr, bool fSuc)
{ {
@@ -90,7 +90,7 @@ namespace Microsoft.Zune.Shell
else else
{ {
SingletonModelItem<WindowSnapSimulator>.Instance.Phase3Init(); SingletonModelItem<WindowSnapSimulator>.Instance.Phase3Init();
ZuneApplication.Service.Phase3Initialize(); Service.Phase3Initialize();
SignIn.Instance.Phase3Init(); SignIn.Instance.Phase3Init();
MetadataNotifications.Instance.Phase2Init(); MetadataNotifications.Instance.Phase2Init();
SingletonModelItem<UIDeviceList>.Instance.Phase2Init(); SingletonModelItem<UIDeviceList>.Instance.Phase2Init();
@@ -98,9 +98,9 @@ namespace Microsoft.Zune.Shell
SingletonModelItem<TransportControls>.Instance.Phase2Init(); SingletonModelItem<TransportControls>.Instance.Phase2Init();
SubscriptionEventsListener.Instance.StartListening(); SubscriptionEventsListener.Instance.StartListening();
SoftwareUpdates.Instance.StartUp(); SoftwareUpdates.Instance.StartUp();
ZuneApplication._interopNotifications = new InteropNotifications(); _interopNotifications = new InteropNotifications();
if (ZuneApplication._interopNotifications != null) if (_interopNotifications != null)
ZuneApplication._interopNotifications.ShowErrorDialog += new OnShowErrorDialogHandler(ZuneApplication.OnShowErrorDialog); _interopNotifications.ShowErrorDialog += new OnShowErrorDialogHandler(OnShowErrorDialog);
Download.Instance.Phase3Init(); Download.Instance.Phase3Init();
SyncControls.Instance.Phase3Init(); SyncControls.Instance.Phase3Init();
PodcastCredentials.Instance.Phase2Init(); PodcastCredentials.Instance.Phase2Init();
@@ -112,10 +112,10 @@ namespace Microsoft.Zune.Shell
SingletonModelItem<ThumbBarButtons>.Instance.Phase3Init(); SingletonModelItem<ThumbBarButtons>.Instance.Phase3Init();
SingletonModelItem<JumpListManager>.Instance.JumpListPinUpdateRequested.Invoke(); SingletonModelItem<JumpListManager>.Instance.JumpListPinUpdateRequested.Invoke();
} }
if (!Microsoft.Zune.QuickMix.QuickMix.Instance.IsReady) if (!QuickMix.QuickMix.Instance.IsReady)
{ {
ZuneApplication._quickMixProgress = new QuickMixProgress(); _quickMixProgress = new QuickMixProgress();
ZuneApplication._quickMixProgress.PropertyChanged += new PropertyChangedEventHandler(ZuneApplication.OnQuickMixPropertyChanged); _quickMixProgress.PropertyChanged += new PropertyChangedEventHandler(OnQuickMixPropertyChanged);
} }
Telemetry.Instance.StartUpload(); Telemetry.Instance.StartUpload();
FeaturesChanged.Instance.StartUp(); FeaturesChanged.Instance.StartUp();
@@ -126,159 +126,159 @@ namespace Microsoft.Zune.Shell
private static void Phase2InitializationUIStage(object arg) private static void Phase2InitializationUIStage(object arg)
{ {
ZuneApplication._initializationFailsafe.Initialize((DeferredInvokeHandler)delegate _initializationFailsafe.Initialize(delegate
{ {
ZuneApplication._appInitializationSequencer.UIReady(); _appInitializationSequencer.UIReady();
}); });
ZuneApplication.ProcessAppArgs(); ProcessAppArgs();
Download.Instance.Phase2Init(); Download.Instance.Phase2Init();
if (!ZuneShell.DefaultInstance.NavigationsPending && ZuneShell.DefaultInstance.CurrentPage is StartupPage) if (!ZuneShell.DefaultInstance.NavigationsPending && ZuneShell.DefaultInstance.CurrentPage is StartupPage)
ZuneUI.Shell.NavigateToHomePage(); ZuneUI.Shell.NavigateToHomePage();
if (ZuneApplication._dbRebuilt) if (_dbRebuilt)
{ {
string caption = ZuneLibrary.LoadStringFromResource(109U); string caption = ZuneLibrary.LoadStringFromResource(109U);
string text = ZuneLibrary.LoadStringFromResource(110U); string text = ZuneLibrary.LoadStringFromResource(110U);
if (!string.IsNullOrEmpty(caption) && !string.IsNullOrEmpty(text)) if (!string.IsNullOrEmpty(caption) && !string.IsNullOrEmpty(text))
Win32MessageBox.Show(text, caption, Win32MessageBoxType.MB_ICONHAND, (DeferredInvokeHandler)null); Win32MessageBox.Show(text, caption, Win32MessageBoxType.MB_ICONHAND, null);
} }
ZuneApplication._phase2InitComplete = true; _phase2InitComplete = true;
} }
private static void Phase2InitializationWorker(object arg) private static void Phase2InitializationWorker(object arg)
{ {
Win32Window.Close(ZuneApplication._hWndSplashScreen); Win32Window.Close(_hWndSplashScreen);
int hr; int hr;
bool flag = ZuneApplication._zuneLibrary.Phase2Initialization(out hr); bool flag = _zuneLibrary.Phase2Initialization(out hr);
Application.DeferredInvoke(new DeferredInvokeHandler(ZuneApplication.Phase2InitializationUIStage), (object)new object[2] Application.DeferredInvoke(new DeferredInvokeHandler(Phase2InitializationUIStage), new object[2]
{ {
(object) hr, hr,
(object) flag flag
}); });
ZuneApplication.ZuneLibrary.CleanupTransientMedia(); ZuneLibrary.CleanupTransientMedia();
ZuneApplication._transientTableCleanupComplete.Set(); _transientTableCleanupComplete.Set();
SQMLog.Log(SQMDataId.GdiMode, Application.RenderingType == RenderingType.GDI ? 1 : 0); SQMLog.Log(SQMDataId.GdiMode, Application.RenderingType == RenderingType.GDI ? 1 : 0);
} }
private static void Phase2Initialization(object arg) => ThreadPool.QueueUserWorkItem(new WaitCallback(ZuneApplication.Phase2InitializationWorker)); private static void Phase2Initialization(object arg) => ThreadPool.QueueUserWorkItem(new WaitCallback(Phase2InitializationWorker));
public static void ProcessMessageFromCommandLine(string strArgs) => Application.DeferredInvoke(new DeferredInvokeHandler(ZuneApplication.ProcessMessageFromCommandLineDeferred), (object)strArgs, DeferredInvokePriority.Low); public static void ProcessMessageFromCommandLine(string strArgs) => Application.DeferredInvoke(new DeferredInvokeHandler(ProcessMessageFromCommandLineDeferred), strArgs, DeferredInvokePriority.Low);
private static void ProcessMessageFromCommandLineDeferred(object args) private static void ProcessMessageFromCommandLineDeferred(object args)
{ {
string[] arArgs = ZuneApplication.SplitCommandLineArguments((string)args); string[] arArgs = SplitCommandLineArguments((string)args);
if (arArgs != null) if (arArgs != null)
{ {
if (ZuneApplication._unprocessedAppArgs == null) if (_unprocessedAppArgs == null)
ZuneApplication._unprocessedAppArgs = new List<Hashtable>(); _unprocessedAppArgs = new List<Hashtable>();
Hashtable hashtable = new Hashtable(); Hashtable hashtable = new Hashtable();
foreach (CommandLineArgument commandLineArgument in CommandLineArgument.ParseArgs(arArgs, ZuneApplication.DefaultCommandLineParameterSwitch)) foreach (CommandLineArgument commandLineArgument in CommandLineArgument.ParseArgs(arArgs, DefaultCommandLineParameterSwitch))
hashtable[(object)commandLineArgument.Name] = (object)commandLineArgument.Value; hashtable[commandLineArgument.Name] = commandLineArgument.Value;
ZuneApplication._unprocessedAppArgs.Add(hashtable); _unprocessedAppArgs.Add(hashtable);
} }
if (!ZuneApplication._phase2InitComplete) if (!_phase2InitComplete)
return; return;
ZuneApplication.ProcessAppArgs(); ProcessAppArgs();
} }
private static void ProcessAppArgs() private static void ProcessAppArgs()
{ {
if (ZuneApplication._unprocessedAppArgs == null) if (_unprocessedAppArgs == null)
return; return;
if (ClientConfiguration.FUE.SettingsVersion < ZuneApplication.ZuneCurrentSettingsVersion || Fue.Instance.IsFirstLaunch) if (ClientConfiguration.FUE.SettingsVersion < ZuneCurrentSettingsVersion || Fue.Instance.IsFirstLaunch)
{ {
Fue.FUECompleted += new EventHandler(ZuneApplication.ProcessAppArgsAfterFUE); Fue.FUECompleted += new EventHandler(ProcessAppArgsAfterFUE);
} }
else else
{ {
for (int index = 0; index < ZuneApplication._unprocessedAppArgs.Count; ++index) for (int index = 0; index < _unprocessedAppArgs.Count; ++index)
ZuneApplication.ProcessAppArgs(ZuneApplication._unprocessedAppArgs[index]); ProcessAppArgs(_unprocessedAppArgs[index]);
ZuneApplication._unprocessedAppArgs = (List<Hashtable>)null; _unprocessedAppArgs = null;
} }
} }
private static void ProcessAppArgs(Hashtable args) private static void ProcessAppArgs(Hashtable args)
{ {
if (args[(object)"device"] is string str && !ZuneApplication._phase2InitComplete) if (args["device"] is string str && !_phase2InitComplete)
{ {
char[] chArray = new char[1] { '"' }; char[] chArray = new char[1] { '"' };
SyncControls.Instance.SetCurrentDeviceByCanonicalName(str.Trim(chArray)); SyncControls.Instance.SetCurrentDeviceByCanonicalName(str.Trim(chArray));
} }
if (args[(object)"link"] is string link && !ZuneUI.Shell.IgnoreAppNavigationsArgs) if (args["link"] is string link && !ZuneUI.Shell.IgnoreAppNavigationsArgs)
ZuneUI.Shell.ProcessExternalLink(link); ZuneUI.Shell.ProcessExternalLink(link);
if (args[(object)"ripcd"] is string playCdPath && !ZuneUI.Shell.IgnoreAppNavigationsArgs) if (args["ripcd"] is string playCdPath && !ZuneUI.Shell.IgnoreAppNavigationsArgs)
CDAccess.HandleDiskFromAutoplay(playCdPath, CDAction.Rip); CDAccess.HandleDiskFromAutoplay(playCdPath, CDAction.Rip);
if (args[(object)"playcd"] is string ripCdPath && !ZuneUI.Shell.IgnoreAppNavigationsArgs) if (args["playcd"] is string ripCdPath && !ZuneUI.Shell.IgnoreAppNavigationsArgs)
CDAccess.HandleDiskFromAutoplay(ripCdPath, CDAction.Play); CDAccess.HandleDiskFromAutoplay(ripCdPath, CDAction.Play);
if (args[(object)"playmedia"] is string initialUrl && !ZuneUI.Shell.IgnoreAppNavigationsArgs) if (args["playmedia"] is string initialUrl && !ZuneUI.Shell.IgnoreAppNavigationsArgs)
ZuneApplication.RegisterNewFileEnumeration(new LaunchFromShellHelper("play", initialUrl)); RegisterNewFileEnumeration(new LaunchFromShellHelper("play", initialUrl));
if (args[(object)"shellhlp_v2"] is string taskName && !ZuneUI.Shell.IgnoreAppNavigationsArgs) if (args["shellhlp_v2"] is string taskName && !ZuneUI.Shell.IgnoreAppNavigationsArgs)
{ {
string marshalledDataObject = args[(object)"dataobject"] as string; string marshalledDataObject = args["dataobject"] as string;
string eventName = args[(object)"event"] as string; string eventName = args["event"] as string;
if (marshalledDataObject != null && eventName != null) if (marshalledDataObject != null && eventName != null)
ZuneApplication.RegisterNewFileEnumeration(new LaunchFromShellHelper(taskName, marshalledDataObject, eventName)); RegisterNewFileEnumeration(new LaunchFromShellHelper(taskName, marshalledDataObject, eventName));
} }
if (args.Contains((object)"refreshlicenses")) if (args.Contains("refreshlicenses"))
ZuneApplication.ZuneLibrary.MarkAllDRMFilesAsNeedingLicenseRefresh(); ZuneLibrary.MarkAllDRMFilesAsNeedingLicenseRefresh();
if (args.Contains((object)"update")) if (args.Contains("update"))
SoftwareUpdates.Instance.InstallUpdates(); SoftwareUpdates.Instance.InstallUpdates();
if (args.Contains((object)"shuffleall") && !ZuneUI.Shell.IgnoreAppNavigationsArgs) if (args.Contains("shuffleall") && !ZuneUI.Shell.IgnoreAppNavigationsArgs)
SingletonModelItem<TransportControls>.Instance.ShuffleAllRequested = true; SingletonModelItem<TransportControls>.Instance.ShuffleAllRequested = true;
if (args.Contains((object)"resumenowplaying") && !ZuneUI.Shell.IgnoreAppNavigationsArgs) if (args.Contains("resumenowplaying") && !ZuneUI.Shell.IgnoreAppNavigationsArgs)
SingletonModelItem<TransportControls>.Instance.ResumeLastNowPlayingHandler(); SingletonModelItem<TransportControls>.Instance.ResumeLastNowPlayingHandler();
if (args.Contains((object)"refreshcontentandexit")) if (args.Contains("refreshcontentandexit"))
{ {
if (!ZuneApplication._phase2InitComplete) if (!_phase2InitComplete)
{ {
HRESULT sOk = HRESULT._S_OK; HRESULT sOk = HRESULT._S_OK;
HRESULT hr = ContentRefreshTask.Instance.StartContentRefresh(new AsyncCompleteHandler(ZuneApplication.OnContentRefreshTaskComplete)); HRESULT hr = ContentRefreshTask.Instance.StartContentRefresh(new AsyncCompleteHandler(OnContentRefreshTaskComplete));
if (hr.IsError) if (hr.IsError)
ZuneApplication.OnContentRefreshTaskComplete(hr); OnContentRefreshTaskComplete(hr);
} }
else else
ZuneApplication.ZuneLibrary.MarkAllDRMFilesAsNeedingLicenseRefresh(); ZuneLibrary.MarkAllDRMFilesAsNeedingLicenseRefresh();
} }
if (!(args[(object)"playpin"] is string pinString) || ZuneUI.Shell.IgnoreAppNavigationsArgs) if (!(args["playpin"] is string pinString) || ZuneUI.Shell.IgnoreAppNavigationsArgs)
return; return;
JumpListManager.PlayPin(JumpListPin.Parse(pinString)); JumpListManager.PlayPin(JumpListPin.Parse(pinString));
} }
private static void OnContentRefreshTaskComplete(HRESULT hr) => Application.DeferredInvoke(new DeferredInvokeHandler(ZuneApplication.DeferredClose), DeferredInvokePriority.Normal); private static void OnContentRefreshTaskComplete(HRESULT hr) => Application.DeferredInvoke(new DeferredInvokeHandler(DeferredClose), DeferredInvokePriority.Normal);
public static void DeferredClose(object arg) => Application.Window.Close(); public static void DeferredClose(object arg) => Application.Window.Close();
private static void ProcessAppArgsAfterFUE(object sender, EventArgs unused) private static void ProcessAppArgsAfterFUE(object sender, EventArgs unused)
{ {
Fue.FUECompleted -= new EventHandler(ZuneApplication.ProcessAppArgsAfterFUE); Fue.FUECompleted -= new EventHandler(ProcessAppArgsAfterFUE);
ZuneApplication.ProcessAppArgs(); ProcessAppArgs();
} }
private static void RegisterNewFileEnumeration(LaunchFromShellHelper helper) private static void RegisterNewFileEnumeration(LaunchFromShellHelper helper)
{ {
if (ZuneApplication._currentShellCommand != null) if (_currentShellCommand != null)
ZuneApplication._currentShellCommand.Cancel(); _currentShellCommand.Cancel();
ZuneApplication._currentShellCommand = helper; _currentShellCommand = helper;
ZuneApplication._currentShellCommand.Go(new DeferredInvokeHandler(ZuneApplication.DataObjectEnumerationComplete)); _currentShellCommand.Go(new DeferredInvokeHandler(DataObjectEnumerationComplete));
} }
private static void DataObjectEnumerationComplete(object args) private static void DataObjectEnumerationComplete(object args)
{ {
if (args != ZuneApplication._currentShellCommand) if (args != _currentShellCommand)
return; return;
string taskName = ZuneApplication._currentShellCommand.TaskName; string taskName = _currentShellCommand.TaskName;
if (taskName == "play" || taskName == "playasplaylist") if (taskName == "play" || taskName == "playasplaylist")
{ {
List<FileEntry> files = ZuneApplication._currentShellCommand.Files; List<FileEntry> files = _currentShellCommand.Files;
MediaType mediaType = ZuneApplication.FilterFiles(files); MediaType mediaType = FilterFiles(files);
if (files != null && files.Count > 0 && (mediaType == MediaType.Track || mediaType == MediaType.Video)) if (files != null && files.Count > 0 && (mediaType == MediaType.Track || mediaType == MediaType.Video))
{ {
PlaybackContext playbackContext = PlaybackContext.Music; PlaybackContext playbackContext = PlaybackContext.Music;
if (mediaType == MediaType.Video) if (mediaType == MediaType.Video)
playbackContext = PlaybackContext.LibraryVideo; playbackContext = PlaybackContext.LibraryVideo;
SingletonModelItem<TransportControls>.Instance.PlayItems((IList)files, playbackContext); SingletonModelItem<TransportControls>.Instance.PlayItems(files, playbackContext);
} }
} }
ZuneApplication._currentShellCommand = (LaunchFromShellHelper)null; _currentShellCommand = null;
} }
private static MediaType FilterFiles(List<FileEntry> enumeratedFiles) private static MediaType FilterFiles(List<FileEntry> enumeratedFiles)
@@ -320,8 +320,8 @@ namespace Microsoft.Zune.Shell
private static string[] SplitCommandLineArguments(string arguments) private static string[] SplitCommandLineArguments(string arguments)
{ {
if (string.IsNullOrEmpty(arguments)) if (string.IsNullOrEmpty(arguments))
return (string[])null; return null;
string[] strArray = (string[])null; string[] strArray = null;
MatchCollection matchCollection = new Regex("(\\S*?(\\\")([^\\\"])+(\\\"))|[^\\s\"]+").Matches(arguments); MatchCollection matchCollection = new Regex("(\\S*?(\\\")([^\\\"])+(\\\"))|[^\\s\"]+").Matches(arguments);
if (matchCollection.Count > 0) if (matchCollection.Count > 0)
{ {
@@ -335,13 +335,13 @@ namespace Microsoft.Zune.Shell
[STAThread] [STAThread]
public static int Launch(string strArgs, IntPtr hWndSplashScreen) public static int Launch(string strArgs, IntPtr hWndSplashScreen)
{ {
Microsoft.Zune.PerfTrace.PerfTrace.PERFTRACE_LAUNCHEVENT(Microsoft.Zune.PerfTrace.PerfTrace.LAUNCH_EVENT.IN_MANAGED_LAUNCH, 0U); PerfTrace.PerfTrace.PERFTRACE_LAUNCHEVENT(PerfTrace.PerfTrace.LAUNCH_EVENT.IN_MANAGED_LAUNCH, 0U);
Application.ErrorReport += new Microsoft.Iris.ErrorReportHandler(ZuneApplication.ErrorReportHandler); Application.ErrorReport += new ErrorReportHandler(ErrorReportHandler);
Hashtable hashtable = StandAlone.Startup(ZuneApplication.SplitCommandLineArguments(strArgs), ZuneApplication.DefaultCommandLineParameterSwitch); Hashtable hashtable = StandAlone.Startup(SplitCommandLineArguments(strArgs), DefaultCommandLineParameterSwitch);
if (hashtable != null) if (hashtable != null)
{ {
ZuneApplication._unprocessedAppArgs = new List<Hashtable>(); _unprocessedAppArgs = new List<Hashtable>();
ZuneApplication._unprocessedAppArgs.Add(hashtable); _unprocessedAppArgs.Add(hashtable);
} }
DialogHelper.DialogCancel = ZuneUI.Shell.LoadString(StringId.IDS_DIALOG_CANCEL); DialogHelper.DialogCancel = ZuneUI.Shell.LoadString(StringId.IDS_DIALOG_CANCEL);
DialogHelper.DialogYes = ZuneUI.Shell.LoadString(StringId.IDS_DIALOG_YES); DialogHelper.DialogYes = ZuneUI.Shell.LoadString(StringId.IDS_DIALOG_YES);
@@ -356,7 +356,7 @@ namespace Microsoft.Zune.Shell
Application.Name = "Zune"; Application.Name = "Zune";
Application.Window.Caption = "Zune"; Application.Window.Caption = "Zune";
Application.Window.SetIcon("ZuneShellResources.dll", 1); Application.Window.SetIcon("ZuneShellResources.dll", 1);
if (!hashtable.Contains((object)"noshadow")) if (!hashtable.Contains("noshadow"))
{ {
Image[] images = new Image[4]; Image[] images = new Image[4];
ImageInset imageInset1 = new ImageInset(26, 0, 30, 0); ImageInset imageInset1 = new ImageInset(26, 0, 30, 0);
@@ -375,24 +375,24 @@ namespace Microsoft.Zune.Shell
Application.Window.SetShadowEdgeImages(false, images); Application.Window.SetShadowEdgeImages(false, images);
} }
Application.Window.CloseRequested += new WindowCloseRequestedHandler(CodeDialogManager.Instance.OnWindowCloseRequested); Application.Window.CloseRequested += new WindowCloseRequestedHandler(CodeDialogManager.Instance.OnWindowCloseRequested);
CodeDialogManager.Instance.WindowCloseNotBlocked += new EventHandler(ZuneApplication.OnWindowCloseNotBlocked); CodeDialogManager.Instance.WindowCloseNotBlocked += new EventHandler(OnWindowCloseNotBlocked);
Application.Window.SessionConnected += new SessionConnectedHandler(ZuneApplication.OnSessionConnected); Application.Window.SessionConnected += new SessionConnectedHandler(OnSessionConnected);
string source = "res://ZuneShellResources!Frame.uix#Frame"; string source = "res://ZuneShellResources!Frame.uix#Frame";
ZuneApplication._hWndSplashScreen = hWndSplashScreen; _hWndSplashScreen = hWndSplashScreen;
ZuneApplication._initializationFailsafe = new InitializationFailsafe(); _initializationFailsafe = new InitializationFailsafe();
Microsoft.Zune.PerfTrace.PerfTrace.PERFTRACE_LAUNCHEVENT(Microsoft.Zune.PerfTrace.PerfTrace.LAUNCH_EVENT.REQUEST_UI_LOAD, 0U); PerfTrace.PerfTrace.PERFTRACE_LAUNCHEVENT(PerfTrace.PerfTrace.LAUNCH_EVENT.REQUEST_UI_LOAD, 0U);
Application.Window.RequestLoad(source); Application.Window.RequestLoad(source);
Microsoft.Zune.PerfTrace.PerfTrace.PERFTRACE_LAUNCHEVENT(Microsoft.Zune.PerfTrace.PerfTrace.LAUNCH_EVENT.REQUEST_UI_LOAD_COMPLETE, 0U); PerfTrace.PerfTrace.PERFTRACE_LAUNCHEVENT(PerfTrace.PerfTrace.LAUNCH_EVENT.REQUEST_UI_LOAD_COMPLETE, 0U);
CallbackOnUIThread callbackOnUiThread = new CallbackOnUIThread(); CallbackOnUIThread callbackOnUiThread = new CallbackOnUIThread();
ZuneApplication._appInitializationSequencer = new AppInitializationSequencer(new CorePhase2ReadyCallback(ZuneApplication.CorePhase3Ready)); _appInitializationSequencer = new AppInitializationSequencer(new CorePhase2ReadyCallback(CorePhase3Ready));
ZuneApplication._zuneLibrary = new ZuneLibrary(); _zuneLibrary = new ZuneLibrary();
int num = ZuneApplication._zuneLibrary.Initialize((string)null, out ZuneApplication._dbRebuilt); int num = _zuneLibrary.Initialize(null, out _dbRebuilt);
if (num == 0) if (num == 0)
{ {
StandAlone.Run(new DeferredInvokeHandler(ZuneApplication.Phase2Initialization)); StandAlone.Run(new DeferredInvokeHandler(Phase2Initialization));
Application.Window.CloseRequested -= new WindowCloseRequestedHandler(CodeDialogManager.Instance.OnWindowCloseRequested); Application.Window.CloseRequested -= new WindowCloseRequestedHandler(CodeDialogManager.Instance.OnWindowCloseRequested);
CodeDialogManager.Instance.WindowCloseNotBlocked -= new EventHandler(ZuneApplication.OnWindowCloseNotBlocked); CodeDialogManager.Instance.WindowCloseNotBlocked -= new EventHandler(OnWindowCloseNotBlocked);
Application.Window.SessionConnected -= new SessionConnectedHandler(ZuneApplication.OnSessionConnected); Application.Window.SessionConnected -= new SessionConnectedHandler(OnSessionConnected);
if (Download.IsCreated) if (Download.IsCreated)
Download.Instance.Dispose(); Download.Instance.Dispose();
ZuneShell.DefaultInstance?.Dispose(); ZuneShell.DefaultInstance?.Dispose();
@@ -406,8 +406,8 @@ namespace Microsoft.Zune.Shell
WorkerQueue.ShutdownAll(); WorkerQueue.ShutdownAll();
if (ContentRefreshTask.HasInstance) if (ContentRefreshTask.HasInstance)
ContentRefreshTask.Instance.Dispose(); ContentRefreshTask.Instance.Dispose();
if (ZuneApplication.Service != null) if (Service != null)
ZuneApplication.Service.Dispose(); Service.Dispose();
if (ShellMessagingNotifier.HasInstance) if (ShellMessagingNotifier.HasInstance)
ShellMessagingNotifier.Instance.Dispose(); ShellMessagingNotifier.Instance.Dispose();
if (MessagingService.HasInstance) if (MessagingService.HasInstance)
@@ -416,14 +416,14 @@ namespace Microsoft.Zune.Shell
FeaturesChangedApi.Instance.Dispose(); FeaturesChangedApi.Instance.Dispose();
CDAccess.Instance.Dispose(); CDAccess.Instance.Dispose();
PlaylistManager.Instance.Dispose(); PlaylistManager.Instance.Dispose();
if (ZuneApplication._interopNotifications != null) if (_interopNotifications != null)
{ {
ZuneApplication._interopNotifications.ShowErrorDialog -= new OnShowErrorDialogHandler(ZuneApplication.OnShowErrorDialog); _interopNotifications.ShowErrorDialog -= new OnShowErrorDialogHandler(OnShowErrorDialog);
ZuneApplication._interopNotifications.Dispose(); _interopNotifications.Dispose();
ZuneApplication._interopNotifications = (InteropNotifications)null; _interopNotifications = null;
} }
} }
ZuneApplication._zuneLibrary.Dispose(); _zuneLibrary.Dispose();
return num; return num;
} }
@@ -440,16 +440,16 @@ namespace Microsoft.Zune.Shell
} }
} }
if (num > 0) if (num > 0)
throw new ZuneShellException("Internal Zune Shell error", string.Format("Scripting errors encountered (Process ID) = {0}\n\n{1}", (object)Process.GetCurrentProcess().Id.ToString((IFormatProvider)CultureInfo.InvariantCulture), (object)str)); throw new ZuneShellException("Internal Zune Shell error", string.Format("Scripting errors encountered (Process ID) = {0}\n\n{1}", Process.GetCurrentProcess().Id.ToString(CultureInfo.InvariantCulture), str));
} }
internal static bool CanAddMedia(IList filenames, MediaType mediaType, CanAddMediaArgs args) internal static bool CanAddMedia(IList filenames, MediaType mediaType, CanAddMediaArgs args)
{ {
foreach (string filename in (IEnumerable)filenames) foreach (string filename in filenames)
{ {
if (args.Aborted) if (args.Aborted)
return false; return false;
if (ZuneApplication.CanAddMedia(filename, mediaType, args)) if (CanAddMedia(filename, mediaType, args))
return true; return true;
} }
return false; return false;
@@ -459,7 +459,7 @@ namespace Microsoft.Zune.Shell
{ {
try try
{ {
return Directory.Exists(filename) ? ZuneApplication.ZuneLibrary.CanAddFromFolder(filename) && (ZuneApplication.CanAddMedia((IList)Directory.GetFiles(filename), mediaType, args) || ZuneApplication.CanAddMedia((IList)Directory.GetDirectories(filename), mediaType, args)) : ZuneApplication.ZuneLibrary.CanAddMedia(filename, (EMediaTypes)mediaType); return Directory.Exists(filename) ? ZuneLibrary.CanAddFromFolder(filename) && (CanAddMedia(Directory.GetFiles(filename), mediaType, args) || CanAddMedia(Directory.GetDirectories(filename), mediaType, args)) : ZuneLibrary.CanAddMedia(filename, (EMediaTypes)mediaType);
} }
catch (UnauthorizedAccessException ex) catch (UnauthorizedAccessException ex)
{ {
@@ -474,8 +474,8 @@ namespace Microsoft.Zune.Shell
internal static bool AddMedia(IList filenames, MediaType mediaType) internal static bool AddMedia(IList filenames, MediaType mediaType)
{ {
bool flag = false; bool flag = false;
foreach (string filename in (IEnumerable)filenames) foreach (string filename in filenames)
flag |= ZuneApplication.AddMedia(filename, mediaType); flag |= AddMedia(filename, mediaType);
return flag; return flag;
} }
@@ -486,11 +486,11 @@ namespace Microsoft.Zune.Shell
{ {
if (Directory.Exists(filename)) if (Directory.Exists(filename))
{ {
flag = ZuneApplication.AddMedia((IList)Directory.GetFiles(filename), mediaType); flag = AddMedia(Directory.GetFiles(filename), mediaType);
flag |= ZuneApplication.AddMedia((IList)Directory.GetDirectories(filename), mediaType); flag |= AddMedia(Directory.GetDirectories(filename), mediaType);
} }
else if (ZuneApplication.ZuneLibrary.CanAddMedia(filename, (EMediaTypes)mediaType)) else if (ZuneLibrary.CanAddMedia(filename, (EMediaTypes)mediaType))
flag = ZuneApplication.ZuneLibrary.AddMedia(filename) != -1; flag = ZuneLibrary.AddMedia(filename) != -1;
} }
catch (UnauthorizedAccessException ex) catch (UnauthorizedAccessException ex)
{ {
@@ -507,8 +507,8 @@ namespace Microsoft.Zune.Shell
out int libraryID, out int libraryID,
out bool fFileAlreadyExists) out bool fFileAlreadyExists)
{ {
ZuneApplication._transientTableCleanupComplete.WaitOne(); _transientTableCleanupComplete.WaitOne();
return ZuneApplication.ZuneLibrary.AddTransientMedia(filename, (EMediaTypes)mediaType, out libraryID, out fFileAlreadyExists); return ZuneLibrary.AddTransientMedia(filename, (EMediaTypes)mediaType, out libraryID, out fFileAlreadyExists);
} }
private static void OnWindowCloseNotBlocked(object sender, EventArgs args) private static void OnWindowCloseNotBlocked(object sender, EventArgs args)
@@ -524,19 +524,19 @@ namespace Microsoft.Zune.Shell
ui = "res://ZuneShellResources!ConfirmClose.uix#ConfirmFirmwareUpdateCloseContentUI"; ui = "res://ZuneShellResources!ConfirmClose.uix#ConfirmFirmwareUpdateCloseContentUI";
else if (flag2) else if (flag2)
ui = "res://ZuneShellResources!ConfirmClose.uix#ConfirmFirmwareRestoreCloseContentUI"; ui = "res://ZuneShellResources!ConfirmClose.uix#ConfirmFirmwareRestoreCloseContentUI";
ConfirmCloseDialog.Show(ui, (EventHandler)delegate ConfirmCloseDialog.Show(ui, delegate
{ {
ZuneApplication.ForceClose(sender, args); ForceClose(sender, args);
}); });
} }
else else
ZuneApplication.ForceClose(sender, args); ForceClose(sender, args);
} }
private static void ForceClose(object sender, EventArgs args) private static void ForceClose(object sender, EventArgs args)
{ {
if (ZuneApplication.Closing != null) if (Closing != null)
ZuneApplication.Closing(sender, args); Closing(sender, args);
Application.Window.ForceClose(); Application.Window.ForceClose();
} }
@@ -547,10 +547,10 @@ namespace Microsoft.Zune.Shell
SingletonModelItem<TransportControls>.Instance.CloseCurrentSession(); SingletonModelItem<TransportControls>.Instance.CloseCurrentSession();
} }
public static void OnShowErrorDialog(int hr, uint uiStringId) => Application.DeferredInvoke(new DeferredInvokeHandler(ZuneApplication.DeferredShowErrorDialog), (object)new object[2] public static void OnShowErrorDialog(int hr, uint uiStringId) => Application.DeferredInvoke(new DeferredInvokeHandler(DeferredShowErrorDialog), new object[2]
{ {
(object) hr, hr,
(object) uiStringId uiStringId
}); });
public static void DeferredShowErrorDialog(object arg) public static void DeferredShowErrorDialog(object arg)
@@ -561,11 +561,11 @@ namespace Microsoft.Zune.Shell
private static void OnQuickMixPropertyChanged(object Sender, PropertyChangedEventArgs e) private static void OnQuickMixPropertyChanged(object Sender, PropertyChangedEventArgs e)
{ {
if (!(e.PropertyName == "Progress") || (double)ZuneApplication._quickMixProgress.Progress < 100.0) if (!(e.PropertyName == "Progress") || _quickMixProgress.Progress < 100.0)
return; return;
NotificationArea.Instance.Add((ZuneUI.Notification)new QuickMixNotification(ZuneUI.Shell.LoadString(StringId.IDS_QUICKMIX_NOTIFICATION_BOOTSTRAP_READY_TITLE), ZuneUI.Shell.LoadString(StringId.IDS_QUICKMIX_NOTIFICATION_BOOTSTRAP_READY_TEXT), NotificationState.Completed, true, 10000)); NotificationArea.Instance.Add(new QuickMixNotification(ZuneUI.Shell.LoadString(StringId.IDS_QUICKMIX_NOTIFICATION_BOOTSTRAP_READY_TITLE), ZuneUI.Shell.LoadString(StringId.IDS_QUICKMIX_NOTIFICATION_BOOTSTRAP_READY_TEXT), NotificationState.Completed, true, 10000));
ZuneApplication._quickMixProgress.PropertyChanged -= new PropertyChangedEventHandler(ZuneApplication.OnQuickMixPropertyChanged); _quickMixProgress.PropertyChanged -= new PropertyChangedEventHandler(OnQuickMixPropertyChanged);
ZuneApplication._quickMixProgress = (QuickMixProgress)null; _quickMixProgress = null;
} }
} }
} }
+2 -2
View File
@@ -15,12 +15,12 @@ namespace Microsoft.Zune.Shell
private string _context; private string _context;
public ZuneShellException(string message) public ZuneShellException(string message)
: this(message, (string)null) : this(message, null)
{ {
} }
public ZuneShellException(string message, string context) public ZuneShellException(string message, string context)
: base(ZuneShellException.PrepareMessage(message, context)) : base(PrepareMessage(message, context))
=> this._context = context; => this._context = context;
protected ZuneShellException(SerializationInfo info, StreamingContext context) protected ZuneShellException(SerializationInfo info, StreamingContext context)
+25 -25
View File
@@ -27,22 +27,22 @@ namespace Microsoft.Zune.Util
public static void Log(SQMDataId sqmDataId, int nData) public static void Log(SQMDataId sqmDataId, int nData)
{ {
SQMDataPoint dataPoint = SQMLog.FindDataPoint(sqmDataId); SQMDataPoint dataPoint = FindDataPoint(sqmDataId);
if (dataPoint.id == SQMDataId.Invalid) if (dataPoint.id == SQMDataId.Invalid)
return; return;
switch (dataPoint.action) switch (dataPoint.action)
{ {
case SQMAction.Add: case SQMAction.Add:
SQMLog.SQMAddWrapper(dataPoint.GetName(), nData); SQMAddWrapper(dataPoint.GetName(), nData);
break; break;
case SQMAction.Inc: case SQMAction.Inc:
SQMLog.SQMAddWrapper(dataPoint.GetName(), 1); SQMAddWrapper(dataPoint.GetName(), 1);
break; break;
case SQMAction.SetFlag: case SQMAction.SetFlag:
SQMLog.SQMSetFlagWrapper(dataPoint.GetName(), nData != 0); SQMSetFlagWrapper(dataPoint.GetName(), nData != 0);
break; break;
case SQMAction.SetBits: case SQMAction.SetBits:
SQMLog.SQMSetBitsWrapper(dataPoint.GetName(), (uint)nData); SQMSetBitsWrapper(dataPoint.GetName(), (uint)nData);
break; break;
default: default:
throw new ArgumentException("Datapoint " + dataPoint.GetName() + " is not a simple DWORD-type datapoint. Use LogToStream for stream-type datapoints."); throw new ArgumentException("Datapoint " + dataPoint.GetName() + " is not a simple DWORD-type datapoint. Use LogToStream for stream-type datapoints.");
@@ -52,7 +52,7 @@ namespace Microsoft.Zune.Util
public static void LogToStream(SQMDataId sqmDataId, params string[] args) public static void LogToStream(SQMDataId sqmDataId, params string[] args)
{ {
SQMDataPoint dataPoint = SQMLog.FindDataPoint(sqmDataId); SQMDataPoint dataPoint = FindDataPoint(sqmDataId);
if (dataPoint.id == SQMDataId.Invalid) if (dataPoint.id == SQMDataId.Invalid)
return; return;
if (dataPoint.action != SQMAction.MixedStream) if (dataPoint.action != SQMAction.MixedStream)
@@ -62,34 +62,34 @@ namespace Microsoft.Zune.Util
if (args.Length != dataPoint.argCount) if (args.Length != dataPoint.argCount)
throw new ArgumentException("Passed-in arg count doesn't match datapoint declaration: " + dataPoint.GetName(), "args.Length"); throw new ArgumentException("Passed-in arg count doesn't match datapoint declaration: " + dataPoint.GetName(), "args.Length");
if (args.Length == 1) if (args.Length == 1)
SQMLog.SQMAddToStream(dataPoint.GetName(), SQMLog.c_rgSPTArrayAllStrings, (uint)args.Length, args[0]); SQMAddToStream(dataPoint.GetName(), c_rgSPTArrayAllStrings, (uint)args.Length, args[0]);
else if (args.Length == 2) else if (args.Length == 2)
SQMLog.SQMAddToStream(dataPoint.GetName(), SQMLog.c_rgSPTArrayAllStrings, (uint)args.Length, args[0], args[1]); SQMAddToStream(dataPoint.GetName(), c_rgSPTArrayAllStrings, (uint)args.Length, args[0], args[1]);
else if (args.Length == 3) else if (args.Length == 3)
SQMLog.SQMAddToStream(dataPoint.GetName(), SQMLog.c_rgSPTArrayAllStrings, (uint)args.Length, args[0], args[1], args[2]); SQMAddToStream(dataPoint.GetName(), c_rgSPTArrayAllStrings, (uint)args.Length, args[0], args[1], args[2]);
else if (args.Length == 4) else if (args.Length == 4)
SQMLog.SQMAddToStream(dataPoint.GetName(), SQMLog.c_rgSPTArrayAllStrings, (uint)args.Length, args[0], args[1], args[2], args[3]); SQMAddToStream(dataPoint.GetName(), c_rgSPTArrayAllStrings, (uint)args.Length, args[0], args[1], args[2], args[3]);
else if (args.Length == 5) else if (args.Length == 5)
SQMLog.SQMAddToStream(dataPoint.GetName(), SQMLog.c_rgSPTArrayAllStrings, (uint)args.Length, args[0], args[1], args[2], args[3], args[4]); SQMAddToStream(dataPoint.GetName(), c_rgSPTArrayAllStrings, (uint)args.Length, args[0], args[1], args[2], args[3], args[4]);
else if (args.Length == 6) else if (args.Length == 6)
SQMLog.SQMAddToStream(dataPoint.GetName(), SQMLog.c_rgSPTArrayAllStrings, (uint)args.Length, args[0], args[1], args[2], args[3], args[4], args[5]); SQMAddToStream(dataPoint.GetName(), c_rgSPTArrayAllStrings, (uint)args.Length, args[0], args[1], args[2], args[3], args[4], args[5]);
else if (args.Length == 7) else if (args.Length == 7)
SQMLog.SQMAddToStream(dataPoint.GetName(), SQMLog.c_rgSPTArrayAllStrings, (uint)args.Length, args[0], args[1], args[2], args[3], args[4], args[5], args[6]); SQMAddToStream(dataPoint.GetName(), c_rgSPTArrayAllStrings, (uint)args.Length, args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
else if (args.Length == 8) else if (args.Length == 8)
{ {
SQMLog.SQMAddToStream(dataPoint.GetName(), SQMLog.c_rgSPTArrayAllStrings, (uint)args.Length, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]); SQMAddToStream(dataPoint.GetName(), c_rgSPTArrayAllStrings, (uint)args.Length, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]);
} }
else else
{ {
if (args.Length != 9) if (args.Length != 9)
return; return;
SQMLog.SQMAddToStream(dataPoint.GetName(), SQMLog.c_rgSPTArrayAllStrings, (uint)args.Length, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8]); SQMAddToStream(dataPoint.GetName(), c_rgSPTArrayAllStrings, (uint)args.Length, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8]);
} }
} }
public static void LogToStream(SQMDataId sqmDataId, params uint[] args) public static void LogToStream(SQMDataId sqmDataId, params uint[] args)
{ {
SQMDataPoint dataPoint = SQMLog.FindDataPoint(sqmDataId); SQMDataPoint dataPoint = FindDataPoint(sqmDataId);
if (dataPoint.id == SQMDataId.Invalid) if (dataPoint.id == SQMDataId.Invalid)
return; return;
if (dataPoint.action != SQMAction.NumStream) if (dataPoint.action != SQMAction.NumStream)
@@ -99,28 +99,28 @@ namespace Microsoft.Zune.Util
if (args.Length != dataPoint.argCount) if (args.Length != dataPoint.argCount)
throw new ArgumentException("Passed-in arg count doesn't match datapoint declaration: " + dataPoint.GetName(), "args.Length"); throw new ArgumentException("Passed-in arg count doesn't match datapoint declaration: " + dataPoint.GetName(), "args.Length");
if (args.Length == 1) if (args.Length == 1)
SQMLog.SQMAddNumbersToStream(dataPoint.GetName(), (uint)args.Length, args[0]); SQMAddNumbersToStream(dataPoint.GetName(), (uint)args.Length, args[0]);
else if (args.Length == 2) else if (args.Length == 2)
SQMLog.SQMAddNumbersToStream(dataPoint.GetName(), (uint)args.Length, args[0], args[1]); SQMAddNumbersToStream(dataPoint.GetName(), (uint)args.Length, args[0], args[1]);
else if (args.Length == 3) else if (args.Length == 3)
SQMLog.SQMAddNumbersToStream(dataPoint.GetName(), (uint)args.Length, args[0], args[1], args[2]); SQMAddNumbersToStream(dataPoint.GetName(), (uint)args.Length, args[0], args[1], args[2]);
else if (args.Length == 4) else if (args.Length == 4)
SQMLog.SQMAddNumbersToStream(dataPoint.GetName(), (uint)args.Length, args[0], args[1], args[2], args[3]); SQMAddNumbersToStream(dataPoint.GetName(), (uint)args.Length, args[0], args[1], args[2], args[3]);
else if (args.Length == 5) else if (args.Length == 5)
SQMLog.SQMAddNumbersToStream(dataPoint.GetName(), (uint)args.Length, args[0], args[1], args[2], args[3], args[4]); SQMAddNumbersToStream(dataPoint.GetName(), (uint)args.Length, args[0], args[1], args[2], args[3], args[4]);
else if (args.Length == 6) else if (args.Length == 6)
SQMLog.SQMAddNumbersToStream(dataPoint.GetName(), (uint)args.Length, args[0], args[1], args[2], args[3], args[4], args[5]); SQMAddNumbersToStream(dataPoint.GetName(), (uint)args.Length, args[0], args[1], args[2], args[3], args[4], args[5]);
else if (args.Length == 7) else if (args.Length == 7)
SQMLog.SQMAddNumbersToStream(dataPoint.GetName(), (uint)args.Length, args[0], args[1], args[2], args[3], args[4], args[5], args[6]); SQMAddNumbersToStream(dataPoint.GetName(), (uint)args.Length, args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
else if (args.Length == 8) else if (args.Length == 8)
{ {
SQMLog.SQMAddNumbersToStream(dataPoint.GetName(), (uint)args.Length, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]); SQMAddNumbersToStream(dataPoint.GetName(), (uint)args.Length, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]);
} }
else else
{ {
if (args.Length != 9) if (args.Length != 9)
return; return;
SQMLog.SQMAddNumbersToStream(dataPoint.GetName(), (uint)args.Length, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8]); SQMAddNumbersToStream(dataPoint.GetName(), (uint)args.Length, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8]);
} }
} }
+1 -1
View File
@@ -25,7 +25,7 @@ namespace ZuneUI
public WirelessStateResults StartOperation( public WirelessStateResults StartOperation(
UIDevice device, UIDevice device,
AsyncOperation.AOComplete completeFunc, AOComplete completeFunc,
bool fIgnoreErrors) bool fIgnoreErrors)
{ {
this.ResetState(fIgnoreErrors); this.ResetState(fIgnoreErrors);
+5 -5
View File
@@ -18,19 +18,19 @@ namespace ZuneUI
private WlanProfileList _computerProfiles; private WlanProfileList _computerProfiles;
private WlanProfile _connectedNetwork; private WlanProfile _connectedNetwork;
public WlanProfile ConnectedNetwork => this.Finished ? this._connectedNetwork : (WlanProfile)null; public WlanProfile ConnectedNetwork => this.Finished ? this._connectedNetwork : null;
private void ResetState() private void ResetState()
{ {
if (!this.Idle && !this.Finished) if (!this.Idle && !this.Finished)
return; return;
this._computerProfiles = new WlanProfileList(); this._computerProfiles = new WlanProfileList();
this._connectedNetwork = (WlanProfile)null; this._connectedNetwork = null;
} }
public WirelessStateResults StartOperation( public WirelessStateResults StartOperation(
UIDevice device, UIDevice device,
AsyncOperation.AOComplete completeFunc) AOComplete completeFunc)
{ {
this.ResetState(); this.ResetState();
return this.StartOperation(device, completeFunc, this._getConnectedNetworkStates); return this.StartOperation(device, completeFunc, this._getConnectedNetworkStates);
@@ -47,10 +47,10 @@ namespace ZuneUI
protected override void EndOperation(WirelessStateResults result) protected override void EndOperation(WirelessStateResults result)
{ {
this._connectedNetwork = (WlanProfile)null; this._connectedNetwork = null;
if (this._computerProfiles == null) if (this._computerProfiles == null)
return; return;
foreach (WlanProfile computerProfile in (List<WlanProfile>)this._computerProfiles) foreach (WlanProfile computerProfile in _computerProfiles)
{ {
if (computerProfile.Connected) if (computerProfile.Connected)
{ {
+3 -3
View File
@@ -16,11 +16,11 @@ namespace ZuneUI
}; };
private WlanProfile _deviceProfile; private WlanProfile _deviceProfile;
public WlanProfile DeviceProfile => this.Finished ? this._deviceProfile : (WlanProfile)null; public WlanProfile DeviceProfile => this.Finished ? this._deviceProfile : null;
public WirelessStateResults StartOperation( public WirelessStateResults StartOperation(
UIDevice device, UIDevice device,
AsyncOperation.AOComplete completeFunc) AOComplete completeFunc)
{ {
this.ResetState(); this.ResetState();
return this.StartOperation(device, completeFunc, this._getDeviceProfileStates); return this.StartOperation(device, completeFunc, this._getDeviceProfileStates);
@@ -39,7 +39,7 @@ namespace ZuneUI
protected override void RemoveListeners() => this._device.WiFiProfilesReceivedEvent -= new FallibleEventHandler(this.Device_GetDeviceWlanProfilesCompleteEvent); protected override void RemoveListeners() => this._device.WiFiProfilesReceivedEvent -= new FallibleEventHandler(this.Device_GetDeviceWlanProfilesCompleteEvent);
private void ResetState() => this._deviceProfile = (WlanProfile)null; private void ResetState() => this._deviceProfile = null;
private void Device_GetDeviceWlanProfilesCompleteEvent(object sender, FallibleEventArgs args) private void Device_GetDeviceWlanProfilesCompleteEvent(object sender, FallibleEventArgs args)
{ {
+5 -5
View File
@@ -20,7 +20,7 @@ namespace ZuneUI
WirelessStates.SniffNetworks WirelessStates.SniffNetworks
}; };
public WlanProfileList NetworkList => this.Finished ? this._networkList : (WlanProfileList)null; public WlanProfileList NetworkList => this.Finished ? this._networkList : null;
private void ResetState() private void ResetState()
{ {
@@ -33,7 +33,7 @@ namespace ZuneUI
public WirelessStateResults StartOperation( public WirelessStateResults StartOperation(
UIDevice device, UIDevice device,
AsyncOperation.AOComplete completeFunc) AOComplete completeFunc)
{ {
this.ResetState(); this.ResetState();
return this.StartOperation(device, completeFunc, this._getNetworkListStates); return this.StartOperation(device, completeFunc, this._getNetworkListStates);
@@ -65,12 +65,12 @@ namespace ZuneUI
Dictionary<string, WlanProfile> dictionary = new Dictionary<string, WlanProfile>(); Dictionary<string, WlanProfile> dictionary = new Dictionary<string, WlanProfile>();
if (this._deviceNetworks != null) if (this._deviceNetworks != null)
{ {
foreach (WlanProfile deviceNetwork in (List<WlanProfile>)this._deviceNetworks) foreach (WlanProfile deviceNetwork in _deviceNetworks)
{ {
if (!dictionary.ContainsKey(deviceNetwork.SSID)) if (!dictionary.ContainsKey(deviceNetwork.SSID))
{ {
WlanProfile wlanProfile = deviceNetwork; WlanProfile wlanProfile = deviceNetwork;
foreach (WlanProfile computerNetwork in (List<WlanProfile>)this._computerNetworks) foreach (WlanProfile computerNetwork in _computerNetworks)
{ {
if (computerNetwork.SSID == deviceNetwork.SSID) if (computerNetwork.SSID == deviceNetwork.SSID)
{ {
@@ -85,7 +85,7 @@ namespace ZuneUI
} }
} }
} }
this._networkList.Sort((IComparer<WlanProfile>)new WlanSignalStrenghComparer()); this._networkList.Sort(new WlanSignalStrenghComparer());
} }
protected override void AddListeners() protected override void AddListeners()
+8 -8
View File
@@ -34,7 +34,7 @@ namespace ZuneUI
public override void Cancel() public override void Cancel()
{ {
base.Cancel(); base.Cancel();
if (this.Idle || this.Finished || this._setProfileStates[AsyncOperation._iCurrentState] != WirelessStates.TestDeviceProfile) if (this.Idle || this.Finished || this._setProfileStates[_iCurrentState] != WirelessStates.TestDeviceProfile)
return; return;
this._device.CancelWiFiTest(); this._device.CancelWiFiTest();
} }
@@ -45,16 +45,16 @@ namespace ZuneUI
return; return;
this._attemptingName = profile.SSID; this._attemptingName = profile.SSID;
this._attemptingProfile = profile; this._attemptingProfile = profile;
this._deviceProfile = (WlanProfile)null; this._deviceProfile = null;
this._fProfileSaved = false; this._fProfileSaved = false;
this._wlanTestResult = (string)null; this._wlanTestResult = null;
this._wlanTestResultCode = HRESULT._S_OK; this._wlanTestResultCode = HRESULT._S_OK;
this._restore.Reset(); this._restore.Reset();
} }
public WirelessStateResults StartOperation( public WirelessStateResults StartOperation(
UIDevice device, UIDevice device,
AsyncOperation.AOComplete completeFunc, AOComplete completeFunc,
WlanProfile newProfile) WlanProfile newProfile)
{ {
if (newProfile == null) if (newProfile == null)
@@ -106,17 +106,17 @@ namespace ZuneUI
if (result == WirelessStateResults.Canceled) if (result == WirelessStateResults.Canceled)
{ {
this._error = Shell.LoadString(StringId.IDS_WIRELESS_SYNC_SETUP_CANCELED); this._error = Shell.LoadString(StringId.IDS_WIRELESS_SYNC_SETUP_CANCELED);
this._detailedError = (string)null; this._detailedError = null;
this._hr = HRESULT._S_OK; this._hr = HRESULT._S_OK;
} }
else if (this._attemptingProfile != null) else if (this._attemptingProfile != null)
this._error = string.Format(Shell.LoadString(StringId.IDS_WIRELESS_SYNC_SETUP_FAILED), (object)this._attemptingProfile.SSID); this._error = string.Format(Shell.LoadString(StringId.IDS_WIRELESS_SYNC_SETUP_FAILED), _attemptingProfile.SSID);
else else
this._error = Shell.LoadString(StringId.IDS_WIRELESS_SYNC_SETUP_FAILED_GENERIC); this._error = Shell.LoadString(StringId.IDS_WIRELESS_SYNC_SETUP_FAILED_GENERIC);
} }
else if (!string.IsNullOrEmpty(this._wlanTestResult)) else if (!string.IsNullOrEmpty(this._wlanTestResult))
{ {
this._error = string.Format(Shell.LoadString(StringId.IDS_WIRELESS_SYNC_TEST_FAILED), (object)this._attemptingProfile.SSID); this._error = string.Format(Shell.LoadString(StringId.IDS_WIRELESS_SYNC_TEST_FAILED), _attemptingProfile.SSID);
this._detailedError = this._wlanTestResult; this._detailedError = this._wlanTestResult;
this._hr = this._wlanTestResultCode; this._hr = this._wlanTestResultCode;
} }
@@ -162,7 +162,7 @@ namespace ZuneUI
{ {
WlanProfileList list = new WlanProfileList(); WlanProfileList list = new WlanProfileList();
hr = this._device.GetWiFiProfileList(ref list); hr = this._device.GetWiFiProfileList(ref list);
this._deviceProfile = list.Count <= 0 ? (WlanProfile)null : list[0]; this._deviceProfile = list.Count <= 0 ? null : list[0];
} }
if (hr.IsSuccess) if (hr.IsSuccess)
this.StepComplete(WirelessStateResults.Success); this.StepComplete(WirelessStateResults.Success);
+33 -33
View File
@@ -36,26 +36,26 @@ namespace ZuneUI
get get
{ {
this.LoadStateData(); this.LoadStateData();
ArrayList arrayList = (ArrayList)null; ArrayList arrayList = null;
if (this.m_states != null) if (this.m_states != null)
{ {
arrayList = new ArrayList(this.m_states.Values.Count); arrayList = new ArrayList(this.m_states.Values.Count);
arrayList.AddRange((ICollection)this.m_states.Values); arrayList.AddRange((ICollection)this.m_states.Values);
arrayList.Sort((IComparer)StringComparer.CurrentCultureIgnoreCase); arrayList.Sort(StringComparer.CurrentCultureIgnoreCase);
} }
return (IList)arrayList; return arrayList;
} }
} }
public CountryFieldValidator GetValidator(CountryFieldValidatorType type) public CountryFieldValidator GetValidator(CountryFieldValidatorType type)
{ {
CountryFieldValidator countryFieldValidator = (CountryFieldValidator)null; CountryFieldValidator countryFieldValidator = null;
if (this.Validators != null && AccountCountry.CountryFieldValidatorLookup.ContainsKey((object)type)) if (this.Validators != null && CountryFieldValidatorLookup.ContainsKey(type))
{ {
for (int index = 0; index < this.Validators.Length; ++index) for (int index = 0; index < this.Validators.Length; ++index)
{ {
CountryFieldValidator validator = this.Validators[index]; CountryFieldValidator validator = this.Validators[index];
if (validator.Name == (string)AccountCountry.CountryFieldValidatorLookup[(object)type]) if (validator.Name == (string)CountryFieldValidatorLookup[type])
{ {
countryFieldValidator = validator; countryFieldValidator = validator;
break; break;
@@ -70,25 +70,25 @@ namespace ZuneUI
get get
{ {
this.LoadStateData(); this.LoadStateData();
string[] array = (string[])null; string[] array = null;
if (this.m_states != null) if (this.m_states != null)
{ {
array = new string[this.m_states.Keys.Count]; array = new string[this.m_states.Keys.Count];
this.m_states.Keys.CopyTo(array, 0); this.m_states.Keys.CopyTo(array, 0);
} }
return (IList)array; return array;
} }
} }
public static AccountCountry Create(CountryBaseDetails details) public static AccountCountry Create(CountryBaseDetails details)
{ {
AccountCountry accountCountry = (AccountCountry)null; AccountCountry accountCountry = null;
if (details != null) if (details != null)
{ {
string[] languageAbbreviations = details.LanguageAbbreviations; string[] languageAbbreviations = details.LanguageAbbreviations;
if (languageAbbreviations != null) if (languageAbbreviations != null)
Array.Sort<string>(languageAbbreviations, LanguageNameComparer.Instance); Array.Sort(languageAbbreviations, LanguageNameComparer.Instance);
string localizedStates = (string)null; string localizedStates = null;
if (details.Abbreviation.Equals("US", StringComparison.InvariantCultureIgnoreCase)) if (details.Abbreviation.Equals("US", StringComparison.InvariantCultureIgnoreCase))
localizedStates = Shell.LoadString(StringId.IDS_BILLING_USA_STATES); localizedStates = Shell.LoadString(StringId.IDS_BILLING_USA_STATES);
else if (details.Abbreviation.Equals("CA", StringComparison.InvariantCultureIgnoreCase)) else if (details.Abbreviation.Equals("CA", StringComparison.InvariantCultureIgnoreCase))
@@ -102,26 +102,26 @@ namespace ZuneUI
{ {
get get
{ {
if (AccountCountry.m_countryFieldValidatorLookup == null) if (m_countryFieldValidatorLookup == null)
{ {
AccountCountry.m_countryFieldValidatorLookup = new Hashtable(); m_countryFieldValidatorLookup = new Hashtable();
AccountCountry.m_countryFieldValidatorLookup.Add((object)CountryFieldValidatorType.FirstName, (object)"firstName"); m_countryFieldValidatorLookup.Add(CountryFieldValidatorType.FirstName, "firstName");
AccountCountry.m_countryFieldValidatorLookup.Add((object)CountryFieldValidatorType.LastName, (object)"lastName"); m_countryFieldValidatorLookup.Add(CountryFieldValidatorType.LastName, "lastName");
AccountCountry.m_countryFieldValidatorLookup.Add((object)CountryFieldValidatorType.AccountHolderName, (object)"accountHolderName"); m_countryFieldValidatorLookup.Add(CountryFieldValidatorType.AccountHolderName, "accountHolderName");
AccountCountry.m_countryFieldValidatorLookup.Add((object)CountryFieldValidatorType.Street1, (object)"street1"); m_countryFieldValidatorLookup.Add(CountryFieldValidatorType.Street1, "street1");
AccountCountry.m_countryFieldValidatorLookup.Add((object)CountryFieldValidatorType.Street2, (object)"street2"); m_countryFieldValidatorLookup.Add(CountryFieldValidatorType.Street2, "street2");
AccountCountry.m_countryFieldValidatorLookup.Add((object)CountryFieldValidatorType.City, (object)"city"); m_countryFieldValidatorLookup.Add(CountryFieldValidatorType.City, "city");
AccountCountry.m_countryFieldValidatorLookup.Add((object)CountryFieldValidatorType.State, (object)"state"); m_countryFieldValidatorLookup.Add(CountryFieldValidatorType.State, "state");
AccountCountry.m_countryFieldValidatorLookup.Add((object)CountryFieldValidatorType.PostalCode, (object)"postalCode"); m_countryFieldValidatorLookup.Add(CountryFieldValidatorType.PostalCode, "postalCode");
AccountCountry.m_countryFieldValidatorLookup.Add((object)CountryFieldValidatorType.District, (object)"district"); m_countryFieldValidatorLookup.Add(CountryFieldValidatorType.District, "district");
AccountCountry.m_countryFieldValidatorLookup.Add((object)CountryFieldValidatorType.Country, (object)"country"); m_countryFieldValidatorLookup.Add(CountryFieldValidatorType.Country, "country");
AccountCountry.m_countryFieldValidatorLookup.Add((object)CountryFieldValidatorType.PhoneType, (object)"phoneType"); m_countryFieldValidatorLookup.Add(CountryFieldValidatorType.PhoneType, "phoneType");
AccountCountry.m_countryFieldValidatorLookup.Add((object)CountryFieldValidatorType.PhonePrefix, (object)"phonePrefix"); m_countryFieldValidatorLookup.Add(CountryFieldValidatorType.PhonePrefix, "phonePrefix");
AccountCountry.m_countryFieldValidatorLookup.Add((object)CountryFieldValidatorType.PhoneNumber, (object)"phoneNumber"); m_countryFieldValidatorLookup.Add(CountryFieldValidatorType.PhoneNumber, "phoneNumber");
AccountCountry.m_countryFieldValidatorLookup.Add((object)CountryFieldValidatorType.PhoneCountryCode, (object)"phoneCountryCode"); m_countryFieldValidatorLookup.Add(CountryFieldValidatorType.PhoneCountryCode, "phoneCountryCode");
AccountCountry.m_countryFieldValidatorLookup.Add((object)CountryFieldValidatorType.PhoneExtension, (object)"phoneExtension"); m_countryFieldValidatorLookup.Add(CountryFieldValidatorType.PhoneExtension, "phoneExtension");
} }
return AccountCountry.m_countryFieldValidatorLookup; return m_countryFieldValidatorLookup;
} }
} }
@@ -134,7 +134,7 @@ namespace ZuneUI
';' ';'
}, StringSplitOptions.RemoveEmptyEntries); }, StringSplitOptions.RemoveEmptyEntries);
int capacity = strArray.Length / 2; int capacity = strArray.Length / 2;
this.m_states = (IDictionary<string, string>)new Dictionary<string, string>(capacity); this.m_states = new Dictionary<string, string>(capacity);
int index1 = 0; int index1 = 0;
int index2 = 1; int index2 = 1;
for (int index3 = 0; index3 < capacity; ++index3) for (int index3 = 0; index3 < capacity; ++index3)
@@ -149,10 +149,10 @@ namespace ZuneUI
public string GetStateAbbreviation(string stateName) public string GetStateAbbreviation(string stateName)
{ {
this.LoadStateData(); this.LoadStateData();
string str = (string)null; string str = null;
if (this.m_states != null && stateName != null) if (this.m_states != null && stateName != null)
{ {
foreach (KeyValuePair<string, string> state in (IEnumerable<KeyValuePair<string, string>>)this.m_states) foreach (KeyValuePair<string, string> state in m_states)
{ {
if (state.Value.Equals(stateName, StringComparison.InvariantCultureIgnoreCase)) if (state.Value.Equals(stateName, StringComparison.InvariantCultureIgnoreCase))
{ {
@@ -167,7 +167,7 @@ namespace ZuneUI
public string GetState(string stateAbbreviation) public string GetState(string stateAbbreviation)
{ {
this.LoadStateData(); this.LoadStateData();
string str = (string)null; string str = null;
if (this.m_states != null && stateAbbreviation != null && this.m_states.ContainsKey(stateAbbreviation)) if (this.m_states != null && stateAbbreviation != null && this.m_states.ContainsKey(stateAbbreviation))
str = this.m_states[stateAbbreviation]; str = this.m_states[stateAbbreviation];
return str; return str;
+10 -10
View File
@@ -25,9 +25,9 @@ namespace ZuneUI
{ {
get get
{ {
if (AccountCountryList.s_instance == null) if (s_instance == null)
AccountCountryList.s_instance = new AccountCountryList(); s_instance = new AccountCountryList();
return AccountCountryList.s_instance; return s_instance;
} }
} }
@@ -35,13 +35,13 @@ namespace ZuneUI
{ {
get get
{ {
string[] array = (string[])null; string[] array = null;
if (this._countries != null) if (this._countries != null)
{ {
array = new string[this._countries.Keys.Count]; array = new string[this._countries.Keys.Count];
this._countries.Keys.CopyTo(array, 0); this._countries.Keys.CopyTo(array, 0);
} }
return (IList)array; return array;
} }
} }
@@ -49,7 +49,7 @@ namespace ZuneUI
public AccountCountry GetCountry(string abbreviation) public AccountCountry GetCountry(string abbreviation)
{ {
AccountCountry accountCountry = (AccountCountry)null; AccountCountry accountCountry = null;
if (this._countries != null && abbreviation != null && this._countries.ContainsKey(abbreviation)) if (this._countries != null && abbreviation != null && this._countries.ContainsKey(abbreviation))
accountCountry = this._countries[abbreviation]; accountCountry = this._countries[abbreviation];
return accountCountry; return accountCountry;
@@ -64,8 +64,8 @@ namespace ZuneUI
bool flag = true; bool flag = true;
if (this._countries == null) if (this._countries == null)
{ {
CountryBaseDetails[] countryDetails = Microsoft.Zune.Service.Service.Instance.GetCountryDetails(); CountryBaseDetails[] countryDetails = Service.Instance.GetCountryDetails();
SortedDictionary<string, AccountCountry> sortedDictionary = (SortedDictionary<string, AccountCountry>)null; SortedDictionary<string, AccountCountry> sortedDictionary = null;
if (countryDetails != null && countryDetails.Length > 0) if (countryDetails != null && countryDetails.Length > 0)
{ {
sortedDictionary = new SortedDictionary<string, AccountCountry>(CountryNameComparer.Instance); sortedDictionary = new SortedDictionary<string, AccountCountry>(CountryNameComparer.Instance);
@@ -75,10 +75,10 @@ namespace ZuneUI
if (sortedDictionary == null || sortedDictionary.Count == 0) if (sortedDictionary == null || sortedDictionary.Count == 0)
flag = false; flag = false;
else else
this._countries = (IDictionary<string, AccountCountry>)sortedDictionary; this._countries = sortedDictionary;
} }
if (flag) if (flag)
Application.DeferredInvoke(new DeferredInvokeHandler(this.NotifyLoaded), (object)null); Application.DeferredInvoke(new DeferredInvokeHandler(this.NotifyLoaded), null);
return flag; return flag;
} }

Some files were not shown because too many files have changed in this diff Show More