コード例 #1
0
        /// <summary>
        /// Split the string of mail addresses on the "," that separates them.
        /// </summary>
        /// <param name="InString"></param>
        /// <returns></returns>
        public static ArrayList SplitStringOfMailAddresses(string InString)
        {
            ArrayList addrList = new ArrayList( );

            TextTraits traits;

            traits = new TextTraits()
                     .SetQuoteEncapsulation(QuoteEncapsulation.Escape);
            traits.DividerPatterns.Replace(new string[] { ",", "\t" }, DelimClassification.DividerSymbol);
            traits.WhitespacePatterns.Replace(" ", "\t", DelimClassification.Whitespace);

            WordCursor word = Scanner.PositionBeginWord(InString, traits);

            while (true)
            {
                ObjectPair pair = ScanNextAddress(InString, word);
                word = (WordCursor )pair.b;

                // got nothing. end of string.
                if (pair.a == null)
                {
                    break;
                }

                // isolate the mail address string.
                string mailAddr = PullMailAddress(InString, pair);

                // add the address string to list of such strings.
                addrList.Add(mailAddr);
            }

            // return the split list of address strings.
            return(addrList);
        }
コード例 #2
0
ファイル: TestUtil.cs プロジェクト: plamikcho/xbrlpoc
        public void CastToStrongTypeChanged()
        {
            object o1 = "25";
            object o2 = 75;
            ObjectPair pair = new ObjectPair(o1, o2);
            Reflection.CastToStrongType(pair);
            o1 = pair.First;
            o2 = pair.Second;

            Assert.IsTrue(o1 is Int32, "(1) o1 type");
            Assert.AreEqual(o1, 25, "(1) o1 value");
            Assert.IsTrue(o2 is Int32, "(1) o2 type");
            Assert.AreEqual(o2, 75, "(1) o2 value");

            o1 = Math.PI;
            o2 = "-6.55";
            pair = new ObjectPair(o1, o2);
            Reflection.CastToStrongType(pair);
            o1 = pair.First;
            o2 = pair.Second;

            Assert.IsTrue(o1 is Double, "(2) o1 type");
            Assert.AreEqual(o1, Math.PI, "(2) o1 value");
            Assert.IsTrue(o2 is Double, "(2) o2 type");
            Assert.AreEqual(o2, -6.55d, "(2) o2 value");
        }
コード例 #3
0
        /// <summary>
        /// Perform one iteration.
        /// </summary>
        ///
        public override sealed void Iteration()
        {
            int length = network.RBF.Length;

            var funcs = new IRadialBasisFunction[length];

            // Iteration over neurons and determine the necessaries
            for (int i = 0; i < length; i++)
            {
                IRadialBasisFunction basisFunc = network.RBF[i];

                funcs[i] = basisFunc;

                // This is the value that is changed using other training methods.
                // weights[i] =
                // network.Structure.Synapses[0].WeightMatrix.Data[i][j];
            }

            ObjectPair <double[][], double[][]> data = TrainingSetUtil
                                                       .TrainingToArray(Training);

            double[][] matrix = EngineArray.AllocateDouble2D(length, network.OutputCount);

            FlatToMatrix(network.Flat.Weights, 0, matrix);
            Error = SVD.Svdfit(data.A, data.B, matrix, funcs);
            MatrixToFlat(matrix, network.Flat.Weights, 0);
        }
コード例 #4
0
ファイル: TestUtil.cs プロジェクト: vkiktev/NxBRE
        public void ParseOperatorCall()
        {
            ObjectPair result = Parameter.ParseOperatorCall(@"Matches(^-?\d+(\.\d{2})?$)");

            Assert.AreEqual("Matches", result.First);
            Assert.AreEqual(@"^-?\d+(\.\d{2})?$", result.Second);
        }
コード例 #5
0
ファイル: TestUtil.cs プロジェクト: vkiktev/NxBRE
        public void CastToStrongTypeChanged()
        {
            object     o1   = "25";
            object     o2   = 75;
            ObjectPair pair = new ObjectPair(o1, o2);

            Reflection.CastToStrongType(pair);
            o1 = pair.First;
            o2 = pair.Second;

            Assert.IsTrue(o1 is Int32, "(1) o1 type");
            Assert.AreEqual(o1, 25, "(1) o1 value");
            Assert.IsTrue(o2 is Int32, "(1) o2 type");
            Assert.AreEqual(o2, 75, "(1) o2 value");

            o1   = Math.PI;
            o2   = "-6.55";
            pair = new ObjectPair(o1, o2);
            Reflection.CastToStrongType(pair);
            o1 = pair.First;
            o2 = pair.Second;

            Assert.IsTrue(o1 is Double, "(2) o1 type");
            Assert.AreEqual(o1, Math.PI, "(2) o1 value");
            Assert.IsTrue(o2 is Double, "(2) o2 type");
            Assert.AreEqual(o2, -6.55d, "(2) o2 value");
        }
コード例 #6
0
ファイル: TestUtil.cs プロジェクト: vkiktev/NxBRE
        public void CastToStrongTypeUnchanged()
        {
            object     o1   = 25;
            object     o2   = 75;
            ObjectPair pair = new ObjectPair(o1, o2);

            Reflection.CastToStrongType(pair);
            o1 = pair.First;
            o2 = pair.Second;

            Assert.IsTrue(o1 is Int32, "(1) o1 type");
            Assert.AreEqual(o1, 25, "(1) o1 value");
            Assert.IsTrue(o2 is Int32, "(1) o2 type");
            Assert.AreEqual(o2, 75, "(1) o2 value");

            o1   = "25";
            o2   = "75";
            pair = new ObjectPair(o1, o2);
            Reflection.CastToStrongType(pair);
            o1 = pair.First;
            o2 = pair.Second;

            Assert.IsTrue(o1 is String, "(2) o1 type");
            Assert.AreEqual(o1, "25", "(2) o1 value");
            Assert.IsTrue(o2 is String, "(2) o2 type");
            Assert.AreEqual(o2, "75", "(2) o2 value");
        }
