Пример #1
0
        private void ToGeometryDrawing(IBaseShape shape, StringBuilder sb, IPathConverter converter)
        {
            if (shape is IGroupShape group)
            {
                foreach (var child in group.Shapes)
                {
                    ToGeometryDrawing(child, sb, converter);
                }
                return;
            }

            if (shape.IsFilled)
            {
                var path = converter.ToFillPathShape(shape);
                if (path != null)
                {
                    var geometry = path.Geometry.ToXamlString();
                    var brush    = (shape.Style.Fill as IArgbColor).ToXamlString();
                    sb.AppendLine($"    <GeometryDrawing Brush=\"{brush}\" Geometry=\"{geometry}\"/>");
                }
            }

            if (shape.IsStroked)
            {
                var path = converter.ToStrokePathShape(shape);
                if (path != null)
                {
                    var geometry = path.Geometry.ToXamlString();
                    var brush    = (shape.Style.Stroke as IArgbColor).ToXamlString();
                    sb.AppendLine($"    <GeometryDrawing Brush=\"{brush}\" Geometry=\"{geometry}\"/>");
                }
            }
        }
Пример #2
0
        private void ToGeometryDrawing(IBaseShape shape, StringBuilder sb, IPathConverter converter)
        {
            if (shape is IGroupShape group)
            {
                foreach (var child in group.Shapes)
                {
                    ToGeometryDrawing(child, sb, converter);
                }
                return;
            }

            if (shape.IsFilled)
            {
                var path = converter.ToFillPathShape(shape);
                if (path != null)
                {
                    var geometry = path.Geometry.ToSvgString();
                    var brush    = (shape.Style.Fill as IArgbColor).ToSvgString();
                    var fillRule = path.Geometry.FillRule == FillRule.Nonzero ? "nonzero" : "evenodd";
                    sb.AppendLine($"    <path fill=\"{brush}\" fill-rule=\"{fillRule}\" d=\"{geometry}\"/>");
                }
            }
            if (shape.IsStroked)
            {
                var path = converter.ToStrokePathShape(shape);
                if (path != null)
                {
                    var geometry = path.Geometry.ToSvgString();
                    var brush    = (shape.Style.Stroke as IArgbColor).ToSvgString();
                    var fillRule = path.Geometry.FillRule == FillRule.Nonzero ? "nonzero" : "evenodd";
                    sb.AppendLine($"    <path fill=\"{brush}\" fill-rule=\"{fillRule}\" d=\"{geometry}\"/>");
                }
            }
        }
Пример #3
0
        private static IPathConverter GetPathConverter()
        {
            if (s_pathConverter == null)
            {
                if (string.IsNullOrEmpty(GetFinalPatchData().pathConverterType) ||
                    GetFinalPatchData().pathConverterType == "None")
                {
                    Debug.LogErrorFormat("Please set Path Converter in Final Patch Manager Editor");
                    return(null);
                }

                try
                {
                    System.Type type = typeof(IPathConverter).Assembly.GetType(GetFinalPatchData().pathConverterType);
                    if (type == null)
                    {
                        Debug.LogErrorFormat("Not found Path Converter Type:'{0}'", GetFinalPatchData().pathConverterType);
                        return(null);
                    }

                    s_pathConverter = System.Activator.CreateInstance(type) as IPathConverter;
                }
                catch (System.Exception e)
                {
                    Debug.LogException(e);
                    return(null);
                }
            }
            return(s_pathConverter);
        }
Пример #4
0
 public static void Reset()
 {
     s_clientData = null;
     s_manifestBundle?.Unload(true);
     s_manifestBundle = null;
     s_manifest       = null;
     s_pathConverter  = null;
 }
Пример #5
0
        private AssetBundleBuild CreateAssetBundleBuild(IPathConverter pathConverter, string assetPath)
        {
            AssetBundleBuild build = new AssetBundleBuild
            {
                assetBundleName = pathConverter.GetAssetBundleName(assetPath),
                assetNames      = new string[] { assetPath }
            };

            return(build);
        }
