Пример #1
0
 /// <summary>
 /// Cria uma instancia com os dados da entrada.
 /// </summary>
 /// <param name="typeName">Nome do tipo da entrada.</param>
 /// <param name="version"></param>
 /// <param name="queryResult">Resultado dos itens da entrada.</param>
 public DataEntry(Colosoft.Reflection.TypeName typeName, DateTime version, Query.IQueryResult queryResult)
 {
     typeName.Require("typeName").NotNull();
     _typeName = typeName;
     _version  = version;
     _result   = queryResult;
 }
Пример #2
0
        /// <summary>
        /// Cria o gerador associado com o tipo informado.
        /// </summary>
        /// <param name="typeName"></param>
        /// <returns></returns>
        public Query.IRecordKeyGenerator CreateGenerator(Colosoft.Reflection.TypeName typeName)
        {
            typeName.Require("typeName").NotNull();
            Query.IRecordKeyGenerator result = null;
            var key = typeName.FullName;

            lock (_generators)
                if (_generators.TryGetValue(key, out result))
                {
                    return(result);
                }
            var typeMetadata = _typeSchema.GetTypeMetadata(key);

            if (typeMetadata == null)
            {
                result = new DefaultRecordKeyGenerator(typeName);
            }
            else
            {
                var keys = typeMetadata.GetKeyProperties().Select(f => f.Name).ToArray();
                result = new Generator(typeName, _cultureInfo, keys);
            }
            lock (_generators)
                if (!_generators.ContainsKey(key))
                {
                    _generators.Add(key, result);
                }
            return(result);
        }
Пример #3
0
 /// <summary>
 /// Construtor padrão.
 /// </summary>
 /// <param name="typeName"></param>
 /// <param name="cultureInfo"></param>
 /// <param name="fieldNames"></param>
 internal Generator(Colosoft.Reflection.TypeName typeName, System.Globalization.CultureInfo cultureInfo, string[] fieldNames)
 {
     typeName.Require("typeName").NotNull();
     fieldNames.Require("fieldNames").NotNull();
     _typeName    = typeName;
     _cultureInfo = cultureInfo;
     _fieldNames  = fieldNames;
 }
Пример #4
0
        /// <summary>
        /// Adicionar o tipo que deve ser ignorado pelo gerenciador.
        /// </summary>
        /// <param name="typeName"></param>
        public void IgnoreType(Colosoft.Reflection.TypeName typeName)
        {
            typeName.Require("typeName").NotNull();
            int index = _ignoreTypes.BinarySearch(typeName, Colosoft.Reflection.TypeName.TypeNameFullNameComparer.Instance);

            if (index < 0)
            {
                _ignoreTypes.Insert(~index, typeName);
            }
        }
Пример #5
0
        /// <summary>
        /// Recupera o membro específico.
        /// </summary>
        /// <param name="typeName"></param>
        /// <param name="memberName"></param>
        /// <returns>A <see cref="System.Reflection.MemberInfo"/> object.</returns>
        public System.Reflection.MemberInfo GetMemberInfo(Colosoft.Reflection.TypeName typeName, string memberName)
        {
            typeName.Require("typeName").NotNull();
            System.Reflection.Assembly assembly = null;
            if (!_assemblies.TryGet(typeName.AssemblyName.Name, out assembly))
            {
                throw new InvalidOperationException(string.Format("Not found assembly '{0}'", typeName.AssemblyName.Name));
            }
            Type inspectedType = assembly.GetType(typeName.FullName, true, true);

            return((string.IsNullOrEmpty(memberName)) ? inspectedType : inspectedType.GetMember(memberName).FirstOrDefault());
        }
Пример #6
0
 /// <summary>
 /// Remove o registro do tipo para ser carregado para o cache.
 /// </summary>
 /// <param name="typeName">Nome do tipo que será removido.</param>
 /// <returns></returns>
 public IDataCacheManager Unregister(Colosoft.Reflection.TypeName typeName)
 {
     typeName.Require("typeFullName").NotNull();
     lock (_objLock)
     {
         var index = _typeNames.FindIndex(f => Reflection.TypeName.TypeNameFullNameComparer.Instance.Equals(f, typeName));
         if (index >= 0)
         {
             _typeNames.RemoveAt(index);
         }
     }
     return(this);
 }
Пример #7
0
 /// <summary>
 /// Construtor padrão.
 /// </summary>
 /// <param name="typeName">Tipo que contem o construtor.</param>
 /// <param name="parameters"></param>
 public ImportingConstructorDescription(Colosoft.Reflection.TypeName typeName, ImportingConstructorParameterDescription[] parameters)
 {
     typeName.Require("type").NotNull();
     _typeName   = typeName;
     _parameters = parameters;
 }
Пример #8
0
 /// <summary>
 /// Adiciona o nome do tipo para ser carregado.
 /// </summary>
 /// <param name="typeName"></param>
 public void Add(Colosoft.Reflection.TypeName typeName)
 {
     typeName.Require("typeName").NotNull();
     _typeNames.Enqueue(typeName);
 }