public string MakeSourceReference(string fullPath) { DocumentReference reference = DocumentReference.Create(fullPath); if (this.sceneViewModel != null) { string str = this.sceneViewModel.Document.DocumentReference.GetRelativePath(reference); if (str != null && this.sceneViewModel.ProjectContext.IsCapabilitySet(PlatformCapability.ShouldSanitizeResourceReferences)) { str = str.Replace(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar); } return(str); } string str1 = this.ActiveProject.DocumentReference.GetRelativePath(reference); if (str1 == null) { return((string)null); } IXamlProject xamlProject = this.ActiveProject as IXamlProject; if (xamlProject != null) { ITypeResolver typeResolver = (ITypeResolver)ProjectContext.GetProjectContext(xamlProject.ProjectContext); if (typeResolver != null && typeResolver.IsCapabilitySet(PlatformCapability.ShouldSanitizeResourceReferences)) { str1 = str1.Replace(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar); } } return(str1); }
public static IEnumerable <SystemFontFamily> GetSystemFonts(ITypeResolver typeResolver) { if (typeResolver.IsCapabilitySet(PlatformCapability.UsesGdiFontNames)) { return(FontEmbedder.GetGdiFontFamilies()); } return(FontEmbedder.GetWpfFontFamilies()); }
public static bool IsPropertyWritable(ITypeResolver typeResolver, IProperty propertyKey, bool allowProtectedProperties) { MemberAccessTypes allowableMemberAccess = TypeHelper.GetAllowableMemberAccess(typeResolver, propertyKey.DeclaringType); if (allowProtectedProperties && !propertyKey.IsAttachable || typeResolver.IsCapabilitySet(PlatformCapability.WorkaroundSL12782) && typeResolver.PlatformMetadata.KnownTypes.UserControl.IsAssignableFrom(propertyKey.DeclaringTypeId) && propertyKey.Equals((object)propertyKey.DeclaringType.Metadata.DefaultContentProperty)) { allowableMemberAccess |= MemberAccessTypes.Protected; } MemberAccessType writeAccess = propertyKey.WriteAccess; return(TypeHelper.IsSet(allowableMemberAccess, writeAccess)); }
public static void AddToolkitReferenceIfNeeded(ITypeResolver typeResolver, ViewUpdateManager viewUpdateManager) { if (typeResolver == null || !typeResolver.IsCapabilitySet(PlatformCapability.VsmInToolkit) || !typeResolver.IsCapabilitySet(PlatformCapability.SupportsVisualStateManager)) { return; } string toolkitPath = ToolkitHelper.GetToolkitPath(); if (string.IsNullOrEmpty(toolkitPath)) { return; } typeResolver.EnsureAssemblyReferenced(toolkitPath); viewUpdateManager.RebuildPostponedViews(); }
public void OnInitialized(IInstanceBuilderContext context, ViewNode target, object instance) { if (instance != null && this.targetType.IsAssignableFrom(instance.GetType())) { ITypeResolver typeResolver = target.DocumentNode.TypeResolver; IPlatform platform = context.Platform; platform.ViewObjectFactory.Instantiate(instance).SetValue(typeResolver, typeResolver.ResolveProperty(DesignTimeProperties.InstanceBuilderContextProperty), (object)new WeakReference((object)context)); IDesignModeValueProviderContext valueProviderContext = context as IDesignModeValueProviderContext; if (valueProviderContext != null) { ValueTranslationService valueTranslationService = valueProviderContext.ValueTranslationService; foreach (PropertyIdentifier identifier in valueTranslationService.GetProperties(this.targetType)) { if (valueTranslationService.HasValueTranslation(this.targetType, identifier)) { ReferenceStep referenceStep = target.Type.GetMember(MemberType.Property, identifier.Name, MemberAccessTypes.All) as ReferenceStep; if (referenceStep != null) { if (!target.Properties.ContainsKey((IProperty)referenceStep)) { ReferenceStep referenceStep1 = (ReferenceStep)DesignTimeProperties.GetShadowProperty((IProperty)referenceStep, (ITypeId)target.Type); object valueToSet = referenceStep.GetValue(instance); if (typeResolver.IsCapabilitySet(PlatformCapability.IsWpf) || valueToSet != null) { referenceStep1.SetValue(instance, valueToSet); } } PropertyIdentifier localProperty = identifier; UIThreadDispatcherHelper.BeginInvoke(DispatcherPriority.Send, (Delegate)(o => { if (target.Parent != null) { DesignModeValueProviderService.RunDesignModeValueProvider(instance, platform, valueTranslationService, target.Type, this.targetType, localProperty, referenceStep, true); } return((object)null); }), (object)null); } } } } } if (!context.IsSerializationScope) { return; } this.builder.OnInitialized(context, target, instance); }
public static IProperty GetProperty(ITypeResolver typeResolver, Type targetType, PropertyDescriptor propertyDescriptor) { if (typeResolver.IsCapabilitySet(PlatformCapability.UseDependencyPropertyDescriptor)) { DependencyPropertyDescriptor propertyDescriptor1 = DependencyPropertyDescriptor.FromProperty(propertyDescriptor); if (propertyDescriptor1 != null) { return((IProperty)DependencyPropertyReferenceStep.GetReferenceStep(typeResolver, targetType, propertyDescriptor1.DependencyProperty)); } } IType type = typeResolver.GetType(targetType); if (typeResolver.PlatformMetadata.IsNullType((ITypeId)type)) { return((IProperty)null); } MemberAccessTypes allowableMemberAccess = TypeHelper.GetAllowableMemberAccess(typeResolver, type); return(type.GetMember(MemberType.Property, propertyDescriptor.Name, allowableMemberAccess) as IProperty); }
public static bool IsEnabled(ITypeResolver typeResolver) { return(typeResolver.IsCapabilitySet(PlatformCapability.SupportAddTriggerDataDragDrop) && BlendSdkHelper.IsSdkInstalled(typeResolver.PlatformMetadata.TargetFramework)); }
public static XmlNamespaceCanonicalization GetNamespaceCanonicalization(ITypeResolver typeResolver) { return(typeResolver.IsCapabilitySet(PlatformCapability.CanonicalizeNamespaceToSilverlight) ? XmlNamespaceCanonicalization.ToJolt : XmlNamespaceCanonicalization.None); }
private static PropertyReference ResolvePropertyPathParts(ITypeResolver typeResolver, string path, Collection <object> parameters, SceneNode pathRoot) { if (path == "(0)") { if (parameters == null || parameters.Count == 0) { return((PropertyReference)null); } DependencyProperty dependencyProperty = parameters[0] as DependencyProperty; if (dependencyProperty == null) { return((PropertyReference)null); } Type targetType = pathRoot != null ? pathRoot.TargetType : dependencyProperty.OwnerType; DependencyPropertyReferenceStep referenceStep = DependencyPropertyReferenceStep.GetReferenceStep(typeResolver, targetType, dependencyProperty); if (referenceStep == null) { return((PropertyReference)null); } return(new PropertyReference((ReferenceStep)referenceStep)); } List <ReferenceStep> list = new List <ReferenceStep>(); object obj = (object)null; if (typeResolver.IsCapabilitySet(PlatformCapability.SupportTypelessPropertyPath) && pathRoot != null && pathRoot.IsViewObjectValid) { obj = pathRoot.ViewObject.PlatformSpecificObject; } IType typeId = obj == null ? (pathRoot == null ? (parameters == null || parameters.Count <= 0 || !(parameters[0] is DependencyProperty) ? typeResolver.ResolveType(PlatformTypes.Object) : typeResolver.GetType(((DependencyProperty)parameters[0]).OwnerType)) : pathRoot.Type) : typeResolver.GetType(obj.GetType()); for (int index1 = 0; index1 < path.Length; ++index1) { ReferenceStep referenceStep = (ReferenceStep)null; char ch = path[index1]; switch (ch) { case '(': int num1 = path.IndexOf(')', index1 + 1); if (num1 < 0) { return((PropertyReference)null); } string s = path.Substring(index1 + 1, num1 - index1 - 1); int result1; if (int.TryParse(s, out result1)) { if (parameters == null || result1 < 0 || result1 >= parameters.Count) { return((PropertyReference)null); } DependencyProperty dependencyProperty = parameters[result1] as DependencyProperty; if (dependencyProperty == null) { return((PropertyReference)null); } referenceStep = (ReferenceStep)DependencyPropertyReferenceStep.GetReferenceStep(typeResolver, typeId.NearestResolvedType.RuntimeType, dependencyProperty); if (referenceStep == null) { PlatformTypes platformTypes = (PlatformTypes)typeResolver.PlatformMetadata; Type runtimeType = typeId.NearestResolvedType.RuntimeType; Type ownerType = dependencyProperty.OwnerType; referenceStep = (ReferenceStep)(platformTypes.GetProperty(typeResolver, ownerType, MemberType.LocalProperty, dependencyProperty.Name) as DependencyPropertyReferenceStep); if (referenceStep == null || !runtimeType.IsAssignableFrom(ownerType)) { return((PropertyReference)null); } } } else { int length = s.IndexOf('.'); string typeName; if (length < 0) { if (!typeResolver.IsCapabilitySet(PlatformCapability.SupportTypelessPropertyPath)) { return((PropertyReference)null); } typeName = typeId.Name; length = -1; } else { typeName = s.Substring(0, length); } string str = s.Substring(length + 1); if (string.IsNullOrEmpty(typeName)) { return((PropertyReference)null); } IType type = typeResolver.GetType((IXmlNamespace)typeResolver.GetCapabilityValue(PlatformCapability.DefaultXmlns), typeName); if (type == null) { IProperty designTimeProperty = typeResolver.PlatformMetadata.GetDesignTimeProperty(str, (IType)null); if (designTimeProperty != null && designTimeProperty.DeclaringType.Name == typeName) { referenceStep = (ReferenceStep)designTimeProperty; } } if (referenceStep == null) { if (type == null) { type = typeId; } referenceStep = type.GetMember(MemberType.Property, str, MemberAccessTypes.Public) as ReferenceStep ?? TimelineSceneNode.ResolveReferenceStepFromValue(typeResolver, pathRoot, list, str); } if (referenceStep == null) { return((PropertyReference)null); } } index1 = num1; break; case '[': int num2 = path.IndexOf(']', index1 + 1); if (num2 < 0) { return((PropertyReference)null); } int result2; if (!int.TryParse(path.Substring(index1 + 1, num2 - index1 - 1), out result2)) { return((PropertyReference)null); } referenceStep = (ReferenceStep)IndexedClrPropertyReferenceStep.GetReferenceStep(typeResolver, typeId.RuntimeType, result2, false); index1 = num2; if (referenceStep == null) { return((PropertyReference)null); } break; default: int startIndex = index1; if ((int)ch == 46) { ++startIndex; } if (index1 >= path.Length - 1) { return((PropertyReference)null); } int index2 = index1 + 1; if ((int)path[index2] != 40) { for (; index2 < path.Length; ++index2) { switch (path[index2]) { case '.': case '[': goto label_52; default: goto default; } } label_52: if (index1 >= index2 - 1) { return((PropertyReference)null); } string str = path.Substring(startIndex, index2 - startIndex); referenceStep = typeId.GetMember(MemberType.LocalProperty | MemberType.Field, str, TypeHelper.GetAllowableMemberAccess(typeResolver, typeId)) as ReferenceStep; if (referenceStep == null) { referenceStep = TimelineSceneNode.ResolveReferenceStepFromValue(typeResolver, pathRoot, list, str); if (referenceStep == null) { return((PropertyReference)null); } } index1 = index2 - 1; break; } break; } if (referenceStep != null) { list.Add(referenceStep); typeId = referenceStep.PropertyType; } } if (list == null || list.Count <= 0) { return((PropertyReference)null); } return(new PropertyReference(list)); }
public string AddSupportingFileToProject(string fileName, out string sourceReference, bool useExistingFile) { sourceReference = (string)null; IProject activeProject = this.importContext.ActiveProject; if (activeProject == null) { return((string)null); } this.GetSupportingFolderName(true); string path = Microsoft.Expression.Framework.Documents.PathHelper.BuildValidFileName(fileName); if (path != null) { ITypeResolver typeResolver = (ITypeResolver)(activeProject as IXamlProject).ProjectContext; if (typeResolver != null && !typeResolver.IsCapabilitySet(PlatformCapability.IsWpf)) { path = path.Replace("%", ""); } } string str1; if (string.IsNullOrEmpty(path)) { str1 = Microsoft.Expression.Framework.Documents.PathHelper.GetSafeExtension(fileName); fileName = StringTable.SupportingFilePlaceholder; if (str1 != null) { fileName += str1; } } else { fileName = path; str1 = Path.GetExtension(path); } string fullPath = (string)null; string str2 = (string)null; bool flag = false; string str3 = !useExistingFile ? this.temporaryFolderPlaceholder.Path : this.supportingDirectoryPath; while (true) { if (str2 != null) { goto label_20; } label_10: try { if (useExistingFile) { str2 = Path.Combine(str3, fileName); } else { str2 = ProjectPathHelper.GetAvailableFilePath(fileName, str3, (IProject)null, true); fileName = Path.GetFileName(str2); } fullPath = Path.Combine(this.supportingDirectoryPath, fileName); if (fullPath.Length > 256 || str2.Length > 256) { fullPath = (string)null; str2 = (string)null; throw new PathTooLongException(); } this.supportingFiles.Add(new KeyValuePair <string, string>(str2, fullPath)); continue; } catch (Exception ex) { if (flag) { fullPath = (string)null; str2 = (string)null; break; } fileName = string.IsNullOrEmpty(str1) ? StringTable.SupportingFilePlaceholder : StringTable.SupportingFilePlaceholder + str1; flag = true; continue; } label_20: if (fullPath == null) { goto label_10; } else { break; } } if (fullPath != null && str2 != null) { sourceReference = this.importContext.MakeSourceReference(fullPath); return(str2); } sourceReference = (string)null; return((string)null); }