Ejemplo n.º 1
0
        private void HandleRowMenuItemClick(object sender, WebMenuItemClickEventArgs e, Action <WebMenuItem, IBusinessObject, int> handler)
        {
            var rowMenu = ArgumentUtility.CheckNotNullAndType <BocListRowMenu> ("sender", sender);

            int listIndex;

            if (!HasValue)
            {
                listIndex = -1;
            }
            else if (rowMenu.Row.Index >= Value.Count)
            {
                listIndex = -1;
            }
            else if (Value[rowMenu.Row.Index].Equals(rowMenu.Row.BusinessObject))
            {
                listIndex = rowMenu.Row.Index;
            }
            else
            {
                listIndex = Value.IndexOf(rowMenu.Row.BusinessObject);
            }

            var businessObject = rowMenu.Row.BusinessObject;

            handler(e.Item, businessObject, listIndex);
        }
        public override void AddAt(int index, Control control)
        {
            TabView view = ArgumentUtility.CheckNotNullAndType <TabView> ("control", control);

            base.AddAt(index, view);
            Owner.OnTabViewInserted(view);
        }
        /// <summary>
        /// Initializes a new instance.
        /// </summary>
        /// <param name="value">The enum value that should be the undefined value. Must not be <see langword="null"/>.</param>
        public UndefinedEnumValueAttribute(object value)
        {
            ArgumentUtility.CheckNotNullAndType <Enum> ("value", value);
            ArgumentUtility.CheckValidEnumValue("value", (Enum)value);

            _value = value;
        }
        public void Delete(IBusinessObject referencingObject, IBusinessObjectReferenceProperty property, IBusinessObject value)
        {
            ArgumentUtility.CheckNotNull("property", property);
            ArgumentUtility.CheckNotNullAndType <ReferenceDataSourceTestDomainBase> ("value", value);

            // NOP
        }
Ejemplo n.º 5
0
        public override IStreamedDataInfo GetOutputDataInfo(IStreamedDataInfo inputInfo)
        {
            var sequenceInfo = ArgumentUtility.CheckNotNullAndType <StreamedSequenceInfo> ("inputInfo", inputInfo);

            CheckSequenceItemType(sequenceInfo, _itemType);
            return(new StreamedSequenceInfo(typeof(IQueryable <>).MakeGenericType(_itemType), new QuerySourceReferenceExpression(this)));
        }
        protected void CheckValues(IBusinessObject value, string stringValue, int int32Value)
        {
            TypeWithAllDataTypes typeWithAllDataTypes = ArgumentUtility.CheckNotNullAndType <TypeWithAllDataTypes> ("value", value);

            Assert.That(typeWithAllDataTypes.String, Is.EqualTo(stringValue));
            Assert.That(typeWithAllDataTypes.Int32, Is.EqualTo(int32Value));
        }
Ejemplo n.º 7
0
        protected override void OnSetComplete(int index, object oldValue, object newValue)
        {
            WebTreeNode node = ArgumentUtility.CheckNotNullAndType <WebTreeNode> ("newValue", newValue);

            base.OnSetComplete(index, oldValue, newValue);
            node.SetParent(_treeView, _parentNode);
        }
Ejemplo n.º 8
0
            public ICollectionEndPointLoadState LoadEndPointAndGetNewState(ICollectionEndPoint endPoint)
            {
                var collectionEndPoint = ArgumentUtility.CheckNotNullAndType <CollectionEndPoint> ("endPoint", endPoint);

                _lazyLoader.LoadLazyCollectionEndPoint(endPoint.ID);
                return(collectionEndPoint._loadState);
            }
        protected override void OnRemoveComplete(int index, object value)
        {
            WebTab tab = ArgumentUtility.CheckNotNullAndType <WebTab> ("value", value);

            base.OnRemoveComplete(index, value);

            tab.SetTabStrip(null);
            if (_tabStrip != null && tab.IsSelected)
            {
                bool wasLastTab = index == InnerList.Count;
                if (wasLastTab)
                {
                    if (InnerList.Count > 1)
                    {
                        WebTab lastTab = (WebTab)InnerList[index - 1];
                        _tabStrip.SetSelectedTabInternal(lastTab);
                    }
                    else
                    {
                        _tabStrip.SetSelectedTabInternal(null);
                    }
                }
                else
                {
                    WebTab nextTab = (WebTab)InnerList[index];
                    _tabStrip.SetSelectedTabInternal(nextTab);
                }
            }
        }