Пример #6
0
        private AssetBundleBuild[] CollectAssetBundleBuilds()
        {
            IPathConverter pathConverter = GetPathConverter();

            string[] guids = AssetDatabase.FindAssets("", new string[] { m_managerWindow.FinalPatchEditorData.assetPath });
            List <AssetBundleBuild>  builds = new List <AssetBundleBuild>();
            Dictionary <string, int> refMap = new Dictionary <string, int>();

            for (int i = 0; i < guids.Length; i++)
            {
                string assetPath = AssetDatabase.GUIDToAssetPath(guids[i]);
                if (builds.FindIndex((b) => ArrayUtility.Contains(b.assetNames, assetPath)) >= 0)
                {
                    continue;
                }

                builds.Add(CreateAssetBundleBuild(pathConverter, assetPath));

                if (m_managerWindow.FinalPatchEditorData.extractDuplicatedDependency)
                {
                    foreach (var dep in AssetDatabase.GetDependencies(assetPath, true))
                    {
                        if (dep == assetPath)
                        {
                            continue;
                        }

                        int count;
                        refMap.TryGetValue(dep, out count);
                        refMap[dep] = count + 1;
                    }
                }
            }

            if (m_managerWindow.FinalPatchEditorData.extractDuplicatedDependency)
            {
                foreach (var item in refMap)
                {
                    if (item.Value <= 1)
                    {
                        continue;
                    }

                    if (builds.FindIndex((b) => ArrayUtility.Contains(b.assetNames, item.Key)) >= 0)
                    {
                        continue;
                    }
                    builds.Add(CreateAssetBundleBuild(pathConverter, item.Key));
                }
            }

            return(builds.ToArray());
        }
