Maintains the synchronization meta-info for a component.
        /// <summary>
        ///   Populates the meta-info from the attributes.
        /// </summary>
        /// <param name = "metaInfo">The meta info.</param>
        /// <param name = "implementation">The implementation type.</param>
        private static void PopulateMetaInfoFromType(SynchronizeMetaInfo metaInfo,
                                                     Type implementation)
        {
            if (implementation == typeof(object)
#if FEATURE_REMOTING
                || implementation == typeof(MarshalByRefObject)
#endif
                )
            {
                return;
            }

            var methods = implementation.GetMethods(MethodBindingFlags);

            foreach (var method in methods)
            {
                var atts = method.GetAttributes <SynchronizeAttribute>(true);

                if (atts.Length != 0)
                {
                    metaInfo.Add(method, atts[0]);
                }
            }

            PopulateMetaInfoFromType(metaInfo, implementation.BaseType);
        }
		/// <summary>
		///   Creates the meta-info from the configuration.
		/// </summary>
		/// <param name = "implementation">The implementation type.</param>
		/// <param name = "config">The configuration.</param>
		/// <returns>The corresponding meta-info.</returns>
		public SynchronizeMetaInfo CreateMetaInfoFromConfig(Type implementation, IConfiguration config)
		{
			var syncAttrib = CreateAttributeFromConfig(config);
			var metaInfo = new SynchronizeMetaInfo(syncAttrib);

			Register(implementation, metaInfo);

			return metaInfo;
		}
        /// <summary>
        /// Creates the meta-info from the configuration.
        /// </summary>
        /// <param name="implementation">The implementation type.</param>
        /// <param name="config">The configuration.</param>
        /// <returns>The corresponding meta-info.</returns>
        public SynchronizeMetaInfo CreateMetaInfoFromConfig(Type implementation, IConfiguration config)
        {
            var syncAttrib = CreateAttributeFromConfig(config);
            var metaInfo   = new SynchronizeMetaInfo(syncAttrib);

            Register(implementation, metaInfo);

            return(metaInfo);
        }
		/// <summary>
		///   Creates the meta-info from the specified type.
		/// </summary>
		/// <param name = "implementation">The implementation type.</param>
		/// <returns>The corresponding meta-info.</returns>
		public SynchronizeMetaInfo CreateMetaFromType(Type implementation)
		{
			var syncAttrib = implementation.GetAttributes<SynchronizeAttribute>()[0];
			var metaInfo = new SynchronizeMetaInfo(syncAttrib);

			PopulateMetaInfoFromType(metaInfo, implementation);

			Register(implementation, metaInfo);

			return metaInfo;
		}
        /// <summary>
        /// Creates the meta-info from the specified type.
        /// </summary>
        /// <param name="implementation">The implementation type.</param>
        /// <returns>The corresponding meta-info.</returns>
        public SynchronizeMetaInfo CreateMetaFromType(Type implementation)
        {
            var syncAttrib = implementation.GetAttributes <SynchronizeAttribute>()[0];
            var metaInfo   = new SynchronizeMetaInfo(syncAttrib);

            PopulateMetaInfoFromType(metaInfo, implementation);

            Register(implementation, metaInfo);

            return(metaInfo);
        }
		/// <summary>
		/// Creates the meta-info from the specified type.
		/// </summary>
		/// <param name="implementation">The implementation type.</param>
		/// <returns>The corresponding meta-info.</returns>
		public SynchronizeMetaInfo CreateMetaFromType(Type implementation)
		{
			SynchronizeAttribute syncAttrib = (SynchronizeAttribute)
			                                  implementation.GetCustomAttributes(true)[0];

			SynchronizeMetaInfo metaInfo = new SynchronizeMetaInfo(syncAttrib);

			PopulateMetaInfoFromType(metaInfo, implementation);

			Register(implementation, metaInfo);

			return metaInfo;
		}
		/// <summary>
		/// Populates the meta-info from the attributes.
		/// </summary>
		/// <param name="metaInfo">The meta info.</param>
		/// <param name="implementation">The implementation type.</param>
		private static void PopulateMetaInfoFromType(SynchronizeMetaInfo metaInfo,
		                                             Type implementation)
		{
			if (implementation == typeof(object) || implementation == typeof(MarshalByRefObject))
			{
				return;
			}

			var methods = implementation.GetMethods(MethodBindingFlags);

			foreach (var method in methods)
			{
				var atts = method.GetAttributes<SynchronizeAttribute>();

				if (atts.Length != 0)
				{
					metaInfo.Add(method, atts[0]);
				}
			}

			PopulateMetaInfoFromType(metaInfo, implementation.BaseType);
		}
		/// <summary>
		/// Populates the meta-info from the attributes.
		/// </summary>
		/// <param name="metaInfo">The meta info.</param>
		/// <param name="implementation">The implementation type.</param>
		private static void PopulateMetaInfoFromType(SynchronizeMetaInfo metaInfo,
		                                             Type implementation)
		{
			if (implementation == typeof(object) ||
			    implementation == typeof(MarshalByRefObject))
			{
				return;
			}

			MethodInfo[] methods = implementation.GetMethods(MethodBindingFlags);

			foreach(MethodInfo method in methods)
			{
				object[] atts = method.GetCustomAttributes(typeof(SynchronizeAttribute), true);

				if (atts.Length != 0)
				{
					metaInfo.Add(method, atts[0] as SynchronizeAttribute);
				}
			}

			PopulateMetaInfoFromType(metaInfo, implementation.BaseType);
		}
