private long GetId(ref long stored, string ns, string alias) { if (stored == 0) { // (Unfortunately) presently the fastest way to get an ID. EntityAlias ea = new EntityAlias(ns, alias, true); stored = EntityIdentificationCache.GetId(ea); } return(stored); }
/// <summary> /// Converts the current entity alias to its corresponding entity id. /// </summary> /// <param name="alias">The alias.</param> /// <returns> /// Entity id of the current entity alias. /// </returns> public static long ToEntityId(EntityAlias alias) { if (alias == null || alias.Alias == null) { throw new ArgumentNullException("alias"); } if (alias.Alias.Length == 0) { throw new ArgumentException(@"alias was empty", "alias"); } return(EntityIdentificationCache.GetId(alias)); }
/// <summary> /// Resolves the identifier. /// </summary> public long ResolveId( ) { if (_id == 0 && !_serializing) { if (_entity != null) { _id = _entity.Id; } else if (Alias != null) { EntityAlias ea = new EntityAlias(Namespace ?? "core", Alias, true); _id = EntityIdentificationCache.GetId(ea); } else { return(0); } } return(_id); }
/// <summary> /// Gets the ID of the type represented by a C# class. /// </summary> /// <param name="type"></param> /// <returns></returns> public long GetTypeId(Type type) { long id; if (!_strongTypeIdCache.TryGetValue(type, out id)) { id = -1; if (type != typeof(Entity)) { ModelClassAttribute modelClass = GetModelClassAttribute(type); if (modelClass != null) { id = EntityIdentificationCache.GetId(modelClass.TypeAlias); } } _strongTypeIdCache[type] = id; } return(id); }
/// <summary> /// Determine if one type is equal to or derived from another. /// </summary> /// <returns>True if the child type is equal to, or derived from, the parent type.</returns> public bool IsDerivedFrom(long possibleChildTypeId, string possibleParentTypeAlias) { long possibleParentTypeId = EntityIdentificationCache.GetId(possibleParentTypeAlias); return(IsDerivedFrom(possibleChildTypeId, possibleParentTypeId)); }