Пример #1
0
 public EventsExchange(
     IExternalDataSource <SportEvent> dataSource,
     ChannelPoolBase <SportEvent, int> pool)
 {
     _dataSource = dataSource;
     _pool       = pool;
 }
Пример #2
0
        public override bool IsServerDelegatable(CallNode callNode, TexlBinding binding)
        {
            Contracts.AssertValue(callNode);
            Contracts.AssertValue(binding);

            IExternalDataSource dataSource = null;

            // Only delegate First, not last
            if (!_isFirst)
            {
                return(false);
            }

            // If has top capability (e.g. Dataverse)
            if (TryGetValidDataSourceForDelegation(callNode, binding, FunctionDelegationCapability, out dataSource))
            {
                return(true);
            }

            // If is a client-side pageable data source
            if (TryGetDataSource(callNode, binding, out dataSource) && dataSource.Kind == DataSourceKind.Connected && dataSource.IsPageable)
            {
                return(true);
            }

            if (dataSource != null && dataSource.IsDelegatable)
            {
                binding.ErrorContainer.EnsureError(DocumentErrorSeverity.Warning, callNode, TexlStrings.OpNotSupportedByServiceSuggestionMessage_OpNotSupportedByService, Name);
            }

            return(false);
        }
Пример #3
0
 /// <summary>
 /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
 /// </summary>
 public void Dispose()
 {
     if (ExternalDataSource != null)
     {
         ExternalDataSource.Dispose();
         ExternalDataSource = null;
     }
 }
Пример #4
0
        public DataSourcer(IDBContext context, IExternalDataSource externalDataSource)
        {
            _useExternalDataSource = Properties.Settings.Default.allowExternalDataSource && externalDataSource != null;
            if (_useExternalDataSource)
            {
                ExternalDataSource = externalDataSource;
            }

            _dataCache = new Dictionary <int, List <OHLCBar> >();

            Context = context;
        }
Пример #5
0
        public DataSourcer(IDBContext context, IExternalDataSource externalDataSource, bool allowExternalDataSource = false)
        {
            _useExternalDataSource = allowExternalDataSource && externalDataSource != null;
            if (_useExternalDataSource)
            {
                ExternalDataSource = externalDataSource;
            }

            _dataCache = new Dictionary <int, List <OHLCBar> >();

            Context = context;
        }
Пример #6
0
        public DataSourcer(IContextFactory contextFactory, IExternalDataSource externalDataSource, DataContainer data, bool allowExternalDataSource = false)
        {
            _useExternalDataSource = allowExternalDataSource && externalDataSource != null;
            if (_useExternalDataSource)
            {
                ExternalDataSource = externalDataSource;
            }

            _dataCache      = new Dictionary <int, List <OHLCBar> >();
            _contextFactory = contextFactory;
            _data           = data;
        }
Пример #7
0
        public DataSourcer(IDBContext context, IExternalDataSource externalDataSource, bool allowExternalDataSource = false)
        {
            _useExternalDataSource = allowExternalDataSource && externalDataSource != null;
            if (_useExternalDataSource)
            {
                ExternalDataSource = externalDataSource;
            }

            _dataCache = new Dictionary<int, List<OHLCBar>>();

            Context = context;
        }
Пример #8
0
        public override bool IsServerDelegatable(CallNode callNode, TexlBinding binding)
        {
            Contracts.AssertValue(callNode);
            Contracts.AssertValue(binding);

            if (!CheckArgsCount(callNode, binding))
            {
                return(false);
            }

            IExternalDataSource dataSource = null;

            // We ensure Document is available because some tests run with a null Document.
            if ((binding.Document != null && !binding.Document.Properties.EnabledFeatures.IsEnhancedDelegationEnabled) || !TryGetValidDataSourceForDelegation(callNode, binding, FunctionDelegationCapability, out dataSource))
            {
                if (dataSource != null && dataSource.IsDelegatable)
                {
                    binding.ErrorContainer.EnsureError(DocumentErrorSeverity.Warning, callNode, TexlStrings.OpNotSupportedByServiceSuggestionMessage_OpNotSupportedByService, Name);
                }

                return(false);
            }

            TexlNode[] args = callNode.Args.Children.VerifyValue();

            if (args.Length == 0)
            {
                return(false);
            }

            // Don't delegate 1-N/N-N counts
            // TASK 9966488: Enable CountRows/CountIf delegation for table relationships
            if (binding.GetType(args[0]).HasExpandInfo)
            {
                SuggestDelegationHint(callNode, binding);
                return(false);
            }

            FilterOpMetadata metadata = dataSource.DelegationMetadata.FilterDelegationMetadata;

            // Validate for each predicate node.
            for (int i = 1; i < args.Length; i++)
            {
                if (!IsValidDelegatableFilterPredicateNode(args[i], binding, metadata))
                {
                    SuggestDelegationHint(callNode, binding);
                    return(false);
                }
            }

            return(true);
        }