Ejemplo n.º 10
0
        protected override void OnInsertComplete(int index, object value)
        {
            WebTreeNode node = ArgumentUtility.CheckNotNullAndType <WebTreeNode> ("value", value);

            base.OnInsertComplete(index, value);
            node.SetParent(_treeView, _parentNode);
        }
        public ISecurableObject GetSecurableObject(WxeFunction function)
        {
            ArgumentUtility.CheckNotNullAndType("function", function, _functionType);

            WxeParameterDeclaration parameterDeclaration = GetParameterDeclaration(function.VariablesContainer.ParameterDeclarations);
            var tuple = GetActualParameterTypeAndValue(parameterDeclaration.Type, function.Variables[parameterDeclaration.Name]);
            var actualParameterType = tuple.Item1;
            var parameterValue      = tuple.Item2;

            if (parameterValue == null)
            {
                throw new WxeException(string.Format(
                                           "The parameter '{1}' specified by the {0} applied to WxeFunction '{2}' is null.",
                                           _attribute.GetType().Name, parameterDeclaration.Name, _functionType.FullName));
            }

            ISecurableObject securableObject = parameterValue as ISecurableObject;

            if (securableObject == null)
            {
                throw new WxeException(string.Format(
                                           "The parameter '{1}' specified by the {0} applied to WxeFunction '{2}' does not implement interface '{3}'.",
                                           _attribute.GetType().Name, parameterDeclaration.Name, _functionType.FullName, typeof(ISecurableObject).FullName));
            }

            if (SecurableClass != null)
            {
                CheckParameterDeclarationMatchesSecurableClass(actualParameterType, parameterDeclaration.Name);
            }
            return(securableObject);
        }
            public IVirtualObjectEndPointLoadState LoadEndPointAndGetNewState(IVirtualObjectEndPoint endPoint)
            {
                var virtualObjectEndPoint = ArgumentUtility.CheckNotNullAndType <VirtualObjectEndPoint> ("endPoint", endPoint);

                _lazyLoader.LoadLazyVirtualObjectEndPoint(virtualObjectEndPoint.ID);
                return(virtualObjectEndPoint._loadState);
            }
        protected override IObjectLoader CreateObjectLoader(
            ClientTransaction constructedTransaction,
            IClientTransactionEventSink eventSink,
            IPersistenceStrategy persistenceStrategy,
            IInvalidDomainObjectManager invalidDomainObjectManager,
            IDataManager dataManager,
            ITransactionHierarchyManager hierarchyManager)
        {
            ArgumentUtility.CheckNotNull("constructedTransaction", constructedTransaction);
            ArgumentUtility.CheckNotNull("eventSink", eventSink);
            var fetchEnabledPersistenceStrategy =
                ArgumentUtility.CheckNotNullAndType <IFetchEnabledPersistenceStrategy> ("persistenceStrategy", persistenceStrategy);

            ArgumentUtility.CheckNotNull("invalidDomainObjectManager", invalidDomainObjectManager);
            ArgumentUtility.CheckNotNull("dataManager", dataManager);
            ArgumentUtility.CheckNotNull("hierarchyManager", hierarchyManager);

            var loadedObjectDataProvider          = new LoadedObjectDataProvider(dataManager, invalidDomainObjectManager);
            var registrationListener              = new LoadedObjectDataRegistrationListener(eventSink, hierarchyManager);
            var loadedObjectDataRegistrationAgent = new LoadedObjectDataRegistrationAgent(constructedTransaction, dataManager, registrationListener);

            IFetchedRelationDataRegistrationAgent registrationAgent =
                new DelegatingFetchedRelationDataRegistrationAgent(
                    new FetchedRealObjectRelationDataRegistrationAgent(),
                    new FetchedVirtualObjectRelationDataRegistrationAgent(dataManager),
                    new FetchedCollectionRelationDataRegistrationAgent(dataManager));
            var eagerFetcher = new EagerFetcher(registrationAgent);

            return(new FetchEnabledObjectLoader(
                       fetchEnabledPersistenceStrategy,
                       loadedObjectDataRegistrationAgent,
                       loadedObjectDataProvider,
                       eagerFetcher));
        }
        /// <inheritdoc />
        public override IStreamedDataInfo GetOutputDataInfo(IStreamedDataInfo inputInfo)
        {
            ArgumentUtility.CheckNotNullAndType <StreamedSequenceInfo> ("inputInfo", inputInfo);

            var aggregatedType = Func.Type.GetGenericArguments()[0];

            if (!aggregatedType.IsAssignableFrom(Seed.Type))
            {
                var message = string.Format(
                    "The seed expression and the aggregating function don't have matching types. The seed is of type '{0}', but the function aggregates '{1}'.",
                    Seed.Type,
                    aggregatedType);
                throw new InvalidOperationException(message);
            }

            var resultTransformedType = OptionalResultSelector != null?OptionalResultSelector.Type.GetGenericArguments()[0] : null;

            if (resultTransformedType != null && aggregatedType != resultTransformedType)
            {
                var message = string.Format(
                    "The aggregating function and the result selector don't have matching types. The function aggregates type '{0}', but the result selector "
                    + "takes '{1}'.",
                    aggregatedType,
                    resultTransformedType);
                throw new InvalidOperationException(message);
            }

            var resultType = GetResultType();

            return(new StreamedScalarValueInfo(resultType));
        }
