Esempio n. 1
0
 public override ModelItem SetValue(object value)
 {
     using (SceneEditTransaction editTransaction = this.CreateEditTransaction())
     {
         ModelItem modelItem = value as ModelItem;
         if (modelItem != null)
         {
             ISceneNodeModelItem sceneNodeModelItem = value as ISceneNodeModelItem;
             value = sceneNodeModelItem == null?modelItem.GetCurrentValue() : (object)sceneNodeModelItem.SceneNode.DocumentNode;
         }
         string text = value as string;
         if (text != null)
         {
             bool flag = true;
             if (text.StartsWith("{", StringComparison.Ordinal))
             {
                 if (text.StartsWith("{}", StringComparison.Ordinal))
                 {
                     text = text.Substring(2);
                 }
                 else
                 {
                     XamlDocument document   = (XamlDocument)this.parent.SceneNode.ViewModel.XamlDocument;
                     DocumentNode parentNode = this.parent.SceneNode.DocumentNode;
                     if (parentNode.DocumentRoot == null)
                     {
                         parentNode = document.RootNode;
                     }
                     IList <XamlParseError> errors;
                     DocumentNode           expressionFromString = XamlExpressionSerializer.GetExpressionFromString(text, document, parentNode, this.PropertyType, out errors);
                     if (errors == null || errors.Count == 0)
                     {
                         flag  = false;
                         value = (object)expressionFromString;
                     }
                 }
             }
             if (flag)
             {
                 value = (object)this.parent.SceneNode.DocumentContext.CreateNode((ITypeId)this.property.PropertyType, (IDocumentNodeValue) new DocumentNodeStringValue(text));
             }
         }
         if (value != null && !(value is DocumentNode) && this.parent.SceneNode.ProjectContext.GetType(value.GetType()) == null)
         {
             throw new InvalidOperationException(string.Format((IFormatProvider)CultureInfo.CurrentCulture, ExceptionStringTable.TypeIsNotResolveableWithinProject, new object[1]
             {
                 (object)value.GetType().FullName
             }));
         }
         this.parent.SceneNode.SetValue((IPropertyId)this.property, value);
         editTransaction.Commit();
     }
     return(this.Value);
 }
Esempio n. 2
0
 private void ParseKeyString()
 {
     if (this.keyString.Length == 0)
     {
         this.parsedKeyString  = (DocumentNode)null;
         this.KeyStringIsValid = false;
     }
     else if ((int)this.keyString[0] != 123)
     {
         this.KeyStringIsValid = true;
         this.parsedKeyString  = (DocumentNode)this.resourceEntryNode.DocumentContext.CreateNode(this.keyString);
     }
     else
     {
         IList <XamlParseError> errors;
         DocumentNode           expressionFromString = XamlExpressionSerializer.GetExpressionFromString(this.keyString, this.resourceEntryNode.DocumentNode, typeof(string), out errors);
         this.parsedKeyString  = expressionFromString == null ? (DocumentNode)null : (!(expressionFromString is DocumentPrimitiveNode) || !(expressionFromString.TargetType == typeof(Type)) ? (!DocumentNodeUtilities.IsStaticExtension(expressionFromString) ? (DocumentNode)null : expressionFromString) : expressionFromString);
         this.KeyStringIsValid = this.parsedKeyString != null;
     }
 }
Esempio n. 3
0
        public EditResourceModel(DesignerContext designerContext, DictionaryEntryNode resourceEntryNode, IPropertyInspector transactionContext)
        {
            this.designerContext   = designerContext;
            this.resourceEntryNode = resourceEntryNode;
            object       key = resourceEntryNode.Key;
            DocumentNode expression;

            if ((expression = key as DocumentNode) != null)
            {
                this.keyString = XamlExpressionSerializer.GetStringFromExpression(expression, resourceEntryNode.DocumentNode);
            }
            else if ((this.keyString = key as string) == null)
            {
                this.keyString = key.ToString();
            }
            this.keyStringIsValid = true;
            ResourceEntryItem resource = (ResourceEntryItem)this.designerContext.ResourceManager.GetResourceItem((DocumentCompositeNode)resourceEntryNode.DocumentNode);

            this.resourceObjectSet = new ResourceValueObjectSet(resource, designerContext, transactionContext);
            this.standInProperty   = this.resourceObjectSet.CreateProperty(new PropertyReference((ReferenceStep)this.resourceObjectSet.ProjectContext.ResolveProperty(DictionaryEntryNode.ValueProperty)), TypeUtilities.GetAttributes(resource.EffectiveType));
            this.standInProperty.PropertyValue.PropertyValueException += new EventHandler <PropertyValueExceptionEventArgs>(this.OnPropertyValueException);
            this.standInProperty.PropertyValue.PropertyChanged        += new PropertyChangedEventHandler(this.OnValuePropertyChanged);
        }