Esempio n. 1
0
        /// <summary>
        /// Cache item with given Func&lt;object>
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="key"></param>
        /// <param name="cacheFunction"></param>
        /// <param name="interval"></param>
        /// <param name="dependencies"></param>
        /// <param name="priority"></param>
        /// <param name="removalCallback"></param>
        /// <param name="settings"></param>
        /// <returns></returns>
        public virtual T CacheItem <T>(string key, Func <object> cacheFunction, double interval = 30, ICacheDependency dependencies = null,
                                       CachePriority priority = CachePriority.Default, Action <string, object, CacheRemovalReason> removalCallback = null, ICacheSettings settings = null)
        {
            if (cacheFunction == null)
            {
                return(default(T));
            }

            settings = settings ?? Settings;
            bool cacheEnabled = settings.Enabled;

            // Handle Structs
            if (_ReflectionHelper.IsValueType(typeof(T)))
            {
                // Boxing needed to avoid nullable checks on structs
                object o           = GetCrossPlatformCacheData(key);
                T      cachedValue = default(T);

                if (o != null)
                {
                    cachedValue = (T)o;
                }

                // !EnableCache allows previewing to disable per user
                if (!cacheEnabled || o == null)
                {
                    cachedValue = (T)cacheFunction();

                    if (cacheEnabled && interval > 0)
                    {
                        SetCrossPlatformCache(key, cachedValue, interval, dependencies, priority, removalCallback);
                    }
                }

                return(cachedValue);
            }

            // Handle Classes
            var cachedData = GetCrossPlatformCacheData(key);

            // !EnableCache allows previewing to disable per user
            if (!cacheEnabled || cachedData == null)
            {
                cachedData = cacheFunction();

                // If cached data is bad, store for a minute.
                if (cachedData == null)
                {
                    interval   = 60;
                    cachedData = new NullData();
                }

                if (cacheEnabled && interval > 0)
                {
                    SetCrossPlatformCache(key, cachedData, interval, dependencies, priority, removalCallback);
                }
            }

            return((cachedData is NullData) ? default(T) : (T)cachedData);
        }
Esempio n. 2
0
        /// <summary>
        /// 参照が設定されていない NotNull なパラメータの一覧を返します
        /// </summary>
        private static IEnumerable <NullData> Validate()
        {
            var gameObjects = Resources
                              .FindObjectsOfTypeAll <GameObject>()
                              .Where(c => c.scene.isLoaded)
                              .Where(c => c.hideFlags == HideFlags.None)
            ;

            foreach (var gameObject in gameObjects)
            {
                var components = gameObject.GetComponents <Component>();

                foreach (var component in components)
                {
                    if (component == null)
                    {
                        continue;
                    }

                    var type   = component.GetType();
                    var fields = type.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);

                    foreach (var field in fields)
                    {
                        var attrs = field.GetCustomAttributes(typeof(JetBrains.Annotations.NotNullAttribute), true)
#if ODIN_INSPECTOR
                                    .Concat(field.GetCustomAttributes(typeof(Sirenix.OdinInspector.RequiredAttribute), true))
                                    .ToArray()
#endif
                        ;

                        if (attrs.Length <= 0)
                        {
                            continue;
                        }

                        var value = field.GetValue(component);

                        if (value != null && value.ToString() != "null")
                        {
                            continue;
                        }

                        var data = new NullData
                                   (
                            component: component,
                            gameObjectName: component.gameObject.name,
                            gameObjectRootPath: component.gameObject.GetRootPath(),
                            componentName: component.GetType().Name,
                            fieldName: field.Name
                                   );

                        yield return(data);
                    }
                }
            }
        }
Esempio n. 3
0
 public void IntersectFirstArgumentNull()
 {
     Assert.Throws <ArgumentNullException>(() => NullData.Intersect(DummyData)).WithParameter("first");
 }
Esempio n. 4
0
 public void AggregateWithSeedSourceArgumentNull()
 {
     Assert.Throws <ArgumentNullException>(() => NullData.Aggregate(new object(), (x, y) => true)).WithParameter("source");
 }
