public void testEqual()
        {
            Defclass    dc    = new Defclass(typeof(TestBean2));
            Deftemplate dtemp = dc.createDeftemplate("testBean2");
            TestBean2   bean  = new TestBean2();

            bean.Attr1 = ("testString");
            bean.Attr2 = (1);
            short a3 = 3;

            bean.Attr3 = (a3);
            long a4 = 101;

            bean.Attr4 = (a4);
            float a5 = 10101;

            bean.Attr5 = (a5);
            double a6 = 101.101;

            bean.Attr6 = (a6);

            IFact fact = dtemp.createFact(bean, dc, 1);

            Assert.IsNotNull(fact);
            Console.WriteLine(fact.toFactString());
            CompositeIndex ci = new CompositeIndex("attr1", Constants.EQUAL, fact.getSlotValue(0));

            Assert.IsNotNull(ci);
            Console.WriteLine(ci.toPPString());
        }
        public void TestJaggedNumberWithThreeDimensionalSystemJaggedForReal()
        {
            int[] dimensions = new[] { 512, 512, 2048 };

            CompositeIndex number = new CompositeIndex(67045, dimensions);

            List <int> expectedIndexes = new List <int> {
                0, 32, 1509
            };                                                         // 0 (из 512) -> 32 (из 512) -> 1509 (из 2048).

            CollectionAssert.AreEqual(expectedIndexes, number.CompositeValue);

            Assert.AreEqual(67045, number.Value);

            number = new CompositeIndex(67045000, dimensions);

            expectedIndexes = new List <int> {
                63, 480, 1672
            };                                                 // 63 (из 512) -> 480 (из 512) -> 1672 (из 2048).

            Assert.AreEqual(67045000, number.Value);

            CollectionAssert.AreEqual(expectedIndexes, number.CompositeValue);

            ExceptionAssert.MakeSureExceptionIsRaisedBy <ArgumentException>(
                delegate
            {
                new CompositeIndex(int.MaxValue, dimensions);
            });
        }
