Exemplo n.º 1
0
        /// <summary>
        ///     Helper method to update the DefaultableValue if and only if the value has changed
        /// </summary>
        /// <param name="existingValue">
        ///     existing value of attribute (StringOrNone.NoneValue indicates attribute
        ///     currently does not exist)
        /// </param>
        /// <param name="newValue">
        ///     new value of attribute passed into setter (null indicates user did not select
        ///     anything on the drop-down and so no setting should take place, StringOrNone.NoneValue indicates user
        ///     selected '(None)' on the drop-down and so attribute should be removed if present)
        /// </param>
        /// <param name="defaultableValueToUpdate"></param>
        internal static void UpdateDefaultableValueIfValuesDiffer(
            StringOrNone existingValue, StringOrNone newValue,
            DefaultableValue <StringOrNone> defaultableValueToUpdate)
        {
            if (null == newValue)
            {
                // user exited drop-down without selecting anything
                return;
            }

            if (existingValue.Equals(newValue))
            {
                // no change in value - so just return
                return;
            }
            else
            {
                // existingValue and valueToSet are different - so update the DefaultableValue
                // if newValue is NoneValue then set valueToSet to null which will remove the attribute
                // otherwise use newValue as is
                var valueToSet = (StringOrNone.NoneValue.Equals(newValue) ? null : newValue);
                var cmd        =
                    new UpdateDefaultableValueCommand <StringOrNone>(defaultableValueToUpdate, valueToSet);
                var cpc = PropertyWindowViewModelHelper.GetCommandProcessorContext();
                CommandProcessor.InvokeSingleCommand(cpc, cmd);
            }
        }
 /// <summary>
 ///     Sets facets on the property being created by the passed in command.
 /// </summary>
 /// <param name="prereq">Must be non-null command creating the conceptual property</param>
 /// <param name="theDefault">Optional facet</param>
 /// <param name="concurrencyMode">Optional facet</param>
 /// <param name="getterAccessModifier">Optional facet</param>
 /// <param name="setterAccessModifier">Optional facet</param>
 internal SetConceptualPropertyFacetsCommand(
     CreatePropertyCommand prereq, StringOrNone theDefault, string concurrencyMode, string getterAccessModifier,
     string setterAccessModifier, StringOrPrimitive <UInt32> maxLength, BoolOrNone fixedLength, StringOrPrimitive <UInt32> precision,
     StringOrPrimitive <UInt32> scale, BoolOrNone unicode, StringOrNone collation)
     : base(prereq, theDefault, maxLength, fixedLength, precision, scale, unicode, collation, concurrencyMode)
 {
     _getterAccessModifier = getterAccessModifier;
     _setterAccessModifier = setterAccessModifier;
 }
 /// <summary>
 ///     Sets facets on the property being created by the passed in command.
 /// </summary>
 /// <param name="prereq">Must be non-null command creating the conceptual property</param>
 /// <param name="theDefault">Optional facet</param>
 /// <param name="concurrencyMode">Optional facet</param>
 /// <param name="getterAccessModifier">Optional facet</param>
 /// <param name="setterAccessModifier">Optional facet</param>
 internal SetConceptualPropertyFacetsCommand(
     CreatePropertyCommand prereq, StringOrNone theDefault, string concurrencyMode, string getterAccessModifier,
     string setterAccessModifier, StringOrPrimitive<UInt32> maxLength, BoolOrNone fixedLength, StringOrPrimitive<UInt32> precision,
     StringOrPrimitive<UInt32> scale, BoolOrNone unicode, StringOrNone collation)
     : base(prereq, theDefault, maxLength, fixedLength, precision, scale, unicode, collation, concurrencyMode)
 {
     _getterAccessModifier = getterAccessModifier;
     _setterAccessModifier = setterAccessModifier;
 }
        /// <summary>
        ///     Sets facets on the passed in property.
        /// </summary>
        /// <param name="property">Must be a non-null storage property</param>
        /// <param name="theDefault">Optional facet</param>
        /// <param name="maxLength">Optional facet</param>
        /// <param name="fixedLength">Optional facet</param>
        /// <param name="precision">Optional facet</param>
        /// <param name="scale">Optional facet</param>
        /// <param name="unicode">Optional facet</param>
        /// <param name="collation">Optional facet</param>
        /// <param name="concurrencyMode">Optional facet</param>
        internal SetPropertyFacetsCommand(
            Property property, StringOrNone theDefault,
            StringOrPrimitive<UInt32> maxLength, BoolOrNone fixedLength, StringOrPrimitive<UInt32> precision,
            StringOrPrimitive<UInt32> scale, BoolOrNone unicode, StringOrNone collation, string concurrencyMode)
        {
            CommandValidation.ValidateProperty(property);

            _property = property;
            _theDefault = theDefault;
            _maxLength = maxLength;
            _fixedLength = fixedLength;
            _precision = precision;
            _scale = scale;
            _unicode = unicode;
            _collation = collation;
            _concurrencyMode = concurrencyMode;
        }