Esempio n. 5
0
 public void LastSourceArgumentNull()
 {
     Assert.Throws <ArgumentNullException>(() => NullData.Last()).WithParameter("source");
 }
 public void OrderByDescendingSourceArgumentNull()
 {
     Assert.Throws <ArgumentNullException>(() => NullData.OrderByDescending(x => x)).WithParameter("source");
 }
Esempio n. 7
0
 public void SkipWhileWithIndexSourceArgumentNull()
 {
     Assert.Throws <ArgumentNullException>(() => NullData.SkipWhile((x, i) => true)).WithParameter("source");
 }
Esempio n. 8
0
 public void GroupBySourceArgumentNull()
 {
     Assert.Throws <ArgumentNullException>(() => NullData.GroupBy(x => x)).WithParameter("source");
 }
Esempio n. 9
0
 public void GroupByWithElementSelectorComparerSourceArgumentNull()
 {
     Assert.Throws <ArgumentNullException>(() => NullData.GroupBy(k => k, e => e, EqualityComparer <object> .Default)).WithParameter("source");
 }
 public void SingleOrDefaultSourceArgumentNull()
 {
     Assert.Throws <ArgumentNullException>(() => NullData.SingleOrDefault()).WithParameter("source");
 }
Esempio n. 11
0
 public void DistinctWithComparerSourceArgumentNull()
 {
     Assert.Throws <ArgumentNullException>(() => NullData.Distinct(EqualityComparer <object> .Default)).WithParameter("source");
 }
Esempio n. 12
0
 public void ToLookupWithElementSelectorSourceArgumentNull()
 {
     Assert.Throws <ArgumentNullException>(() => NullData.ToLookup(k => k, e => e)).WithParameter("source");
 }
Esempio n. 13
0
 public void ToLookupWithComparerSourceArgumentNull()
 {
     Assert.Throws <ArgumentNullException>(() => NullData.ToLookup(x => x, EqualityComparer <object> .Default)).WithParameter("source");
 }
Esempio n. 14
0
 public void ToLookupSourceArgumentNull()
 {
     Assert.Throws <ArgumentNullException>(() => NullData.ToLookup(x => x)).WithParameter("source");
 }
Esempio n. 15
0
        private void _parse()
        {
            _datatype = ((DataType)m_io.ReadU1());
            switch (Datatype)
            {
            case DataType.Integer:
            {
                _dataValue = new Integer(m_io, this, m_root);
                break;
            }

            case DataType.Unsigned:
            {
                _dataValue = new Unsigned(m_io, this, m_root);
                break;
            }

            case DataType.Long:
            {
                _dataValue = new Long(m_io, this, m_root);
                break;
            }

            case DataType.Boolean:
            {
                _dataValue = new Boolean(m_io, this, m_root);
                break;
            }

            case DataType.Structure:
            {
                _dataValue = new Structure(m_io, this, m_root);
                break;
            }

            case DataType.Array:
            {
                _dataValue = new Array(m_io, this, m_root);
                break;
            }

            case DataType.Float64:
            {
                _dataValue = new Float64(m_io, this, m_root);
                break;
            }

            case DataType.DoNotCare:
            {
                _dataValue = new DoNotCare(m_io, this, m_root);
                break;
            }

            case DataType.LongUnsigned:
            {
                _dataValue = new LongUnsigned(m_io, this, m_root);
                break;
            }

            case DataType.Time:
            {
                _dataValue = new Time(m_io, this, m_root);
                break;
            }

            case DataType.OctetString:
            {
                _dataValue = new OctetString(m_io, this, m_root);
                break;
            }

            case DataType.NullData:
            {
                _dataValue = new NullData(m_io, this, m_root);
                break;
            }

            case DataType.CompactArray:
            {
                _dataValue = new CompactArray(m_io, this, m_root);
                break;
            }

            case DataType.DateTime:
            {
                _dataValue = new DateTime(m_io, this, m_root);
                break;
            }

            case DataType.DoubleLongUnsigned:
            {
                _dataValue = new DoubleLongUnsigned(m_io, this, m_root);
                break;
            }

            case DataType.Float32:
            {
                _dataValue = new Float32(m_io, this, m_root);
                break;
            }

            case DataType.Long64Unsigned:
            {
                _dataValue = new Long64Unsigned(m_io, this, m_root);
                break;
            }

            case DataType.DoubleLong:
            {
                _dataValue = new DoubleLong(m_io, this, m_root);
                break;
            }

            case DataType.Long64:
            {
                _dataValue = new Long64(m_io, this, m_root);
                break;
            }

            case DataType.Date:
            {
                _dataValue = new Date(m_io, this, m_root);
                break;
            }

            case DataType.Enum:
            {
                _dataValue = new Enum(m_io, this, m_root);
                break;
            }

            case DataType.Bcd:
            {
                _dataValue = new Bcd(m_io, this, m_root);
                break;
            }

            case DataType.VisibleString:
            {
                _dataValue = new VisibleString(m_io, this, m_root);
                break;
            }

            case DataType.BitString:
            {
                _dataValue = new BitString(m_io, this, m_root);
                break;
            }
            }
        }
