Exemple #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);
            }
        }
Exemple #2
0
        protected override void PreParse()
        {
            Debug.Assert(State != EFElementState.Parsed, "this object should not already be in the parsed state");

            ClearEFObject(_commandText);
            _commandText = null;

            ClearEFObject(_returnTypeAttr);
            _returnTypeAttr = null;
            ClearEFObject(_aggregateAttr);
            _aggregateAttr = null;
            ClearEFObject(_builtInAttr);
            _builtInAttr = null;
            ClearEFObject(_storeFunctionNameAttr);
            _storeFunctionNameAttr = null;
            ClearEFObject(_niladicFunctionAttr);
            _niladicFunctionAttr = null;
            ClearEFObject(_isComposableAttr);
            _isComposableAttr = null;
            ClearEFObject(_parameterTypeSemanticsAttr);
            _parameterTypeSemanticsAttr = null;
            ClearEFObject(_schemaAttr);
            _schemaAttr = null;
            ClearEFObject(_storeSchemaGenSchemaAttr);
            _storeSchemaGenSchemaAttr = null;
            ClearEFObject(_storeSchemaGenNameAttr);
            _storeSchemaGenNameAttr = null;

            ClearEFObjectCollection(_parameters);

            base.PreParse();
        }
        // helper method to return the runtime facet default for a Property type (either S- or C-side) and facet
        // (Note: this is different from defaultableValue.DefaultValue which returns what to show in the
        // Designer as the default - usually "(None)")
        private static T GetFacetDefault <T>(
            IDictionary <string, IDictionary <string, object> > propertyTypeToFacetsMap, string propertyType,
            DefaultableValue <T> defaultableValue) where T : class
        {
            if (string.IsNullOrWhiteSpace(propertyType))
            {
                // cannot return facet defaults if type is not defined
                return(null);
            }

            IDictionary <string, object> facetToDefaultMap;

            if (propertyTypeToFacetsMap.TryGetValue(propertyType, out facetToDefaultMap))
            {
                object facetDefaultAsObject;
                if (null != facetToDefaultMap &&
                    facetToDefaultMap.TryGetValue(defaultableValue.AttributeName, out facetDefaultAsObject))
                {
                    var facetDefault =
                        (null == facetDefaultAsObject ? null : defaultableValue.ConvertStringToValue(facetDefaultAsObject.ToString()));
                    return(facetDefault);
                }
            }

            return(null);
        }
Exemple #4
0
        protected override void PreParse()
        {
            Debug.Assert(State != EFElementState.Parsed, "this object should not already be in the parsed state");

            ClearEFObject(_valueAttr);
            _valueAttr = null;

            base.PreParse();
        }
        protected override void PreParse()
        {
            Debug.Assert(State != EFElementState.Parsed, "this object should not already be in the parsed state");

            ClearEFObject(_typeAttr);
            _typeAttr = null;

            base.PreParse();
        }
        protected override void PreParse()
        {
            Debug.Assert(State != EFElementState.Parsed, "this object should not already be in the parsed state");

            ClearEFObjectCollection(_properties);
            ClearEFObject(_typeAccessAttr);
            _typeAccessAttr = null;

            base.PreParse();
        }
Exemple #7
0
        protected override void PreParse()
        {
            Debug.Assert(State != EFElementState.Parsed, "this object should not already be in the parsed state");

            ClearEFObject(_manuallyRoutedAttr);
            _manuallyRoutedAttr = null;
            ClearEFObjectCollection(_connectorPoints);

            base.PreParse();
        }
        protected override void PreParse()
        {
            Debug.Assert(State != EFElementState.Parsed, "this object should not already be in the parsed state");

            ClearEntitySets();
            ClearEFObjectCollection(_functionImports);
            ClearEFObject(_typeAccessAttr);
            ClearEFObject(_lazyLoadingEnabledAttr);
            _lazyLoadingEnabledAttr = null;

            base.PreParse();
        }
Exemple #9
0
        protected override void PreParse()
        {
            Debug.Assert(State != EFElementState.Parsed, "this object should not already be in the parsed state");

            ClearEFObject(_defaultUnspecifiedMaps);
            _defaultUnspecifiedMaps = null;

            ClearEFObjectCollection(_aliases);
            ClearEFObjectCollection(_entityContainerMappings);

            base.PreParse();
        }
        protected override void InvokeInternal(CommandProcessorContext cpc)
        {
            // if the _value is null it means that we are removing underlying XAttribute so we don't validate that
            if (Value != null &&
                DefaultableValue.IsValidValue(Value) == false)
            {
                var msg = string.Format(CultureInfo.CurrentCulture, Resources.INVALID_FORMAT, Value);
                throw new CommandValidationFailedException(msg);
            }

            DefaultableValue.Value = Value;
        }