Ejemplo n.º 15
0
        private void HandleSubstitutedRolePreRender(object sender, EventArgs e)
        {
            var substituededRoleReferenceValue = ArgumentUtility.CheckNotNullAndType <BocReferenceValue> ("sender", sender);
            var substitution = substituededRoleReferenceValue.DataSource.BusinessObject;
            var roles        = substituededRoleReferenceValue.Property.SearchAvailableObjects(substitution, new DefaultSearchArguments(null));

            substituededRoleReferenceValue.SetBusinessObjectList(roles);
        }
Ejemplo n.º 16
0
        public sealed override IStreamedData ExecuteInMemory(IStreamedData input)
        {
            var sequenceInput = ArgumentUtility.CheckNotNullAndType <StreamedSequence>("input", input);

            var executeMethod = s_executeMethod.MakeGenericMethod(sequenceInput.DataInfo.ResultItemType);

            return((StreamedValue)InvokeExecuteMethod(executeMethod, sequenceInput));
        }
        public RdbmsProviderDefinition(string name, IStorageObjectFactory factory, string connectionString)
            : base(name, factory)
        {
            ArgumentUtility.CheckNotNullOrEmpty("connectionString", connectionString);
            ArgumentUtility.CheckNotNullAndType <IRdbmsStorageObjectFactory> ("factory", factory);

            _connectionString = connectionString;
        }
        /// <overloads> Sets the value accessed through the specified property. </overloads>
        /// <summary> Sets the value accessed through the specified <see cref="IBusinessObjectProperty"/>. </summary>
        /// <param name="property">
        ///   The <see cref="IBusinessObjectProperty"/> used to access the value. Must not be <see langword="null"/>.
        /// </param>
        /// <param name="value"> The new value for the <paramref name="property"/> parameter. </param>
        /// <exception cref="Exception">
        ///   Thrown if the <paramref name="property"/> is not part of this business object's class.
        /// </exception>
        public void SetProperty(IBusinessObjectProperty property, object value)
        {
            var propertyBase = ArgumentUtility.CheckNotNullAndType <PropertyBase> ("property", property);

            object nativeValue = propertyBase.ConvertToNativePropertyType(value);

            propertyBase.SetValue((IBusinessObject)Target, nativeValue);
        }
        public Expression GetFlatValueExpressionForSerialization(object id)
        {
            var classContext = ArgumentUtility.CheckNotNullAndType <ClassContext> ("id", id);

            var classContextExpression = GetClassContextExpression(classContext);

            return(Expression.Call(s_createFlatClassContext, classContextExpression));
        }
        public Expression GetExpression(object id)
        {
            var classContext = ArgumentUtility.CheckNotNullAndType <ClassContext> ("id", id);

            var classContextExpression = GetClassContextExpression(classContext);

            return(Expression.Convert(classContextExpression, typeof(object)));
        }
        public override void Remove(Control control)
        {
            TabView view = ArgumentUtility.CheckNotNullAndType <TabView> ("control", control);

            Owner.OnTabViewRemove(view);
            base.Remove(control);
            Owner.OnTabViewRemoved(view);
        }
