コード例 #1
0
		/// <summary>
		/// Ensure that moniker resolvers and domain element serializers are installed properly on the given store, 
		/// so that deserialization can be carried out correctly.
		/// </summary>
		/// <param name="store">Store on which moniker resolvers will be set up.</param>
		internal protected virtual void InitializeSerialization(DslModeling::Store store)
		{
			#region Check Parameters
			global::System.Diagnostics.Debug.Assert(store != null);
			if (store == null)
				throw new global::System.ArgumentNullException("store");
			#endregion
	
			DslModeling::DomainXmlSerializerDirectory directory = this.GetDirectory(store);
	
			// Register the moniker resolver for this model, unless one is already registered
			DslModeling::IMonikerResolver monikerResolver = store.FindMonikerResolver(HostDesignerDomainModel.DomainModelId);
			if (monikerResolver == null)
			{
				monikerResolver = new HostDesignerSerializationBehaviorMonikerResolver(store, directory);
				store.AddMonikerResolver(HostDesignerDomainModel.DomainModelId, monikerResolver);
			}
			
			// Add serialization behaviors
			directory.AddBehavior(HostDesignerSerializationBehavior.Instance);
		}
コード例 #2
0
		/// <summary>
		/// Ensure that moniker resolvers are installed properly on the given store, so that deserialization can be carried out correctly.
		/// </summary>
		/// <param name="serializationContext">SerializationContext of the current operations.</param>
		/// <param name="store">Store on which moniker resolvers will be set up.</param>
		protected virtual void SetupMonikerResolver(DslModeling::SerializationContext serializationContext, DslModeling::Store store)
		{
			#region Check Parameters
			global::System.Diagnostics.Debug.Assert(serializationContext != null);
			if (serializationContext == null)
				throw new global::System.ArgumentNullException("serializationContext");
			global::System.Diagnostics.Debug.Assert(store != null);
			if (store == null)
				throw new global::System.ArgumentNullException("store");
			#endregion
	
			global::System.Collections.Generic.IDictionary<global::System.Guid, DslModeling::IMonikerResolver> resolvers = this.GetMonikerResolvers(store);
			foreach (global::System.Collections.Generic.KeyValuePair<global::System.Guid, DslModeling::IMonikerResolver> pair in resolvers)
			{
				DslModeling::IMonikerResolver existingMonikerResolver = store.FindMonikerResolver(pair.Key);
				if (existingMonikerResolver == null)
				{
					existingMonikerResolver = pair.Value;
					store.AddMonikerResolver(pair.Key, existingMonikerResolver);
				}
				DslModeling::SimpleMonikerResolver simpleMonikerResolver = existingMonikerResolver as DslModeling::SimpleMonikerResolver;
				if (simpleMonikerResolver != null)
					simpleMonikerResolver.SerializationContext = serializationContext;
			}
		}