Exemple #11
0
        /// <summary>
        ///     Change the property type to an enum type.
        /// </summary>
        /// <param name="typeName"></param>
        public void ChangePropertyType(EnumType enumType)
        {
            Debug.Assert(enumType != null, "typeName parameter value is null");
            if (enumType != null)
            {
                ClearEFObject(_typeAttrForPrimitiveType);
                _typeAttrForPrimitiveType = null;

                EnumTypeAttribute.SetRefName(enumType);
                EnumTypeAttribute.Rebind();
            }
        }
Exemple #12
0
        protected override void PreParse()
        {
            Debug.Assert(State != EFElementState.Parsed, "this object should not already be in the parsed state");

            ClearEFObject(_typeAttrForPrimitiveType);
            _typeAttrForPrimitiveType = null;

            ClearEFObject(_typeAttrForEnumType);
            _typeAttrForEnumType = null;

            base.PreParse();
        }
        protected override void PreParse()
        {
            Debug.Assert(State != EFElementState.Parsed, "this object should not already be in the parsed state");

            ClearEFObject(_property);
            _property = null;

            ClearEFObject(_column);
            _column = null;

            base.PreParse();
        }
        /// <summary>
        ///     Change the property type to an enum type.
        /// </summary>
        /// <param name="typeName"></param>
        public void ChangePropertyType(EnumType enumType)
        {
            Debug.Assert(enumType != null, "typeName parameter value is null");
            if (enumType != null)
            {
                ClearEFObject(_typeAttrForPrimitiveType);
                _typeAttrForPrimitiveType = null;

                EnumTypeAttribute.SetRefName(enumType);
                EnumTypeAttribute.Rebind();
            }
        }
        protected override void PreParse()
        {
            Debug.Assert(State != EFElementState.Parsed, "this object should not already be in the parsed state");

            // clear this here instead of in base class, since we populate it here
            ClearEFObjectCollection(_entityContainers);
            ClearEFObjectCollection(_complexTypes);
            ClearEFObjectCollection(_usings);
            ClearEFObjectCollection(_enumTypes);
            ClearEFObject(_useStrongSpatialTypesAttr);
            _useStrongSpatialTypesAttr = null;

            base.PreParse();
        }
Exemple #16
0
        protected override void PreParse()
        {
            Debug.Assert(State != EFElementState.Parsed, "this object should not already be in the parsed state");

            ClearEFObject(_multiplicityAttr);
            _multiplicityAttr = null;
            ClearEFObject(_typeBinding);
            _typeBinding = null;
            ClearEFObject(_roleAttr);
            _roleAttr = null;
            ClearEFObject(_onDeteleAction);
            _onDeteleAction = null;

            base.PreParse();
        }
Exemple #17
0
        protected override void PreParse()
        {
            Debug.Assert(State != EFElementState.Parsed, "this object should not already be in the parsed state");

            ClearEFObject(_providerAttr);
            _providerAttr = null;

            ClearEFObject(_providerManifestTokenAttr);
            _providerManifestTokenAttr = null;

            // clear this here instead of in base class, since we populate it here
            ClearEFObjectCollection(_entityContainers);
            ClearEFObjectCollection(_functions);
            base.PreParse();
        }
Exemple #18
0
        protected override void PreParse()
        {
            Debug.Assert(State != EFElementState.Parsed, "this object should not already be in the parsed state");

            ClearEFObject(_typeName);
            _typeName = null;

            ClearEFObject(_isPartial);
            _isPartial = null;

            ClearEFObjectCollection(_scalarProperties);
            ClearEFObjectCollection(_complexProperties);
            ClearEFObjectCollection(_conditions);

            base.PreParse();
        }
Exemple #19
0
        protected override void PreParse()
        {
            Debug.Assert(State != EFElementState.Parsed, "this object should not already be in the parsed state");

            // don't clear this collection here; the derived classes do it
            //ClearEFObjectCollection(_entityContainers);
            ClearEFObjectCollection(_associations);
            ClearEFObjectCollection(_entityTypes);

            ClearEFObject(_aliasAttr);
            _aliasAttr = null;
            ClearEFObject(_namespaceAttr);
            _namespaceAttr = null;

            base.PreParse();
        }
