Пример #1
0
        /// <summary>
        /// Gets the serialization context
        /// </summary>
        public SerializationContext(String propertyName, IViewModelSerializer context, Object instance)
        {
            this.PropertyName         = propertyName;
            this.Parent               = null;
            this.Instance             = instance;
            this.Context              = context;
            this.ViewModelDescription = this.Context.ViewModel;
            this.LoadedProperties     = new Dictionary <Guid, HashSet <string> >();

            // Attempt to load from cache
            object check = null;

            if (instance != null && !m_cachedSerializationChecks.TryGetValue(instance.GetType(), out check))
            {
                this.m_serializationCheck = instance?.GetType().GetRuntimeProperties()
                                            .Select(p => new { MethodInfo = p.DeclaringType.GetRuntimeMethod($"ShouldSerialize{p.Name}", new Type[0]), SerializationName = p.GetCustomAttributes <XmlElementAttribute>().FirstOrDefault()?.ElementName })
                                            .Where(o => o.MethodInfo != null && !String.IsNullOrEmpty(o.SerializationName))
                                            .ToDictionary(o => o.SerializationName, o => o.MethodInfo);
                m_cachedSerializationChecks.TryAdd(instance.GetType(), this.m_serializationCheck);
            }
            else if (check != null)
            {
                this.m_serializationCheck = (Dictionary <String, MethodInfo>)check;
            }
        }
Пример #2
0
        /// <summary>
        /// Creates a new reflection based classifier
        /// </summary>
        public JsonReflectionClassifier(Type type, IViewModelSerializer owner)
        {
            this.m_type = type;
            var classifierAtt = type.StripGeneric().GetCustomAttribute <ClassifierAttribute>();

            this.m_classifierAttribute = classifierAtt;
            this.m_serializer          = owner;
        }
Пример #3
0
 /// <summary>
 /// Gets the serialization context
 /// </summary>
 public SerializationContext(String propertyName, IViewModelSerializer context, Object instance)
 {
     this.PropertyName         = propertyName;
     this.Parent               = null;
     this.Instance             = instance;
     this.Context              = context;
     this.ViewModelDescription = this.Context.ViewModel;
     this.LoadedProperties     = new Dictionary <Guid, HashSet <string> >();
 }
Пример #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DotvvmPresenter" /> class.
 /// </summary>
 public DotvvmPresenter(DotvvmConfiguration configuration, IDotvvmViewBuilder viewBuilder, IViewModelLoader viewModelLoader, IViewModelSerializer viewModelSerializer,
                        IOutputRenderer outputRender, ICsrfProtector csrfProtector)
 {
     DotvvmViewBuilder   = viewBuilder;
     ViewModelLoader     = viewModelLoader;
     ViewModelSerializer = viewModelSerializer;
     OutputRenderer      = outputRender;
     CsrfProtector       = csrfProtector;
     ApplicationPath     = configuration.ApplicationPhysicalPath;
 }
Пример #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DotvvmPresenter"/> class.
 /// </summary>
 public DotvvmPresenter(
     IDotvvmViewBuilder dotvvmViewBuilder,
     IViewModelLoader viewModelLoader,
     IViewModelSerializer viewModelSerializer,
     IOutputRenderer outputRenderer,
     ICsrfProtector csrfProtector
     )
 {
     DotvvmViewBuilder   = dotvvmViewBuilder;
     ViewModelLoader     = viewModelLoader;
     ViewModelSerializer = viewModelSerializer;
     OutputRenderer      = outputRenderer;
     CsrfProtector       = csrfProtector;
 }
Пример #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DotvvmPresenter"/> class.
 /// </summary>
 public DotvvmPresenter(
     IDotvvmViewBuilder dotvvmViewBuilder,
     IViewModelLoader viewModelLoader,
     IViewModelSerializer viewModelSerializer,
     IOutputRenderer outputRenderer,
     ICsrfProtector csrfProtector
 )
 {
     DotvvmViewBuilder = dotvvmViewBuilder;
     ViewModelLoader = viewModelLoader;
     ViewModelSerializer = viewModelSerializer;
     OutputRenderer = outputRenderer;
     CsrfProtector = csrfProtector;
 }
