Ejemplo n.º 1
0
        private IVersionProvider CreateVersionProviderFor(T newValue, T oldValue)
        {
            int initial_version = (m_VersionProvider.GetVersionFor(oldValue) + 1);

            if (newValue == null)
            {
                return(new NullObjectVersionProvider(initial_version));
            }

            Type runtimeType = newValue.GetType();

            if (HashVersionProvider.CanHandle(runtimeType))
            {
                return(new HashVersionProvider(newValue, initial_version));
            }
            else if (NotifyPropertyChangedVersionProvider.CanHandle(runtimeType))
            {
                return(new NotifyPropertyChangedVersionProvider(newValue, initial_version));
            }
            else
            {
                throw new InvalidOperationException(String.Format("No IVersionProvider found that can handle type '{0}'", typeof(T).FullName));
            }
        }