Exemple #20
0
        protected override void PreParse()
        {
            Debug.Assert(State != EFElementState.Parsed, "this object should not already be in the parsed state");

            ClearEFObject(_cdmEntityContainer);
            _cdmEntityContainer = null;

            ClearEFObject(_storageEntityContainer);
            _storageEntityContainer = null;

            ClearEFObject(_generateUpdateViewsAttr);
            _generateUpdateViewsAttr = null;

            ClearEFObjectCollection(_entitySetMappings);
            ClearEFObjectCollection(_associationSetMappings);
            ClearEFObjectCollection(_functionImportMappings);
            base.PreParse();
        }
        protected override void PreParse()
        {
            Debug.Assert(State != EFElementState.Parsed, "this object should not already be in the parsed state");

            ClearEFObject(_entityTypeBinding);
            _entityTypeBinding = null;
            ClearEFObject(_pointXAttr);
            _pointXAttr = null;
            ClearEFObject(_pointYAttr);
            _pointYAttr = null;
            ClearEFObject(_widthAttr);
            _widthAttr = null;
            ClearEFObject(_isExpandedAttr);
            _isExpandedAttr = null;
            ClearEFObject(_fillColorAttr);
            _fillColorAttr = null;
            base.PreParse();
        }
Exemple #22
0
        protected override void PreParse()
        {
            Debug.Assert(State != EFElementState.Parsed, "this object should not already be in the parsed state");

            ClearEFObject(_returnTypeAsEntityType);
            _returnTypeAsEntityType = null;
            ClearEFObject(_returnTypeAsComplexType);
            _returnTypeAsComplexType = null;
            ClearEFObject(_returnTypeAsPrimitiveType);
            _returnTypeAsPrimitiveType = null;
            ClearEFObject(_entitySet);
            _entitySet = null;
            ClearEFObject(_methodAccessAttr);
            _methodAccessAttr = null;

            ClearEFObjectCollection(_parameters);

            base.PreParse();
        }
Exemple #23
0
        protected override void PreParse()
        {
            Debug.Assert(State != EFElementState.Parsed, "this object should not already be in the parsed state");

            ClearEFObject(_definingQuery);
            _definingQuery = null;

            ClearEFObject(_schemaAttr);
            _schemaAttr = null;
            ClearEFObject(_tableAttr);
            _tableAttr = null;
            ClearEFObject(_storeSchemaGenTypeAttr);
            _storeSchemaGenTypeAttr = null;
            ClearEFObject(_storeSchemaGenSchemaAttr);
            _storeSchemaGenSchemaAttr = null;
            ClearEFObject(_storeSchemaGenNameAttr);
            _storeSchemaGenNameAttr = null;

            base.PreParse();
        }
Exemple #24
0
        protected override void PreParse()
        {
            Debug.Assert(State != EFElementState.Parsed, "this object should not already be in the parsed state");

            ClearEFObjectCollection(_members);

            ClearEFObject(_typeAccessAttr);
            _typeAccessAttr = null;

            ClearEFObject(_isFlagAttr);
            _isFlagAttr = null;

            ClearEFObject(_underlyingTypeAttr);
            _underlyingTypeAttr = null;

            ClearEFObject(_externalTypeAttr);
            _externalTypeAttr = null;

            base.PreParse();
        }
Exemple #25
0
        protected override void PreParse()
        {
            Debug.Assert(State != EFElementState.Parsed, "this object should not already be in the parsed state");

            ClearEFObject(_id);
            _id = null;
            ClearEFObject(_zoomLevelAttr);
            _zoomLevelAttr = null;
            ClearEFObject(_showGridAttr);
            _showGridAttr = null;
            ClearEFObject(_snapToGridAttr);
            _snapToGridAttr = null;
            ClearEFObject(_displayTypeAttr);
            _displayTypeAttr = null;

            ClearEFObjectCollection(_entityTypeShapes);
            ClearEFObjectCollection(_associationConnectors);
            ClearEFObjectCollection(_inheritanceConnectors);

            base.PreParse();
        }