Пример #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RedwoodPresenter"/> class.
 /// </summary>
 public RedwoodPresenter(
     IRedwoodViewBuilder redwoodViewBuilder,
     IViewModelLoader viewModelLoader,
     IViewModelSerializer viewModelSerializer,
     IOutputRenderer outputRenderer,
     ICsrfProtector csrfProtector
 )
 {
     RedwoodViewBuilder = redwoodViewBuilder;
     ViewModelLoader = viewModelLoader;
     ViewModelSerializer = viewModelSerializer;
     OutputRenderer = outputRenderer;
     CsrfProtector = csrfProtector;
 }
Пример #8
0
        public DotvvmPresenter(DotvvmConfiguration configuration, IDotvvmViewBuilder viewBuilder, IViewModelLoader viewModelLoader, IViewModelSerializer viewModelSerializer,
                               IOutputRenderer outputRender, ICsrfProtector csrfProtector, IViewModelParameterBinder viewModelParameterBinder,
#pragma warning disable CS0618
                               IStaticCommandServiceLoader staticCommandServiceLoader
#pragma warning restore CS0618
                               )
        {
            DotvvmViewBuilder        = viewBuilder;
            ViewModelLoader          = viewModelLoader;
            ViewModelSerializer      = viewModelSerializer;
            OutputRenderer           = outputRender;
            CsrfProtector            = csrfProtector;
            ViewModelParameterBinder = viewModelParameterBinder;
#pragma warning disable CS0618
            StaticCommandServiceLoader = staticCommandServiceLoader;
#pragma warning restore CS0618
            ApplicationPath = configuration.ApplicationPhysicalPath;
        }
Пример #9
0
 /// <summary>
 /// Serialization context
 /// </summary>
 public NullSerializationContext(string propertyName, IViewModelSerializer context, object instance, SerializationContext parent) :
     base(propertyName, context, instance, parent)
 {
 }
Пример #10
0
 public DotvvmAmpPresenter(DotvvmConfiguration configuration, Func <IAmpStylesheetResourceCollection> ampStylesheetResourceCollectionFactory, IAmpDotvvmViewBuilder viewBuilder, IViewModelLoader viewModelLoader, IViewModelSerializer viewModelSerializer, IAmpOutputRenderer outputRender, ICsrfProtector csrfProtector, IViewModelParameterBinder viewModelParameterBinder, IStaticCommandServiceLoader staticCommandServiceLoader) : base(configuration, viewBuilder, viewModelLoader, viewModelSerializer, outputRender, csrfProtector, viewModelParameterBinder, staticCommandServiceLoader)
 {
     this.ampStylesheetResourceCollectionFactory = ampStylesheetResourceCollectionFactory;
 }
 public StatusPagePresenter(DotvvmConfiguration configuration, IDotvvmViewBuilder viewBuilder, IViewModelLoader viewModelLoader,
                            IViewModelSerializer viewModelSerializer, IOutputRenderer outputRender, ICsrfProtector csrfProtector,
                            IViewModelParameterBinder viewModelParameterBinder, IStaticCommandServiceLoader staticCommandServiceLoader) :
     base(configuration, viewBuilder, new DefaultViewModelLoader(), viewModelSerializer, outputRender, csrfProtector, viewModelParameterBinder, staticCommandServiceLoader)
 {
 }
Пример #12
0
 /// <summary>
 /// Gets the serialization context
 /// </summary>
 public SerializationContext(String propertyName, IViewModelSerializer context, Object instance, SerializationContext parent) : this(propertyName, context, instance)
 {
     this.Parent           = parent;
     this.m_objectId       = this.Root.m_masterObjectId++;
     this.LoadedProperties = parent?.LoadedProperties ?? new Dictionary <Guid, HashSet <string> >();
 }