本文整理汇总了C#中Guid类的典型用法代码示例。如果您正苦于以下问题:C# Guid类的具体用法?C# Guid怎么用?C# Guid使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Guid类属于命名空间,在下文中一共展示了Guid类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateInfoDC
public UpdateInfoDC(Guid registrationId, Guid client, string meshId, PeerNodeAddress address)
{
this.ClientId = client;
this.MeshId = meshId;
this.NodeAddress = address;
this.RegistrationId = registrationId;
}
示例2: LogHttpResponse
public static void LogHttpResponse(this DiagnosticListener @this, HttpResponseMessage response, Guid loggingRequestId)
{
if (@this.IsEnabled(HttpHandlerLoggingStrings.ResponseWriteName))
{
LogHttpResponseCore(@this, response, loggingRequestId);
}
}
示例3: SetCurrentThreadActivityId
// ActivityID support (see also WriteEventWithRelatedActivityIdCore)
/// <summary>
/// When a thread starts work that is on behalf of 'something else' (typically another
/// thread or network request) it should mark the thread as working on that other work.
/// This API marks the current thread as working on activity 'activityID'. This API
/// should be used when the caller knows the thread's current activity (the one being
/// overwritten) has completed. Otherwise, callers should prefer the overload that
/// return the oldActivityThatWillContinue (below).
///
/// All events created with the EventSource on this thread are also tagged with the
/// activity ID of the thread.
///
/// It is common, and good practice after setting the thread to an activity to log an event
/// with a 'start' opcode to indicate that precise time/thread where the new activity
/// started.
/// </summary>
/// <param name="activityId">A Guid that represents the new activity with which to mark
/// the current thread</param>
public static void SetCurrentThreadActivityId(Guid activityId)
{
if (TplEtwProvider.Log != null)
TplEtwProvider.Log.SetActivityId(activityId);
#if FEATURE_MANAGED_ETW
#if FEATURE_ACTIVITYSAMPLING
Guid newId = activityId;
#endif // FEATURE_ACTIVITYSAMPLING
// We ignore errors to keep with the convention that EventSources do not throw errors.
// Note we can't access m_throwOnWrites because this is a static method.
if (UnsafeNativeMethods.ManifestEtw.EventActivityIdControl(
UnsafeNativeMethods.ManifestEtw.ActivityControl.EVENT_ACTIVITY_CTRL_GET_SET_ID,
ref activityId) == 0)
{
#if FEATURE_ACTIVITYSAMPLING
var activityDying = s_activityDying;
if (activityDying != null && newId != activityId)
{
if (activityId == Guid.Empty)
{
activityId = FallbackActivityId;
}
// OutputDebugString(string.Format("Activity dying: {0} -> {1}", activityId, newId));
activityDying(activityId); // This is actually the OLD activity ID.
}
#endif // FEATURE_ACTIVITYSAMPLING
}
#endif // FEATURE_MANAGED_ETW
}
示例4: AsyncResult
/// <summary>
/// Constructor
/// </summary>
/// <param name="ownerId">
/// Instance Id of the object creating this instance
/// </param>
/// <param name="callback">
/// A AsyncCallback to call once the async operation completes.
/// </param>
/// <param name="state">
/// A user supplied state object
/// </param>
internal AsyncResult(Guid ownerId, AsyncCallback callback, object state)
{
Dbg.Assert(Guid.Empty != ownerId, "ownerId cannot be empty");
OwnerId = ownerId;
Callback = callback;
AsyncState = state;
}
示例5: Register_ActivateAccount
public static void Register_ActivateAccount(Guid UserNameValidActivationToken)
{
ControllerFake<UserAccountController, object> controller = new ControllerFake<UserAccountController, object>();
ActionResult resultValid = controller.Controller.Activate(UserNameValidActivationToken.ToString());
Assert.AreEqual(true, resultValid.GetType() == typeof(RedirectResult));
Assert.AreEqual(true, (((RedirectResult)resultValid).Url == controller.Controller.RedirectResultOnLogIn().Url));
}
示例6: ReadChangeSetRequestAsync
public static async Task<IList<HttpRequestMessage>> ReadChangeSetRequestAsync(this ODataBatchReader reader, Guid batchId, CancellationToken cancellationToken)
{
if (reader == null)
{
throw Error.ArgumentNull("reader");
}
if (reader.State != ODataBatchReaderState.ChangesetStart)
{
throw Error.InvalidOperation(
SRResources.InvalidBatchReaderState,
reader.State.ToString(),
ODataBatchReaderState.ChangesetStart.ToString());
}
Guid changeSetId = Guid.NewGuid();
List<HttpRequestMessage> requests = new List<HttpRequestMessage>();
while (reader.Read() && reader.State != ODataBatchReaderState.ChangesetEnd)
{
if (reader.State == ODataBatchReaderState.Operation)
{
requests.Add(await ReadOperationInternalAsync(reader, batchId, changeSetId, cancellationToken));
}
}
return requests;
}
示例7: Schedule
protected internal override void Schedule (WaitCallback callback, Guid workflowInstanceId, DateTime whenUtc, Guid timerId)
{
//WorkflowInstance wi = WorkflowRuntime.GetInstanceFromGuid (workflowInstanceId);
//wi.TimerEventSubscriptionCollection.Add
// (new TimerEventSubscription (workflowInstanceId, timerId));
}
示例8: SymDocumentWriter
public virtual ISymbolDocumentWriter DefineDocument
(String url, Guid language, Guid languageVendor,
Guid documentType)
{
// Nothing to do here.
return new SymDocumentWriter();
}
示例9:
protected void GenerateLoadSqlCommand
(
SqlCommand command,
LoadType loadType,
Guid keyToLoadBy,
Guid instanceId,
List<CorrelationKey> keysToAssociate
)
{
long surrogateLockOwnerId = base.StoreLock.SurrogateLockOwnerId;
byte[] concatenatedKeyProperties = null;
bool singleKeyToAssociate = (keysToAssociate != null && keysToAssociate.Count == 1);
if (keysToAssociate != null)
{
concatenatedKeyProperties = SerializationUtilities.CreateKeyBinaryBlob(keysToAssociate);
}
double operationTimeout = this.TimeoutHelper.RemainingTime().TotalMilliseconds;
SqlParameterCollection parameters = command.Parameters;
parameters.Add(new SqlParameter { ParameterName = "@surrogateLockOwnerId", SqlDbType = SqlDbType.BigInt, Value = surrogateLockOwnerId });
parameters.Add(new SqlParameter { ParameterName = "@operationType", SqlDbType = SqlDbType.TinyInt, Value = loadType });
parameters.Add(new SqlParameter { ParameterName = "@keyToLoadBy", SqlDbType = SqlDbType.UniqueIdentifier, Value = keyToLoadBy });
parameters.Add(new SqlParameter { ParameterName = "@instanceId", SqlDbType = SqlDbType.UniqueIdentifier, Value = instanceId });
parameters.Add(new SqlParameter { ParameterName = "@handleInstanceVersion", SqlDbType = SqlDbType.BigInt, Value = base.InstancePersistenceContext.InstanceVersion });
parameters.Add(new SqlParameter { ParameterName = "@handleIsBoundToLock", SqlDbType = SqlDbType.Bit, Value = base.InstancePersistenceContext.InstanceView.IsBoundToLock });
parameters.Add(new SqlParameter { ParameterName = "@keysToAssociate", SqlDbType = SqlDbType.Xml, Value = singleKeyToAssociate ? DBNull.Value : SerializationUtilities.CreateCorrelationKeyXmlBlob(keysToAssociate) });
parameters.Add(new SqlParameter { ParameterName = "@encodingOption", SqlDbType = SqlDbType.TinyInt, Value = base.Store.InstanceEncodingOption });
parameters.Add(new SqlParameter { ParameterName = "@concatenatedKeyProperties", SqlDbType = SqlDbType.VarBinary, Value = (object) concatenatedKeyProperties ?? DBNull.Value });
parameters.Add(new SqlParameter { ParameterName = "@operationTimeout", SqlDbType = SqlDbType.Int, Value = (operationTimeout < Int32.MaxValue) ? Convert.ToInt32(operationTimeout) : Int32.MaxValue });
parameters.Add(new SqlParameter { ParameterName = "@singleKeyId", SqlDbType = SqlDbType.UniqueIdentifier, Value = singleKeyToAssociate ? keysToAssociate[0].KeyId : (object) DBNull.Value });
}
示例10: Vote
public bool Vote(string serviceID, string clientID, string pollStr, string choiceStr)
{
BowmarPollsDataContext context = new BowmarPollsDataContext();
Guid choice = new Guid(choiceStr);
Guid poll = new Guid(pollStr);
if (this.hasClientParticipated(context, poll, clientID))
return false;
var query = from element in context.PollElements
where element.id == choice
select element;
foreach (PollElement element in query)
{
if (element.count == null)
element.count = 0;
element.count++;
}
ClientParticipation cp = new ClientParticipation();
cp.client_id = clientID;
cp.poll_id = poll;
context.ClientParticipations.InsertOnSubmit(cp);
context.SubmitChanges();
return true;
}
示例11: CheckRegistered
private static unsafe bool CheckRegistered(Guid id, Assembly assembly, [MarshalAs(UnmanagedType.U1)] bool checkCache, [MarshalAs(UnmanagedType.U1)] bool cacheOnly)
{
if (checkCache && (_regCache[assembly] != null))
{
return true;
}
if (cacheOnly)
{
return false;
}
bool flag = false;
string name = @"CLSID\{" + id.ToString() + @"}\InprocServer32";
RegistryKey key = Registry.ClassesRoot.OpenSubKey(name, false);
if (key != null)
{
_regCache[assembly] = bool.TrueString;
}
else if (IsWin64(&flag))
{
HKEY__* hkey__Ptr;
IntPtr hglobal = Marshal.StringToHGlobalUni(name);
char* chPtr = (char*) hglobal.ToPointer();
int num = flag ? 0x100 : 0x200;
Marshal.FreeHGlobal(hglobal);
if (RegOpenKeyExW(-2147483648, (char modopt(IsConst)*) chPtr, 0, (uint modopt(IsLong)) (num | 0x20019), &hkey__Ptr) != 0)
{
return false;
}
RegCloseKey(hkey__Ptr);
return true;
}
return ((key != null) ? ((bool) ((byte) 1)) : ((bool) ((byte) 0)));
}
示例12: Create
public void Create()
{
// SqlGuid (Byte[])
byte[] b = new byte[16];
b[0] = 100;
b[1] = 200;
try
{
SqlGuid Test = new SqlGuid(b);
// SqlGuid (Guid)
Guid TestGuid = new Guid(b);
Test = new SqlGuid(TestGuid);
// SqlGuid (string)
Test = new SqlGuid("12345678-1234-1234-1234-123456789012");
// SqlGuid (int, short, short, byte, byte, byte, byte, byte, byte, byte, byte)
Test = new SqlGuid(10, 1, 2, 13, 14, 15, 16, 17, 19, 20, 21);
}
catch (Exception e)
{
Assert.False(true);
}
}
示例13: AuditRuleFactory
public virtual AuditRule AuditRuleFactory (IdentityReference identityReference, int accessMask,
bool isInherited, InheritanceFlags inheritanceFlags,
PropagationFlags propagationFlags, AuditFlags flags,
Guid objectType, Guid inheritedObjectType)
{
throw GetNotImplementedException ();
}
示例14: Guid
static Guid()
{
// Note: this type is marked as 'beforefieldinit'.
Guid guid = new Guid(new byte[16]);
Guid.zeroString = guid.ToString();
Guid.random = new Random();
}
示例15: MembershipUnitTests
public MembershipUnitTests()
{
_userGuid = Guid.NewGuid();
_userName = _userGuid.ToString();
_userEmail = string.Format("{0}@gmail.com", _userName.Replace("-", string.Empty));
_userPwd = "1*dk**_=lsdk/()078909";
}