コード例 #1
0
 public virtual void RemoveStorableType(Type typeToRemove)
 {
     if (StoredTypes.Contains(typeToRemove))
     {
         StoredTypes.Remove(typeToRemove);
     }
 }
コード例 #2
0
 public override object FromRawState(TextState raw)
 {
     try
     {
         var stateType = StoredTypes.ForName(raw.Type);
         return(JsonSerialization.Deserialized(raw.Data, stateType) !);
     }
     catch (Exception e)
     {
         throw new InvalidOperationException($"Cannot convert to type: {raw.Type}", e);
     }
 }
コード例 #3
0
 public virtual void AddStorableType(Type typeToAdd)
 {
     if (IsTypeStorable(typeToAdd, false))
     {
         return;
     }
     if (StoredTypes.Contains(typeToAdd))
     {
         return;
     }
     StoredTypes.Add(typeToAdd);
 }
コード例 #4
0
 public override TState FromEntry(TextEntry entry)
 {
     try
     {
         var sourceType = StoredTypes.ForName(entry.TypeName);
         var bland      = JsonSerialization.Deserialized(entry.EntryData, sourceType);
         return((TState)bland !);
     }
     catch (Exception)
     {
         throw new InvalidOperationException($"Cannot convert to type: {entry.TypeName}");
     }
 }
コード例 #5
0
        public virtual PropertyValueType LookUpType(String typeName)
        {
            PropertyValueType type = null;

            foreach (PropertyValueType t in StoredTypes)
            {
                if (t.ValueTypeName == typeName)
                {
                    type = t;
                    break;
                }
            }
            if (null == type)
            {
                type = new PropertyValueType(typeName);
                if (null != type)
                {
                    StoredTypes.Add(type);
                }
            }
            return(type);
        }
コード例 #6
0
        public static IEnumerable <IEntry <T> > None => new IEntry <T> [0]; // Enumerable.Empty<IEntry<T>>(); throws an exception on deserialization with Netwtonsoft

        public static Type TypedFrom(string type) => StoredTypes.ForName(type) !;
コード例 #7
0
 /// <inheritdoc />
 protected override bool IsQualifiedByPredicate(Type type)
 {
     return(StoredTypes.Contains(type) == false);
 }