public void TryAdd(Type type, ReflectionInfo fields)
 {
   cacheLock.EnterWriteLock();
   try
   {
     harvestCache.Add(type, fields);
   }
   finally
   {
     cacheLock.ExitWriteLock();
   }
 }
Beispiel #2
0
        void IntrospectComplexType(object source, Field field, Type sourceType)
        {
            Reference optionReferenceInfo;

            seenBefore.TryGetValue(source, out optionReferenceInfo);

            tokens.Add(new Token(TokenType.FieldnameWithTypeAndReference, field, null, optionReferenceInfo, sourceType));
            tokens.Add(Startscope);

            ReflectionInfo reflection = ReflectFields(sourceType);

            for (int i = 0; i < reflection.Fields.Length; i++)
            {
                Introspect(reflection.ValueProviders[i](source), reflection.Fields[i]);
            }

            tokens.Add(Endscope);
        }
        ReflectionInfo ReflectFields(Type sourceType)
        {
            ReflectionInfo reflection;

            if ((reflection = harvestCache.TryGet(sourceType)) == null)
            {
                IFieldHarvester harvester;
                if (!configuration.TryGetFieldHarvester(sourceType, out harvester))
                {
                    throw new Exception(string.Format("No fieldharvester is configured for handling type '{0}'. Try using 'ConfigurationHelper.GetStandardConfiguration()' to get started.", sourceType));
                }

                List <SanitiedFieldInfo> fields = harvester.GetFields(sourceType);
                reflection = new ReflectionInfo(fields);
                harvestCache.TryAdd(sourceType, reflection);
            }

            return(reflection);
        }
Beispiel #4
0
        ReflectionInfo ReflectFields(Type sourceType)
        {
            ReflectionInfo reflection;

            if ((reflection = harvestCache.TryGet(sourceType)) == null)
            {
                IFieldHarvester harvester;
                if (!Configuration.TryGetFieldHarvester(sourceType, out harvester))
                {
                    throw new Exception(string.Format("No fieldharvester is configured for handling type '{0}'", sourceType));
                }

                var fields = harvester.GetFields(sourceType);
                reflection = new ReflectionInfo(fields);
                harvestCache.TryAdd(sourceType, reflection);
            }

            return(reflection);
        }
Beispiel #5
0
        void IntrospectComplexType(object source, Field field, Type sourceType)
        {
            Reference optionReferenceInfo;

            seenBefore.TryGetValue(source, out optionReferenceInfo);

            tokens.Add(new Token(TokenType.FieldnameWithTypeAndReference, field, null, optionReferenceInfo, sourceType));
            tokens.Add(Startscope);

            ReflectionInfo reflection = ReflectFields(sourceType);

            for (int i = 0; i < reflection.RawReflectedFields.Count; i++)
            {
                var ffield = reflection.RawReflectedFields[i];
                Introspect(ffield.GetValue(source), reflection.Fields[i]);
            }

            tokens.Add(Endscope);
        }
Beispiel #6
0
    ReflectionInfo ReflectFields(Type sourceType)
    {
      ReflectionInfo reflection;
      if ((reflection = harvestCache.TryGet(sourceType)) == null)
      {
        IFieldHarvester harvester;
        if (!Configuration.TryGetFieldHarvester(sourceType, out harvester))
          throw new Exception(string.Format("No fieldharvester is configured for handling type '{0}'", sourceType));

        var fields = harvester.GetFields(sourceType);
        reflection = new ReflectionInfo(fields);
        harvestCache.TryAdd(sourceType, reflection);
      }

      return reflection;
    }
        ReflectionInfo ReflectFields(Type sourceType)
        {
            ReflectionInfo reflection;
            if ((reflection = harvestCache.TryGet(sourceType)) == null)
            {
                IFieldHarvester harvester;
                if (!configuration.TryGetFieldHarvester(sourceType, out harvester))
                    throw new Exception(
                            string.Format(
                                    "No fieldharvester is configured for handling type '{0}'. Try using 'ConfigurationHelper.GetStandardConfiguration()' to get started.",
                                    sourceType));

                List<SanitizedFieldInfo> fields = harvester.GetFields(sourceType);
                reflection = new ReflectionInfo(fields);
                harvestCache.TryAdd(sourceType, reflection);
            }

            return reflection;
        }