本文整理汇总了C#中BsonDocument.SetIfNotNull方法的典型用法代码示例。如果您正苦于以下问题:C# BsonDocument.SetIfNotNull方法的具体用法?C# BsonDocument.SetIfNotNull怎么用?C# BsonDocument.SetIfNotNull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BsonDocument
的用法示例。
在下文中一共展示了BsonDocument.SetIfNotNull方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Serialize
public BsonDocument Serialize(Scope scope)
{
var doc = new BsonDocument();
doc["_id"] = scope.Name;
doc["_version"] = 1;
doc.SetIfNotNull("displayName", scope.DisplayName);
var claims = new BsonArray();
foreach (ScopeClaim scopeClaim in scope.Claims)
{
var claim = new BsonDocument();
claim["name"] = scopeClaim.Name;
claim["alwaysIncludeInIdToken"] = scopeClaim.AlwaysIncludeInIdToken;
claim.SetIfNotNull("description", scopeClaim.Description);
claims.Add(claim);
}
doc["claims"] = claims;
doc.SetIfNotNull("claimsRule", scope.ClaimsRule);
doc.SetIfNotNull("description", scope.Description);
doc["emphasize"] = scope.Emphasize;
doc["enabled"] = scope.Enabled;
doc["includeAllClaimsForUser"] = scope.IncludeAllClaimsForUser;
doc["required"] = scope.Required;
doc["showInDiscoveryDocument"] = scope.ShowInDiscoveryDocument;
doc["type"] = scope.Type.ToString();
return doc;
}
示例2: Serialize
public BsonDocument Serialize(string key, AuthorizationCode code)
{
var doc = new BsonDocument();
doc["_id"] = key;
doc["_version"] = 1;
doc["_clientId"] = code.ClientId;
doc["_subjectId"] = code.SubjectId;
doc["_expires"] = code.CreationTime.AddSeconds(code.Client.AuthorizationCodeLifetime).ToBsonDateTime();
doc["creationTime"] = code.CreationTime.ToBsonDateTime();
doc["isOpenId"] = code.IsOpenId;
doc["redirectUri"] = code.RedirectUri;
doc["wasConsentShown"] = code.WasConsentShown;
doc.SetIfNotNull("nonce", code.Nonce);
doc["subject"] = SerializeIdentities(code);
var requestedScopes = new BsonArray();
foreach (var scope in code.RequestedScopes.Select(x=>x.Name))
{
requestedScopes.Add(scope);
}
doc["requestedScopes"] = requestedScopes;
return doc;
}