Exemplo n.º 5
0
        /// <summary>
        ///     Sets facets on the passed in property.
        /// </summary>
        /// <param name="property">Must be a non-null storage property</param>
        /// <param name="theDefault">Optional facet</param>
        /// <param name="maxLength">Optional facet</param>
        /// <param name="fixedLength">Optional facet</param>
        /// <param name="precision">Optional facet</param>
        /// <param name="scale">Optional facet</param>
        /// <param name="unicode">Optional facet</param>
        /// <param name="collation">Optional facet</param>
        /// <param name="concurrencyMode">Optional facet</param>
        internal SetPropertyFacetsCommand(
            Property property, StringOrNone theDefault,
            StringOrPrimitive <UInt32> maxLength, BoolOrNone fixedLength, StringOrPrimitive <UInt32> precision,
            StringOrPrimitive <UInt32> scale, BoolOrNone unicode, StringOrNone collation, string concurrencyMode)
        {
            CommandValidation.ValidateProperty(property);

            _property        = property;
            _theDefault      = theDefault;
            _maxLength       = maxLength;
            _fixedLength     = fixedLength;
            _precision       = precision;
            _scale           = scale;
            _unicode         = unicode;
            _collation       = collation;
            _concurrencyMode = concurrencyMode;
        }
        /// <summary>
        ///     Sets facets on the property being created by the passed in command.
        /// </summary>
        /// <param name="prereq">Must be non-null command creating the storage property</param>
        /// <param name="theDefault">Optional facet</param>
        /// <param name="maxLength">Optional facet</param>
        /// <param name="fixedLength">Optional facet</param>
        /// <param name="precision">Optional facet</param>
        /// <param name="scale">Optional facet</param>
        /// <param name="unicode">Optional facet</param>
        /// <param name="collation">Optional facet</param>
        /// <param name="concurrencyMode">Optional facet</param>
        internal SetPropertyFacetsCommand(
            CreatePropertyCommand prereq, StringOrNone theDefault,
            StringOrPrimitive<UInt32> maxLength, BoolOrNone fixedLength, StringOrPrimitive<UInt32> precision,
            StringOrPrimitive<UInt32> scale, BoolOrNone unicode, StringOrNone collation, string concurrencyMode)
        {
            ValidatePrereqCommand(prereq);

            _theDefault = theDefault;
            _maxLength = maxLength;
            _fixedLength = fixedLength;
            _precision = precision;
            _scale = scale;
            _unicode = unicode;
            _collation = collation;
            _concurrencyMode = concurrencyMode;

            AddPreReqCommand(prereq);
        }
        /// <summary>
        ///     Creates a new property in the passed in storage entity and optionally sets additional
        ///     facets on the property.
        ///     NOTE: If the cpc already has an active transaction, these changes will be in that transaction
        ///     and the caller of this helper method must commit it to see these changes commited.
        /// </summary>
        /// <param name="cpc"></param>
        /// <param name="name">The name of the property</param>
        /// <param name="entityType">Must be a storage entity</param>
        /// <param name="type">The type to use for this property (cannot be empty)</param>
        /// <param name="nullable">Flag whether the property is nullable or not</param>
        /// <param name="theDefault">Optional: the default value for this property</param>
        /// <param name="maxLength">Optional facet</param>
        /// <param name="fixedLength">Optional facet</param>
        /// <param name="precision">Optional facet</param>
        /// <param name="scale">Optional facet</param>
        /// <param name="unicode">Optional facet</param>
        /// <param name="collation">Optional facet</param>
        /// <param name="concurrencyMode">Optional: the concurrency mode for this property</param>
        /// <returns>The new Property</returns>
        internal static Property CreateStorageProperty(
            CommandProcessorContext cpc, string name, StorageEntityType entityType,
            string type, bool?nullable, StringOrNone theDefault, StringOrPrimitive <UInt32> maxLength, BoolOrNone fixedLength,
            StringOrPrimitive <UInt32> precision,
            StringOrPrimitive <UInt32> scale, BoolOrNone unicode, StringOrNone collation, string concurrencyMode)
        {
            CommandValidation.ValidateStorageEntityType(entityType);

            var cpcd = new CreatePropertyCommand(name, entityType, type, nullable);
            var ssp  = new SetPropertyFacetsCommand(
                cpcd, theDefault, maxLength, fixedLength, precision, scale, unicode, collation, concurrencyMode);

            var cp = new CommandProcessor(cpc, cpcd, ssp);

            cp.Invoke();

            return(cpcd.CreatedProperty);
        }
