コード例 #1
0
ファイル: ProtoPoc.cs プロジェクト: stormleoxia/Twitool
        private static void AddProperties(RuntimeTypeModel model, Type type)
        {
            var metaType = model.Add(type, true);
            foreach (var property in type.GetProperties().OrderBy(x => x.Name))
            {
                metaType.Add(property.Name);
                var propertyType = property.PropertyType;
                if (!IsBuiltinType(propertyType) &&
                    !model.IsDefined(propertyType) &&
                    propertyType.GetProperties().Length > 0)
                {

                    AddProperties(model, propertyType);
                }
            }
        }
コード例 #2
0
ファイル: TypeModelCreator.cs プロジェクト: Boxxxx/clicker
        /// <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;
        }