Ejemplo n.º 22
0
        protected override void OnInsertComplete(int index, object value)
        {
            WebTab tab = ArgumentUtility.CheckNotNullAndType <WebTab> ("value", value);

            base.OnInsertComplete(index, value);
            tab.SetTabStrip(_tabStrip);
            InitalizeSelectedTab();
        }
        public override IStreamedDataInfo GetOutputDataInfo(IStreamedDataInfo inputInfo)
        {
            var sequenceInfo = ArgumentUtility.CheckNotNullAndType <StreamedSequenceInfo> ("inputInfo", inputInfo);

            Type resultType = GetResultType(sequenceInfo.ResultItemType);

            return(new StreamedScalarValueInfo(resultType));
        }
Ejemplo n.º 24
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="StreamedSequence" /> class, setting the <see cref="Sequence" /> and
        ///     <see cref="DataInfo" /> properties.
        /// </summary>
        /// <param name="sequence">The sequence.</param>
        /// <param name="streamedSequenceInfo">An instance of <see cref="StreamedSequenceInfo" /> describing the sequence.</param>
        public StreamedSequence([NotNull] IEnumerable sequence, [NotNull] StreamedSequenceInfo streamedSequenceInfo)
        {
            ArgumentUtility.CheckNotNull("streamedSequenceInfo", streamedSequenceInfo);
            ArgumentUtility.CheckNotNullAndType("sequence", sequence, streamedSequenceInfo.DataType);

            DataInfo = streamedSequenceInfo;
            Sequence = sequence;
        }
        public override IStreamedDataInfo GetOutputDataInfo(IStreamedDataInfo inputInfo)
        {
            var sequenceInfo = ArgumentUtility.CheckNotNullAndType <StreamedSequenceInfo> ("inputInfo", inputInfo);

            return(new StreamedSequenceInfo(
                       typeof(IQueryable <>).MakeGenericType(CastItemType),
                       GetNewItemExpression(sequenceInfo.ItemExpression)));
        }
Ejemplo n.º 26
0
 public SmartPageInfo(ISmartPage page)
 {
     ArgumentUtility.CheckNotNullAndType <Page> ("page", page);
     _page       = page;
     _page.Init += Page_Init;
     // PreRenderComplete-handler must be registered before ScriptManager registers its own PreRenderComplete-handler during OnInit.
     _page.PreRenderComplete += Page_PreRenderComplete;
 }
Ejemplo n.º 27
0
        public override void SetDataFromSubTransaction(ICollectionEndPoint collectionEndPoint, IVirtualEndPointLoadState <ICollectionEndPoint, ReadOnlyCollectionDataDecorator, ICollectionEndPointDataManager> sourceLoadState)
        {
            ArgumentUtility.CheckNotNull("collectionEndPoint", collectionEndPoint);
            var sourceCompleteLoadState = ArgumentUtility.CheckNotNullAndType <CompleteCollectionEndPointLoadState> ("sourceLoadState", sourceLoadState);

            DataManager.SetDataFromSubTransaction(sourceCompleteLoadState.DataManager, EndPointProvider);

            RaiseReplaceDataEvent(collectionEndPoint);
        }
        public override IStreamedData ExecuteQueryModel(QueryModel queryModel, IQueryExecutor executor)
        {
            ArgumentUtility.CheckNotNull("queryModel", queryModel);
            var asyncExecutor = ArgumentUtility.CheckNotNullAndType <IAsyncQueryExecutor>("executor", executor);
            var executeMethod = _executeMethod.MakeGenericMethod(_itemType);
            var result        = executeMethod.Invoke(null, new object[] { queryModel, asyncExecutor, _cancel });

            return(new StreamedValue(result, this));
        }
        public override void SetDataFromSubTransaction(
            IVirtualObjectEndPoint endPoint,
            IVirtualEndPointLoadState <IVirtualObjectEndPoint, DomainObject, IVirtualObjectEndPointDataManager> sourceLoadState)
        {
            ArgumentUtility.CheckNotNull("endPoint", endPoint);
            var sourceCompleteLoadState = ArgumentUtility.CheckNotNullAndType <CompleteVirtualObjectEndPointLoadState> ("sourceLoadState", sourceLoadState);

            DataManager.SetDataFromSubTransaction(sourceCompleteLoadState.DataManager, EndPointProvider);
        }
Ejemplo n.º 30
0
        protected void SetEditControl(int index, IBusinessObjectBoundEditableWebControl control)
        {
            Control webControl = ArgumentUtility.CheckNotNullAndType <Control> ("control", control);

            ControlCollection cellControls = GetEditControls(index);

            cellControls.Clear();
            cellControls.Add(webControl);
        }