本文整理汇总了C#中System.Guid.CompareTo方法的典型用法代码示例。如果您正苦于以下问题:C# Guid.CompareTo方法的具体用法?C# Guid.CompareTo怎么用?C# Guid.CompareTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Guid
的用法示例。
在下文中一共展示了Guid.CompareTo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: typeof
int IServiceProvider.QueryService(ref Guid guidService, ref Guid riid, out IntPtr ppvObject)
{
////int hr = HRESULT.E_NOINTERFACE;
//if (guidService == IID_IAuthenticate && riid == IID_IAuthenticate)
//{
// ppvObject = Marshal.GetComInterfaceForObject(this, typeof(IAuthenticate)); // this as IAuthenticate; //
// //if (ppvObject != null) {
// // hr = HRESULT.S_OK;
// //}
//}
//else
//{
// ppvObject = IntPtr.Zero;
//}
////return hr;
int nRet = guidService.CompareTo(IID_IAuthenticate); // Zero
//returned if the compared objects are equal
if (nRet == 0)
{
nRet = riid.CompareTo(IID_IAuthenticate); // Zero
//returned if the compared objects are equal
if (nRet == 0)
{
ppvObject = Marshal.GetComInterfaceForObject(this, typeof(IAuthenticate));
return S_OK;
}
}
ppvObject = new IntPtr();
return INET_E_DEFAULT_ACTION;
}
示例2: ExportAttachments
protected override Guid ExportAttachments(JsonTextWriter jsonWriter, Guid lastEtag)
{
var totalCount = 0;
while (true)
{
var array = GetAttachments(totalCount, lastEtag);
if (array.Length == 0)
{
var databaseStatistics = GetStats();
if (lastEtag.CompareTo(databaseStatistics.LastAttachmentEtag) < 0)
{
lastEtag = Etag.Increment(lastEtag, smugglerOptions.BatchSize);
ShowProgress("Got no results but didn't get to the last attachment etag, trying from: {0}", lastEtag);
continue;
}
ShowProgress("Done with reading attachments, total: {0}", totalCount);
return lastEtag;
}
totalCount += array.Length;
ShowProgress("Reading batch of {0,3} attachments, read so far: {1,10:#,#;;0}", array.Length, totalCount);
foreach (var item in array)
{
item.WriteTo(jsonWriter);
}
lastEtag = new Guid(array.Last().Value<string>("Etag"));
}
}
示例3: IsSqlProj
public static bool IsSqlProj(EnvDTE.Project project)
{
if (project != null)
{
string kind = project.Kind;
if (string.IsNullOrEmpty(kind) == false)
{
Guid thisProjectGuid = new Guid(kind);
Guid databaseProjectGuid = new Guid(GuidList.guidSqlProjProjectString);
if (thisProjectGuid.CompareTo(databaseProjectGuid) == 0)
{
return true;
}
}
}
return false;
}
示例4: PosTest1
public bool PosTest1()
{
bool retVal = true;
Guid g1;
Guid g2;
int a;
short b;
short c;
byte[] d;
int compare;
TestLibrary.TestFramework.BeginScenario("PosTest1: Guid.CompareTo(Guid) always equals");
try
{
d = new byte[8];
for(int i=0;i<d.Length; i++) d[i] = TestLibrary.Generator.GetByte(-55);
a = TestLibrary.Generator.GetInt32(-55);
b = TestLibrary.Generator.GetInt16(-55);
c = TestLibrary.Generator.GetInt16(-55);
g1 = new Guid(a, b, c, d);
// equals
g2 = new Guid(a, b, c, d);
compare = g1.CompareTo(g2);
if (0 != compare)
{
TestLibrary.TestFramework.LogError("000", "Guid1: " + g1);
TestLibrary.TestFramework.LogError("001", "Guid2: " + g2);
TestLibrary.TestFramework.LogError("002", "Compare mismatch: Exepcted(0) Actual("+compare+")");
retVal = false;
}
}
catch (Exception e)
{
TestLibrary.TestFramework.LogError("003", "Unexpected exception: " + e);
retVal = false;
}
return retVal;
}
示例5: IsStaleByEtag
private bool IsStaleByEtag(string entityName, DateTime? cutOff)
{
var lastIndexedEtag = new Guid(
Api.RetrieveColumn(session, IndexesStats, tableColumnsCache.IndexesStatsColumns["last_indexed_etag"])
);
Api.JetSetCurrentIndex(session, Documents, "by_etag");
if (!Api.TryMoveLast(session, Documents))
{
return false;
}
do
{
var lastEtag =
new Guid(Api.RetrieveColumn(session, Documents, tableColumnsCache.DocumentsColumns["etag"]));
if (lastEtag.CompareTo(lastIndexedEtag) <= 0)
break;
if (entityName != null)
{
var metadata =
Api.RetrieveColumn(session, Documents, tableColumnsCache.DocumentsColumns["metadata"]).
ToJObject();
if (metadata.Value<string>("Raven-Entity-Name") != entityName)
continue;
}
if (cutOff != null)
{
var lastIndexedTimestamp =
Api.RetrieveColumnAsDateTime(session, IndexesStats,
tableColumnsCache.IndexesStatsColumns["last_indexed_timestamp"])
.Value;
if (cutOff.Value > lastIndexedTimestamp)
return true;
}
else
{
return true;
}
} while (Api.TryMovePrevious(session, Documents));
return false;
}
示例6: PosTest1
public bool PosTest1()
{
bool retVal = true;
TestLibrary.TestFramework.BeginScenario("PosTest1: Call CompareTo to compare with guid itself");
try
{
Guid guid = new Guid();
int result = guid.CompareTo(guid);
if ( result != 0)
{
TestLibrary.TestFramework.LogError("001.1", "Call CompareTo to compare with guid itself does not return 0");
TestLibrary.TestFramework.LogInformation("WARNING [LOCAL VARIABLE] guid = " + guid + ", result = " + result);
retVal = false;
}
byte[] bytes = new byte[c_GUID_BYTE_ARRAY_SIZE];
TestLibrary.Generator.GetBytes(-55, bytes);
guid = new Guid(bytes);
result = guid.CompareTo(guid);
if (result != 0)
{
TestLibrary.TestFramework.LogError("001.2", "Call CompareTo to compare with guid itself does not return 0");
TestLibrary.TestFramework.LogInformation("WARNING [LOCAL VARIABLE] guid = " + guid + ", result = " + result);
retVal = false;
}
}
catch (Exception e)
{
TestLibrary.TestFramework.LogError("001.0", "Unexpected exception: " + e);
TestLibrary.TestFramework.LogInformation(e.StackTrace);
retVal = false;
}
return retVal;
}
示例7: GetDatabaseProjects
public static IList<EnvDTE.Project> GetDatabaseProjects(DTE2 applicationObject)
{
IList<EnvDTE.Project> foundProjects = new List<EnvDTE.Project>();
foreach (EnvDTE.Project proj in applicationObject.Solution.Projects)
{
EnvDTE.Project thisProject = proj as EnvDTE.Project;
if (thisProject != null)
{
string kind = thisProject.Kind;
if (string.IsNullOrEmpty(kind) == false)
{
Guid thisProjectGuid = new Guid(kind);
Guid databaseProjectGuid = new Guid(GuidList.guidSqlProjProjectString);
if (thisProjectGuid.CompareTo(databaseProjectGuid) == 0)
{
foundProjects.Add(thisProject);
}
}
}
}
return foundProjects;
}
示例8: GetGuidProperty
/// <include file='doc\Project.uex' path='docs/doc[@for="Project.GetGuidProperty"]/*' />
public override int GetGuidProperty(int propid, out Guid guid)
{
guid = Guid.Empty;
switch ((__VSHPROPID)propid)
{
case __VSHPROPID.VSHPROPID_ProjectIDGuid:
guid = ProjectIDGuid;
break;
case __VSHPROPID.VSHPROPID_CmdUIGuid:
guid = VsMenus.guidStandardCommandSet2K;
break;
} //-2054, PreferredLanguageSID?
CCITracing.TraceCall(String.Format("Property {0} not found", propid));
if (guid.CompareTo(Guid.Empty) == 0)
return NativeMethods.DISP_E_MEMBERNOTFOUND;
return NativeMethods.S_OK;
}
示例9: GetGuidProperty
/// <summary>
/// Gets the GUID value of the node.
/// </summary>
/// <param name="propid">A __VSHPROPID or __VSHPROPID2 value of the guid property</param>
/// <param name="guid">The guid to return for the property.</param>
/// <returns>A success or failure value.</returns>
public override int GetGuidProperty(int propid, out Guid guid)
{
guid = Guid.Empty;
if ((__VSHPROPID)propid == __VSHPROPID.VSHPROPID_ProjectIDGuid)
{
guid = this.ProjectIDGuid;
}
else if (propid == (int)__VSHPROPID.VSHPROPID_CmdUIGuid)
{
guid = this.ProjectGuid;
}
else if ((__VSHPROPID2)propid == __VSHPROPID2.VSHPROPID_ProjectDesignerEditor && this.SupportsProjectDesigner)
{
guid = this.ProjectDesignerEditor;
}
else
{
base.GetGuidProperty(propid, out guid);
}
if (guid.CompareTo(Guid.Empty) == 0)
{
return VSConstants.DISP_E_MEMBERNOTFOUND;
}
return VSConstants.S_OK;
}
示例10: IntPtr
/// <summary>
/// <c>QueryService</c>IServiceProvider interface method implementation
/// </summary>
/// <param name="guidService"></param>
/// <param name="riid"></param>
/// <param name="ppvObject"></param>
/// <returns></returns>
int Interfaces.IServiceProvider.QueryService(ref Guid guidService, ref Guid riid, out IntPtr ppvObject)
{
ppvObject = new IntPtr();
try
{
int nRet = guidService.CompareTo(IID_IAuthenticate);
// Zero //returned if the compared objects are equal
if (nRet == 0)
{
nRet = riid.CompareTo(IID_IAuthenticate);
// Zero //returned if the compared objects are equal
if (nRet == 0)
{
ppvObject = Marshal.GetComInterfaceForObject(this, typeof(IAuthenticate));
return S_OK;
}
}
}
catch (Exception ex)
{ }
return INET_E_DEFAULT_ACTION;
}
示例11: AudioGUIDToString
protected string AudioGUIDToString(Guid guid)
{
if (guid.CompareTo(BDAudioGuids.AC3) == 0)
return "AC3";
else if (guid.CompareTo(BDAudioGuids.DOLBY_DDPLUS) == 0)
return "AC3+";
else if (guid.CompareTo(BDAudioGuids.DTS) == 0)
return "DTS";
else if (guid.CompareTo(BDAudioGuids.DTS_HD) == 0)
return "DTS-HD";
else if (guid.CompareTo(BDAudioGuids.DTSHD_MASTER) == 0)
return "DTS-HD Master";
else if (guid.CompareTo(BDAudioGuids.LPCM) == 0)
return "LPCM";
else if (guid.CompareTo(BDAudioGuids.DOLBY_TRUEHD) == 0)
return "TrueHD";
else if (guid.CompareTo(MediaSubType.MPEG1Audio) == 0)
return "MPEG1";
else if (guid.CompareTo(MediaSubType.Mpeg2Audio) == 0)
return "MPEG2";
else
return Strings.Unknown;
}
示例12: Guid_CompareTo_Test9
public MFTestResults Guid_CompareTo_Test9()
{
/// <summary>
/// 1. Creates Guids with different values
/// 2. Verifies their equality using CompareTo
/// </summary>
///
MFTestResults testResult = MFTestResults.Pass;
Guid guid1 = Guid.Empty;
Log.Comment("Verifing any instance of Guid, regardless of its value, is greater than null");
if (guid1.CompareTo(null) <= 0)
{
Log.Comment("Expected : " + guid1.ToString() + " is greater than null");
testResult = MFTestResults.Fail;
}
Byte[] _bArr = new Byte[16];
Log.Comment("Creating a Guid with all bytes zero");
Guid guid2 = new Guid(_bArr);
if (guid1.CompareTo(guid2) != 0)
{
Log.Comment("Expected : " + guid1.ToString() + " equals " + guid2.ToString());
testResult = MFTestResults.Fail;
}
Guid guid3 = new Guid(0x4dff36b5, 0x9dde, 0x4f76, 0x9a, 0x2a, 0x96, 0x43, 0x50, 0x47, 0x06, 0x3d);
if (guid3.CompareTo(guid1) <= 0)
{
Log.Comment("Expected : " + guid3.ToString() + " is greater than " + guid1.ToString());
testResult = MFTestResults.Fail;
}
Guid guid4 = new Guid(0x4dff36b5, 0x9dde, 0x4f76, 0x9a, 0x2a, 0x96, 0x43, 0x50, 0x47, 0x06, 0x3d);
if (guid4.CompareTo(guid3) != 0)
{
Log.Comment("Expected : " + guid4.ToString() + " is equal to " + guid3.ToString());
testResult = MFTestResults.Fail;
}
Guid guid5 = new Guid(0x4dff36b5, 0x9dde, 0x4f76, 0x9a, 0x2a, 0x96, 0x43, 0x50, 0x47, 0x06, 0x3e);
if (guid5.CompareTo(guid4) <= 0)
{
Log.Comment("Expected : " + guid5.ToString() + " is greater than " + guid4.ToString());
testResult = MFTestResults.Fail;
}
if (guid4.CompareTo(guid5) >= 0)
{
Log.Comment("Expected : " + guid4.ToString() + " is less than " + guid5.ToString());
testResult = MFTestResults.Fail;
}
return testResult;
}
示例13: VerificationHelper
private bool VerificationHelper(Guid guid1, Guid guid2, bool greaterThanZero, string errorNo)
{
bool retVal = true;
int result = guid1.CompareTo(guid2);
bool actual = result > 0;
if (actual != greaterThanZero)
{
TestLibrary.TestFramework.LogError(errorNo, "Call CompareTo to compare with guid itself does not return 0");
TestLibrary.TestFramework.LogInformation("WARNING [LOCAL VARIABLE] guid1 = " + guid1 + ", guid2 = " + guid2 + ", greaterThanZero = " + greaterThanZero + ", result = " + result + ", actual = " + actual);
retVal = false;
}
return retVal;
}
示例14: QueryService
public int QueryService(ref Guid guidService, ref Guid riid, out IntPtr ppvObject)
{
if (guidService.CompareTo(Win32.IID_IAuthenticate) == 0 && riid.CompareTo(Win32.IID_IAuthenticate) == 0)
{
ppvObject = Marshal.GetComInterfaceForObject(this, typeof(Win32.IAuthenticate));
return Win32.S_OK;
}
else
{
ppvObject = IntPtr.Zero;
return Win32.INET_E_DEFAULT_ACTION;
}
}
示例15: StopMonitoring
public void StopMonitoring(Guid subscriptionToken)
{
if (subscriptionToken.CompareTo(_subscriptionToken) != 0) {
throw new InvalidOperationException("Invalid subscription token. Cannot stop monitoring.");
}
}