Beispiel #3
0
        /// <summary>
        /// Устанавливает в качестве текущего блок заданного номера.
        /// </summary>
        /// <param name="newPosition"></param>
        /// <exception cref="ArgumentOutOfRangeException"></exception>
        public void SetPosition(int newPosition)
        {
            if (newPosition == EnumeratorAddressable <IDiskBlock> .IndexOfPositionBeforeFirstElement)
            {
                this.Reset();
                return;
            }

            MethodArgumentValidator.ThrowIfNegative(newPosition, "newPosition");

            if (newPosition >= _numberOfBlocks)
            {
                throw new ArgumentOutOfRangeException("newPosition", "Невозможно установить позицию за границей массива");
            }

            #region совсем топорная версия
//            if (newPosition < _position)
//            {
//                this.Reset();
//            }
//
//            while (_position != newPosition)
//            {
//                this.MoveNext();
//            }
//
            //return;
            #endregion

            var compositeIndex = new CompositeIndex(newPosition,
                                                    new[]
            {
                _addressingSystemParameters.IndirectBlockReferencesCountInDoubleIndirectBlock,
                _addressingSystemParameters.DataBlockReferencesCountInSingleIndirectBlock
            });

            var sizes = _blockSizesCalculator.GetSizesOfAddressingBlocksSufficientToStoreItems(newPosition);

            _doubleIndirectListEnumerator.SetPosition(compositeIndex.CompositeValue[0]);

            bool isLastDoubleIndirectionBlock = _doubleIndirectListEnumerator.IsAtLastElement;

            int numberOfSingleIndirectBlockReferences =
                isLastDoubleIndirectionBlock ?
                _addressingSystemSizesOfLastBlocks.LastSingleIndirectBlockSize
                : _addressingSystemParameters.DataBlockReferencesCountInSingleIndirectBlock;

            this.InitializeSingleIndirectionBlock(
                _doubleIndirectListEnumerator.Current,
                numberOfSingleIndirectBlockReferences,
                compositeIndex.CompositeValue[1]);

            this.InitializeCurrentBlockBrowser();

            _position = newPosition;
        }
        public void testIndex()
        {
            Defclass    dc    = new Defclass(typeof(TestBean2));
            Deftemplate dtemp = dc.createDeftemplate("testBean2");
            TestBean2   bean  = new TestBean2();

            bean.Attr1 = ("testString");
            bean.Attr2 = (1);
            short a3 = 3;

            bean.Attr3 = (a3);
            long a4 = 101;

            bean.Attr4 = (a4);
            float a5 = 10101;

            bean.Attr5 = (a5);
            double a6 = 101.101;

            bean.Attr6 = (a6);

            IFact fact = dtemp.createFact(bean, dc, 1);

            Assert.IsNotNull(fact);
            Console.WriteLine(fact.toFactString());
            CompositeIndex ci =
                new CompositeIndex("attr1", Constants.EQUAL, fact.getSlotValue(0));

            Assert.IsNotNull(ci);
            Console.WriteLine(ci.toPPString());
            GenericHashMap <object, object> map = new GenericHashMap <object, object>();

            map.Put(ci, bean);

            CompositeIndex ci2 =
                new CompositeIndex("attr1", Constants.EQUAL, fact.getSlotValue(0));

            Assert.IsTrue(map.ContainsKey(ci2));

            CompositeIndex ci3 =
                new CompositeIndex("attr1", Constants.NOTEQUAL, fact.getSlotValue(0));

            Assert.IsFalse(map.ContainsKey(ci3));

            CompositeIndex ci4 =
                new CompositeIndex("attr1", Constants.NILL, fact.getSlotValue(0));

            Assert.IsFalse(map.ContainsKey(ci4));

            CompositeIndex ci5 =
                new CompositeIndex("attr1", Constants.NOTNILL, fact.getSlotValue(0));

            Assert.IsFalse(map.ContainsKey(ci5));
        }
        protected override void OnStateChange()
        {
            if (State == State.SetDefaults)
            {
                Description                  = @"Enter the description for your new custom Strategy here.";
                Name                         = "ConstanceBrown";
                Calculate                    = Calculate.OnBarClose;
                EntriesPerDirection          = 1;
                EntryHandling                = EntryHandling.AllEntries;
                IsExitOnSessionCloseStrategy = true;
                ExitOnSessionCloseSeconds    = 30;
                IsFillLimitOnTouch           = false;
                MaximumBarsLookBack          = MaximumBarsLookBack.TwoHundredFiftySix;
                OrderFillResolution          = OrderFillResolution.Standard;
                Slippage                     = 0;
                StartBehavior                = StartBehavior.WaitUntilFlat;
                TimeInForce                  = TimeInForce.Gtc;
                TraceOrders                  = false;
                RealtimeErrorHandling        = RealtimeErrorHandling.StopCancelClose;
                StopTargetHandling           = StopTargetHandling.PerEntryExecution;
                BarsRequiredToTrade          = 20;
                // Disable this property for performance gains in Strategy Analyzer optimizations
                // See the Help Guide for additional information
                IsInstantiatedOnEachOptimizationIteration = true;
            }
            else if (State == State.Configure)
            {
                AddDataSeries(Data.BarsPeriodType.Second, 5);

                stochasticsFast_14_3 = StochasticsFast(3, 14);
                stochasticsFast_14_3.Plots[0].Brush = Brushes.Transparent;
                stochasticsFast_14_3.Plots[1].Brush = Brushes.Red;
                AddChartIndicator(stochasticsFast_14_3);

                compositeIndex = CompositeIndex(14, 9, 3, 3);
                AddChartIndicator(compositeIndex);

                List <DisasbleTimeRange> disableTimeRanges = new List <DisasbleTimeRange>();
                //disableTimeRanges.Add(new DisasbleTimeRange() { Day = DayOfWeek.Monday, StartHour = 0, StartMinute = 0, EndHour = 9, EndMinute = 59 });
                //disableTimeRanges.Add(new DisasbleTimeRange() { Day = DayOfWeek.Monday, StartHour = 12, StartMinute = 30, EndHour = 24, EndMinute = 59 });

                foreach (DisasbleTimeRange d in disableTimeRanges)
                {
                    disableManager.AddRange(DayOfWeek.Sunday, d.StartHour, d.StartMinute, d.EndHour, d.EndMinute);
                    disableManager.AddRange(DayOfWeek.Monday, d.StartHour, d.StartMinute, d.EndHour, d.EndMinute);
                    disableManager.AddRange(DayOfWeek.Tuesday, d.StartHour, d.StartMinute, d.EndHour, d.EndMinute);
                    disableManager.AddRange(DayOfWeek.Wednesday, d.StartHour, d.StartMinute, d.EndHour, d.EndMinute);
                    disableManager.AddRange(DayOfWeek.Thursday, d.StartHour, d.StartMinute, d.EndHour, d.EndMinute);
                    disableManager.AddRange(DayOfWeek.Friday, d.StartHour, d.StartMinute, d.EndHour, d.EndMinute);
                }
            }
        }
        public void TestJaggedNumberWithFourDimensionalSystemDecimal()
        {
            int[] dimensions = new[] { 10, 10, 10, 10 };

            CompositeIndex number = new CompositeIndex(9876, dimensions);

            List <int> expectedIndexes = new List <int> {
                9, 8, 7, 6
            };

            CollectionAssert.AreEqual(expectedIndexes, number.CompositeValue);
            Assert.AreEqual(9876, number.Value);

            ExceptionAssert.MakeSureExceptionIsRaisedBy <ArgumentException>(
                delegate
            {
                new CompositeIndex(10 * 10 * 10 * 10, dimensions);
            });
        }
        public void TestJaggedNumberWithTwoDimensionalSystem()
        {
            int[] dimensions = new[] { 16, 16 };

            CompositeIndex index = new CompositeIndex(254, dimensions);

            List <int> indexCapacities = new List <int> {
                15, 14
            };                                                    // 0xFE

            CollectionAssert.AreEqual(indexCapacities, index.CompositeValue);

            ExceptionAssert.MakeSureExceptionIsRaisedBy <ArgumentException>(
                delegate
            {
                new CompositeIndex(15000, dimensions);
            });

            ExceptionAssert.MakeSureExceptionIsRaisedBy <ArgumentException>(
                delegate
            {
                new CompositeIndex(16 * 16, dimensions);
            });
        }
        public void TestJaggedNumberWithOneDimensionalSystem()
        {
            int[] indexCapacities = new[] { 25 };

            CompositeIndex compositeIndex = new CompositeIndex(22, indexCapacities);

            List <int> expectedIndexes = new List <int> {
                22
            };

            CollectionAssert.AreEqual(expectedIndexes, compositeIndex.CompositeValue);

            ExceptionAssert.MakeSureExceptionIsRaisedBy <ArgumentException>(
                delegate
            {
                new CompositeIndex(1500, indexCapacities);
            });

            ExceptionAssert.MakeSureExceptionIsRaisedBy <ArgumentException>(
                delegate
            {
                new CompositeIndex(25, indexCapacities);
            });
        }
