/// <summary>
 ///     The add.
 /// </summary>
 /// <param name="context">
 ///     The context.
 /// </param>
 /// <param name="metadata">
 ///     The metadata.
 /// </param>
 /// <param name="shareLifetime">
 ///     The share lifetime.
 /// </param>
 public void Add(ILifetimeContext context, ExportMetadata metadata, bool shareLifetime)
 {
     lock (this)
     {
         if (shareLifetime) _global[metadata.Export] = context;
         else _local[metadata] = context;
     }
 }
示例#2
0
        protected override void ReadSpecific(BinaryReader reader)
        {
            var count = reader.ReadVarUint32();

            for (var i = 0; i < count; i++)
            {
                Exports.Add(ExportMetadata.Read(reader));
            }
        }
        /// <summary>
        ///     Initialisiert eine neue Instanz der <see cref="BuildObject" /> Klasse.
        /// </summary>
        /// <param name="imports">
        ///     The imports.
        /// </param>
        /// <param name="targetExport">
        /// </param>
        public BuildObject(IEnumerable<ImportMetadata> imports, ExportMetadata targetExport, [CanBeNull]BuildParameter[] buildParameters)
        {
            Contract.Requires<ArgumentNullException>(imports != null, "imports");
            Contract.Requires<ArgumentNullException>(targetExport != null, "targetExport");

            Metadata = targetExport;
            this.imports = imports.ToArray();
            Export = targetExport.Export;
            BuildParameters = buildParameters;
        }
        public ProxyGenerator Generate(ExportMetadata metadata, ImportMetadata[] imports, out IImportInterceptor interceptor)
        {
            Contract.Requires<ArgumentNullException>(metadata != null, "metadata");
            Contract.Requires<ArgumentNullException>(imports != null, "imports");
            Contract.Ensures(Contract.Result<ProxyGenerator>() != null);

            interceptor = null;

            return null;
        }
            public ProxyGenerator Generate(ExportMetadata metadata, ImportMetadata[] imports, out IImportInterceptor interceptor)
            {
                interceptor = null;
                if (!typeof (ModelBase).IsAssignableFrom(metadata.Export.ImplementType)) return _genericGenerator;

                var targetImports =
                    imports.Where(meta => meta.Metadata.ContainsKey(EnablePropertyInheritanceMetadataName))
                        .Where(m => (bool) m.Metadata[EnablePropertyInheritanceMetadataName])
                        .ToArray();

                if (targetImports.Length == 0) return _genericGenerator;

                interceptor = new PropertyImportInterceptor(targetImports);

                return _genericGenerator;
            }
        public SimpleResolver([NotNull] ExportMetadata metadata, [NotNull] IContainer container,
                              bool isExportFactory, [CanBeNull] Type factoryType, [CanBeNull] object metadataObject,
                              [CanBeNull] Type metadataType, [CanBeNull] InterceptorCallback interceptor, bool isDescriptor,
                              [NotNull] IResolverExtension[] extensions)
        {
            Contract.Requires<ArgumentNullException>(extensions != null, "extensions");
            Contract.Requires<ArgumentNullException>(container != null, "container");
            Contract.Requires<ArgumentNullException>(!isExportFactory || metadataType != null, "metadataType");

            _metadata = metadata;
            _container = container;
            _isExportFactory = isExportFactory;
            _factoryType = factoryType;
            _metadataObject = metadataObject;
            _metadataType = metadataType;
            _interceptor = interceptor;
            _isDescriptor = isDescriptor;
            _extensions = extensions;
        }
示例#7
0
        public static dynamic ToDynamic(this object value, ExportMetadata metadata)
        {
            IDictionary <string, object> expando = new ExpandoObject();

            if (value is IEnumerable)
            {
                var items  = new List <object>();
                var values = value as IEnumerable;
                foreach (var v in values)
                {
                    items.Add(GetExpandoObject(v));
                }
                expando.Add("Items", items);
                expando.Add("$Meta", metadata);
            }
            else
            {
                expando = GetExpandoObject(value);
                expando.Add("$Meta", metadata);
            }
            return(expando);
        }
        /// <summary>
        ///     The get.
        /// </summary>
        /// <param name="metadata">
        ///     The metadata.
        /// </param>
        /// <returns>
        ///     The <see cref="ILifetimeContext" />.
        /// </returns>
        public ILifetimeContext GetContext(ExportMetadata metadata)
        {
            lock (this)
            {
                ILifetimeContext context;
                if (metadata.Export.ShareLifetime) _global.TryGetValue(metadata.Export, out context);
                else _local.TryGetValue(metadata, out context);

                return context;
            }
        }
 public IImportInterceptor CreateInterceptor(ExportMetadata export)
 {
     Contract.Requires<ArgumentNullException>(export != null, "export");
     return null;
 }
 public ExportFactoryHelper([NotNull] IContainer container, [NotNull] ExportMetadata buildMetadata, 
     [NotNull] object metadataObject, [CanBeNull] InterceptorCallback interceptor,
     [NotNull] IResolverExtension[] extensions)
 {
     _container = container;
     _buildMetadata = buildMetadata;
     _metadataObject = metadataObject;
     _interceptor = interceptor;
     _extensions = extensions;
 }
        public ProxyGenerator Generate(ExportMetadata metadata, ImportMetadata[] imports, out IImportInterceptor interceptor)
        {
            interceptor = null;

            return GenericGenerator;
        }
        /// <summary>
        ///     The add.
        /// </summary>
        /// <param name="context">
        ///     The context.
        /// </param>
        /// <param name="metadata">
        ///     The metadata.
        /// </param>
        /// <param name="shareLifetime">
        ///     The share lifetime.
        /// </param>
        /// <exception cref="NotImplementedException">
        /// </exception>
        public void Add(ILifetimeContext context, ExportMetadata metadata, bool shareLifetime)
        {
            Contract.Requires<ArgumentNullException>(context != null, "context");
            Contract.Requires<ArgumentNullException>(metadata != null, "metadata");

            throw new NotImplementedException();
        }
        /// <summary>
        ///     The get context.
        /// </summary>
        /// <param name="metadata">
        ///     The metadata.
        /// </param>
        /// <returns>
        ///     The <see cref="ILifetimeContext" />.
        /// </returns>
        /// <exception cref="NotImplementedException">
        /// </exception>
        public ILifetimeContext GetContext(ExportMetadata metadata)
        {
            Contract.Requires<ArgumentNullException>(metadata != null, "metadata");

            throw new NotImplementedException();
        }
        /// <summary>
        ///     The build up.
        /// </summary>
        /// <param name="data">
        ///     The data.
        /// </param>
        /// <param name="errorTracer"></param>
        /// <param name="parameters"></param>
        /// <returns>
        ///     The <see cref="object" />.
        /// </returns>
        /// <exception cref="NotImplementedException">
        /// </exception>
        public object BuildUp(ExportMetadata data, ErrorTracer errorTracer, params BuildParameter[] parameters)
        {
            Contract.Requires<ArgumentNullException>(data != null, "data");
            Contract.Requires<ArgumentNullException>(errorTracer != null, "errorTracer");

            throw new NotImplementedException();
        }