Exemple #1
0
        /// <summary>
        /// Serialalize type.
        /// </summary>
        /// <param name="tobj"></param>
        /// <param name="exclude"></param>
        /// <param name="noReturn"></param>
        /// <param name="JSNamespace"></param>
        /// <returns></returns>
        public void Execute(Type tobj, bool noReturn, ConfigJS.JSNamespace JSNamespace, string exclude = "System.")
        {
            this.Context_global = new GlobalRecursiveContext(idx_max, tobj);

            //if (tobj.FullName == "QuadraEden.Domain.EffetFacture")//-- debug
            //{
            //    var aa = 1;
            //}

            var next_stamp = this.Context_global.GetNext_Stamp();

            this.Context_global.RecursiveContext_Execution.Add(tobj);
            this.Execute(next_stamp, tobj, this.idx_max, noReturn, JSNamespace, exclude);

            foreach (var kv in this.Context_global.OccurencesOfDependanceType)
            {
                if (this.OccurencesOfDependanceType_All.ContainsKey(kv.Key) == false)
                {
                    //-- All occurences of complex types
                    this.OccurencesOfDependanceType_All.Add(kv.Key, kv.Value);
                }
            }

            this.Context_global = null;
        }
Exemple #2
0
        /// <summary>
        /// Serialalize type. Recursive function.
        /// </summary>
        /// <param name="stamp"></param>
        /// <param name="tobj">type of object</param>
        /// <param name="_idx_max"></param>
        /// <param name="noReturn"></param>
        /// <param name="JSNamespace"></param>
        /// <param name="exclude"></param>
        /// <returns></returns>
        internal void Execute(int stamp, Type tobj, int _idx_max, bool noReturn, ConfigJS.JSNamespace JSNamespace, string exclude = "System.")
        {
            TypeSorter_ tSorter = new TypeSorter_(tobj);

            IList <MemberInfo> complexMembersTemp = tSorter.DetermineIfMemberInfoAreComplexMembers_unresolved(TypesToIgnore);

            foreach (MemberInfo mi in complexMembersTemp)
            {
                Type tmem = TypeHelper.GetMemberType(mi);

                Type telem_work = TypeHelper.GetElementTypeOfCollectionOrDefault(tmem);

                if (this.ResolvedTypes.ContainsKey(telem_work) == true)
                {
                    tSorter.ResolveComplexMember(mi);
                    continue;
                }


                if (typeof(System.Object) == telem_work)
                {
                    tSorter.ResolveComplexMember(mi);
                }
                else
                {
                    if (string.IsNullOrWhiteSpace(exclude) || (string.IsNullOrWhiteSpace(exclude) == false && telem_work.FullName != null && telem_work.FullName.Contains(exclude) == false))
                    {
                        if (this.Context_global.TestOverFlow(telem_work) == false)
                        {
                            //-- memorize executions.
                            this.Context_global.Add(telem_work);

                            //-- recursive
                            this.Context_global.RecursiveContext_Execution.Add(telem_work);
                            int next_stamp = this.Context_global.GetNext_Stamp();
                            this.Execute(next_stamp, telem_work, _idx_max, noReturn, JSNamespace, exclude);
                        }
                        else
                        {
                            //-- it's recursive member.
                            tSorter.ResolveComplexMember(mi);
                        }
                    }
                    else
                    {
                        tSorter.ResolveComplexMember(mi);
                    }
                }
            }

            #region "extra"
            //------------------- DON'T DELETE
            //if (tSorter.IsResolved == false)
            //{
            //    foreach (var mi in tSorter.GetComplexMembers_unresolved())
            //    {
            //        Type tmi = TypeHelper.GetMemberType(mi);
            //        Type telem_work = TypeHelper.GetElementTypeOfCollectionOrDefault(tmi);
            //        if (this.ResolvedTypes.ContainsKey(telem_work))
            //        {
            //            tSorter.ResolveComplexMember(mi);
            //        }
            //    }
            //}
            #endregion

            if (tSorter.IsResolved && (ResolvedTypes.ContainsKey(tobj) == false))
            {
                this.ResolvedTypes.Add(tobj, tSorter);
            }
        }