private ClrTypeDefinition(
            TypeDefinition definition,
            ClrAssembly assembly,
            TypeParent parent,
            QualifiedName fullName)
        {
            this.Definition          = definition;
            this.Assembly            = assembly;
            this.Parent              = parent;
            this.contentsInitializer = Assembly
                                       .CreateSynchronizedInitializer(AnalyzeContents);
            this.OverrideInitializer = Assembly
                                       .CreateSynchronizedInitializer(AnalyzeOverrides);

            this.FullName        = fullName;
            this.nestedTypeCache = Assembly
                                   .CreateSynchronizedLazy <IReadOnlyList <ClrTypeDefinition> >(() =>
            {
                return(definition.NestedTypes
                       .Select(t => new ClrTypeDefinition(t, this))
                       .ToArray());
            });
            this.genericParamCache = Assembly
                                     .CreateSynchronizedLazy <IReadOnlyList <ClrGenericParameter> >(() =>
            {
                return(definition.GenericParameters
                       .Skip(
                           parent.IsType
                            ? parent.TypeOrNull.GenericParameters.Count
                            : 0)
                       .Select(param => new ClrGenericParameter(param, this))
                       .ToArray());
            });
        }
Beispiel #2
0
        /// <summary>
        /// Creates a new decoder state that is identical to this
        /// decoder state in every way except for the decoding scope.
        /// </summary>
        /// <param name="newScope">
        /// The decoding scope for the new decoder state.
        /// </param>
        /// <returns>
        /// A new decoder state.
        /// </returns>
        public DecoderState WithScope(TypeParent newScope)
        {
            var result = new DecoderState(Log, TypeResolver, Codec, newScope);

            result.typeCache = typeCache;
            return(result);
        }
 private ClrGenericParameter(
     GenericParameter definition,
     ClrAssembly assembly,
     TypeParent parent)
 {
     this.Definition = definition;
     this.Assembly   = assembly;
     this.Parent     = parent;
     this.FullName   = new SimpleName(definition.Name)
                       .Qualify(parent.Member.FullName);
     this.contentsInitializer = Assembly.CreateSynchronizedInitializer(
         AnalyzeContents);
 }
Beispiel #4
0
 //-------------------------------------------------------------------
 /// <summary>
 /// Remplit une hashtable IdChamp->Champ
 /// avec tous les champs liés.(hiérarchique)
 /// </summary>
 /// <param name="tableChamps">HAshtable à remplir</param>
 private void FillHashtableChamps(Hashtable tableChamps)
 {
     foreach (IRelationDefinisseurChamp_ChampCustom relation in RelationsChampsCustomDefinis)
     {
         tableChamps[relation.ChampCustom.Id] = relation.ChampCustom;
     }
     foreach (IRelationDefinisseurChamp_Formulaire relation in RelationsFormulaires)
     {
         foreach (CRelationFormulaireChampCustom relFor in relation.Formulaire.RelationsChamps)
         {
             tableChamps[relFor.Champ.Id] = relFor.Champ;
         }
     }
     if (TypeParent != null)
     {
         TypeParent.FillHashtableChamps(tableChamps);
     }
 }
Beispiel #5
0
 /// <summary>
 /// Creates a decoder.
 /// </summary>
 /// <param name="log">A log to use for error and warning messages.</param>
 /// <param name="typeResolver">A read-only type resolver for resolving types.</param>
 /// <param name="codec">A Flame IR codec.</param>
 /// <param name="scope">The decoder's scope.</param>
 private DecoderState(
     ILog log,
     ReadOnlyTypeResolver typeResolver,
     IrCodec codec,
     TypeParent scope)
 {
     this.Log             = log;
     this.TypeResolver    = typeResolver;
     this.Codec           = codec;
     this.Scope           = scope;
     this.typeCache       = new ConcurrentDictionary <LNode, IType>();
     this.TypeMemberIndex = new Index <IType, UnqualifiedName, ITypeMember>(
         type =>
         type.Fields
         .Concat <ITypeMember>(type.Properties)
         .Concat <ITypeMember>(type.Methods)
         .Select(member =>
                 new KeyValuePair <UnqualifiedName, ITypeMember>(
                     member.Name,
                     member)));
 }
Beispiel #6
0
        //-------------------------------------------------------------
        public CLocalTypeAlarme GetTypeForSupervision(CMemoryDb database, bool bWithChilds)
        {
            if (database == null)
            {
                database = CMemoryDbPourSupervision.GetMemoryDb(ContexteDonnee);
            }
            CLocalTypeAlarme typeParent = null;

            if (TypeParent != null)
            {
                typeParent = TypeParent.GetTypeForSupervision(database, false);
            }
            CLocalTypeAlarme typeAlarme = new CLocalTypeAlarme(database);

            if (!typeAlarme.ReadIfExist(Id.ToString(), false))
            {
                typeAlarme.CreateNew(Id.ToString());
            }
            else
            if (!typeAlarme.IsToRead())
            {
                return(typeAlarme);
            }
            typeAlarme.Row[CMemoryDb.c_champIsToRead] = false;
            typeAlarme.Libelle              = Libelle;
            typeAlarme.ModeCalculEtat       = ModeCalculEtatParent.Code;
            typeAlarme.ActionsSurParent     = FormuleCalculActionsSurParent;
            typeAlarme.EtatDefaut           = EtatInitial.Code;
            typeAlarme.TypeParent           = typeParent;
            typeAlarme.RegrouperSurLaCle    = RegrouperSurLaCle;
            typeAlarme.FormuleLibelle       = FormuleCalculLibelle;
            typeAlarme.ActionsSurParent     = FormuleCalculActionsSurParent;
            typeAlarme.AAcquitter           = AAcquitter;
            typeAlarme.TypeElementSupervise = TypeElementSupervise.Code;

            CLocalSeveriteAlarme severite = null;

            if (Severite != null)
            {
                severite = Severite.GetTypeForSupervision(database);
            }
            typeAlarme.Severite = severite;

            foreach (CRelationTypeAlarme_ChampCustom rel in RelationsChampsCustomDefinis)
            {
                if (rel.ChampCustom != null && rel.ChampCustom.Id > 0)
                {
                    CLocalChampTypeAlarme champ = GetChampTypeAlarme(database, rel.ChampCustom);
                    CLocalRelationTypeAlarmeChampAlarme relLocale = new CLocalRelationTypeAlarmeChampAlarme(database);
                    if (!relLocale.ReadIfExist(rel.Id.ToString()))
                    {
                        relLocale.CreateNew(rel.Id.ToString());
                        relLocale.Champ      = champ;
                        relLocale.TypeAlarme = typeAlarme;
                        relLocale.IsKey      = rel.IsKey;
                    }
                }
            }
            if (bWithChilds)
            {
                foreach (CTypeAlarme typeChild in TypesFils)
                {
                    CLocalTypeAlarme typeFils = typeChild.GetTypeForSupervision(database, true);
                    typeFils.TypeParent = typeAlarme;
                }
            }
            return(typeAlarme);
        }