Exemple #1
0
        public static void Configure(String fileName)
        {
            try
            {
                XmlSerializer s  = new XmlSerializer(typeof(XMLContextRoot));
                FileStream    fs = File.Open(fileName, FileMode.Open);
                IContextRoot  r  = (IContextRoot)s.Deserialize(fs);
                fs.Close();

                IConfigurationElementVisitor v = new XMLParentInitializationVisitor();
                r.Accept(v);

                v = new ConfigurationCheckVisitor();
                r.Accept(v);

                foreach (IContext context in r.Contexts)
                {
                    ContextManager.Instance.RegisterContext(context);
                }
            }
            catch (Exception ex)
            {
                throw new ContextCorruptedException("Context couldn't be configured. (" + ex.Message + ")");
            }
        }
 /// <summary>
 /// This outlines the signature to perform a write based on contextual criteria.
 /// </summary>
 /// <param name="oldValue">The old value.</param>
 /// <param name="newValue">The new value.</param>
 /// <param name="contextData">The contextual data from which to make a decision as to which value to return.</param>
 /// <returns>The result of the contextual decision. Should be either <paramref name="oldValue"/> or <paramref name="newValue"/>.</returns>
 public object DoWrite(object oldValue, object newValue, IContextRoot contextData)
 {
     if (newValue == null)
     {
         return(oldValue);
     }
     return(newValue);
 }
Exemple #3
0
        /// <summary>
        /// This outlines the signature to perform a write based on contextual criteria.
        /// </summary>
        /// <param name="oldValue">The old value.</param>
        /// <param name="newValue">The new value.</param>
        /// <param name="contextData">The contextual data from which to make a decision as to which value to return.</param>
        /// <returns>
        /// The result of the contextual decision. Should be either <paramref name="oldValue" /> or <paramref name="newValue" />.
        /// </returns>
        public object DoWrite(object oldValue, object newValue, IContextRoot contextData)
        {
            var oldCollection = (List <T>)oldValue;
            var newCollection = (List <T>)newValue;

            oldCollection.AddRange(newCollection);
            oldCollection.Sort(_comparer);

            return(oldCollection);
        }
Exemple #4
0
        /// <summary>
        /// This outlines the signature to perform a write based on contextual criteria.
        /// </summary>
        /// <param name="oldValue">The old value.</param>
        /// <param name="newValue">The new value.</param>
        /// <param name="contextData">The contextual data from which to make a decision as to which value to return.</param>
        /// <returns>
        /// The result of the contextual decision. Should be either <paramref name="oldValue" /> or <paramref name="newValue" />.
        /// </returns>
        /// <exception cref="System.NotImplementedException"></exception>
        public object DoWrite(object oldValue, object newValue, IContextRoot contextData)
        {
            if (contextData == null)
            {
                throw new ArgumentNullException(nameof(contextData));
            }

            var oldRoot = (SequencedComplexItem)contextData.OldValue;

            if (oldRoot.SequenceID == 1)
            {
                return(oldValue);
            }
            return(newValue);
        }
 public void Visit(IContextRoot contextRoot)
 {
 }
Exemple #6
0
 public void Visit(IContextRoot contextRoot)
 {
 }