本文整理汇总了C#中ID.ToShortID方法的典型用法代码示例。如果您正苦于以下问题:C# ID.ToShortID方法的具体用法?C# ID.ToShortID怎么用?C# ID.ToShortID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ID
的用法示例。
在下文中一共展示了ID.ToShortID方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShouldAddFieldById
public void ShouldAddFieldById([NoAutoProperties]DbTemplate template, ID fieldId)
{
template.Add(fieldId);
template.Fields[fieldId].Should().NotBeNull();
template.Fields[fieldId].Name.Should().Be(fieldId.ToShortID().ToString());
}
示例2: DbItem
/// <summary>
/// Initializes a new instance of the <see cref="DbItem"/> class.
/// </summary>
/// <param name="name">The item name.</param>
/// <param name="id">The item id.</param>
/// <param name="templateId">The template id.</param>
public DbItem(string name, ID id, ID templateId)
{
this.Name = !string.IsNullOrEmpty(name) ? name : id.ToShortID().ToString();
this.ID = id;
this.TemplateID = templateId;
this.Access = new DbItemAccess();
this.Fields = new DbFieldCollection();
this.Children = new DbItemChildCollection(this);
this.versionsCount = new Dictionary<string, int>();
}
示例3: AddCurrentBaseLayout_WithCurrentBaseLayoutIdNotNull_AddsQueryStringParameter
public void AddCurrentBaseLayout_WithCurrentBaseLayoutIdNotNull_AddsQueryStringParameter()
{
// Arrange
var urlString = new UrlString();
var id = new ID();
var options = new SelectBaseLayoutOptions {CurrentBaseLayoutId = id};
// Act
var result = options.AddCurrentBaseLayout(urlString);
// Assert
Assert.Equal(id.ToShortID().ToString(), result.Parameters[SelectBaseLayoutOptions.CurrentBaseLayoutQueryKey]);
}
示例4: ParseCurrentBaseLayout_WithValidQueryString_SetsCurrentBaseLayoutId
public void ParseCurrentBaseLayout_WithValidQueryString_SetsCurrentBaseLayoutId()
{
// Arrange
var id = new ID();
var options = Substitute.ForPartsOf<SelectBaseLayoutOptions>();
options.When(o => o.GetQueryString(Arg.Any<string>())).DoNotCallBase();
options.GetQueryString(SelectBaseLayoutOptions.CurrentBaseLayoutQueryKey).Returns(id.ToShortID().ToString());
// Act
options.ParseCurrentBaseLayout();
// Assert
Assert.Equal(id, options.CurrentBaseLayoutId);
}
示例5: GetFieldIdNamePair
public KeyValuePair<ID, string> GetFieldIdNamePair(ID id, string name)
{
if (string.IsNullOrEmpty(name))
{
name = WellknownFields.ContainsKey(id) ? WellknownFields[id] : id.ToShortID().ToString();
}
if (!ID.IsNullOrEmpty(id))
{
return new KeyValuePair<ID, string>(id, name);
}
var keyValuePair = WellknownFields.FirstOrDefault(kvp => kvp.Value == name);
var newId = !ID.IsNullOrEmpty(keyValuePair.Key) ? keyValuePair.Key : ID.NewID;
return new KeyValuePair<ID, string>(newId, name);
}
示例6: DbItem
public DbItem(string name, ID id, ID templateId, params object[] children)
{
this.Name = !string.IsNullOrEmpty(name) ? name : id.ToShortID().ToString();
this.ID = id;
this.TemplateID = templateId;
this.Access = new DbItemAccess();
this.Fields = new DbFieldCollection();
this.Children = new DbItemChildCollection(this);
this.VersionsCount = new Dictionary<string, int>();
if (children != null)
{
var items = children.OfType<DbItem>();
foreach (var item in items)
{
this.Add(item);
}
}
}
示例7: TransformValue
/// <summary>
/// Transforms a value for use in the index
/// </summary>
/// <param name="id">The ID to transform</param>
/// <returns>A value suitable for usage with the index</returns>
protected virtual string TransformValue(ID id)
{
return id.ToShortID().ToString().ToLower();
}
示例8: VariableValueItemStub
// Methods
public VariableValueItemStub(ID id, string name)
{
Assert.ArgumentNotNull(id, "id");
Assert.ArgumentNotNull(name, "name");
Datasource = string.Empty;
HideComponent = false;
ReplacementComponent = string.Empty;
Name = name;
this.id = id.ToShortID().ToString();
}
示例9: SutGeneratesNameBasedOnIdIfNotSet
public void SutGeneratesNameBasedOnIdIfNotSet(ID id)
{
var sut = new DbItem(null, id);
sut.Name.Should().Be(id.ToShortID().ToString());
}
示例10: NormalizeGuid
public static string NormalizeGuid(ID id, bool lowercase)
{
return lowercase ? id.ToShortID().ToString().ToLowerInvariant() : id.ToShortID().ToString();
}
示例11: ShouldReturnFieldInfoWithNameFromId
public void ShouldReturnFieldInfoWithNameFromId(IdBasedFieldGenerator sut, ID id)
{
sut.Build(id).Name.Should().Be(id.ToShortID().ToString());
}