Exemple #9
0
 /// <summary>
 ///   Sets the intercepted ComponentModel.
 /// </summary>
 /// <param name = "target">The targets ComponentModel.</param>
 public void SetInterceptedComponentModel(ComponentModel target)
 {
     metaInfo = metaStore.GetMetaFor(target.Implementation);
 }
		/// <summary>
		///   Registers the meta-info for the specified implementation type.
		/// </summary>
		/// <param name = "implementation">The implementation type.</param>
		/// <param name = "metaInfo">The meta-info.</param>
		private void Register(Type implementation, SynchronizeMetaInfo metaInfo)
		{
			type2MetaInfo[implementation] = metaInfo;
		}
		/// <summary>
		///   Constructs the selector with the existing selector.
		/// </summary>
		/// <param name = "metaInfo">The sync metadata.</param>
		/// <param name = "existingSelector">The existing selector.</param>
		public SynchronizeInterceptorSelector(SynchronizeMetaInfo metaInfo,
		                                      IInterceptorSelector existingSelector)
		{
			this.metaInfo = metaInfo;
			this.existingSelector = existingSelector;
		}
 /// <summary>
 /// Registers the meta-info for the specified implementation type.
 /// </summary>
 /// <param name="implementation">The implementation type.</param>
 /// <param name="metaInfo">The meta-info.</param>
 private void Register(Type implementation, SynchronizeMetaInfo metaInfo)
 {
     type2MetaInfo[implementation] = metaInfo;
 }
 /// <summary>
 ///   Constructs the selector with the existing selector.
 /// </summary>
 /// <param name = "metaInfo">The sync metadata.</param>
 /// <param name = "existingSelector">The existing selector.</param>
 public SynchronizeInterceptorSelector(SynchronizeMetaInfo metaInfo,
                                       IInterceptorSelector existingSelector)
 {
     this.metaInfo         = metaInfo;
     this.existingSelector = existingSelector;
 }
		/// <summary>
		/// Sets the intercepted ComponentModel.
		/// </summary>
		/// <param name="target">The targets ComponentModel.</param>
		public void SetInterceptedComponentModel(ComponentModel target)
		{
			metaInfo = metaStore.GetMetaFor(target.Implementation);
		}