コード例 #1
0
 internal Attachment(Revision revision, String name, IDictionary<String, Object> metadata)
 {
     Revision = revision;
     Name = name;
     Metadata = metadata;
     Compressed = false;
 }
コード例 #2
0
		internal Attachment(Revision revision, string name, IDictionary<string, object> metadata
			)
		{
			this.revision = revision;
			this.name = name;
			this.metadata = metadata;
			this.gzipped = false;
		}
コード例 #3
0
			public void Validate(Revision newRevision, ValidationContext context)
			{
				NUnit.Framework.Assert.IsNotNull(newRevision);
				NUnit.Framework.Assert.IsNotNull(context);
				NUnit.Framework.Assert.IsTrue(newRevision.GetProperties() != null || newRevision.
					IsDeletion());
				this._enclosing.validationCalled = true;
				bool hoopy = newRevision.IsDeletion() || (newRevision.GetProperties().Get("towel"
					) != null);
				Log.V(ValidationsTest.Tag, string.Format("--- Validating %s --> %b", newRevision.
					GetProperties(), hoopy));
				if (!hoopy)
				{
					context.Reject("Where's your towel?");
				}
			}
コード例 #4
0
		internal void SetRevision(Revision revision)
		{
			this.revision = revision;
		}
コード例 #5
0
ファイル: ApiTest.cs プロジェクト: Redth/couchbase-lite-net
			public void Validate(Revision newRevision, ValidationContext context)
			{
				{
					if (newRevision.GetProperty("groovy") == null)
					{
						context.Reject("uncool");
					}
				}
			}
コード例 #6
0
ファイル: ApiTest.cs プロジェクト: Redth/couchbase-lite-net
			public void Validate(Revision newRevision, ValidationContext context)
			{
			}
コード例 #7
0
 public ImageConverter(Revision rev)
 {
     this.rev = rev;
     attachmentNamesCount = new Dictionary<string, int> ();
 }
コード例 #8
0
        static JsonSerializer GetSerializer(Type serType, Revision rev, Database db,
		                                     IDReferenceResolver resolver, List<Type> localTypes)
        {
            if (resolver == null) {
                resolver = new IDReferenceResolver ();
            }
            if (localTypes == null) {
                localTypes = new List<Type> ();
            }
            localTypes.Add (serType);
            JsonSerializerSettings settings = new JsonSerializerSettings ();
            settings.Formatting = Formatting.Indented;
            settings.PreserveReferencesHandling = PreserveReferencesHandling.Objects;
            settings.TypeNameHandling = TypeNameHandling.Objects;
            settings.Converters.Add (new ImageConverter (rev));
            settings.Converters.Add (new VersionConverter ());
            settings.Converters.Add (new StorablesConverter (db, resolver, localTypes));
            settings.Converters.Add (new LongoMatchConverter (false));
            settings.ReferenceResolver = resolver;
            return JsonSerializer.Create (settings);
        }
コード例 #9
0
        /// <summary>
        /// Serializes an object into a <c>JObject</c>.
        /// </summary>
        /// <returns>A new object serialized.</returns>
        /// <param name="obj">The <c>IStorable</c> to serialize.</param>
        /// <param name="rev">The document revision to serialize.</param>
        /// <param name="localStorables">A list of <see cref="LongoMatch.Core.Interfaces.IStorable"/>
        /// types that should be serialized as local referencies instead of by document ID.</param>
        internal static JObject SerializeObject(IStorable obj, Revision rev, Database db,
		                                         IDReferenceResolver resolver = null)
        {
            JsonSerializer serializer = GetSerializer (obj.GetType (), rev, db,
                                            resolver, GetLocalTypes (obj.GetType ()));

            JObject jo = JObject.FromObject (obj, serializer);
            jo ["DocType"] = obj.GetType ().Name;
            return jo;
        }