Exemplo n.º 8
0
        /// <summary>
        ///     Sets facets on the property being created by the passed in command.
        /// </summary>
        /// <param name="prereq">Must be non-null command creating the storage property</param>
        /// <param name="theDefault">Optional facet</param>
        /// <param name="maxLength">Optional facet</param>
        /// <param name="fixedLength">Optional facet</param>
        /// <param name="precision">Optional facet</param>
        /// <param name="scale">Optional facet</param>
        /// <param name="unicode">Optional facet</param>
        /// <param name="collation">Optional facet</param>
        /// <param name="concurrencyMode">Optional facet</param>
        internal SetPropertyFacetsCommand(
            CreateComplexTypePropertyCommand prereq, StringOrNone theDefault,
            StringOrPrimitive <UInt32> maxLength, BoolOrNone fixedLength, StringOrPrimitive <UInt32> precision,
            StringOrPrimitive <UInt32> scale, BoolOrNone unicode, StringOrNone collation, string concurrencyMode)
        {
            ValidatePrereqCommand(prereq);

            _theDefault      = theDefault;
            _maxLength       = maxLength;
            _fixedLength     = fixedLength;
            _precision       = precision;
            _scale           = scale;
            _unicode         = unicode;
            _collation       = collation;
            _concurrencyMode = concurrencyMode;

            AddPreReqCommand(prereq);
        }