Beispiel #9
0
        /// <summary>
        /// Detect an existing <seealso cref="ProcessApplication"/> component.
        /// </summary>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: protected org.jboss.as.ee.component.ComponentDescription detectExistingComponent(org.jboss.as.server.deployment.DeploymentUnit deploymentUnit) throws org.jboss.as.server.deployment.DeploymentUnitProcessingException
        protected internal virtual ComponentDescription detectExistingComponent(DeploymentUnit deploymentUnit)
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.jboss.as.ee.component.EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION);
            EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.jboss.as.ee.component.EEApplicationClasses eeApplicationClasses = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_APPLICATION_CLASSES_DESCRIPTION);
            EEApplicationClasses eeApplicationClasses = deploymentUnit.getAttachment(Attachments.EE_APPLICATION_CLASSES_DESCRIPTION);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.jboss.as.server.deployment.annotation.CompositeIndex compositeIndex = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.COMPOSITE_ANNOTATION_INDEX);
            CompositeIndex compositeIndex = deploymentUnit.getAttachment([email protected]_ANNOTATION_INDEX);

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.jboss.as.web.common.WarMetaData warMetaData = deploymentUnit.getAttachment(org.jboss.as.web.common.WarMetaData.ATTACHMENT_KEY);
            WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);

            // extract deployment metadata
            IList <AnnotationInstance> processApplicationAnnotations = null;
            IList <AnnotationInstance> postDeployAnnnotations        = null;
            IList <AnnotationInstance> preUndeployAnnnotations       = null;
            ISet <ClassInfo>           servletProcessApplications    = null;

            if (compositeIndex != null)
            {
//JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method:
                processApplicationAnnotations = compositeIndex.getAnnotations(DotName.createSimple(typeof(ProcessApplication).FullName));
//JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method:
                postDeployAnnnotations = compositeIndex.getAnnotations(DotName.createSimple(typeof(PostDeploy).FullName));
//JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method:
                preUndeployAnnnotations = compositeIndex.getAnnotations(DotName.createSimple(typeof(PreUndeploy).FullName));
//JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method:
                servletProcessApplications = compositeIndex.getAllKnownSubclasses(DotName.createSimple(typeof(ServletProcessApplication).FullName));
            }
            else
            {
                return(null);
            }

            if (processApplicationAnnotations.Count == 0)
            {
                // no pa found, this is not a process application deployment.
                return(null);
            }
            else if (processApplicationAnnotations.Count > 1)
            {
                // found multiple PAs -> unsupported.
                throw new DeploymentUnitProcessingException("Detected multiple classes annotated with @" + typeof(ProcessApplication).Name + ". A deployment must only provide a single @" + typeof(ProcessApplication).Name + " class.");
            }
            else
            {
                // found single PA

                AnnotationInstance annotationInstance = processApplicationAnnotations[0];
                ClassInfo          paClassInfo        = (ClassInfo)annotationInstance.target();
                string             paClassName        = paClassInfo.name().ToString();

                ComponentDescription paComponent = null;

                // it can either be a Servlet Process Application or a Singleton Session Bean Component or
                if (servletProcessApplications.Contains(paClassInfo))
                {
                    // Servlet Process Applications can only be deployed inside Web Applications
                    if (warMetaData == null)
                    {
                        throw new DeploymentUnitProcessingException("@ProcessApplication class is a ServletProcessApplication but deployment is not a Web Application.");
                    }

                    // check whether it's already a servlet context listener:
                    JBossWebMetaData         mergedJBossWebMetaData = warMetaData.MergedJBossWebMetaData;
                    IList <ListenerMetaData> listeners = mergedJBossWebMetaData.Listeners;
                    if (listeners == null)
                    {
                        listeners = new List <ListenerMetaData>();
                        mergedJBossWebMetaData.Listeners = listeners;
                    }

                    bool isListener = false;
                    foreach (ListenerMetaData listenerMetaData in listeners)
                    {
                        if (listenerMetaData.ListenerClass.Equals(paClassInfo.name().ToString()))
                        {
                            isListener = true;
                        }
                    }

                    if (!isListener)
                    {
                        // register as Servlet Context Listener
                        ListenerMetaData listener = new ListenerMetaData();
                        listener.ListenerClass = paClassName;
                        listeners.Add(listener);

                        // synthesize WebComponent
                        WebComponentDescription paWebComponent = new WebComponentDescription(paClassName, paClassName, eeModuleDescription, deploymentUnit.ServiceName, eeApplicationClasses);

                        eeModuleDescription.addComponent(paWebComponent);

                        deploymentUnit.addToAttachmentList(WebComponentDescription.WEB_COMPONENTS, paWebComponent.StartServiceName);

                        paComponent = paWebComponent;
                    }
                    else
                    {
                        // lookup the existing component
                        paComponent = eeModuleDescription.getComponentsByClassName(paClassName).get(0);
                    }

                    // deactivate sci
                }
                else
                {
                    // if its not a ServletProcessApplication it must be a session bean component

                    IList <ComponentDescription> componentsByClassName = eeModuleDescription.getComponentsByClassName(paClassName);

                    if (componentsByClassName.Count > 0 && (componentsByClassName[0] is SessionBeanComponentDescription))
                    {
                        paComponent = componentsByClassName[0];
                    }
                    else
                    {
                        throw new DeploymentUnitProcessingException("Class " + paClassName + " is annotated with @" + typeof(ProcessApplication).Name + " but is neither a ServletProcessApplication nor an EJB Session Bean Component.");
                    }
                }

                // attach additional metadata to the deployment unit

                if (postDeployAnnnotations.Count > 0)
                {
                    if (postDeployAnnnotations.Count == 1)
                    {
                        ProcessApplicationAttachments.attachPostDeployDescription(deploymentUnit, postDeployAnnnotations[0]);
                    }
                    else
                    {
                        throw new DeploymentUnitProcessingException("There can only be a single method annotated with @PostDeploy. Found [" + postDeployAnnnotations + "]");
                    }
                }

                if (preUndeployAnnnotations.Count > 0)
                {
                    if (preUndeployAnnnotations.Count == 1)
                    {
                        ProcessApplicationAttachments.attachPreUndeployDescription(deploymentUnit, preUndeployAnnnotations[0]);
                    }
                    else
                    {
                        throw new DeploymentUnitProcessingException("There can only be a single method annotated with @PreUndeploy. Found [" + preUndeployAnnnotations + "]");
                    }
                }

                return(paComponent);
            }
        }