Exemplo n.º 1
0
        public static bool TryGetRelatedResource(string resourcePath, ResourceMode mode, Func <string, bool> resourceExists, out RelatedResourceInfo otherResourceInfo)
        {
            string fileExtension = Path.GetExtension(resourcePath);

            if (mode == ResourceMode.Release)
            {
                var compiledResource = ToCompiledPath(resourcePath, fileExtension);
                if (resourceExists(compiledResource))
                {
                    otherResourceInfo = new RelatedResourceInfo
                    {
                        ModeOfRelatedPath = ResourceMode.Release,
                        RelatedPath       = compiledResource
                    };
                    return(true);
                }

                var minResource = ToMinPath(resourcePath, fileExtension);
                if (resourceExists(minResource))
                {
                    otherResourceInfo = new RelatedResourceInfo
                    {
                        ModeOfRelatedPath = ResourceMode.Release,
                        RelatedPath       = minResource
                    };
                    return(true);
                }
            }
            else
            {
                var debugResource = ToDebugPath(resourcePath, fileExtension);
                if (resourceExists(debugResource))
                {
                    otherResourceInfo = new RelatedResourceInfo
                    {
                        ModeOfRelatedPath = ResourceMode.Debug,
                        RelatedPath       = debugResource
                    };
                    return(true);
                }
            }

            otherResourceInfo = null;
            return(false);
        }
Exemplo n.º 2
0
        public static bool TryGetRelatedResource(string resourcePath, ResourceMode mode, Func<string, bool> resourceExists, out RelatedResourceInfo otherResourceInfo)
        {
            string fileExtension = Path.GetExtension(resourcePath);
            if (mode == ResourceMode.Release)
            {
                var compiledResource = ToCompiledPath(resourcePath, fileExtension);
                if (resourceExists(compiledResource))
                {
                    otherResourceInfo = new RelatedResourceInfo
                    {
                        ModeOfRelatedPath = ResourceMode.Release,
                        RelatedPath = compiledResource
                    };
                    return true;
                }

                var minResource = ToMinPath(resourcePath, fileExtension);
                if (resourceExists(minResource))
                {
                    otherResourceInfo = new RelatedResourceInfo
                    {
                        ModeOfRelatedPath = ResourceMode.Release,
                        RelatedPath = minResource
                    };
                    return true;
                }
            }
            else
            {
                var debugResource = ToDebugPath(resourcePath, fileExtension);
                if (resourceExists(debugResource))
                {
                    otherResourceInfo = new RelatedResourceInfo
                    {
                        ModeOfRelatedPath = ResourceMode.Debug,
                        RelatedPath = debugResource
                    };
                    return true;
                }
            }

            otherResourceInfo = null;
            return false;
        }