コード例 #1
0
            private int VerifyPartCreator(PartCreator <IId> creator)
            {
                var val1 = creator.CreatePart();
                var val2 = creator.CreatePart();

                Assert.AreNotEqual(val1.ExportedValue, val2.ExportedValue, "Values should not be the same");
                Assert.AreNotEqual(val1.ExportedValue.Id, val2.ExportedValue.Id, "Value Ids should not be the same");

                Assert.IsTrue(val1.ExportedValue.Id >= 0, "Id should be positive");

                val1.Dispose();

                Assert.IsTrue(val1.ExportedValue.Id < 0, "Disposal of the value should set the id to negative");

                return(creator.CreatePart().ExportedValue.Id);
            }
コード例 #2
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value != null)
            {
                PartCreator <IShape, IShapeMetadata> partCreator = value as PartCreator <IShape, IShapeMetadata>;

                if (partCreator != null)
                {
                    return(partCreator.CreatePart().ExportedValue);
                }

                throw new ArgumentOutOfRangeException(string.Format(CultureInfo.CurrentCulture, "value is {0}", value.GetType().FullName));
            }

            throw new ArgumentNullException("value");
        }
コード例 #3
0
ファイル: SpaceObject.cs プロジェクト: ibratoev/MEF.NET35
 public SpaceObjectBindingHelper(PartCreator<SpaceObject, ISpaceObjectMetadata> creator)
 {
     Creator = creator;
     SpaceObject = Creator.CreatePart().ExportedValue;
 }