コード例 #7
0
        public IReadOnlyCollection <UserManagementViewModel> GetUserManagementViewModel()
        {
            List <UserManagementViewModel>            usermodels          = new List <UserManagementViewModel>();
            IEnumerable <IObjectPair <long, string> > ratingcount         = userRepo.GetRatingCountFromAllUsers();
            IEnumerable <IObjectPair <long, string> > divergentIABRatings = userRepo.GetDivergentIABRatingsFromAllUser();
            IEnumerable <IObjectPair <long, string> > divergentPADRatings = userRepo.GetDivergentPADRatingsFromAllUser();
            IObjectPair <long, string> defaultPair = new ObjectPair <long, string>()
            {
                Object1 = 0
            };

            foreach (ISearchUser user in userRepo.GetAll())
            {
                UserManagementViewModel userVM = new UserManagementViewModel();
                userVM.User        = user;
                userVM.RatingCount = ratingcount.Where((t) => t.Object2 == user.UserID).Select(x => x.Object1).DefaultIfEmpty(0).FirstOrDefault();
                try
                {
                    userVM.ProcentIABDivergent = Convert.ToInt32(divergentIABRatings.Where(x => x.Object2 == user.UserID).DefaultIfEmpty(defaultPair).First().Object1 / (double)userVM.RatingCount * (double)100);
                    userVM.ProcentPADDivergent = Convert.ToInt32(divergentPADRatings.Where(x => x.Object2 == user.UserID).DefaultIfEmpty(defaultPair).First().Object1 / (double)userVM.RatingCount * (double)100);
                }
                catch
                {
                    userVM.ProcentIABDivergent = -1;
                    userVM.ProcentPADDivergent = -1;
                }
                userVM.PicturePath = pictureHandler.GetPictureWithUserID(user.UserID);
                usermodels.Add(userVM);
            }
            return(usermodels);
        }
コード例 #8
0
ファイル: Atom.cs プロジェクト: ilkerhalil/NxBRE
        /// <summary>
        /// Checks if the predicates of the current Atom match with the predicates of another one, i.e. are equal or functions resolve to True.
        /// </summary>
        /// <param name="atom">The other atom to determine the predicates matching.</param>
        /// <param name="strictTyping">True if String individual predicate are not considered as potential representations of other types.</param>
        /// <param name="ignoredPredicates">A list of predicate positions to exclude from comparison, or null if all predicates must be matched</param>
        /// <returns>True if the two atoms have matching predicates, False otherwise.</returns>
        internal bool PredicatesMatch(Atom atom, bool strictTyping, IList <int> ignoredPredicates)
        {
            for (int position = 0; position < predicates.Length; position++)
            {
                if ((ignoredPredicates == null) || ((ignoredPredicates != null) && (!ignoredPredicates.Contains(position))))
                {
                    if ((predicates[position] is Individual) &&
                        (atom.predicates[position] is Function) &&
                        (!((Function)atom.predicates[position]).Evaluate((Individual)predicates[position])))
                    {
                        return(false);
                    }
                    else if ((predicates[position] is Function) &&
                             (atom.predicates[position] is Individual) &&
                             (!((Function)predicates[position]).Evaluate((Individual)atom.predicates[position])))
                    {
                        return(false);
                    }
                    else if ((predicates[position] is Function) &&
                             (atom.predicates[position] is Function) &&
                             (!(predicates[position].Equals(atom.predicates[position]))))
                    {
                        return(false);
                    }
                    else if ((predicates[position] is Individual) && (atom.predicates[position] is Individual))
                    {
                        // we have two individuals
                        if (predicates[position].Value.GetType() == atom.predicates[position].Value.GetType())
                        {
                            if (!predicates[position].Equals(atom.predicates[position]))
                            {
                                // the two individuals are of same types: if equals fail, no match
                                return(false);
                            }
                        }
                        else
                        {
                            if (!strictTyping)
                            {
                                // the two individuals are of different types and we are not in strict typing, so
                                // we try to cast to stronger type and compare
                                ObjectPair pair = new ObjectPair(predicates[position].Value, atom.predicates[position].Value);
                                Reflection.CastToStrongType(pair);
                                if (!pair.First.Equals(pair.Second))
                                {
                                    return(false);
                                }
                            }
                            else
                            {
                                return(false);
                            }
                        }
                    }
                }
            }

            // we went through all the comparisons without a scratch, it means the atoms do match
            return(true);
        }
コード例 #9
0
ファイル: CartCentering.cs プロジェクト: lulzzz/BraneCloud
        public override float EvaluateTestCase(GAIndividual inIndividual, object inInput, object inOutput)
        {
            int        timeSteps       = 1000;
            float      timeDiscritized = 0.01f;
            float      maxTime         = timeSteps * timeDiscritized;
            float      captureRadius   = 0.01f;
            ObjectPair xv       = (ObjectPair)inInput;
            float      position = (float)xv._first;
            float      velocity = (float)xv._second;

            for (int step = 1; step <= timeSteps; step++)
            {
                _interpreter.ClearStacks();
                FloatStack   fStack = _interpreter.FloatStack();
                BooleanStack bStack = _interpreter.BoolStack();
                ObjectStack  iStack = _interpreter.InputStack();
                // Position will be on the top of the stack, and velocity will be
                // second.
                fStack.Push(position);
                fStack.Push(velocity);
                // Must be included in order to use the input stack. Uses same order
                // as inputs on Float stack.
                iStack.Push(position);
                iStack.Push(velocity);
                _interpreter.Execute(((PushGPIndividual)inIndividual)._program, _executionLimit);
                // If there is no boolean on the stack, the program has failed to
                // return a reasonable output. So, return a penalty fitness of
                // twice the maximum time.
                if (bStack.Size() == 0)
                {
                    return(2 * maxTime);
                }
                // If there is a boolean, use it to compute the next position and
                // velocity. Then, check for termination conditions.
                // NOTE: If result == True, we will apply the force in the positive
                // direction, and if result == False, we will apply the force in
                // the negative direction.
                bool  positiveForce = bStack.Top();
                float acceleration;
                if (positiveForce)
                {
                    acceleration = 0.5f;
                }
                else
                {
                    acceleration = -0.5f;
                }
                velocity = velocity + (timeDiscritized * acceleration);
                position = position + (timeDiscritized * velocity);
                // Check for termination conditions
                if (position <= captureRadius && position >= -captureRadius && velocity <= captureRadius && velocity >= -captureRadius)
                {
                    //Cart is centered, so return time it took.
                    return(step * timeDiscritized);
                }
            }
            // If here, the cart failed to come to rest in the allotted time. So,
            // return the failed error of maxTime.
            return(maxTime);
        }
