示例#1
0
        public override void Save(TextWriter writer, object value)
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }

            IPropertyStore pp = Adaptable.TryAdapt <IPropertyStore>(value);

            if (pp == null)
            {
                pp = Runtime.Properties.FromValue(value);
            }

            if (pp == null)
            {
                throw Failure.NotAdaptableTo("value", value, typeof(IPropertyStore));
            }

            using (PropertiesWriter pw = new PropertiesWriter(writer)) {
                pw.WriteProperties(pp);
            }
        }
示例#2
0
        protected virtual object BindParameterSubscription(ParameterInfo parameter,
                                                           IServiceProvider serviceProvider)
        {
            object value = null;

            Type requiredType = parameter.ParameterType;

            if (IsServiceBindableType(requiredType))
            {
                value = serviceProvider.GetService(requiredType);
            }

            if (value != null)
            {
                value = Adaptable.TryAdapt(value, requiredType, serviceProvider);
            }

            return(value);
        }