コード例 #1
0
        /// <exception cref="ArgumentNullException"><c>has</c> is null.</exception>
        public static IResourceDefinition ResourcesWithKey(this IHas has, object resourceKey)
        {
            if (has == null)
            {
                throw new ArgumentNullException("has");
            }
            if (resourceKey == null)
            {
                throw new ArgumentNullException("resourceKey");
            }

            var  resourceKeyAsType    = resourceKey as Type;
            bool isStrictRegistration = false;

            if (resourceKeyAsType != null && CodecRegistration.IsStrictRegistration(resourceKeyAsType))
            {
                resourceKey          = CodecRegistration.GetStrictType(resourceKeyAsType);
                isStrictRegistration = true;
            }
            var registration = new ResourceModel
            {
                ResourceKey          = resourceKey,
                IsStrictRegistration = isStrictRegistration
            };

            var hasBuilder = (IFluentTarget)has;

            hasBuilder.Repository.ResourceRegistrations.Add(registration);
            return(new ResourceDefinition(hasBuilder.TypeSystem, registration));
        }
コード例 #2
0
        static ResourceModel RegisterResourceModel(IFluentTarget has, object resourceKey)
        {
            var  resourceKeyAsType    = resourceKey as Type;
            bool isStrictRegistration = false;

            if (resourceKeyAsType != null && CodecRegistration.IsStrictRegistration(resourceKeyAsType))
            {
                resourceKey          = CodecRegistration.GetStrictType(resourceKeyAsType);
                isStrictRegistration = true;
            }
            var registration = new ResourceModel
            {
                ResourceKey          = resourceKey,
                IsStrictRegistration = isStrictRegistration
            };

            has.Repository.ResourceRegistrations.Add(registration);
            return(registration);
        }