Exemple #1
0
        public string GetRandomValue(SampleBasicType sampleType, string format, string formatParameters)
        {
            object obj = this.GetValueBuilder(sampleType, format, formatParameters).Value;

            if (obj == null)
            {
                return((string)null);
            }
            return(obj as string ?? MetadataStore.GetTypeConverter(obj.GetType()).ConvertToInvariantString((ITypeDescriptorContext)null, obj));
        }
        public BindingDialogModelBase(SceneNode targetElement, ReferenceStep targetProperty)
        {
            this.TargetElement  = targetElement;
            this.TargetProperty = targetProperty;
            IType type1 = this.ViewModel.ProjectContext.ResolveType(PlatformTypes.BindingMode);

            this.supportedBindingModeNames = Enum.GetNames(type1.RuntimeType);
            this.bindingModeProxy          = new BindingProxy <BindingMode>();
            this.bindingModesCollection    = new ObservableCollection <BindingMode>();
            foreach (BindingMode bindingMode in this.bindingModes)
            {
                if (this.IsBindingModeSupported(bindingMode))
                {
                    this.bindingModesCollection.Add(bindingMode);
                }
            }
            this.bindingModesView = (CollectionView) new DataBindingProxyCollectionView <BindingMode>(this.bindingModesCollection, (IDataBindingProxy <BindingMode>) this.bindingModeProxy);
            this.bindingModesView.MoveCurrentToFirst();
            this.bindingModeProxy.Value = BindingPropertyHelper.GetDefaultBindingMode(this.TargetElement.DocumentNode, (IPropertyId)this.TargetProperty, (DataSchemaNodePath)null).Mode;
            if (this.TargetProperty != null)
            {
                BindingSceneNode binding = this.TargetElement.GetBinding((IPropertyId)this.TargetProperty);
                if (binding != null)
                {
                    this.originalValueConverter = binding.Converter;
                }
            }
            this.updateSourceTriggerProxy = new BindingProxy <object>();
            ObservableCollection <object> collection = new ObservableCollection <object>();
            IType type2 = this.ViewModel.ProjectContext.ResolveType(PlatformTypes.UpdateSourceTrigger);

            if (!this.ViewModel.ProjectContext.PlatformMetadata.IsNullType((ITypeId)type2))
            {
                IProperty property = this.ViewModel.ProjectContext.ResolveProperty(BindingSceneNode.UpdateSourceTriggerProperty);
                if (property != null)
                {
                    this.updateSourceTriggerProxy.Value = property.GetDefaultValue(type1.RuntimeType);
                }
                foreach (object obj in (IEnumerable)MetadataStore.GetTypeConverter(type2.RuntimeType).GetStandardValues())
                {
                    collection.Add(obj);
                }
            }
            this.updateSourceTriggersView = (CollectionView) new DataBindingProxyCollectionView <object>(collection, (IDataBindingProxy <object>) this.updateSourceTriggerProxy);
        }
Exemple #3
0
        private string GetTriggerValueCore()
        {
            object obj  = this.condition.Value;
            bool   flag = obj == null;

            if (!flag && Nullable.GetUnderlyingType(obj.GetType()) != (Type)null)
            {
                flag = obj.Equals((object)null);
            }
            string str;

            if (!flag)
            {
                TypeConverter typeConverter = MetadataStore.GetTypeConverter(obj);
                str = typeConverter == null || !typeConverter.CanConvertTo(typeof(string)) ? obj.ToString() : typeConverter.ConvertToString((ITypeDescriptorContext)null, CultureInfo.InvariantCulture, obj);
            }
            else
            {
                str = "null";
            }
            return(str);
        }
Exemple #4
0
 private static TypeConverter GetTypeConverterForProperty(DependencyProperty property)
 {
     return(!(property.Name == "Content") && !(property.Name == "Header") && (!(property.Name == "ToolTip") && !(property.Name == "Tag")) || !property.PropertyType.IsAssignableFrom(typeof(object)) ? MetadataStore.GetTypeConverter(property.PropertyType) : (TypeConverter) new StringConverter());
 }