/// <summary> /// Adds the provided extension point to the given pattern. /// </summary> internal static void AddProvidedExtensionPoint(this PatternSchema product, IExtensionPointSchema extensionPoint) { Guard.NotNull(() => product, product); product.ProvidedExtensionPoints.Add( product.Store.ElementFactory.CreateElement <ProvidedExtensionPointSchema>() .With(ext => ext.ExtensionPointId = extensionPoint.RequiredExtensionPointId)); }
public void InitializeContext() { var uriService = Mock.Of <IUriReferenceService>( u => u.ResolveUri <IInstanceBase>(It.IsAny <Uri>()) == Mock.Of <IProduct>(p => p.ToolkitInfo.Identifier == "ToolkitId")); var serviceProvider = Mock.Get(this.store.ServiceProvider); serviceProvider.Setup(s => s.GetService(typeof(IPatternManager))).Returns( Mock.Of <IPatternManager>(p => p.InstalledToolkits == new List <IInstalledToolkitInfo>())); ExtensionPointSchema hosted = null; this.store.TransactionManager.DoWithinTransaction(() => { var patternModel = this.store.ElementFactory.CreateElement <PatternModelSchema>(); var patternSchema = patternModel.CreatePatternSchema() as PatternSchema; patternSchema.PatternLink = "patternmanager://foo"; patternSchema.UriService = uriService; var view = patternSchema.Create <ViewSchema>(); view.Name = "View1"; this.extensionPointSchema = view.Create <ExtensionPointSchema>(); this.extensionPointSchema.Name = "ep1"; hosted = view.Create <ExtensionPointSchema>(); hosted.Name = "hostedExtensionPoint"; var prop1 = hosted.Create <PropertySchema>(); prop1.Name = "PartiallyCustomizable"; prop1.Type = "System.String"; prop1.IsCustomizable = CustomizationState.True; prop1.EnsurePolicyAndDefaultSettings(); prop1.Policy.Settings[0].Value = false; var prop2 = hosted.Create <PropertySchema>(); prop2.Name = "FullyCustomizable"; prop2.Type = "System.String"; prop2.IsCustomizable = CustomizationState.False; prop2.EnsurePolicyAndDefaultSettings(); }); this.hostedExtensionPoint = hosted as IExtensionPointSchema; this.userMessageService = new Mock <IUserMessageService>(); var defaultDescriptor = TypeDescriptor.CreateProperty(typeof(ExtensionPointSchema), Reflector <ExtensionPointSchema> .GetPropertyName(e => e.RepresentedExtensionPointId), typeof(string), null); this.descriptor = new HostedExtensionPointPropertyDescriptor( defaultDescriptor, this.extensionPointSchema, this.userMessageService.Object); }
private static StandardValue CreateStandardValue(IExtensionPointSchema extensionPoint) { var descriptionAtt = TypeDescriptor.GetAttributes(extensionPoint) .OfType<DescriptionAttribute>() .Select(att => att.Description) .FirstOrDefault(); descriptionAtt = descriptionAtt ?? string.Empty; var displayNameAtt = TypeDescriptor.GetAttributes(extensionPoint) .OfType<DisplayNameAttribute>() .Select(att => att.DisplayName) .FirstOrDefault(); displayNameAtt = displayNameAtt ?? TypeDescriptor.GetConverter(extensionPoint).ConvertToString(extensionPoint); return new StandardValue(displayNameAtt, extensionPoint, descriptionAtt); }
private static StandardValue CreateStandardValue(IExtensionPointSchema extensionPoint) { var descriptionAtt = TypeDescriptor.GetAttributes(extensionPoint) .OfType <DescriptionAttribute>() .Select(att => att.Description) .FirstOrDefault(); descriptionAtt = descriptionAtt ?? string.Empty; var displayNameAtt = TypeDescriptor.GetAttributes(extensionPoint) .OfType <DisplayNameAttribute>() .Select(att => att.DisplayName) .FirstOrDefault(); displayNameAtt = displayNameAtt ?? TypeDescriptor.GetConverter(extensionPoint).ConvertToString(extensionPoint); return(new StandardValue(displayNameAtt, extensionPoint, descriptionAtt)); }
public void InitializeContext() { var uriService = Mock.Of<IUriReferenceService>( u => u.ResolveUri<IInstanceBase>(It.IsAny<Uri>()) == Mock.Of<IProduct>(p => p.ToolkitInfo.Identifier == "ToolkitId")); var serviceProvider = Mock.Get(this.store.ServiceProvider); serviceProvider.Setup(s => s.GetService(typeof(IPatternManager))).Returns( Mock.Of<IPatternManager>(p => p.InstalledToolkits == new List<IInstalledToolkitInfo>())); ExtensionPointSchema hosted = null; this.store.TransactionManager.DoWithinTransaction(() => { var patternModel = this.store.ElementFactory.CreateElement<PatternModelSchema>(); var patternSchema = patternModel.CreatePatternSchema() as PatternSchema; patternSchema.PatternLink = "patternmanager://foo"; patternSchema.UriService = uriService; var view = patternSchema.Create<ViewSchema>(); view.Name = "View1"; this.extensionPointSchema = view.Create<ExtensionPointSchema>(); this.extensionPointSchema.Name = "ep1"; hosted = view.Create<ExtensionPointSchema>(); hosted.Name = "hostedExtensionPoint"; var prop1 = hosted.Create<PropertySchema>(); prop1.Name = "PartiallyCustomizable"; prop1.Type = "System.String"; prop1.IsCustomizable = CustomizationState.True; prop1.EnsurePolicyAndDefaultSettings(); prop1.Policy.Settings[0].Value = false; var prop2 = hosted.Create<PropertySchema>(); prop2.Name = "FullyCustomizable"; prop2.Type = "System.String"; prop2.IsCustomizable = CustomizationState.False; prop2.EnsurePolicyAndDefaultSettings(); }); this.hostedExtensionPoint = hosted as IExtensionPointSchema; this.userMessageService = new Mock<IUserMessageService>(); var defaultDescriptor = TypeDescriptor.CreateProperty(typeof(ExtensionPointSchema), Reflector<ExtensionPointSchema>.GetPropertyName(e => e.RepresentedExtensionPointId), typeof(string), null); this.descriptor = new HostedExtensionPointPropertyDescriptor( defaultDescriptor, this.extensionPointSchema, this.userMessageService.Object); }
/// <summary> /// Adds the contract properties from the given extension point to the pattern. /// </summary> internal static void CopyProvidedContractProperties(this PatternSchema product, IExtensionPointSchema extensionPoint) { Guard.NotNull(() => product, product); Guard.NotNull(() => extensionPoint, extensionPoint); foreach (var property in extensionPoint.Properties) { if (!product.Properties.Any( p => p.Name.Equals(property.Name, StringComparison.OrdinalIgnoreCase) && p.Type.Equals(property.Type, StringComparison.OrdinalIgnoreCase))) { var prop = property as PropertySchema; product.Properties.Add(prop.CloneAsExtensionContractProperty(product)); } } }
/// <summary> /// Adds the provided extension point to the given pattern. /// </summary> internal static void AddProvidedExtensionPoint(this PatternSchema product, IExtensionPointSchema extensionPoint) { Guard.NotNull(() => product, product); product.ProvidedExtensionPoints.Add( product.Store.ElementFactory.CreateElement<ProvidedExtensionPointSchema>() .With(ext => ext.ExtensionPointId = extensionPoint.RequiredExtensionPointId)); }
/// <summary> /// Copies the properties from given source extension point to the given target extension point. /// </summary> internal static void CopyHostedContractProperties(this ExtensionPointSchema targetExtensionPoint, IExtensionPointSchema sourceExtensionPoint) { Guard.NotNull(() => targetExtensionPoint, targetExtensionPoint); Guard.NotNull(() => sourceExtensionPoint, sourceExtensionPoint); foreach (var property in sourceExtensionPoint.Properties) { var prop = property as PropertySchema; targetExtensionPoint.Properties.Add(prop.CloneAsExtensionContractProperty(targetExtensionPoint)); } }