コード例 #10
0
        /// <summary>
        /// Split the string of mail addresses on the "," that separates them.
        /// </summary>
        /// <param name="InString"></param>
        /// <returns></returns>
        public static ArrayList SplitStringOfMailAddresses(string InString)
        {
            ArrayList addrList = new ArrayList( );

            Scanner.WordCursor word = Scanner.PositionBeginWord( );
            while (true)
            {
                ObjectPair pair = ScanNextAddress(InString, word);
                word = (Scanner.WordCursor)pair.b;

                // got nothing. end of string.
                if (pair.a == null)
                {
                    break;
                }

                // isolate the mail address string.
                string mailAddr = PullMailAddress(InString, pair);

                // add the address string to list of such strings.
                addrList.Add(mailAddr);
            }

            // return the split list of address strings.
            return(addrList);
        }
コード例 #11
0
ファイル: DiffNode.cs プロジェクト: rfellers/pwiz
        public DiffNodeNamePair FindFirstMultiChildParent(DiffTree tree, PropertyName name, bool shortenName, bool allowReflection, DiffNode parentNode = null)
        {
            var oneNode = Nodes.Count == 1;

            var propertyNameString = Property.GetName(tree.Root, this, parentNode);

            // Collection elements should be referred to by their name or string representation
            var propName = IsCollectionElement
                ? new PropertyElementName(ObjectToString(allowReflection))
                : (Property.IsTab ? new PropertyTabName(propertyNameString) : new PropertyName(propertyNameString));

            // If the node can't be displayed and its name cant be ignored,
            // we can't go further down the tree. This can happen theoretically but hasn't occured anywhere yet
            if (propName.Name == null && !Property.IgnoreName)
            {
                return(new DiffNodeNamePair(parentNode?.ChangeExpanded(false), name, allowReflection));
            }

            var newName = name.SubProperty(propName);

            var elemName = Property.GetElementName();

            if (shortenName && Property.GetElementName() != null && !IsCollectionElement)
            {
                if (oneNode)
                {
                    // Remove everything from the path and replace it with the element name, e.g "Settings > DataSettings > GroupComparisons"
                    // becomes "GroupComparison:"
                    newName = PropertyName.ROOT.SubProperty(new PropertyElementName(elemName));
                }
                else
                {
                    // Multiple changes have been made to the collection
                    newName = propName;
                }
            }

            if (Property.IgnoreName && !IsCollectionElement)
            {
                newName = name;
            }

            var objects = Objects.Select(AuditLogObject.GetAuditLogObject)
                          .Where(o => o == null || o.IsName).ToArray();

            if (objects.Length == 2)
            {
                var type = Property.GetPropertyType(ObjectPair.Create(objects[1], objects[0]));
                if (((objects[0] != null) != (objects[1] != null) ||
                     (objects[0] != null && objects[1] != null && objects[0].AuditLogText != objects[1].AuditLogText && !typeof(DocNode).IsAssignableFrom(type))) &&
                    !Property.IsRoot)
                {
                    oneNode = false;     // Stop recursion, since in the undo-redo/summary log we don't want to go deeper for objects where the name changed
                }
            }

            return(oneNode && !IsFirstExpansionNode
                ? Nodes[0].FindFirstMultiChildParent(tree, newName, shortenName, allowReflection, this)
                : new DiffNodeNamePair(ChangeExpanded(false), newName, allowReflection));
        }
コード例 #12
0
ファイル: TestUtil.cs プロジェクト: plamikcho/xbrlpoc
        public void CastToStrongTypeUnchanged()
        {
            object o1 = 25;
            object o2 = 75;
            ObjectPair pair = new ObjectPair(o1, o2);
            Reflection.CastToStrongType(pair);
            o1 = pair.First;
            o2 = pair.Second;

            Assert.IsTrue(o1 is Int32, "(1) o1 type");
            Assert.AreEqual(o1, 25, "(1) o1 value");
            Assert.IsTrue(o2 is Int32, "(1) o2 type");
            Assert.AreEqual(o2, 75, "(1) o2 value");

            o1 = "25";
            o2 = "75";
            pair = new ObjectPair(o1, o2);
            Reflection.CastToStrongType(pair);
            o1 = pair.First;
            o2 = pair.Second;

            Assert.IsTrue(o1 is String, "(2) o1 type");
            Assert.AreEqual(o1, "25", "(2) o1 value");
            Assert.IsTrue(o2 is String, "(2) o2 type");
            Assert.AreEqual(o2, "75", "(2) o2 value");
        }
コード例 #13
0
        public static DiffNodeEnumerator EnumerateDiffNodes(ObjectPair <object> rootPair, Property rootProperty, T obj, Func <DiffNode, bool> nodeSelector = null)
        {
            var objInfo = new ObjectInfo <object>()
                          .ChangeNewObject(obj)
                          .ChangeRootObjectPair(rootPair);

            return(new DiffNodeEnumerator(EnumerateDiffNodes(objInfo, rootProperty, true)));
        }
コード例 #14
0
        public string Localize(ObjectInfo <object> objectInfo)
        {
            var pair = ObjectPair <object> .Create(
                FindObject(objectInfo.OldObjectGroup),
                FindObject(objectInfo.NewObjectGroup));

            return(Localize(pair));
        }
