Example #1
0
 /// <summary>
 /// Gets the resource id of this file for the provided policy
 /// </summary>
 internal string GetResourceId(ResourceNamePolicy policy)
 {
     if (string.IsNullOrEmpty(resourceId) && (Project is DotNetProject))
     {
         return(((DotNetProject)Project).GetDefaultResourceIdForPolicy(this, policy));
     }
     return(resourceId);
 }
        public void LoadFrom(DotNetNamingPolicy policy)
        {
            checkAssociateNamespacesDirectories.Active = (policy.DirectoryNamespaceAssociation != DirectoryNamespaceAssociation.None);
            checkDefaultAsRoot.Active = policy.DirectoryNamespaceAssociation == DirectoryNamespaceAssociation.PrefixedFlat ||
                                        policy.DirectoryNamespaceAssociation == DirectoryNamespaceAssociation.PrefixedHierarchical;
            radioHierarch.Active = policy.DirectoryNamespaceAssociation == DirectoryNamespaceAssociation.Hierarchical ||
                                   policy.DirectoryNamespaceAssociation == DirectoryNamespaceAssociation.PrefixedHierarchical;

            if (policy.ResourceNamePolicy == ResourceNamePolicy.FileFormatDefault)
            {
                checkVSStyleResourceNames.Inconsistent = true;
            }
            else
            {
                checkVSStyleResourceNames.Active       = policy.ResourceNamePolicy == ResourceNamePolicy.MSBuild;
                checkVSStyleResourceNames.Inconsistent = false;
            }

            if (firstLoad)
            {
                initialResourceNaming = policy.ResourceNamePolicy;
                firstLoad             = false;
            }
        }
		void MigrateResourceIds (ResourceNamePolicy oldPolicy, ResourceNamePolicy newPolicy)
		{
			if (oldPolicy != newPolicy) {
				// If the file format has a default resource handler different from the one
				// choosen for this project, then all resource ids must be converted
				foreach (ProjectFile file in Files.Where (f => f.BuildAction == BuildAction.EmbeddedResource)) {
					if (file.Subtype == Subtype.Directory)
						continue;
					string oldId = file.GetResourceId (oldPolicy);
					string newId = file.GetResourceId (newPolicy);
					string newDefault = GetDefaultResourceIdForPolicy (file, newPolicy);
					if (oldId != newId) {
						if (newDefault == oldId)
							file.ResourceId = null;
						else
							file.ResourceId = oldId;
					} else {
						if (newDefault == oldId)
							file.ResourceId = null;
					}
				}
			}
		}
		/// <summary>
		/// Migrates resource identifiers from a policy to the current policy of the project.
		/// </summary>
		/// <param name="oldPolicy">Old policy.</param>
		public void MigrateResourceIds (ResourceNamePolicy oldPolicy)
		{
			MigrateResourceIds (oldPolicy, Policies.Get<DotNetNamingPolicy>().ResourceNamePolicy);
		}
		internal string GetDefaultResourceIdForPolicy (ProjectFile projectFile, ResourceNamePolicy policy)
		{
			if (policy == ResourceNamePolicy.FileFormatDefault || policy == ResourceNamePolicy.MSBuild)
				return GetDefaultMSBuildResourceId (projectFile);
			else
				return projectFile.FilePath.FileName;
		}
Example #6
0
 public DotNetNamingPolicy(DirectoryNamespaceAssociation association, ResourceNamePolicy resourceNamePolicy)
 {
     this.DirectoryNamespaceAssociation = association;
     this.ResourceNamePolicy            = resourceNamePolicy;
 }
		/// <summary>
		/// Gets the resource id of this file for the provided policy
		/// </summary>
		internal string GetResourceId (ResourceNamePolicy policy)
		{
			if (string.IsNullOrEmpty (resourceId) && (Project is DotNetProject))
				return ((DotNetProject)Project).GetDefaultResourceIdForPolicy (this, policy);
			return resourceId;
		}