Exemple #26
0
 /// <summary>
 ///     Remove all facets except Nullable (i.e. the setting of Nullable remains as is).
 /// </summary>
 internal void RemoveAllFacetsExceptNullable()
 {
     if (null != DefaultValue)
     {
         DefaultValue.Delete();
         _defaultAttr = null;
     }
     if (null != MaxLength)
     {
         MaxLength.Delete();
         _maxLengthAttr = null;
     }
     if (null != FixedLength)
     {
         FixedLength.Delete();
         _fixedLengthAttr = null;
     }
     if (null != Precision)
     {
         Precision.Delete();
         _precisionAttr = null;
     }
     if (null != Scale)
     {
         Scale.Delete();
         _scaleAttr = null;
     }
     if (null != Unicode)
     {
         Unicode.Delete();
         _unicodeAttr = null;
     }
     if (null != Collation)
     {
         Collation.Delete();
         _collationAttr = null;
     }
 }
Exemple #27
0
        protected override void PreParse()
        {
            Debug.Assert(State != EFElementState.Parsed, "this object should not already be in the parsed state");

            ClearEFObject(_nullableAttr);
            _nullableAttr = null;

            ClearEFObject(_defaultAttr);
            _defaultAttr = null;

            ClearEFObject(_concurrencyModeAttr);
            _concurrencyModeAttr = null;

            ClearEFObject(_maxLengthAttr);
            _maxLengthAttr = null;

            ClearEFObject(_fixedLengthAttr);
            _fixedLengthAttr = null;

            ClearEFObject(_precisionAttr);
            _precisionAttr = null;

            ClearEFObject(_scaleAttr);
            _scaleAttr = null;

            ClearEFObject(_unicodeAttr);
            _unicodeAttr = null;

            ClearEFObject(_collationAttr);
            _collationAttr = null;

            ClearEFObject(_storeGeneratedPatternAttr);
            _storeGeneratedPatternAttr = null;

            base.PreParse();
        }
 internal UpdateEntityTypeTypeAccessCommand(DefaultableValue<string> typeAccess, string value)
 {
     _typeAccess = typeAccess;
     _newValue = value;
 }