Esempio n. 16
0
 public void ToArraySourceArgumentNull()
 {
     Assert.Throws <ArgumentNullException>(() => NullData.ToArray()).WithParameter("source");
 }
Esempio n. 17
0
 public void IntersectWithComparerFirstArgumentNull()
 {
     Assert.Throws <ArgumentNullException>(() => NullData.Intersect(DummyData, EqualityComparer <object> .Default)).WithParameter("first");
 }
Esempio n. 18
0
 public void SequenceEqualFirstArgumentNull()
 {
     Assert.Throws <ArgumentNullException>(() => NullData.SequenceEqual(DummyData)).WithParameter("first");
 }
Esempio n. 19
0
 public void AllSourceArgumentNull()
 {
     Assert.Throws <ArgumentNullException>(() => NullData.All(x => true)).WithParameter("source");
 }
Esempio n. 20
0
 public void SelectSourceArgumentNull()
 {
     Assert.Throws <ArgumentNullException>(() => NullData.Select(x => x)).WithParameter("source");
 }
Esempio n. 21
0
 public void GroupByWithElementAndResultSelectorSourceArgumentNull()
 {
     Assert.Throws <ArgumentNullException>(() => NullData.GroupBy(k => k, e => e, (k, c) => k)).WithParameter("source");
 }
 public void ElementAtOrDefaultSourceArgumentNull()
 {
     Assert.Throws <ArgumentNullException>(() => NullData.ElementAtOrDefault(0)).WithParameter("source");
 }
Esempio n. 23
0
 public void OfTypeSourceArgumentNull()
 {
     Assert.Throws <ArgumentNullException>(() => NullData.OfType <string>()).WithParameter("source");
 }
Esempio n. 24
0
 public void ContainsSourceArgumentNull()
 {
     Assert.Throws <ArgumentNullException>(() => NullData.Contains(new object())).WithParameter("source");
 }
 public void OrderByDescendingWithComparerSourceArgumentNull()
 {
     Assert.Throws <ArgumentNullException>(() => NullData.OrderByDescending(x => x, Comparer <object> .Default)).WithParameter("source");
 }
Esempio n. 26
0
 public void SingleWithPredicateSourceArgumentNull()
 {
     Assert.Throws <ArgumentNullException>(() => NullData.Single(x => true)).WithParameter("source");
 }
Esempio n. 27
0
 public void ContainsWithComparerSourceArgumentNull()
 {
     Assert.Throws <ArgumentNullException>(() => NullData.Contains(new object(), EqualityComparer <object> .Default)).WithParameter("source");
 }
Esempio n. 28
0
 public void GroupJoinOuterArgumentNull()
 {
     Assert.Throws <ArgumentNullException>(() => NullData.GroupJoin(DummyData, x => x, x => x, (x, y) => x)).WithParameter("outer");
 }
Esempio n. 29
0
 public void LastOrDefaultWithPredicateSourceArgumentNull()
 {
     Assert.Throws <ArgumentNullException>(() => NullData.LastOrDefault(x => true)).WithParameter("source");
 }
Esempio n. 30
0
 public void GroupJoinWithComparerOuterArgumentNull()
 {
     Assert.Throws <ArgumentNullException>(() => NullData.GroupJoin(DummyData, x => x, x => x, (x, y) => x, EqualityComparer <object> .Default)).WithParameter("outer");
 }