示例#1
0
        public static Puzzle ParseFrom(TextReader reader)
        {
            var metadata     = PuzzleMetadata.ParseFrom(reader);
            var initialState = State.ParseFrom(reader);

            return(new Puzzle(metadata, initialState));
        }
示例#2
0
        public static PuzzleMetadata FromDictionary(IDictionary <string, string> dict)
        {
            var result = new PuzzleMetadata();

            foreach (var entry in dict)
            {
                switch (entry.Key)
                {
                case "Name":
                    result.Name = entry.Value;
                    break;

                case "AuthorName":
                    result.AuthorName = entry.Value;
                    break;

                case "AuthorEmail":
                    result.AuthorEmail = entry.Value;
                    break;

                case "CreationDate":
                    result.CreationDate = DateTimeOffset.Parse(entry.Value);
                    break;

                case "Difficulty":
                    result.Difficulty =
                        (PuzzleDifficulty)Enum.Parse(typeof(PuzzleDifficulty), entry.Value);
                    break;
                }
            }
            return(result);
        }
示例#3
0
 public Puzzle(PuzzleMetadata metadata, State initialState)
 {
     Metadata     = metadata;
     InitialState = initialState;
 }