예제 #1
0
        /// <summary>
        /// Creates a reference to an existing ParseObject for use in creating associations between
        /// ParseObjects. Calling <see cref="IsDataAvailable"/> on this object will return
        /// <c>false</c> until <see cref="ParseExtensions.FetchIfNeededAsync{T}(T)"/> has been called.
        /// No network request will be made.
        /// </summary>
        /// <param name="className">The object's class.</param>
        /// <param name="objectId">The object id for the referenced object.</param>
        /// <returns>A ParseObject without data.</returns>
        public static ParseObject CreateObjectWithoutData(this IParseObjectClassController classController, string className, string objectId, IServiceHub serviceHub)
        {
            ParseObject.CreatingPointer.Value = true;
            try
            {
                ParseObject result = classController.Instantiate(className, serviceHub);
                result.ObjectId = objectId;

                // Left in because the property setter might be doing something funky.

                result.IsDirty = false;
                return(result.IsDirty ? throw new InvalidOperationException("A ParseObject subclass default constructor must not make changes to the object that cause it to be dirty.") : result);
            }
            finally { ParseObject.CreatingPointer.Value = false; }
        }
예제 #2
0
 /// <summary>
 /// Creates a new ParseObject based upon a given subclass type.
 /// </summary>
 /// <returns>A new ParseObject for the given class name.</returns>
 public static T CreateObject <T>(this IParseObjectClassController classController, IServiceHub serviceHub) where T : ParseObject => (T)classController.Instantiate(classController.GetClassName(typeof(T)), serviceHub);