Beispiel #1
0
 /// <summary>Imports services from external service provider. </summary>
 /// <param name="app">External service provider, usually another entity applications.</param>
 /// <param name="serviceTypes">Types of services to import.</param>
 public void ImportServices(EntityApp app, params Type[] serviceTypes)
 {
     foreach (var type in serviceTypes)
     {
         var serv = app.GetService(type);
         if (serv != null)
         {
             this._services[type] = app.GetService(type);
         }
     }
 }
Beispiel #2
0
        /// <summary>Registers the size for string and binary columns for the size code that should be applied for entities in the module. </summary>
        /// <param name="sizeCode">The size code.</param>
        /// <param name="size">The size value.</param>
        /// <remarks>Most often size codes are registered at entity app level, and applied to all entities in all modules.
        /// However, if you need to set specific size values for codes used in some module, you can use this method to set these
        /// values when you setup the application. The method uses module's namespace as a prefix in full size code that is registered
        /// in the app-wide Sizes table. The Size attribute code looks up the size value first using the full size code (with namespace),
        /// then by size code alone. The implicit assumption is that entity interfaces are declared in the same namespace
        /// as the containing module.</remarks>
        public virtual void RegisterSize(string sizeCode, int size)
        {
            var serv = App.GetService <IEntityModelCustomizationService>();

            Util.Check(serv != null, "{0} not available. Initializer entity app with proper host services.", nameof(IEntityModelCustomizationService));
            var fullCode = this.GetType().Namespace + "#" + sizeCode;

            serv.RegisterSize(sizeCode, size, this);
        }
Beispiel #3
0
        //.NET framework's GetHashCode() is not guaranteed to be stable between .NET versions.
        // If we want to keep hashes in database, we need a stable hash implementation
        public static int ComputeStableHash(this EntityApp app, string value)
        {
            if (string.IsNullOrWhiteSpace(value))
            {
                return(0);
            }
            var hasher = app.GetService <IHashingService>();

            return(hasher.ComputeHash(value));
        }