Ejemplo n.º 1
0
        private static void MakeContractProperty(this PropertySchema property, string baseId)
        {
            property.BaseId = baseId;
            property.SetUsageExtensionPoint();

            property.SetLocks(Locks.Delete);
        }
Ejemplo n.º 2
0
        private static void MakeVariableProperty(this PropertySchema property)
        {
            property.SetLocks(Locks.None);

            property.BaseId = string.Empty;
            property.SetUsageGeneral();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Creates a copy of the given property as a <see cref="PropertyUsages.ExtensionContract"/> property.
        /// </summary>
        public static PropertySchema CloneAsExtensionContractProperty(this PropertySchema source, PatternElementSchema owner)
        {
            Guard.NotNull(() => source, source);
            Guard.NotNull(() => owner, owner);

            PropertySchema newProperty = null;

            owner.Store.TransactionManager.DoWithinTransaction(() =>
            {
                newProperty = owner.Store.ElementFactory.CreateElement <PropertySchema>()
                              .With(p =>
                {
                    p.BaseId                = source.BaseId;
                    p.Category              = source.Category;
                    p.RawDefaultValue       = source.RawDefaultValue;
                    p.Description           = source.Description;
                    p.DisplayName           = source.DisplayName;
                    p.EditorTypeName        = source.EditorTypeName;
                    p.IsCustomizable        = source.IsCustomizable;
                    p.IsReadOnly            = source.IsReadOnly;
                    p.IsSystem              = source.IsSystem;
                    p.IsVisible             = source.IsVisible;
                    p.Name                  = source.Name;
                    p.Type                  = source.Type;
                    p.TypeConverterTypeName = source.TypeConverterTypeName;
                    p.RawValidationRules    = source.RawValidationRules;
                    p.EnsurePolicyAndDefaultSettings();
                });
            });

            // Copy customization settings
            foreach (var srcSetting in source.Policy.Settings)
            {
                var setting = newProperty.Policy.Settings.First(s => s.PropertyId == srcSetting.PropertyId);
                setting.Value = srcSetting.Value;
                if (!setting.Value)
                {
                    setting.Disable();
                }
            }

            // Apply Tailoring customization rules
            if (source.IsCustomizable == CustomizationState.False ||
                (source.IsCustomizable == CustomizationState.Inherited && source.GetAncestorCustomizationState() == CustomizationState.False))
            {
                newProperty.DisableCustomization();
            }

            // Convert to a contract property
            newProperty.MakeContractProperty(source.Id.ToString());

            return(newProperty);
        }
Ejemplo n.º 4
0
		private static void WritePropertiesAsElements(DslModeling::SerializationContext serializationContext, PropertySchema element, global::System.Xml.XmlWriter writer)
		{
			// RawDefaultValue
			if (!serializationContext.Result.Failed)
			{
				global::System.String propValue = element.RawDefaultValue;
				if (!serializationContext.Result.Failed)
				{
					if (!string.IsNullOrEmpty(propValue))
					PatternModelSerializationHelper.Instance.WriteElementString(serializationContext, element, writer, "defaultValue", propValue);
	
				}
			}
			// RawValidationRules
			if (!serializationContext.Result.Failed)
			{
				global::System.String propValue = element.RawValidationRules;
				if (!serializationContext.Result.Failed)
				{
					if (!string.IsNullOrEmpty(propValue))
					PatternModelSerializationHelper.Instance.WriteElementString(serializationContext, element, writer, "validationRules", propValue);
	
				}
			}
			// RawValueProvider
			if (!serializationContext.Result.Failed)
			{
				global::System.String propValue = element.RawValueProvider;
				if (!serializationContext.Result.Failed)
				{
					if (!string.IsNullOrEmpty(propValue))
					PatternModelSerializationHelper.Instance.WriteElementString(serializationContext, element, writer, "valueProvider", propValue);
	
				}
			}
		} 
Ejemplo n.º 5
0
		private static void ReadPropertiesFromElements(DslModeling::SerializationContext serializationContext, PropertySchema element, global::System.Xml.XmlReader reader)
		{
			while (!serializationContext.Result.Failed && !reader.EOF && reader.NodeType == global::System.Xml.XmlNodeType.Element)
			{
				switch (reader.LocalName)
				{
					case "defaultValue":	// RawDefaultValue
						if (reader.IsEmptyElement)
						{	// No serialized value, must be default one.
							DslModeling::SerializationUtilities.Skip(reader);  // Skip this tag.
						}
						else
						{
							string strRawDefaultValue = PatternModelSerializationHelper.Instance.ReadElementContentAsString(serializationContext, element, reader);
							global::System.String valueOfRawDefaultValue;
							if (DslModeling::SerializationUtilities.TryGetValue<global::System.String>(serializationContext, strRawDefaultValue, out valueOfRawDefaultValue))
							{
								// Non-public setter, use DomainPropertyInfo method.
								DslModeling::DomainPropertyInfo propInfo = element.Partition.DomainDataDirectory.GetDomainProperty (PropertySchema.RawDefaultValueDomainPropertyId);
								global::System.Diagnostics.Debug.Assert (propInfo != null, "Cannot get DomainPropertyInfo for PropertySchema.RawDefaultValue!");
								propInfo.SetValue(element, valueOfRawDefaultValue);
							}
							else
							{	// Invalid property value, ignored.
								PatternModelSerializationBehaviorSerializationMessages.IgnoredPropertyValue(serializationContext, reader, "defaultValue", typeof(global::System.String), strRawDefaultValue);
							}
	
							DslModeling::SerializationUtilities.SkipToNextElement(reader);
						}
						break;
					case "validationRules":	// RawValidationRules
						if (reader.IsEmptyElement)
						{	// No serialized value, must be default one.
							DslModeling::SerializationUtilities.Skip(reader);  // Skip this tag.
						}
						else
						{
							string strRawValidationRules = PatternModelSerializationHelper.Instance.ReadElementContentAsString(serializationContext, element, reader);
							global::System.String valueOfRawValidationRules;
							if (DslModeling::SerializationUtilities.TryGetValue<global::System.String>(serializationContext, strRawValidationRules, out valueOfRawValidationRules))
							{
								element.RawValidationRules = valueOfRawValidationRules;
							}
							else
							{	// Invalid property value, ignored.
								PatternModelSerializationBehaviorSerializationMessages.IgnoredPropertyValue(serializationContext, reader, "validationRules", typeof(global::System.String), strRawValidationRules);
							}
	
							DslModeling::SerializationUtilities.SkipToNextElement(reader);
						}
						break;
					case "valueProvider":	// RawValueProvider
						if (reader.IsEmptyElement)
						{	// No serialized value, must be default one.
							DslModeling::SerializationUtilities.Skip(reader);  // Skip this tag.
						}
						else
						{
							string strRawValueProvider = PatternModelSerializationHelper.Instance.ReadElementContentAsString(serializationContext, element, reader);
							global::System.String valueOfRawValueProvider;
							if (DslModeling::SerializationUtilities.TryGetValue<global::System.String>(serializationContext, strRawValueProvider, out valueOfRawValueProvider))
							{
								element.RawValueProvider = valueOfRawValueProvider;
							}
							else
							{	// Invalid property value, ignored.
								PatternModelSerializationBehaviorSerializationMessages.IgnoredPropertyValue(serializationContext, reader, "valueProvider", typeof(global::System.String), strRawValueProvider);
							}
	
							DslModeling::SerializationUtilities.SkipToNextElement(reader);
						}
						break;
					default:
						return;  // Don't know this element.
				}
			}
		}
Ejemplo n.º 6
0
 /// <summary>
 /// Resets the property usage to General
 /// </summary>
 public static void SetUsageGeneral(this PropertySchema property)
 {
     property.PropertyUsage = Runtime.PropertyUsages.General;
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Sets the property usage to ExtensionContract
 /// </summary>
 public static void SetUsageExtensionPoint(this PropertySchema property)
 {
     property.PropertyUsage |= Runtime.PropertyUsages.ExtensionContract;
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Determines if the Property usage is ExtensionContract
 /// </summary>
 public static bool IsUsageExtensionPoint(this PropertySchema property)
 {
     return((property.PropertyUsage & Runtime.PropertyUsages.ExtensionContract) == Runtime.PropertyUsages.ExtensionContract);
 }