public void Should_Convert_Guid_Correctly() { var id = Guid.NewGuid(); var shortId = ShortGuid.ToShortId(id); var longId = ShortGuid.FromShortId(shortId); Assert.Equal(id, longId); }
/// <summary> /// Create a new ChatMessage /// </summary> /// <param name="sourceIdentifier">The source identifier</param> /// <param name="sourceName">The source name</param> /// <param name="message">The message to be sent</param> /// <param name="messageIndex">The index of this message</param> public ChatMessage(ShortGuid sourceIdentifier, string sourceName, string message, long messageIndex) { this._sourceIdentifier = sourceIdentifier; this.SourceName = sourceName; this.Message = message; this.MessageIndex = messageIndex; this.RelayCount = 0; }
/// <summary> /// Create an ChunkAvailabilityReply which will precede the requested data. /// </summary> /// <param name="sourceNetworkIdentifier">The network identifier of the source of this ChunkAvailabilityReply</param> /// <param name="itemCheckSum">The checksum of the DFS item</param> /// <param name="chunkIndex">The chunkIndex of the requested item</param> /// <param name="packetIdentifier">The packet identifier used to send the data</param> public ChunkAvailabilityReply(ShortGuid sourceNetworkIdentifier, string itemCheckSum, byte chunkIndex, string packetIdentifier) { this.SourceNetworkIdentifier = sourceNetworkIdentifier; this.ItemCheckSum = itemCheckSum; this.ChunkIndex = chunkIndex; this.PacketIdentifier = packetIdentifier; this.ReplyState = ChunkReplyState.DataIncluded; }
public void SerializationTest() { var sg = new ShortGuid(Guid.NewGuid()); var strSg = JsonConvert.SerializeObject(sg); var expected = "\"" + sg + "\""; Assert.AreEqual(expected, strSg); }
public void DeSerializationTest() { var origional = new ShortGuid(Guid.NewGuid()); var jsonData = "\"" + origional.Value + "\""; var deserialized = JsonConvert.DeserializeObject <ShortGuid>(jsonData); Assert.AreEqual(origional.Guid, deserialized.Guid); }
public void ShortGuidEncodingUsingShortGuidConstructor() { var g = Guid.NewGuid(); var sg = new ShortGuid(g).Value; var newSg = new ShortGuid(sg); Assert.AreEqual(g, newSg.Guid); }
public DummyMoleculeContainerDTO MapFrom(IObjectBase objectBase) { var dto = Map <DummyMoleculeContainerDTO>(objectBase); dto.Id = ShortGuid.NewGuid(); dto.MoleculePropertiesContainer = _objectBaseToDTOObjectBaseMapper.MapFrom(_moleculePropertiesContainer); return(dto); }
public void CreateShortGuidFromTheSameGuidTwice_ReturnsTheSameResult() { var guid = Guid.NewGuid(); var shortGuid1 = new ShortGuid(guid); var shortGuid2 = new ShortGuid(guid); Assert.Equal(shortGuid1.ToString(), shortGuid2.ToString()); }
private EntityMetaData mapFrom(CurveChart chart) { var entityMetaData = new EntityMetaData { Id = ShortGuid.NewGuid() }; serialize(entityMetaData, chart); return(entityMetaData); }
public void FromShortId_Should_Convert_Correctly() { var shortId = Guid.NewGuid().ToShortId() + "=="; Assert.NotNull(ShortGuid.FromShortId(shortId)); shortId = ShortGuid.ToShortId(Guid.NewGuid()) + "=="; Assert.NotNull(ShortGuid.FromShortId(shortId)); }
public string CreateUserAndAccount(string userName, string password, string email, Guid myGuid, bool requireConfirmationToken = false) { if (string.IsNullOrEmpty(userName)) { throw new ArgumentNullException(nameof(userName)); } if (string.IsNullOrEmpty(password)) { throw new ArgumentNullException(nameof(password)); } if (string.IsNullOrEmpty(email)) { throw new ArgumentNullException(nameof(email)); } string token = null; if (requireConfirmationToken) { token = ShortGuid.NewGuid(); } var isConfirmed = !requireConfirmationToken; if (token == null) { return(null); } var user = new ApplicationUser { UserName = userName.Trim(), Email = email.Trim(), ConfirmationToken = token.Trim(), IsConfirmed = isConfirmed }; user.TrackingState = TrackingState.Added; var result = _userManager.Create(user, password.Trim()); if (result.Succeeded) { return(token); } var innerMsg = new StringBuilder(); foreach (var msg in result.Errors) { innerMsg.Append(msg); } var ex = new MembershipCreateUserException(innerMsg.ToString()); throw ex; }
public DummyReactionDTO MapFrom(IReactionBuilder reactionBuilder, IContainer container) { var dto = Map <DummyReactionDTO>(reactionBuilder); dto.Id = ShortGuid.NewGuid(); dto.ReactionBuilder = reactionBuilder; dto.StructureParent = container; return(dto); }
public UsedObservedDataNode(UsedObservedData usedObservedData, DataRepository observedData) : base(usedObservedData) { _observedData = observedData; Tag = usedObservedData; UpdateText(); //new id should not be the one from the data repository=>hence a new id _id = ShortGuid.NewGuid(); }
public DummyMoleculeDTO MapFrom(IMoleculeBuilder moleculeBuilder, IContainer container) { var dto = Map <DummyMoleculeDTO>(moleculeBuilder); dto.MoleculeBuilder = moleculeBuilder; dto.StructureParent = container; dto.Id = ShortGuid.NewGuid(); return(dto); }
protected override IHttpHandler GetHttpHandler(RequestContext requestContext) { //Dont redirect for Post action, as we may loose the form data if (requestContext.HttpContext.Request.HttpMethod == HttpMethod.Post.ToString()) { return base.GetHttpHandler(requestContext); } //Get current unique id from RouteData var guidString = Convert.ToString(requestContext.RouteData.Values["tabid"]); //if true, then construct new url with tab id if (!string.IsNullOrEmpty(guidString)) { //create new guid guidString = ShortGuid.NewGuid().ToString(); //construct redirect url string rootUrl = requestContext.AbsoluteUriBeforeRoute(); string controller = Convert.ToString(requestContext.RouteData.Values["controller"]); string action = Convert.ToString(requestContext.RouteData.Values["action"]); string id = Convert.ToString(requestContext.RouteData.Values["id"]); string queryString = requestContext.HttpContext.Request.Url.Query; string url = $"{rootUrl}/t/{guidString}"; bool skipToQueryString = false; if (controller.Equals("Main", StringComparison.OrdinalIgnoreCase) && action.Equals("Index", StringComparison.OrdinalIgnoreCase)) { skipToQueryString = true; } if(!skipToQueryString) { url += $"/{controller}"; if (!action.Equals("Index", StringComparison.OrdinalIgnoreCase)) { url += $"/{action}"; } } if (!string.IsNullOrWhiteSpace(id)) { url += $"/{id}"; } url += queryString; //redirect permanantly to unique tab url requestContext.HttpContext.Response.Redirect(url, true); } return base.GetHttpHandler(requestContext); }
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { if (value is string) { var shortGuid = new ShortGuid(value.ToString()); return(shortGuid); } return(base.ConvertFrom(context, culture, value)); }
private void SetListActionViewBags(IProjectPoco projectWithUsers) { var projectUsers = projectWithUsers.ProjectUsers.Select(p => p.User); ViewBag.PId = ShortGuid.Encode(projectWithUsers.Id); ViewBag.ProjectUsers = projectUsers.ToDictionary(p => p.Id, d => d.UserName); ViewBag.PriorityList = lookupService.GetAllTaskPriority().ToDictionary(p => p.Id, d => d.Name); ViewBag.StatusList = lookupService.GetAllTaskStatus().ToDictionary(p => p.Id, d => d.Name); }
public SimulationTransfer() { AllObservedData = new List <DataRepository>(); PkmlVersion = Constants.PKML_VERSION; ReactionDimensionMode = ReactionDimensionMode.AmountBased; Id = ShortGuid.NewGuid(); Favorites = new Favorites(); JournalPath = string.Empty; }
public RootNodeType(string name, ApplicationIcon icon, ClassificationType classificationType = ClassificationType.Unknown) { Id = ShortGuid.NewGuid().ToString(); Name = name; Icon = icon; _classification = new Classification { ClassificationType = classificationType }; }
public void NewGuidTest() { ShortGuid expected = new ShortGuid(); // TODO: Initialize to an appropriate value ShortGuid actual; actual = ShortGuid.NewGuid(); Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
protected override void When() { var shortGuid = new ShortGuid(this.guid); ShortGuid outed; ShortGuid.TryParse(shortGuid.ToString(), out outed); this.returned = outed.ToGuid(); }
/// <summary> /// Message constructer /// </summary> /// <param name="header">message type</param> /// <param name="message">message readable contents</param> public Message(ShortGuid sourceIdentifier, string sourceName, string header, string message, long messageIndex) { this._sourceIdentifier = sourceIdentifier; this.SourceName = sourceName; this.coincheHeader = header; this.MessageContent = message; this.MessageIndex = messageIndex; this.RelayCount = 0; }
protected override void unpack(BinaryBitReader reader) { CheckFlags flags = (CheckFlags)reader.ReadByte(); if (flags.HasFlag(CheckFlags.HasByskyToken)) { ByskyToken = new ShortGuid(reader.ReadBytes(16)); } }
public void ShowData(IReadOnlyList <DataRepository> data) { var chart = _chartFactory.Create <CurveChart>().WithAxes(); chart.Id = ShortGuid.NewGuid(); chart.Name = getChartName(data); addChartToProject(chart); ShowChart(chart, data); }
public Curve() { Id = ShortGuid.NewGuid(); _name = string.Empty; _description = string.Empty; _xData = null; _yData = null; CurveOptions = new CurveOptions(); Rules = new BusinessRuleSet(); }
void instance_equality_equals() { var actual = new ShortGuid(SampleShortGuidString); Assert.True(actual.Equals(actual)); Assert.False(actual.Equals(null)); Assert.True(actual.Equals(SampleGuid)); Assert.True(actual.Equals(SampleGuidString)); Assert.True(actual.Equals(SampleShortGuidString)); }
private void PeerDiscovered(ShortGuid peerIdentifier, Dictionary <ConnectionType, List <EndPoint> > discoveredListenerEndPoints) { if (discoveredListenerEndPoints[ConnectionType.UDP].Any()) { var address = discoveredListenerEndPoints[ConnectionType.UDP].First(); (address as IPEndPoint).Port = CommonHelpers.PeerPort; AddPeer(address); } }
public void op_ImplicitTest3() { ShortGuid shortGuid = new ShortGuid(); // TODO: Initialize to an appropriate value string expected = string.Empty; // TODO: Initialize to an appropriate value string actual; actual = shortGuid; Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
public void DecodeTest() { string value = string.Empty; // TODO: Initialize to an appropriate value Guid expected = new Guid(); // TODO: Initialize to an appropriate value Guid actual; actual = ShortGuid.Decode(value); Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
public void GetHashCodeTest() { ShortGuid target = new ShortGuid(); // TODO: Initialize to an appropriate value int expected = 0; // TODO: Initialize to an appropriate value int actual; actual = target.GetHashCode(); Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
public void ToStringTest() { ShortGuid target = new ShortGuid(); // TODO: Initialize to an appropriate value string expected = string.Empty; // TODO: Initialize to an appropriate value string actual; actual = target.ToString(); Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
public void ConvertGuidToShortGuidTest() { Stopwatch watch = Stopwatch.StartNew(); for (int i = 0; i < 1000000; i++) { Guid g = Guid.NewGuid(); ShortGuid s = g; string v = s.Value; var s2 = new ShortGuid(v); Assert.AreEqual(s, s2); Guid g2 = s2; Assert.AreEqual(g, g2); } watch.Stop(); Console.WriteLine("Time: {0} ms", watch.ElapsedMilliseconds); }
public void ConvertZero() { Stopwatch watch = Stopwatch.StartNew(); Guid g = Guid.Empty; ShortGuid s = g; string v = s.Value; ShortGuid s2 = new ShortGuid(v); watch.Stop(); Console.WriteLine("Time: {0} ms", watch.ElapsedMilliseconds); Assert.AreEqual(s, s2); Guid g2 = s2; Assert.AreEqual(g, g2); }
async Task<bool> Commit(Package package) { var done = Version.IsBlank() ? package.Commit(Force, !NoDownCase) : package.Commit(Version, Force, !NoDownCase); if (done && Register != null && _config.RegisterKey != null) { System.Console.WriteLine("Registering with the API... please stand by"); var registeredId = await package.Register(_publishingApi, Register, _config.RegisterKey).ConfigureAwait(false); var shortId = new ShortGuid(registeredId); System.Console.WriteLine("The ID of the registration is: " + shortId); } return done; }
public static string ToShortString(this Guid guid) { var id = new ShortGuid(guid); return id.Value; }
protected virtual List<string> ReplceTempToStaticUrls(List<string> urls, string contentID) { List<string> result = new List<string>(); string tempBaseUrl = PathCreator.CreateTempUrlRoot(); foreach (string url in urls) { if (!url.StartsWith(tempBaseUrl)) { result.Add(url); continue; } Guid? fileID = PathCreator.ExtractFileIDFromTemp(url); if (fileID == null) { result.Add(string.Empty); continue; } string shortFileID = new ShortGuid(fileID.Value); string staticUrl = PathCreator.CreateStaticUrl(contentID, shortFileID); result.Add(staticUrl); } return result; }
protected virtual Task<bool> CopyTempToStatic(List<string> tempNamePaths, string contentID) { List<string> oldNamePaths = new List<string>(); List<string> newNamePaths = new List<string>(); foreach (string tempNamePath in tempNamePaths) { Guid? fileID = PathCreator.ExtractFileIDFromTemp(tempNamePath); if (fileID == null) continue; string shortFileID = new ShortGuid(fileID.Value); string staticNamePath = PathCreator.CreateStaticNamePath(contentID, shortFileID); oldNamePaths.Add(tempNamePath); newNamePaths.Add(staticNamePath); } return oldNamePaths.Count > 0 ? FileStorage.Copy(oldNamePaths, newNamePaths) : Task.FromResult(true); }
public string GetNewShortGuid() { var sguid = new ShortGuid(Guid.NewGuid()); return sguid.Value; }