示例#1
0
        public static async Task <Copyable> DecodeFile(string[] paths, Window sender, Type ensure)
        {
            Copyable ret = new Copyable();

            try {
                foreach (string path in paths)
                {
                    Copyable copyable;

                    using (FileStream file = File.Open(path, FileMode.Open, FileAccess.Read))
                        copyable = await Decoder.Decode(file, typeof(Copyable));

                    if (!ensure.IsAssignableFrom(copyable.Type))
                    {
                        throw new InvalidDataException();
                    }

                    ret.Merge(copyable);
                }

                return(ret);
            } catch {
                await MessageWindow.CreateReadError(sender);

                return(null);
            }
        }
示例#2
0
        public void Merge(Copyable merging)
        {
            if (Type != merging.Type && Type != null && merging.Type != null)
            {
                return;
            }

            foreach (ISelect item in merging.Contents)
            {
                Contents.Add(item);
            }
        }