Exemplo n.º 9
0
        internal PropertyClipboardFormat(Property property)
            : base(property)
        {
            var complexProperty = property as ComplexConceptualProperty;

            if (complexProperty != null)
            {
                _propertyType      = complexProperty.ComplexType.RefName;
                _isComplexProperty = true;
            }
            else
            {
                _propertyType      = property.TypeName;
                _isComplexProperty = false;
            }
            _isNullable      = (property.Nullable.Value.StringValue == null ? property.Nullable.Value.PrimitiveValue : (bool?)null);
            _isKeyProperty   = property.IsKeyProperty;
            _defaultValue    = property.DefaultValue.Value;
            _concurrencyMode = property.ConcurrencyMode.IsDefaulted ? null : property.ConcurrencyMode.Value;
            _maxLength       = property.MaxLength.IsDefaulted ? null : property.MaxLength.Value;
            _fixedLength     = property.FixedLength.GetAsNullableBool();
            _precision       = property.Precision.Value;
            _scale           = property.Scale.Value;
            _unicode         = property.Unicode.GetAsNullableBool();
            _collation       = property.Collation.Value;

            var conceptualProp = property as ConceptualProperty;

            if (conceptualProp != null)
            {
                _isConceptualProperty  = true;
                _storeGeneratedPattern = conceptualProp.StoreGeneratedPattern.IsDefaulted
                                             ? null
                                             : conceptualProp.StoreGeneratedPattern.Value;
            }
            else
            {
                _isConceptualProperty  = false;
                _storeGeneratedPattern = null;
            }
        }
        internal PropertyClipboardFormat(Property property)
            : base(property)
        {
            var complexProperty = property as ComplexConceptualProperty;
            if (complexProperty != null)
            {
                _propertyType = complexProperty.ComplexType.RefName;
                _isComplexProperty = true;
            }
            else
            {
                _propertyType = property.TypeName;
                _isComplexProperty = false;
            }
            _isNullable = (property.Nullable.Value.StringValue == null ? property.Nullable.Value.PrimitiveValue : (bool?)null);
            _isKeyProperty = property.IsKeyProperty;
            _defaultValue = property.DefaultValue.Value;
            _concurrencyMode = property.ConcurrencyMode.IsDefaulted ? null : property.ConcurrencyMode.Value;
            _maxLength = property.MaxLength.IsDefaulted ? null : property.MaxLength.Value;
            _fixedLength = property.FixedLength.GetAsNullableBool();
            _precision = property.Precision.Value;
            _scale = property.Scale.Value;
            _unicode = property.Unicode.GetAsNullableBool();
            _collation = property.Collation.Value;

            var conceptualProp = property as ConceptualProperty;
            if (conceptualProp != null)
            {
                _isConceptualProperty = true;
                _storeGeneratedPattern = conceptualProp.StoreGeneratedPattern.IsDefaulted
                                             ? null
                                             : conceptualProp.StoreGeneratedPattern.Value;
            }
            else
            {
                _isConceptualProperty = false;
                _storeGeneratedPattern = null;
            }
        }
        /// <summary>
        ///     Creates a new property in the passed in conceptual entity and optionally sets additional
        ///     facets on the property.
        ///     NOTE: If the cpc already has an active transaction, these changes will be in that transaction
        ///     and the caller of this helper method must commit it to see these changes commited.
        /// </summary>
        /// <param name="cpc"></param>
        /// <param name="name">The name of the property</param>
        /// <param name="entityType">Must be a conceptual entity</param>
        /// <param name="type">The type to use for this property (cannot be empty)</param>
        /// <param name="nullable">Flag whether the property is nullable or not</param>
        /// <param name="theDefault">Optional: the default value for this property</param>
        /// <param name="concurrencyMode">Optional: the concurrency mode for this property</param>
        /// <param name="getterAccessModifier">Optional: Get access modifier.</param>
        /// <param name="setterAccessModifier">Optional: Set access modifier.</param>
        /// <returns>The new Property</returns>
        internal static Property CreateConceptualProperty(
            CommandProcessorContext cpc, string name, ConceptualEntityType entityType,
            string type, bool?nullable, StringOrNone theDefault, string concurrencyMode, string getterAccessModifier,
            string setterAccessModifier,
            StringOrPrimitive <UInt32> maxLength, bool?fixedLength, StringOrPrimitive <UInt32> precision, StringOrPrimitive <UInt32> scale,
            bool?unicode, StringOrNone collation, string storeGeneratedPattern, InsertPropertyPosition insertPosition)
        {
            CommandValidation.ValidateConceptualEntityType(entityType);

            var cpcd = new CreatePropertyCommand(name, entityType, type, nullable, insertPosition);
            var scp  = new SetConceptualPropertyFacetsCommand(
                cpcd, theDefault, concurrencyMode, getterAccessModifier, setterAccessModifier,
                maxLength, DefaultableValueBoolOrNone.GetFromNullableBool(fixedLength), precision, scale,
                DefaultableValueBoolOrNone.GetFromNullableBool(unicode), collation);
            var scpac = new SetConceptualPropertyAnnotationsCommand(cpcd, storeGeneratedPattern);

            var cp = new CommandProcessor(cpc, cpcd, scp, scpac);

            cp.Invoke();

            return(cpcd.CreatedProperty);
        }
        /// <summary>
        ///     Creates a new property in the passed in storage entity and optionally sets additional
        ///     facets on the property.
        ///     NOTE: If the cpc already has an active transaction, these changes will be in that transaction
        ///     and the caller of this helper method must commit it to see these changes commited.
        /// </summary>
        /// <param name="cpc"></param>
        /// <param name="name">The name of the property</param>
        /// <param name="entityType">Must be a storage entity</param>
        /// <param name="type">The type to use for this property (cannot be empty)</param>
        /// <param name="nullable">Flag whether the property is nullable or not</param>
        /// <param name="theDefault">Optional: the default value for this property</param>
        /// <param name="maxLength">Optional facet</param>
        /// <param name="fixedLength">Optional facet</param>
        /// <param name="precision">Optional facet</param>
        /// <param name="scale">Optional facet</param>
        /// <param name="unicode">Optional facet</param>
        /// <param name="collation">Optional facet</param>
        /// <param name="concurrencyMode">Optional: the concurrency mode for this property</param>
        /// <returns>The new Property</returns>
        internal static Property CreateStorageProperty(
            CommandProcessorContext cpc, string name, StorageEntityType entityType,
            string type, bool? nullable, StringOrNone theDefault, StringOrPrimitive<UInt32> maxLength, BoolOrNone fixedLength,
            StringOrPrimitive<UInt32> precision,
            StringOrPrimitive<UInt32> scale, BoolOrNone unicode, StringOrNone collation, string concurrencyMode)
        {
            CommandValidation.ValidateStorageEntityType(entityType);

            var cpcd = new CreatePropertyCommand(name, entityType, type, nullable);
            var ssp = new SetPropertyFacetsCommand(
                cpcd, theDefault, maxLength, fixedLength, precision, scale, unicode, collation, concurrencyMode);

            var cp = new CommandProcessor(cpc, cpcd, ssp);
            cp.Invoke();

            return cpcd.CreatedProperty;
        }
        /// <summary>
        ///     Creates a new property in the passed in conceptual entity and optionally sets additional
        ///     facets on the property.
        ///     NOTE: If the cpc already has an active transaction, these changes will be in that transaction
        ///     and the caller of this helper method must commit it to see these changes commited.
        /// </summary>
        /// <param name="cpc"></param>
        /// <param name="name">The name of the property</param>
        /// <param name="entityType">Must be a conceptual entity</param>
        /// <param name="type">The type to use for this property (cannot be empty)</param>
        /// <param name="nullable">Flag whether the property is nullable or not</param>
        /// <param name="theDefault">Optional: the default value for this property</param>
        /// <param name="concurrencyMode">Optional: the concurrency mode for this property</param>
        /// <param name="getterAccessModifier">Optional: Get access modifier.</param>
        /// <param name="setterAccessModifier">Optional: Set access modifier.</param>
        /// <returns>The new Property</returns>
        internal static Property CreateConceptualProperty(
            CommandProcessorContext cpc, string name, ConceptualEntityType entityType,
            string type, bool? nullable, StringOrNone theDefault, string concurrencyMode, string getterAccessModifier,
            string setterAccessModifier,
            StringOrPrimitive<UInt32> maxLength, bool? fixedLength, StringOrPrimitive<UInt32> precision, StringOrPrimitive<UInt32> scale,
            bool? unicode, StringOrNone collation, string storeGeneratedPattern, InsertPropertyPosition insertPosition)
        {
            CommandValidation.ValidateConceptualEntityType(entityType);

            var cpcd = new CreatePropertyCommand(name, entityType, type, nullable, insertPosition);
            var scp = new SetConceptualPropertyFacetsCommand(
                cpcd, theDefault, concurrencyMode, getterAccessModifier, setterAccessModifier,
                maxLength, DefaultableValueBoolOrNone.GetFromNullableBool(fixedLength), precision, scale,
                DefaultableValueBoolOrNone.GetFromNullableBool(unicode), collation);
            var scpac = new SetConceptualPropertyAnnotationsCommand(cpcd, storeGeneratedPattern);

            var cp = new CommandProcessor(cpc, cpcd, scp, scpac);
            cp.Invoke();

            return cpcd.CreatedProperty;
        }