コード例 #15
0
ファイル: ReflectorEnumerator.cs プロジェクト: rfellers/pwiz
        public static DiffNodeEnumerator EnumerateDiffNodes(ObjectPair <object> rootPair, Property rootProperty, SrmDocument.DOCUMENT_TYPE defaultDocumentType, T obj, Func <DiffNode, bool> nodeSelector = null)
        {
            var objInfo = new ObjectInfo <object>()
                          .ChangeNewObject(obj)
                          .ChangeRootObjectPair(rootPair);

            return(new DiffNodeEnumerator(EnumerateDiffNodes(objInfo, rootProperty, defaultDocumentType, true)));
        }
コード例 #16
0
        public static string ToString(ObjectPair <object> rootPair, T obj, ToStringState state)
        {
            var objectInfo = new ObjectInfo <object>().ChangeNewObject(obj)
                             .ChangeRootObjectPair(rootPair ?? ObjectPair <object> .Create(null, null));
            var rootProp = RootProperty.Create(typeof(T));

            var enumerator = EnumerateDiffNodes(objectInfo, rootProp, true);

            return(ToString(objectInfo.ParentObjectPair, DiffTree.FromEnumerator(enumerator, DateTime.Now).Root, state));
        }
コード例 #17
0
    private void _UnloadUpdate()
    {
        List <string> nBundleObjectKeys = new List <string>(nBundleObjectAssetList.Keys);
        int           nCount            = nBundleObjectKeys.Count;

        for (int i = 0; i < nCount; i++)
        {
            nBundleObjectAssetList[nBundleObjectKeys[i]].RemoveWhere(item =>
            {
                if (item == null)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            });

            if (nBundleObjectAssetList[nBundleObjectKeys[i]].Count == 0)
            {
                UnloadObject(nBundleObjectKeys[i]);
                nBundleObjectAssetList.Remove(nBundleObjectKeys[i]);
            }
        }
        LinkedListNode <ObjectPair> node = mReleaseLinkedList.First;

        while (node != null)
        {
            LinkedListNode <ObjectPair> nextNode = node.Next;

            float timeLeft = BundleConfig.limitedTimeEachFrame;
            float begin    = Time.realtimeSinceStartup;
            {//具体逻辑
                ObjectPair op = node.Value;
                mReleaseLinkedList.Remove(node);
                if (node.Value != null)
                {
                    if (node.Value.mDelRes && node.Value.mObject != null)
                    {
                        GameObject.Destroy(node.Value.mObject);
                    }
                    mAssetLoader.UnloadAssetBundle(node.Value.mResName, node.Value.mDelRes);
                }
            }
            timeLeft -= (Time.realtimeSinceStartup - begin);
            if (timeLeft < 0.0f)
            {
                break;
            }

            node = nextNode;
        }
    }
コード例 #18
0
ファイル: Atom.cs プロジェクト: vkiktev/NxBRE
        /// <summary>
        /// Checks if the current Atom matches with another one, i.e. if they are of same type,
        /// contain the same number of predicates, and if their Individual predicates are equal.
        /// </summary>
        /// <description>
        /// This functions takes care of casting as it always tries to cast to the strongest type
        /// of two compared individuals. Since predicates can come from weakly-typed rule files
        /// (Strings) and other predicates can be generated by the user, this function tries to
        /// convert from String to the type of the other predicate (as String is considered not
        /// strongly typed).
        /// </description>
        /// <param name="atom">The other atom to determine the matching.</param>
        /// <returns>True if the two atoms match.</returns>
        public bool Matches(Atom atom)
        {
            if (!BasicMatches(atom))
            {
                return(false);
            }

            for (int i = 0; i < predicates.Length; i++)
            {
                if ((predicates[i] is Individual) &&
                    (atom.predicates[i] is Function) &&
                    (!((Function)atom.predicates[i]).Evaluate((Individual)predicates[i])))
                {
                    return(false);
                }

                else if ((predicates[i] is Function) &&
                         (atom.predicates[i] is Individual) &&
                         (!((Function)predicates[i]).Evaluate((Individual)atom.predicates[i])))
                {
                    return(false);
                }

                else if ((predicates[i] is Function) &&
                         (atom.predicates[i] is Function) &&
                         (!(predicates[i].Equals(atom.predicates[i]))))
                {
                    return(false);
                }

                else if ((predicates[i] is Individual) && (atom.predicates[i] is Individual))
                {
                    // we have two individuals
                    if ((predicates[i].Value.GetType() == atom.predicates[i].Value.GetType()) &&
                        (!predicates[i].Equals(atom.predicates[i])))
                    {
                        // the two individuals are of same types: direct compare
                        return(false);
                    }
                    else
                    {
                        // the two individuals are of different types
                        ObjectPair pair = new ObjectPair(predicates[i].Value, atom.predicates[i].Value);
                        Reflection.CastToStrongType(pair);
                        if (!pair.First.Equals(pair.Second))
                        {
                            return(false);
                        }
                    }
                }
            }
            return(true);
        }
