internal static IPropertyId RefineDataContextProperty(SceneNode target, IPropertyId targetProperty, DocumentNode dataNode) { if (targetProperty.MemberType == MemberType.DesignTimeProperty || !DataContextHelper.IsDataContextProperty(target.DocumentNode, targetProperty)) { return(targetProperty); } SampleNonBasicType sampleNonBasicType = dataNode.Type as SampleNonBasicType; if (sampleNonBasicType != null) { if (!sampleNonBasicType.DeclaringDataSet.IsEnabledAtRuntime) { return(DesignTimeProperties.DesignDataContextProperty); } if (((DocumentCompositeNode)target.DocumentNode).Properties[targetProperty] != null) { DataContextInfo dataContextInfo = new DataContextEvaluator().Evaluate(target, targetProperty, true); if (dataContextInfo.DataSource != null && !(dataContextInfo.DataSource.DataSourceType is SampleNonBasicType)) { return(DesignTimeProperties.DesignDataContextProperty); } } return(targetProperty); } if (PlatformTypes.IsExpressionInteractiveType(dataNode.Type.RuntimeType)) { return(DesignTimeProperties.DesignDataContextProperty); } return(targetProperty); }
private static bool IsTypeSerializable(ITypeResolver typeResolver, IType type) { if (type.IsInProject(typeResolver) || PlatformTypes.IsDesignTimeType(type.NearestResolvedType.RuntimeType)) { return(true); } return(!PlatformTypes.IsExpressionInteractiveType(type.NearestResolvedType.RuntimeType)); }
public Type GetDesignType(IDesignTypeGeneratorContext context, Type runtimeType) { if (runtimeType == null) { return(runtimeType); } if (PlatformTypes.IsExpressionInteractiveType(runtimeType)) { return(runtimeType); } if (runtimeType.IsPrimitive || runtimeType.IsGenericParameter) { return(runtimeType); } if (!this.IsCorePlatformType(runtimeType)) { return(null); } Type replacementForPlatformType = this.GetReplacementForPlatformType(runtimeType); if (replacementForPlatformType != null) { return(replacementForPlatformType); } if (runtimeType.IsInterface) { return(null); } if (!runtimeType.IsGenericType) { if (runtimeType.IsArray && this.GetDesignType(context, DesignTypeGenerator.GetArrayItemType(runtimeType)) == null) { return(null); } return(runtimeType); } Type[] genericArguments = runtimeType.GetGenericArguments(); for (int i = 0; i < (int)genericArguments.Length; i++) { if (this.GetDesignType(context, genericArguments[i]) == null) { return(null); } } return(runtimeType); }
private static bool IsMediaElementInstance(Visual visual) { if (visual is MediaElement) { System.Type type = visual.GetType(); if (PlatformTypes.IsExpressionInteractiveType(type)) { try { return(type.GetCustomAttributes(typeof(DesignTimeMediaElementAttribute), false).Length != 0); } catch (Exception ex) { } } } return(false); }
protected virtual void CopyProperty(IPropertyId propertyId) { DependencyPropertyReferenceStep propertyReferenceStep = this.TextSource.DesignerContext.DesignerDefaultPlatformService.DefaultPlatform.Metadata.ResolveProperty(propertyId) as DependencyPropertyReferenceStep; ReferenceStep referenceStep1 = PlatformTypes.IsExpressionInteractiveType(PlatformTypeHelper.GetDeclaringType((IMember)propertyReferenceStep)) ? (ReferenceStep)propertyReferenceStep : PlatformTypeHelper.GetProperty((ITypeResolver)this.TextSource.ProjectContext, (ITypeId)this.TextSource.Type, MemberType.LocalProperty, propertyReferenceStep.Name); if (referenceStep1 == null) { return; } object computedValueAsWpf = this.TextSource.GetComputedValueAsWpf((IPropertyId)referenceStep1); if (!this.TextSource.ProjectContext.IsCapabilitySet(PlatformCapability.IsWpf)) { if (DesignTimeProperties.GetShadowProperty((IProperty)referenceStep1, (ITypeId)this.TextSource.Type) != null) { for (SceneNode sceneNode = (SceneNode)this.TextSource; sceneNode != null; sceneNode = sceneNode.Parent) { IProperty property = PlatformTypes.IsExpressionInteractiveType(PlatformTypeHelper.GetDeclaringType((IMember)referenceStep1)) ? (IProperty)referenceStep1 : (IProperty)PlatformTypeHelper.GetProperty((ITypeResolver)this.TextSource.ProjectContext, (ITypeId)sceneNode.Type, MemberType.LocalProperty, referenceStep1.Name); if (property != null && sceneNode.IsSet((IPropertyId)property) == PropertyState.Set) { computedValueAsWpf = sceneNode.GetComputedValueAsWpf((IPropertyId)property); break; } } } } try { ReferenceStep referenceStep2 = referenceStep1; if (!this.TextSource.ProjectContext.IsCapabilitySet(PlatformCapability.IsWpf)) { referenceStep2 = (ReferenceStep)propertyReferenceStep; } referenceStep2.SetValue(this.EditingElement.PlatformSpecificObject, computedValueAsWpf); } catch { } }