예제 #1
0
        public object GetInstance()
        {
            object instance;

            if (repository.HasType(type))
            {
                instance = repository.Get(type);
            }
            else
            {
                var constructor = GetConstructor();

                var parameters = GetConstructorParameterValues(constructor);
                try
                {
                    instance = constructor.Invoke(parameters);
                }
                catch (Exception exception)
                {
                    throw new UnableToReadXMLTextException(
                              string.Format("Exception thrown from contructor of type '{0}'.", type.FullName), exception);
                }
            }

            if (instance == null)
            {
                Exception exception = new UnableToReadXMLTextException(
                    string.Format("Unable to create instance of type '{0}'.", type.FullName));
                throw exception;
            }

            return(instance);
        }
예제 #2
0
 public bool CanWrite(object instance, Type referencedAsType)
 {
     return(appObjectRepository.HasType(referencedAsType));
 }