Ejemplo n.º 1
0
        /// <summary>
        /// Adds a custom object dependency to the dependencies of a list of cached objects.
        /// </summary>
        /// <param name="dependent">The <see cref="IObjectDependency"/> to be added.</param>
        /// <param name="references">Array of <see cref="ObjectReference"/> specifying the
        /// cached objects whose dependencies <paramref name="dependent"/> is added.</param>
        /// <exception cref="ArgumentNullException">
        /// <para><paramref name="dependent"/> is <see langword="null"/>.</para>
        /// <para>-or-</para>
        /// <para><paramref name="references"/> is <see langword="null"/>.</para>
        /// </exception>
        /// <exception cref="ArgumentOutOfRangeException">
        /// <para><paramref name="dependent"/> is empty.</para>
        /// </exception>
        public static void AddDependent(IObjectDependency dependent, params ObjectReference[] references)
        {
            if (dependent == null)
            {
                throw new ArgumentNullException("dependent");
            }
            if (references == null)
            {
                throw new ArgumentNullException("references");
            }
            var len = references.Length;

            if (len == 0)
            {
                throw new ArgumentOutOfRangeException("references");
            }
            for (var idx = 0; idx < len; ++idx)
            {
                var reference    = references[idx];
                var dependencies = GetDependencies(reference.TypeId, reference.ObjectId, true);
                using (var dependencyList = dependencies.Instance)
                {
                    dependencyList.Add(new ObjectDependency(dependent));
                }
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 ///     <para>Initializes a new instance of the <see cref="ObjectDependency"/> class
 ///		for deserialization.</para>
 /// </summary>
 internal ObjectDependency()
 {
     CustomDependency = null;
     Reference        = null;
     LastUpdatedDate  = new DateTime();
     Type             = new DependencyType();
 }
Ejemplo n.º 3
0
 /// <summary>
 ///     <para>Deserialize the class data from a stream.</para>
 /// </summary>
 /// <param name="reader">
 ///     <para>The <see cref="IPrimitiveReader"/> that extracts used to extra data from a stream.</para>
 /// </param>
 /// <param name="version">
 ///     <para>The value of <see cref="CurrentVersion"/> that was written to the stream when it was originally serialized to a stream; the version of the <paramref name="reader"/> data.</para>
 /// </param>
 public void Deserialize(IPrimitiveReader reader, int version)
 {
     if (version == 1)
     {
         if (reader.ReadBoolean())
         {
             var keySpace          = DataBuffer.DeserializeValue(reader);
             var descr             = LocalCache.Policy.GetDescription(keySpace);
             var dependencyVersion = reader.ReadInt32();
             CustomDependency = (IObjectDependency)descr.Creator();
             CustomDependency.Deserialize(reader, dependencyVersion);
             Type            = new DependencyType();
             Reference       = null;
             LastUpdatedDate = new DateTime();
         }
         else
         {
             CustomDependency = null;
             Type             = (DependencyType)reader.ReadInt32();
             Reference        = reader.Read <ObjectReference>(false);
             LastUpdatedDate  = reader.ReadDateTime();
         }
     }
     else
     {
         reader.Response = SerializationResponse.Unhandled;
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 ///     <para>Initializes a new instance of the <see cref="ObjectDependency"/>
 ///		class for expiration of other objects.</para>
 /// </summary>
 /// <param name="reference">
 ///     <para>Reference to the dependent object.</para>
 /// </param>
 /// <param name="lastUpdatedDate">
 ///     <para>Last updated date of the dependent object.</para>
 /// </param>
 /// <param name="type">
 ///     <para>Type of dependency.</para>
 /// </param>
 internal ObjectDependency(ObjectReference reference, DateTime lastUpdatedDate,
                           DependencyType type)
 {
     CustomDependency = null;
     Reference        = reference;
     LastUpdatedDate  = lastUpdatedDate;
     Type             = type;
 }