コード例 #19
0
        /// <exception cref="System.Exception"/>
        protected internal override void InitFromParameters()
        {
            base.InitFromParameters();
            _effort = 0;
            string cases      = GetParam("test-cases", true);
            string casesClass = GetParam("test-case-class", true);

            if (cases == null && casesClass == null)
            {
                throw new Exception("No acceptable test-case parameter.");
            }
            if (casesClass != null)
            {
                // Get test cases from the TestCasesClass.
                Type   iclass  = Type.GetType(casesClass);
                object iObject = System.Activator.CreateInstance(iclass);
                if (!(iObject is TestCaseGenerator))
                {
                    throw (new Exception("test-case-class must inherit from class TestCaseGenerator"));
                }
                TestCaseGenerator testCaseGenerator = (TestCaseGenerator)iObject;
                int numTestCases = testCaseGenerator.TestCaseCount();
                for (int i = 0; i < numTestCases; i++)
                {
                    ObjectPair testCase = testCaseGenerator.TestCase(i);
                    float      @in      = (float)testCase._first;
                    float      @out     = (float)testCase._second;
                    Print(";; Fitness case #" + i + " input: " + @in + " output: " + @out + "\n");
                    _testCases.Add(new GATestCase(@in, @out));
                }
            }
            else
            {
                // Get test cases from test-cases.
                Program caselist = new Program(cases);
                for (int i = 0; i < caselist.Size(); i++)
                {
                    Program p = (Program)caselist.DeepPeek(i);
                    if (p.Size() < 2)
                    {
                        throw new Exception("Not enough elements for fitness case \"" + p + "\"");
                    }
                    float @in  = System.Convert.ToSingle(p.DeepPeek(0).ToString());
                    float @out = System.Convert.ToSingle(p.DeepPeek(1).ToString());
                    Print(";; Fitness case #" + i + " input: " + @in + " output: " + @out + "\n");
                    _testCases.Add(new GATestCase(@in, @out));
                }
            }
            // Create and initialize predictors
            _predictorEffortPercent = GetFloatParam("PREDICTOR-effort-percent", true);
            _predictorGA            = PredictionGA.PredictionGAWithParameters(this, GetPredictorParameters(_parameters));
        }
コード例 #20
0
        public IObjectPair <int, int> GetParentTiers(int _categoryID)
        {
            IObjectPair <int, int> parentTiers = new ObjectPair <int, int>();
            ICategory current = categories.Where(x => x.UniqueID == _categoryID).First();

            while (current.ParentID != null)
            {
                parentTiers.Object1 = (int)current.ParentID;
                parentTiers.Object2 = current.UniqueID;
                current             = GetCategory(parentTiers.Object1);
            }
            return(parentTiers);
        }
コード例 #21
0
    /**
     *  @brief	Add the module input needs to the CaptureManager device search. The application must call
     *  this function for all modules before the LocalStreams function, where the CaptureManager performs
     *  the device match.
     *  @param[in]	mid					The module identifier. The application can use any unique value to later identify the module.
     *  @param[in]	inputs				The module input descriptor.
     *  @return PXCM_STATUS_NO_ERROR	Successful executation.
     */
    public pxcmStatus RequestStreams(Int32 mid, PXCMVideoModule.DataDesc inputs)
    {
        ObjectPair op = new ObjectPair(inputs);

        descriptors.Add(op);
        pxcmStatus sts = PXCMCaptureManager_RequestStreams(instance, mid, op.unmanaged);

        if (sts < pxcmStatus.PXCM_STATUS_NO_ERROR)
        {
            descriptors.Clear();
        }
        return(sts);
    }
コード例 #22
0
ファイル: Reflection.cs プロジェクト: Ghasan/NxBRE
 /// <summary>
 /// Converts either object1 to the type of object2, or the contrary, based on the object having
 /// the weakest type, i.e. System.String. If none of the objects are System.String
 /// object2 will be casted to object1.
 /// </summary>
 /// <param name="pair">A reference to the pair of objects to cast.</param>
 public static void CastToStrongType(ObjectPair pair)
 {
     if ((pair.First.GetType().GetInterface("System.IConvertible", false) != null) &&
         (pair.Second.GetType().GetInterface("System.IConvertible", false) != null)) {
         // if they are both convertible, convert to the strongest type (non string)
         // or arbitrary cast the second to the first
         if (pair.First is System.String) {
             pair.First = CastValue(pair.First, pair.Second.GetType());
         }
         else {
             pair.Second = CastValue(pair.Second, pair.First.GetType());
         }
     }
 }
コード例 #23
0
        void Awake()
        {
            for (int i = 0; i < Elements.Count; i++)
            {
                ObjectPair p = Elements[i];
                if (_elements.ContainsKey(p.Name))
                {
                    Debug.LogError("In prefab [" + gameObject.name + "] elements mapper has duplicate name [" + p.Name + "]");
                }

                _elements[p.Name] = p.GameObject;
            }
            Elements.Clear();
        }
