Exemplo n.º 1
0
        /// <summary>
        ///     注册晚加载关系
        /// </summary>
        /// <param name="intfType">接口类型或抽象类</param>
        /// <param name="implType">实现intfType的最终类型,必须有一个默认的无参构造类</param>
        /// <param name="priority">优先级,总是使用优先级最高的实现类</param>
        public static void RegisterLazyLoading(
            Type intfType, Type implType, LoadingPriority priority)
        {
            if (intfType == null)
            {
                throw new ArgumentNullException("intfType", "RegLazyLoadingAttribute 参数1不能为null。");
            }
            if (implType == null)
            {
                throw new ArgumentNullException("implType", "RegLazyLoadingAttribute 参数2不能为null。");
            }
            if (!intfType.IsAssignableFrom(implType))
            {
                throw new ArgumentException(string.Format("类‘{0}’必须实现接口‘{1}'", implType, intfType));
            }
            if (implType.GetConstructor(new Type[0]) == null)
            {
                throw new ArgumentException(string.Format("类‘{0}’没有默认构造函数", implType));
            }

            var list = (ImplCollection)LazyLoadings[intfType];

            if (list == null)
            {
                list = new ImplCollection();
                LazyLoadings.Add(intfType, list);
            }
            list.Add(implType, priority);
        }
Exemplo n.º 2
0
        public static ResourceSpawnHandle SpawnAsync(ulong pathHash, LoadingPriority priority = LoadingPriority.Normal)
        {
            ResourceSpawnHandle result = null;

            if (!Application.isPlaying)
            {
                string path = HashToPath(pathHash);
                result = SpawnAsync(path, priority);
            }
            else
            {
                result = ResourcePoolManager.Instance.SpawnAsync(pathHash, (int)priority);
            }

            return(result);
        }
Exemplo n.º 3
0
        public static ResourceLoadHandle LoadAsync <T>(ulong pathHash, LoadingPriority priority = LoadingPriority.Normal) where T : Object
        {
            ResourceLoadHandle result = null;

            if (!Application.isPlaying)
            {
                string path = HashToPath(pathHash);
                result = LoadAsync <T>(path, priority);
            }
            else
            {
                result = ResourceDataManager.Instance.LoadAsync(pathHash, typeof(T), (int)priority);
            }

            return(result);
        }
Exemplo n.º 4
0
        public static ResourceSpawnHandle SpawnAsync(string path, LoadingPriority priority = LoadingPriority.Normal)
        {
            ResourceSpawnHandle result = null;

            if (!Application.isPlaying)
            {
                result            = new ResourceSpawnHandle();
                result.progress   = 1.0f;
                result.isDone     = true;
                result.gameObject = Spawn(path);
            }
            else
            {
                ulong pathHash = PathToHash(path);
                result = SpawnAsync(pathHash, priority);
            }

            return(result);
        }
Exemplo n.º 5
0
        public static ResourceLoadHandle LoadAsync <T>(string path, LoadingPriority priority = LoadingPriority.Normal) where T : Object
        {
            ResourceLoadHandle result = null;

            if (!Application.isPlaying)
            {
                result          = new ResourceLoadHandle();
                result.progress = 1.0f;
                result.isDone   = true;
                result.asset    = Resources.Load(path, typeof(T));
            }
            else
            {
                ulong pathHash = PathToHash(path);
                result = LoadAsync <T>(pathHash, priority);
            }

            return(result);
        }
Exemplo n.º 6
0
        public static IScheduledWork Load(string url, UIImageView view, int retry = 0, LoadingPriority priority = LoadingPriority.Normal, string placeHolder = "", string microUrl = null, CGSize size = new CGSize())
        {
            var width = (int)((size.Width == 0 ? view.Frame.Size.Width : size.Width) * UIScreen.MainScreen.Scale);

            return(ImageService.Instance.LoadUrl(url.GetImageProxy(width, width), TimeSpan.FromDays(5))
                   .Retry(retry)
                   .FadeAnimation(false)
                   .LoadingPlaceholder(placeHolder)
                   .ErrorPlaceholder(placeHolder)
                   .WithCache(FFImageLoading.Cache.CacheType.All)
                   .WithPriority(priority)
                   .Error((error) =>
            {
                ImageService.Instance.LoadUrl(microUrl != null ? microUrl : url, TimeSpan.FromDays(5))
                .Retry(retry)
                .FadeAnimation(false)
                .WithCache(FFImageLoading.Cache.CacheType.All)
                .DownSample((int)view.Frame.Size.Width)
                .WithPriority(priority)
                .Into(view);
            })
                   .Into(view));
        }
Exemplo n.º 7
0
 public Implement(Type implType, LoadingPriority priority)
 {
     ImplType  = implType;
     Priority  = (byte)priority;
     metadatas = ImplType.GetCustomAttributes <Attribute>(false).ToArray();
 }
Exemplo n.º 8
0
 public void Add(Type implType, LoadingPriority priority)
 {
     _list.Add(new Implement(implType, priority));
     _sorted = _list.Count < 2;
 }
Exemplo n.º 9
0
 /// <summary>
 /// Defines the loading priority, the default is LoadingPriority.Normal
 /// </summary>
 /// <returns>The TaskParameter instance for chaining the call.</returns>
 /// <param name="priority">Priority.</param>
 public TaskParameter WithPriority(LoadingPriority priority)
 {
     Priority = (int)priority;
     return(this);
 }
Exemplo n.º 10
0
		/// <summary>
		/// Defines the loading priority, the default is LoadingPriority.Normal
		/// </summary>
		/// <returns>The TaskParameter instance for chaining the call.</returns>
		/// <param name="priority">Priority.</param>
		public TaskParameter WithPriority(LoadingPriority priority)
		{
			Priority = (int)priority;
			return this;
		}
Exemplo n.º 11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RegLazyLoadingAttribute"/> class.
 /// </summary>
 /// <param name="intfType">Type of the intf.</param>
 /// <param name="implType">Type of the impl.</param>
 /// <param name="priority">The priority.</param>
 public RegLazyLoadingAttribute(Type intfType, Type implType, LoadingPriority priority)
 {
     IntfType = intfType;
     ImplType = implType;
     Priority = priority;
 }
Exemplo n.º 12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RegLazyLoadingAttribute"/> class.
 /// </summary>
 /// <param name="intfType">Type of the intf.</param>
 /// <param name="implType">Type of the impl.</param>
 public RegLazyLoadingAttribute(Type intfType, Type implType)
 {
     IntfType = intfType;
     ImplType = implType;
     Priority = LoadingPriority.Normal;
 }
Exemplo n.º 13
0
 public ContentAttribute(string resourceName, ContentCategory contentCategory, LoadingPriority loadingPriority = LoadingPriority.Immediate)
 {
     this.ContentCategory = contentCategory;
     this.LoadingPriority = loadingPriority;
     this.ResourceName = resourceName;
 }
Exemplo n.º 14
0
 public Implement(Type implType, LoadingPriority priority)
 {
     ImplType = implType;
     Priority = (byte)priority;
 }