SimpleIdentity.cs 772 B

123456789101112131415161718192021222324252627282930313233
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. namespace Taobao.Top.Link.Endpoints
  5. {
  6. /// <summary>simple id with Name
  7. /// </summary>
  8. public class SimpleIdentity : Identity
  9. {
  10. public string Name { get; private set; }
  11. public SimpleIdentity(string name)
  12. {
  13. this.Name = name;
  14. }
  15. public Identity Parse(object data)
  16. {
  17. return new SimpleIdentity((data as IDictionary<string, string>)["name"]);
  18. }
  19. public void Render(object to)
  20. {
  21. (to as IDictionary<string, object>).Add("name", this.Name);
  22. }
  23. public bool Equals(Identity id)
  24. {
  25. return this.Name.Equals((id as SimpleIdentity).Name);
  26. }
  27. }
  28. }