コード例 #24
0
ファイル: TestCompiler.cs プロジェクト: CDHDeveloper/NetMeter
        /** {@inheritDoc} */
        public void SubtractNode()
        {
            LOG.Debug("Subtracting node, stack size = " + stack.Count);
            TestElement child = stack.Last.Value;

            trackIterationListeners(stack);
            if (child is TestAgent)
            {
                saveSamplerConfigs((TestAgent)child);
            }
            else if (child is TransactionController)
            {
                saveTransactionControllerConfigs((TransactionController)child);
            }
            stack.RemoveLast();
            if (stack.Count > 0)
            {
                TestElement parent    = stack.Last.Value;
                Boolean     duplicate = false;
                // Bug 53750: this condition used to be in ObjectPair#addTestElements()
                if (parent is Controller && (child is TestAgent || child is Controller))
                {
                    if (!IS_USE_STATIC_SET && parent instanceof TestCompilerHelper)
                    {
                        TestCompilerHelper te = (TestCompilerHelper)parent;
                        duplicate = !te.addTestElementOnce(child);
                    }
                    else
                    { // this is only possible for 3rd party controllers by default
                        ObjectPair pair = new ObjectPair(child, parent);
                        synchronized(PAIRING)
                        {// Called from multiple threads
                            if (!PAIRING.Contains(pair))
                            {
                                parent.addTestElement(child);
                                PAIRING.Add(pair);
                            }
                            else
                            {
                                duplicate = true;
                            }
                        }
                    }
                }
                if (duplicate)
                {
                    LOG.Warn("Unexpected duplicate for " + parent.GetType().Name + " and " + child.GetType().Name);
                }
            }
コード例 #25
0
        public IObjectPair <string, string> GetVideoTitleAndImage(string _mediaID)
        {
            IObjectPair <string, string> titleImage = new ObjectPair <string, string>();

            foreach (JObject video in json["playlist"])
            {//loops for every item in the playlist
                if ((string)video["mediaid"] == _mediaID)
                {
                    titleImage.Object1 = (string)video["title"];
                    titleImage.Object2 = (string)video["image"];
                    return(titleImage);
                }
            }
            return(titleImage);
        }
コード例 #26
0
 /// <exception cref="System.Exception"/>
 protected internal override void InitFromParameters() {
   base.InitFromParameters();
   string cases = GetParam("test-cases");
   Program caselist = new Program(cases);
   for (int i = 0; i < caselist.Size(); i++) {
     Program singleCase = (Program)caselist.DeepPeek(i);
     if (singleCase.Size() < 2) {
       throw new Exception("Not enough elements for fitness case \"" + singleCase + "\"");
     }
     float x = System.Convert.ToSingle(singleCase.DeepPeek(0).ToString());
     float v = System.Convert.ToSingle(singleCase.DeepPeek(1).ToString());
     Print(";; Fitness case #" + i + " position: " + x + " velocity: " + v + "\n");
     ObjectPair xv = new ObjectPair(x, v);
     _testCases.Add(new GATestCase(xv, null));
   }
 }
コード例 #27
0
        // --------------------------- PullMailAddress ------------------------------
        private static string PullMailAddress(string InString, ObjectPair InPair)
        {
            Scanner.WordCursor bgnAddrWord = (Scanner.WordCursor)InPair.a;
            Scanner.WordCursor endAddrWord = (Scanner.WordCursor)InPair.b;

            int Bx = bgnAddrWord.WordBx;
            int Ex = endAddrWord.WordEx;

            if ((Bx == -1) || (Ex == -1))
            {
                throw(new ApplicationException(
                          "email address not properly formed: " + InString));
            }

            return(InString.Substring(Bx, Ex - Bx + 1));
        }
コード例 #28
0
ファイル: ElementsMapper.cs プロジェクト: MildHot/FirstWork
    private void Init()
    {
        for (int i = 0; i < Elements.Count; i++)
        {
            ObjectPair p = Elements[i];
            if (_elements.ContainsKey(p.Name))
            {
                Debug.LogError("In prefab [" + gameObject.name + "] elements mapper has duplicate name [" + p.Name + "]");
            }

            _elements[p.Name] = p.GameObject;
        }
#if !UNITY_EDITOR
        Elements.Clear();
#endif
        inited = true;
    }
コード例 #29
0
        public void ChecGetSetEqual()
        {
            IObjectPair <double, double> pls = new ObjectPair <double, double>
            {
                Object1 = 5,
                Object2 = 8
            };

            video.ArrouselAverageAndDeviation  = pls;
            video.DominanceAverageAndDeviation = pls;
            video.PleaureAverageAndDeviation   = pls;
            video.Thumbnail = "KEKPIC";
            List <IObjectPair <string, int> > help1 = new List <IObjectPair <string, int> >();
            IObjectPair <string, int>         help  = new ObjectPair <string, int>
            {
                Object1 = "LOL",
                Object2 = 5
            };

            help1.Add(help);
            IEnumerable <IObjectPair <string, int> > pls2 = help1;

            video.IABCategoryNameAndPercentage = pls2;
            video.Title      = "IOBJECTPAIRSUK";
            video.WatchCount = 50;
            ISearchVideo search = new Video
            {
                Finished = true
            };

            video.Video = search;

            Assert.Equal(5, video.ArrouselAverageAndDeviation.Object1);
            Assert.Equal(8, video.ArrouselAverageAndDeviation.Object2);
            Assert.Equal(5, video.DominanceAverageAndDeviation.Object1);
            Assert.Equal(8, video.DominanceAverageAndDeviation.Object2);
            Assert.Equal(5, video.PleaureAverageAndDeviation.Object1);
            Assert.Equal(8, video.PleaureAverageAndDeviation.Object2);
            Assert.NotEmpty(video.IABCategoryNameAndPercentage);
            Assert.Equal("KEKPIC", video.Thumbnail);
            Assert.Equal("IOBJECTPAIRSUK", video.Title);
            Assert.Equal(50, video.WatchCount);
            Assert.True(video.Video.Finished);
        }
コード例 #30
0
ファイル: FlowEngineBinder.cs プロジェクト: ilkerhalil/NxBRE
        /// <summary>
        /// Façade for calling an NxBRE Flow Engine RI helper operator.
        /// </summary>
        /// <param name="functionName">The prefixed name of the helper operator to evaluate.</param>
        /// <param name="values">The arguments to pass to the operator.</param>
        /// <returns>True if the value matches the operator.</returns>
        /// <see cref="NxBRE.FlowEngine.IBREOperator"/>
        public static bool EvaluateFERIOperator(string functionName, params object[] values)
        {
            if (values.Length != 2)
            {
                throw new BREException(values.Length +
                                       " is not a valid number of arguments for: " +
                                       functionName +
                                       ", only 2 is supported.");
            }

            string operatorType = "NxBRE.FlowEngine.Rules.";

            if (functionName.ToLower().StartsWith("nxbre:"))
            {
                operatorType += functionName.Substring(6).Split(Parameter.PARENTHESIS)[0];
            }
            else
            {
                operatorType += functionName.Split(Parameter.PARENTHESIS)[0];
            }

            IBREOperator operatorObject;

            lock (nxbreOperatorCache) {
                if (!nxbreOperatorCache.ContainsKey(operatorType))
                {
                    operatorObject = (IBREOperator)Reflection.ClassNew(operatorType, null);
                    nxbreOperatorCache.Add(operatorType, operatorObject);
                }
                else
                {
                    operatorObject = nxbreOperatorCache[operatorType];
                }
            }

            ObjectPair pair = new ObjectPair(values[0], values[1]);

            Reflection.CastToStrongType(pair);

            return(operatorObject.ExecuteComparison(null,
                                                    null,
                                                    pair.First,
                                                    pair.Second));
        }
コード例 #31
0
        /// <summary>
        /// 确定指定的两个对象包含的值是否递归相等。
        /// </summary>
        /// <param name="value">要进行值相等比较的第一个对象。</param>
        /// <param name="other">要进行值相等比较的第二个对象。</param>
        /// <param name="compared">当前已经比较过的对象的键值对。</param>
        /// <returns>若 <paramref name="value"/> 与 <paramref name="other"/> 包含的值递归相等,
        /// 则为 <see langword="true"/>;否则为 <see langword="false"/>。</returns>
        /// <exception cref="MemberAccessException">调用方没有权限来访问对象的成员。</exception>
        private static bool RecursiveEquals(
            object?value, object?other, HashSet <ObjectPair> compared)
        {
            if (RuntimeHelpers.Equals(value, other))
            {
                return(true);
            }
            if ((value is null) || (other is null))
            {
                return(false);
            }
            if (value.GetType() != other.GetType())
            {
                return(false);
            }

            var pair = new ObjectPair(value, other);

            if (!compared.Add(pair))
            {
                return(true);
            }

            var type = value.GetType();

            if (type.IsPrimitive)
            {
                return(ObjectRuntimeValue.PrimitiveEquals(value, other));
            }
            if (type == typeof(string))
            {
                return(ObjectRuntimeValue.PrimitiveEquals(value, other));
            }
            else if (type.IsArray)
            {
                return(ObjectRuntimeValue.ArrayRecursiveEquals((Array)value, (Array)other, compared));
            }
            else
            {
                return(ObjectRuntimeValue.ObjectRecursiveEquals(value, other, compared));
            }
        }
コード例 #32
0
ファイル: Property.cs プロジェクト: CMRI-ProCan/pwiz
        // These functions get the most derived, common type of the given objects
        // For instance, if the property type is DocNode, the oldObject a PeptideDocNode and
        // the newObject a PeptideGroupDocNode we only compare based on the DocNode properties. If the newObject
        // was also a PeptideDocNode, we compare based on PeptideDocNode properties.

        public static Type GetPropertyType(Type type, ObjectPair <object> objectPair)
        {
            var type1 = objectPair.OldObject == null ? null : objectPair.OldObject.GetType();
            var type2 = objectPair.NewObject == null ? null : objectPair.NewObject.GetType();

            // Compare based on the object type if the types are the same and not null,
            // otherwise compare by the type of the property, which is guaranteed to be a shared
            // base by both objects
            if ((type1 == type2 || type2 == null) && type1 != null)
            {
                return(type1);
            }

            if (type1 == null && type2 != null)
            {
                return(type2);
            }

            return(type);
        }
コード例 #33
0
ファイル: FindDock.cs プロジェクト: chkob/behaviac-old
        public static void ShowObject(ObjectPair obj)
        {
            BehaviorTreeList behaviorTreeList = BehaviorManager.Instance as BehaviorTreeList;

            if (behaviorTreeList == null)
            {
                return;
            }

            Nodes.Node             node   = null;
            Attachments.Attachment attach = null;

            if (obj.Obj is Nodes.Node)
            {
                node = (Nodes.Node)obj.Obj;
            }
            else if (obj.Obj is Attachments.Attachment)
            {
                attach = (Attachments.Attachment)obj.Obj;
                node   = attach.Node;
            }

            if (node != null)
            {
                behaviorTreeList.ShowNode(node, obj.Root);

                if (BehaviorTreeViewDock.LastFocused != null)
                {
                    BehaviorTreeView behaviorTreeView = BehaviorTreeViewDock.LastFocused.BehaviorTreeView;

                    if (behaviorTreeView != null)
                    {
                        behaviorTreeView.SelectedNodePending       = node;
                        behaviorTreeView.SelectedAttachmentPending = attach;

                        behaviorTreeView.Refresh();
                    }
                }
            }
        }
コード例 #34
0
ファイル: TestCompiler.cs プロジェクト: RalphC/NetMeter
 /** {@inheritDoc} */
 public void SubtractNode()
 {
     LOG.Debug("Subtracting node, stack size = " + stack.Count);
     TestElement child = stack.Last.Value;
     trackIterationListeners(stack);
     if (child is TestAgent)
     {
         saveSamplerConfigs((TestAgent) child);
     }
     else if(child is TransactionController)
     {
         saveTransactionControllerConfigs((TransactionController) child);
     }
     stack.RemoveLast();
     if (stack.Count > 0)
     {
         TestElement parent = stack.Last.Value;
         Boolean duplicate = false;
         // Bug 53750: this condition used to be in ObjectPair#addTestElements()
         if (parent is Controller && (child is TestAgent || child is Controller))
         {
             if (!IS_USE_STATIC_SET && parent instanceof TestCompilerHelper)
             {
                 TestCompilerHelper te = (TestCompilerHelper) parent;
                 duplicate = !te.addTestElementOnce(child);
             }
             else
             { // this is only possible for 3rd party controllers by default
                 ObjectPair pair = new ObjectPair(child, parent);
                 synchronized (PAIRING)
                 {// Called from multiple threads
                     if (!PAIRING.Contains(pair))
                     {
                         parent.addTestElement(child);
                         PAIRING.Add(pair);
                     } else {
                         duplicate = true;
                     }
                 }
             }
         }
         if (duplicate) {
             LOG.Warn("Unexpected duplicate for " + parent.GetType().Name + " and " + child.GetType().Name);
         }
     }
コード例 #35
0
	private void InitializPairs()
	{
		// the parent of object at real map
		GameObject realMapParentObj = GameObject.Find( "TrafficLightParent" ) ;
		if( null == realMapParentObj )
		{
			Debug.LogError( "MinimapManager01:InitializPairs() null == realMapParentObj" ) ;
			return ;
		}
		
		ObjectPair newPair = null ;
		Transform trans = null ;
		GameObject realObj = null ;
		string trafficLightName = "";
		for( int i = 0 ; i < 3 ; ++i )
		{
			// use this will result in TrafficLight0 , TrafficLight1 , TrafficLight2
			// trafficLightName = "TrafficLight" + i.ToString() ;
			
			// use this will result in TrafficLight00 , TrafficLight01 , TrafficLight02
			trafficLightName = string.Format( "TrafficLight{0:00}" , i ) ;
			
			
			// find child at realmap
			trans = realMapParentObj.transform.FindChild( trafficLightName ) ;
			if( null != trans )
			{
				realObj = trans.gameObject ;
				
				Object prefabObj = Resources.Load( "Prefabs/TrafficSignal" ) ;
				if( null != prefabObj )
				{
					GameObject newSingalObject = (GameObject) GameObject.Instantiate( prefabObj ) ;
					
					newSingalObject.name = "TrafficSignal_" + trafficLightName ;
					
					// collect this object under parent
					if( null != m_TrafficSignalParent )
					{
						newSingalObject.transform.parent = m_TrafficSignalParent.transform ;
					}
					
					// add in dictionary
					newPair = new ObjectPair() ;
					newPair.UnitObj = realObj ;
					newPair.MiniMapObj = newSingalObject ;
					m_MiniMapPairs.Add( trafficLightName , newPair ) ;
				}
			}
		}
		
	}
コード例 #36
0
ファイル: Atom.cs プロジェクト: plamikcho/xbrlpoc
        /// <summary>
        /// Checks if the predicates of the current Atom match with the predicates of another one, i.e. are equal or functions resolve to True.
        /// </summary>
        /// <param name="atom">The other atom to determine the predicates matching.</param>
        /// <param name="strictTyping">True if String individual predicate are not considered as potential representations of other types.</param>
        /// <param name="ignoredPredicates">A list of predicate positions to exclude from comparison, or null if all predicates must be matched</param>
        /// <returns>True if the two atoms have matching predicates, False otherwise.</returns>
        internal bool PredicatesMatch(Atom atom, bool strictTyping, IList<int> ignoredPredicates)
        {
            for(int position=0; position<predicates.Length; position++) {
                if ((ignoredPredicates == null) || ((ignoredPredicates != null) && (!ignoredPredicates.Contains(position)))) {
                    if ((predicates[position] is Individual) &&
                        (atom.predicates[position] is Function) &&
                        (!((Function)atom.predicates[position]).Evaluate((Individual)predicates[position]))) {
                        return false;
                    }
                    else if ((predicates[position] is Function) &&
                             (atom.predicates[position] is Individual) &&
                             (!((Function)predicates[position]).Evaluate((Individual)atom.predicates[position]))) {
                        return false;
                    }
                    else if ((predicates[position] is Function) &&
                             (atom.predicates[position] is Function) &&
                             (!(predicates[position].Equals(atom.predicates[position])))) {
                        return false;
                    }
                    else if ((predicates[position] is Individual) && (atom.predicates[position] is Individual)) {
                        // we have two individuals
                        if (predicates[position].Value.GetType() == atom.predicates[position].Value.GetType()) {
                          if (!predicates[position].Equals(atom.predicates[position]))
                                // the two individuals are of same types: if equals fail, no match
                                return false;
                        }
                        else {
                            if (!strictTyping) {
                                // the two individuals are of different types and we are not in strict typing, so
                                // we try to cast to stronger type and compare
                                ObjectPair pair = new ObjectPair(predicates[position].Value, atom.predicates[position].Value);
                                Reflection.CastToStrongType(pair);
                                if (!pair.First.Equals(pair.Second)) return false;
                            }
                            else {
                                return false;
                            }
                        }
                    }
                }
            }

            // we went through all the comparisons without a scratch, it means the atoms do match
            return true;
        }
コード例 #37
0
 /**
     @brief	Add the module input needs to the CaptureManager device search. The application must call
     this function for all modules before the LocalStreams function, where the CaptureManager performs
     the device match.
     @param[in]	mid					The module identifier. The application can use any unique value to later identify the module.
     @param[in]	inputs				The module input descriptor.
     @return PXCM_STATUS_NO_ERROR	Successful executation.
 */
 public pxcmStatus RequestStreams(Int32 mid, PXCMVideoModule.DataDesc inputs)
 {
     ObjectPair op = new ObjectPair(inputs);
     descriptors.Add(op);
     pxcmStatus sts = PXCMCaptureManager_RequestStreams(instance, mid, op.unmanaged);
     if (sts < pxcmStatus.PXCM_STATUS_NO_ERROR)
         descriptors.Clear();
     return sts;
 }
コード例 #38
0
ファイル: FlowEngineBinder.cs プロジェクト: Ghasan/NxBRE
        /// <summary>
        /// Façade for calling an NxBRE Flow Engine RI helper operator.
        /// </summary>
        /// <param name="functionName">The prefixed name of the helper operator to evaluate.</param>
        /// <param name="values">The arguments to pass to the operator.</param>
        /// <returns>True if the value matches the operator.</returns>
        /// <see cref="NxBRE.FlowEngine.IBREOperator"/>
        public static bool EvaluateFERIOperator(string functionName, params object[] values)
        {
            if (values.Length != 2)
                throw new BREException(values.Length +
                                       " is not a valid number of arguments for: " +
                                       functionName +
                                       ", only 2 is supported.");

            string operatorType = "NxBRE.FlowEngine.Rules.";

            if (functionName.ToLower().StartsWith("nxbre:")) operatorType += functionName.Substring(6).Split(Parameter.PARENTHESIS)[0];
            else operatorType += functionName.Split(Parameter.PARENTHESIS)[0];

            IBREOperator operatorObject;

            lock(nxbreOperatorCache) {
                if (!nxbreOperatorCache.ContainsKey(operatorType)) {
                    operatorObject = (IBREOperator)Reflection.ClassNew(operatorType, null);
                    nxbreOperatorCache.Add(operatorType, operatorObject);
                }
                else {
                    operatorObject = nxbreOperatorCache[operatorType];
                }
            }

            ObjectPair pair = new ObjectPair(values[0], values[1]);
            Reflection.CastToStrongType(pair);

            return operatorObject.ExecuteComparison(null,
                                                    null,
                                                    pair.First,
                                                    pair.Second);
        }