public void Validate() { TypeIds.ValidateOptional <string>("TypeIds"); Sections.ValidateOptional <string>("Sections"); ImageTypes.ValidateOptional <string>("ImageTypes"); LastClientRefresh.ValidateOptional("LastClientRefresh"); }
public object GetDisplayObject(Entities.TourCostRuleConstraintPropertyCollection properties) { Entities.ConstraintTourTime time = new Entities.ConstraintTourTime(); foreach (Entities.TourCostRuleConstraintProperty property in properties) { TypeIds type = (TypeIds)property.TypeId; switch (type) { case TypeIds.StartHour: time.StartTime.Hour = (int)property.Value; break; case TypeIds.StartMinute: time.StartTime.Minute = (int)property.Value; break; case TypeIds.EndHour: time.EndTime.Hour = (int)property.Value; break; case TypeIds.EndMinute: time.EndTime.Minute = (int)property.Value; break; } } return(time); }
/// <summary> /// Initializes a new instance of the <see cref="SerializableEntityId" /> class. /// </summary> /// <param name="id">The identifier.</param> /// <param name="typeIds">The type ids.</param> public SerializableEntityId(long id, IEnumerable <long> typeIds) : this() { Id = id; if (typeIds != null) { TypeIds.AddRange(typeIds); } }
/// <summary> /// Resolves the ids. /// </summary> /// <param name="idMap">The identifier map.</param> public void ResolveIds(Dictionary <long, long> idMap) { long id0 = Id; Id = JsonEntityQueryResult.ResolveId(Id, idMap); if (Id != id0 && DataState == DataState.Create) { DataState = DataState.Unchanged; EventLog.Application.WriteTrace("Resolved id from {0} to {1} so changed dataState from Create to Unchanged", id0, Id); } TypeIds = TypeIds.Select(p => JsonEntityQueryResult.ResolveId(p, idMap)).ToList( ); Fields.ForEach(p => { p.FieldId = JsonEntityQueryResult.ResolveId(p.FieldId, idMap); }); Relationships.ForEach(p => p.ResolveIds(idMap)); }
/// <summary> /// Returns a hash code for this instance. /// </summary> /// <returns> /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. /// </returns> public override int GetHashCode( ) { unchecked { int hashCode = 17; hashCode = hashCode * 92821 + Id.GetHashCode( ); hashCode = hashCode * 92821 + ReadOnly.GetHashCode( ); hashCode = hashCode * 92821 + TenantId.GetHashCode( ); if (TypeIds != null) { hashCode = hashCode * 92821 + TypeIds.GetHashCode( ); } return(hashCode); } }
/// <summary>Creates an <see cref="CssPacket" /> instance from type.</summary> public static CssPacket CreateInstance(TypeIds id) { switch (id) { case TypeIds.Identity: return new CsspIdentity(); case TypeIds.Exception: return new CsspException(); case TypeIds.Log: return new CsspLog(); case TypeIds.Feedback: return new CsspFeedback(); case TypeIds.InfoIdentity: return new CsspInfoIdentity(); case TypeIds.InfoApplication: return new CsspInfoApplication(); case TypeIds.InfoComputer: return new CsspInfoComputer(); case TypeIds.InfoUser: return new CsspInfoUser(); } throw new Exception($"Unknown packet with id='{id}'"); }
public object GetDisplayObject(Entities.TourCostRuleConstraintPropertyCollection properties) { Entities.ConstraintTourDate date = new Entities.ConstraintTourDate(); foreach (Entities.TourCostRuleConstraintProperty property in properties) { TypeIds type = (TypeIds)property.TypeId; switch (type) { case TypeIds.StartYear: date.StartDate.Year = (int)property.Value; break; case TypeIds.StartMonth: date.StartDate.Month = (int)property.Value; break; case TypeIds.StartDay: date.StartDate.Day = (int)property.Value; break; case TypeIds.EndYear: date.EndDate.Year = (int)property.Value; break; case TypeIds.EndMonth: date.EndDate.Month = (int)property.Value; break; case TypeIds.EndDay: date.EndDate.Day = (int)property.Value; break; } } return(date); }
public static int GetTypeId <T>() { return(TypeIds.GetValueByKey(typeof(T))); }
public static int GetTypeId(Type type) { return(TypeIds.GetValueByKey(type)); }
public static Type GetType(int typeId) { return(TypeIds.GetKeyByValue(typeId)); }
public static void Init() { var assembly = typeof(Game).Assembly; foreach (Type type in assembly.GetTypes()) { if (type.IsAbstract) { continue; } var typeId = 0; var entityDefineAttribute = type.GetCustomAttribute <EntityDefineAttribute>(); if (entityDefineAttribute != null) { var arr = type.Name.ToCharArray(); var i = 0; typeId = (int)arr[i]; Log.Debug($"{type.Name} {typeId.ToString()}"); i++; while (TypeIds.ContainsValue(typeId) && i < arr.Length) { typeId = int.Parse(typeId.ToString() + (int)arr[i]); Log.Debug($"{type.Name} {typeId.ToString()}"); i++; } entityDefineAttribute.EntityTypeId = typeId; TypeIds.Add(type, typeId); } var conponentDefineAttribute = type.GetCustomAttribute <ComponentDefineAttribute>(); if (conponentDefineAttribute != null) { var arr = type.Name.ToCharArray(); var i = 0; typeId = (int)arr[i]; Log.Debug($"{type.Name} {typeId.ToString()}"); i++; while (TypeIds.ContainsValue(typeId) && i < arr.Length) { typeId = int.Parse(typeId.ToString() + (int)arr[i]); Log.Debug($"{type.Name} {typeId.ToString()}"); i++; } conponentDefineAttribute.ComponentTypeId = typeId; TypeIds.Add(type, typeId); } if (typeId == 0) { continue; } PropertyDefineCollectionMap.Add(typeId, new Dictionary <string, PropertyDefineAttribute>()); PropertyCollectionMap.Add(typeId, new Dictionary <int, PropertyInfo>()); ReactPropertyCollectionMap.Add(typeId, new Dictionary <int, PropertyInfo>()); foreach (var propertyInfo in type.GetProperties()) { var attribute = propertyInfo.GetCustomAttribute <PropertyDefineAttribute>(); if (attribute != null) { attribute.Type = propertyInfo.PropertyType; PropertyDefineCollectionMap[typeId].Add(propertyInfo.Name, attribute); // var arr1 = propertyInfo.Name.ToCharArray(); var j = 0; var propertyId = (int)arr1[j]; Log.Debug($"{propertyInfo.Name} {propertyId.ToString()}"); j++; while (PropertyCollectionMap[typeId].ContainsKey(propertyId) && j < arr1.Length) { propertyId = int.Parse(propertyId.ToString() + (int)arr1[j]); Log.Debug($"{propertyInfo.Name} {propertyId.ToString()}"); j++; } attribute.Id = propertyId; // PropertyCollectionMap[typeId].Add(attribute.Id, propertyInfo); var reactPropertyInfo = type.GetProperty($"{propertyInfo.Name}Property"); ReactPropertyCollectionMap[typeId].Add(attribute.Id, reactPropertyInfo); } } } }
/// <summary> /// Determines whether the specified <see cref="ActivationData" /> is equal to this instance. /// </summary> /// <param name="obj"> /// The <see cref="ActivationData" /> to compare with this instance. /// </param> /// <returns> /// <c>true</c> if the specified <see cref="ActivationData" /> is equal to this instance; otherwise, <c>false</c>. /// </returns> public bool Equals(ActivationData obj) { return(Id == obj.Id && ReadOnly == obj.ReadOnly && TenantId == obj.TenantId && ((TypeIds == null && obj.TypeIds == null) || TypeIds.Equals(obj.TypeIds))); }