Пример #1
0
 private static bool ContainsType(RuntimeTypeModel model, Type type)
 {
     foreach (MetaType metaType in model.GetTypes())
     {
         if (metaType.Type == type)
         {
             return true;
         }
     }
     return false;
 }
Пример #2
0
        /// <summary>
        /// Returns true if the given RuntimeTypeModel contains a definition for the given type.
        /// </summary>
        private static bool ContainsType(RuntimeTypeModel model, Type type) {
            bool emit = !type.IsNullableType();
            bool fastCheck = model.IsDefined(type);

            // DEBUGGING: comment this if statement out if there are protobuf-net related issues
            if (emit) {
                return fastCheck;
            }

            foreach (MetaType metaType in model.GetTypes()) {
                if (metaType.Type == type) {
                    if (emit && fastCheck != true) UnityEngine.Debug.Log("Fast check failed for " + type.CSharpName() + " (nullabe? " + type.IsNullableType() + ")!");
                    return true;
                }
            }

            if (emit && fastCheck != false) UnityEngine.Debug.Log("Fast check failed for " + type.CSharpName() + " (nullabe? " + type.IsNullableType() + ")!");
            return false;
        }