Пример #7
0
        private void ToGeometryDrawing(BaseShapeViewModel shape, StringBuilder sb, IPathConverter converter)
        {
            if (shape is GroupShapeViewModel group)
            {
                foreach (var child in group.Shapes)
                {
                    ToGeometryDrawing(child, sb, converter);
                }
                return;
            }

            if (shape.IsFilled)
            {
                var path = converter.ToFillPathShape(shape);
                if (path is { })
Пример #8
0
 static public void ResisterGroupPath(
     string groupPath,
     SEULoaderType loaderType,
     SEUUnLoadType unLoadType  = SEUUnLoadType.REFCOUNT_ZERO,
     string manifestBundlePath = null,
     IPathConverter resToBundlerPathConverter = null,
     SEUBundleLoaderType bundleLoaderType     = SEUBundleLoaderType.Defualt_Memory_BundleLoader
     )
 {
     if (groupPath.EndsWith("/"))
     {
         groupPath = groupPath.Substring(0, groupPath.Length - 1);
     }
     m_ResourcePool.ResisterGroupPath(groupPath, loaderType, unLoadType, resToBundlerPathConverter, bundleLoaderType, manifestBundlePath);
 }
Пример #9
0
        /// <summary>Forward OnNext</summary>
        public void OnNext(IEvent @event)
        {
            // A component observer registers in.
            if (@event is IStartEvent)
            {
                Interlocked.Increment(ref feedingObserverCount); return;
            }

            // If observer dispose has completed, don't forward events.
            if (this.IsDisposing)
            {
                return;
            }

            // Get child's state object
            StateInfo      state         = @event.Observer.State as StateInfo;
            IPathConverter pathConverter = state?.pathConverter;
            // Convert paths
            string newOldPath, newNewPath = null;

            if (pathConverter == null)
            {
                newOldPath = @event.Path;
                if (@event is IRenameEvent re)
                {
                    newNewPath = re.NewPath;
                }
            }
            else
            {
                if (!pathConverter.ChildToParent(@event.Path, out newOldPath))
                {
                    return;
                }
                if (@event is IRenameEvent re)
                {
                    if (!pathConverter.ChildToParent(re.NewPath, out newNewPath))
                    {
                        return;
                    }
                }
            }
            // Try to decorate event
            @event = EventDecoration.DecorateObserverAndPath(@event, this, newOldPath, newNewPath, false);
            // Forward event in this thread, which should be dispatcher's thread
            Observer.OnNext(@event);
        }
        internal void ResisterGroupPath(
            string groupPath,
            SEULoaderType loaderType,
            SEUUnLoadType unLoadType = SEUUnLoadType.REFCOUNT_ZERO,
            IPathConverter resToBundlerPathConverter = null,
            SEUBundleLoaderType bundleLoaderType     = SEUBundleLoaderType.Defualt_Memory_BundleLoader,
            string manifestBundlePath = null
            )
        {
            SEUResourcesPool pool = m_GroupPoolRegister.ResisterGroupPath(groupPath);

            if (pool != null)
            {
                pool.InitPool(groupPath, loaderType, unLoadType, resToBundlerPathConverter, bundleLoaderType, manifestBundlePath);
                AddGroupPool(pool);
            }
        }
        internal void InitPool(
            string groupPath,
            SEULoaderType loaderType,
            SEUUnLoadType unLoadType = SEUUnLoadType.REFCOUNT_ZERO,
            IPathConverter resToBundlerPathConverter = null,
            SEUBundleLoaderType bundleLoaderType     = SEUBundleLoaderType.Defualt_Memory_BundleLoader,
            string manifestBundlePath = null
            )
        {
            m_GroupPath  = groupPath;
            m_LoaderType = loaderType;
            m_UnloadType = unLoadType;
            m_ResourceToBundlePathConverter = resToBundlerPathConverter;
            m_ManifestPath     = manifestBundlePath;
            m_BundleLoaderType = bundleLoaderType;

            if (m_ResourceToBundlePathConverter == null)
            {
                m_ResourceToBundlePathConverter = new SEUBundlePathConverter();
            }

            Debug_InitPool();
        }
Пример #12
0
        /// <summary>
        /// Reads through html <paramref name="html"/> and scans for anchor elements with "href" attributes.
        /// Validates local or global links that refer to a subfile or subdirectory.
        /// </summary>
        /// <param name="baseUri">The uri where the document was loaded. Used for creating absolute uris from relative uris.</param>
        /// <param name="html">document data as stream</param>
        /// <param name="pathConverter">convert child urls (the real URIs) back to parent (API caller's) path format</param>
        /// <returns>array of files</returns>
        /// <exception cref="Exception"></exception>
        public virtual IEnumerable <IEntry> ReadEntries(string baseUri, string html, IPathConverter pathConverter)
        {
            // Result set
            HashSet <string> yielded = new HashSet <string>();
            // Parse base uri
            Uri _baseUri = new Uri(baseUri);
            // Get absolute uri
            string baseUriAbsolute = _baseUri.GetComponents(UriComponents.Scheme | UriComponents.UserInfo | UriComponents.Host | UriComponents.Port | UriComponents.Path, UriFormat.Unescaped);

            // Search achors
            foreach (Match m in anchorPattern.Matches(html))
            {
                // Get href
                string href = m.Groups[1].Value;
                // Test not empty
                if (String.IsNullOrEmpty(href))
                {
                    continue;
                }
                // Parse attribute
                href = HttpUtility.HtmlDecode(href);
                // Entry
                IEntry entry = null;
                try
                {
                    // Parse uri
                    Uri uri = new Uri(_baseUri, href);
                    // Get absolute uri
                    string absoluteUri = uri.GetComponents(UriComponents.Scheme | UriComponents.UserInfo | UriComponents.Host | UriComponents.Port | UriComponents.Path, UriFormat.Unescaped);
                    // Test that is child of baseUri
                    if (absoluteUri.Length <= baseUriAbsolute.Length || !absoluteUri.StartsWith(baseUriAbsolute))
                    {
                        continue;
                    }
                    // Test only one slash after baseUriAbsolute
                    int slashCount = 0;
                    int startIx    = baseUriAbsolute.EndsWith("/") ? baseUriAbsolute.Length : baseUriAbsolute.Length + 1;
                    for (int i = startIx; i < absoluteUri.Length - 1; i++)
                    {
                        // Not slash
                        if (absoluteUri[i] != '/')
                        {
                            continue;
                        }
                        // Add slash
                        slashCount++;
                        break;
                    }
                    // Too many slashes "<baseuri>/Dir/Dir/file", thereof not immediate child
                    if (slashCount >= 1)
                    {
                        continue;
                    }
                    // Already yielded?
                    if (!yielded.Add(absoluteUri))
                    {
                        continue;
                    }
                    // Extract name
                    String name = GetEntryName(absoluteUri);
                    // Convert path
                    string parentUri;
                    if (!pathConverter.ChildToParent(absoluteUri, out parentUri))
                    {
                        continue;
                    }
                    // Is directory
                    if (absoluteUri.EndsWith("/"))
                    {
                        entry = new DirectoryEntry(this, parentUri, name, DateTimeOffset.MinValue, DateTimeOffset.MinValue, null);
                    }
                    // Is unknown if is file or directory, so report as both
                    else
                    {
                        entry = new DirectoryAndFileEntry(this, parentUri, name, DateTimeOffset.MinValue, DateTimeOffset.MinValue, -1L, null);
                    }
                }
                catch (Exception)
                {
                    // bad uri
                    continue;
                }
                // Yield entry
                if (entry != null)
                {
                    yield return(entry);
                }
            }
        }
Пример #13
0
 /// <summary>
 /// Create state info.
 /// </summary>
 /// <param name="pathConverter"></param>
 /// <param name="state"></param>
 public StateInfo(IPathConverter pathConverter, object state)
 {
     this.pathConverter = pathConverter;
     this.state         = state;
 }
Пример #14
0
 public BreadcrumbBar( IPathConverter pathconv ) : this()
 {
     _pathconverter = pathconv;
 }