Пример #9
0
        /// <summary>
        /// Registers a control as being an external data source for server-side rendering.
        /// Usually the controls should handle this call internally.
        /// </summary>
        /// <param name="control"></param>
        /// <returns></returns>
        public IExternalDataSource RegisterExternalServerRenderControl(IExternalDataSource control, int validViewsMask)
        {
            if (control == null)
            {
                return(null);
            }
            ExternalControlDef cdef;

            cdef.ExternalSource = control;
            cdef.ValidViewMask  = validViewsMask;
            ExternalServerRenderControls.Add(cdef);
            return(control);
        }
Пример #10
0
        // See if CountDistinct delegation is available. If true, we can make use of it on primary key as a workaround for CountRows delegation
        internal bool TryGetValidDataSourceForDelegation(CallNode callNode, TexlBinding binding, out IExternalDataSource dataSource, out DelegationCapability preferredFunctionDelegationCapability)
        {
            Contracts.AssertValue(callNode);
            Contracts.AssertValue(binding);

            preferredFunctionDelegationCapability = FunctionDelegationCapability;
            // We ensure Document is available because some tests run with a null Document.
            if ((binding.Document != null &&
                 binding.Document.Properties.EnabledFeatures.IsEnhancedDelegationEnabled) &&
                TryGetValidDataSourceForDelegation(callNode, binding, FunctionDelegationCapability, out dataSource) &&
                !ExpressionContainsView(callNode, binding))
            {
                // Check that target table is not an expanded entity (1-N/N-N relationships)
                // TASK 9966488: Enable CountRows/CountIf delegation for table relationships
                TexlNode[] args = callNode.Args.Children.VerifyValue();
                if (args.Length > 0)
                {
                    if (binding.GetType(args[0]).HasExpandInfo)
                    {
                        SuggestDelegationHint(callNode, binding);
                        return(false);
                    }
                    else
                    {
                        return(true);
                    }
                }
            }

            TryGetValidDataSourceForDelegation(callNode, binding, DelegationCapability.CountDistinct, out dataSource);
            if (dataSource != null && dataSource.IsDelegatable)
            {
                binding.ErrorContainer.EnsureError(DocumentErrorSeverity.Warning, callNode, TexlStrings.OpNotSupportedByServiceSuggestionMessage_OpNotSupportedByService, Name);
            }

            return(false);
        }
Пример #11
0
        public static DelegationTelemetryInfo CreateDataSourceNotDelegatableTelemetryInfo(IExternalDataSource ds)
        {
            Contracts.AssertValue(ds);

            return(new DelegationTelemetryInfo(ds.Name));
        }
Пример #12
0
 /// <summary>
 /// Registers a control as being an external data source for server-side rendering.
 /// Usually the controls should handle this call internally.
 /// </summary>
 /// <param name="control"></param>
 /// <returns></returns>
 public IExternalDataSource RegisterExternalServerRenderControl(IExternalDataSource control)
 {
     return(RegisterExternalServerRenderControl(control, 0));
 }
Пример #13
0
        // from FunctionUtils.TryGetDataSource
        public static bool TryGetDataSource(this IExternalEntityScope entityScope, TexlNode node, out IExternalDataSource dataSourceInfo)
        {
            Contracts.AssertValue(entityScope);
            Contracts.AssertValue(node);

            FirstNameNode firstNameNode;

            if ((firstNameNode = node.AsFirstName()) == null)
            {
                dataSourceInfo = null;
                return(false);
            }

            return(entityScope.TryGetEntity <IExternalDataSource>(firstNameNode.Ident.Name, out dataSourceInfo));
        }