Exemple #29
0
        protected override void PreParse()
        {
            Debug.Assert(State != EFElementState.Parsed, "this object should not already be in the parsed state");

            ClearEFObjectCollection(_members);

            ClearEFObject(_typeAccessAttr);
            _typeAccessAttr = null;

            ClearEFObject(_isFlagAttr);
            _isFlagAttr = null;

            ClearEFObject(_underlyingTypeAttr);
            _underlyingTypeAttr = null;

            ClearEFObject(_externalTypeAttr);
            _externalTypeAttr = null;

            base.PreParse();
        }
        // helper method which compares values and synchronizes the C-side facet to the S-side value if they differ
        private void SynchronizeFacet <T>(
            string sSidePropertyType, DefaultableValue <T> sSideDefaultableValue,
            string cSidePropertyType, DefaultableValue <T> cSideDefaultableValue) where T : class
        {
            if (null == sSidePropertyType)
            {
                Debug.Fail("sSidePropertyType cannot be null");
                return;
            }

            if (null == sSideDefaultableValue)
            {
                Debug.Fail("sSideDefaultableValue cannot be null");
                return;
            }

            if (null == cSidePropertyType)
            {
                Debug.Fail("cSidePropertyType cannot be null");
                return;
            }

            if (null == cSideDefaultableValue)
            {
                Debug.Fail("cSideDefaultableValue cannot be null");
                return;
            }

            if (false == ConceptualFacetExists(cSidePropertyType, cSideDefaultableValue.AttributeName))
            {
                // this facet does not apply to a C-side property of this type - so do not attempt to propagate the S-side value
                // (this can happen e.g. if an S-side property is mapped to a C-side property with an inconsistent type)
                return;
            }

            // get values that S- and C-side DefaultableValues will assume at runtime if they are absent
            // (Note: this is different from DefaultableValue.DefaultValue which returns what
            // to show in the Designer as the default - usually "(None)")
            var sSideDefaultableValueDefaultValue = GetStorageFacetDefault(sSidePropertyType, sSideDefaultableValue);

            var sSideValueToPropagate = sSideDefaultableValue.Value;
            var preExistingCSideValue = cSideDefaultableValue.Value;
            T   valueToSet;

            if (sSideDefaultableValue.IsDefaulted
                ||
                null == sSideValueToPropagate
                ||
                sSideValueToPropagate.Equals(sSideDefaultableValueDefaultValue))
            {
                // sometimes the default value for a facet on the C-side is the same as that for the same
                // facet on the S-side, but sometimes they are different. Here the S-side has been defaulted
                // so we need to do different things dependent on whether these default values are the same.
                var cSideDefaultableValueDefaultValue = GetConceptualFacetDefault(cSidePropertyType, cSideDefaultableValue);
                if ((null == sSideDefaultableValueDefaultValue && null == cSideDefaultableValueDefaultValue)
                    ||
                    (null != sSideDefaultableValueDefaultValue &&
                     sSideDefaultableValueDefaultValue.Equals(cSideDefaultableValueDefaultValue)))
                {
                    // default value for C-side facet is the same as the default value for the S-side facet
                    if (cSideDefaultableValue.IsDefaulted
                        ||
                        null == preExistingCSideValue
                        ||
                        preExistingCSideValue.Equals(cSideDefaultableValueDefaultValue))
                    {
                        // the attribute on both sides is either absent or explicitly set to the default value
                        // (note: the null case is when the default value itself is null)- so no need to update the C-side.
                        // This prevents "absent" on the S-side causing an update when the pre-existing C-side value is
                        // the default value and vice versa.
                        return;
                    }

                    // if absent on the S-side, set valueToSet to null which will cause the C-side attribute to be removed,
                    // otherwise use the S-side's explicit value.
                    valueToSet = (sSideDefaultableValue.IsDefaulted ? null : sSideValueToPropagate);
                }
                else if (sSideDefaultableValue.IsDefaulted &&
                         null == sSideDefaultableValueDefaultValue)
                {
                    // S-side is defaulted but we have no default value to propagate
                    Debug.Fail(
                        "S-side DefaultableValue is defaulted but default value of S-side DefaultableValue is null, so defaulting C-side DefaultableValue would cause it to assume different default value: "
                        + cSideDefaultableValueDefaultValue);
                    return;
                }
                else
                {
                    // default value for C-side facet is different from the default value for the S-side facet
                    // so need to explictly set the C-side. Only reason for not updating is if the value is
                    // already what we would set it to.
                    if (false == cSideDefaultableValue.IsDefaulted &&
                        sSideDefaultableValueDefaultValue.Equals(preExistingCSideValue))
                    {
                        return;
                    }

                    valueToSet = (sSideDefaultableValue.IsDefaulted ? sSideDefaultableValueDefaultValue : sSideValueToPropagate);
                }
            }
            else
            {
                // we are synchronizing an explicit (i.e. non-default) value from the S-side to the C-side -
                // only reason for not updating is if the value is already what we would set it to.
                if (sSideValueToPropagate.Equals(preExistingCSideValue))
                {
                    // values are the same - so no need to update
                    return;
                }

                valueToSet = sSideValueToPropagate;
            }

            // now update the C-side facet
            var cmd = new UpdateDefaultableValueCommand <T>(cSideDefaultableValue, valueToSet);

            CommandProcessor.InvokeSingleCommand(_cpc, cmd);
        }
Exemple #31
0
 public Test(string initialValue)
 {
     this.AString = new DefaultableValue <string>(initialValue,
                                                  (value) => string.IsNullOrWhiteSpace(value),
                                                  () => string.Empty);
 }
        protected override void PreParse()
        {
            Debug.Assert(State != EFElementState.Parsed, "this object should not already be in the parsed state");

            // clear this here instead of in base class, since we populate it here
            ClearEFObjectCollection(_entityContainers);
            ClearEFObjectCollection(_complexTypes);
            ClearEFObjectCollection(_usings);
            ClearEFObjectCollection(_enumTypes);
            ClearEFObject(_useStrongSpatialTypesAttr);
            _useStrongSpatialTypesAttr = null;

            base.PreParse();
        }
 internal UpdateEntityTypeTypeAccessCommand(DefaultableValue <string> typeAccess, string value)
 {
     _typeAccess = typeAccess;
     _newValue   = value;
 }
 internal DeleteDefaultableValueCommand(DefaultableValue <T> defaultableValue)
 {
     _defaultableValue = defaultableValue;
 }
 internal UpdateDefaultableValueCommand(DefaultableValue <T> defaultableValue, T value)
 {
     DefaultableValue = defaultableValue;
     Value            = value;
 }
        protected override void PreParse()
        {
            Debug.Assert(State != EFElementState.Parsed, "this object should not already be in the parsed state");

            ClearEntitySets();
            ClearEFObjectCollection(_functionImports);
            ClearEFObject(_typeAccessAttr);
            ClearEFObject(_lazyLoadingEnabledAttr);
            _lazyLoadingEnabledAttr = null;

            base.PreParse();
        }