// Use this for initialization
	void Start () 
    {
        if (Obj != null && !ResetObject)
            return;
        
        Obj = new SerializableObject() { Object = 10.0f };
        Debug.Log("Created new SerializableObject");
	}
예제 #2
0
        public Workplace(string name, FileInfo info)
        {
            // Initialize simulated multiple-inheritance helpers
            serializableObject = new SerializableObject<Workplace>(this);
            sinapseDocument = new SinapseDocument(name, info);

            //        documents = new SinapseDocumentInfoCollection();
            //        documents.ListChanged += new ListChangedEventHandler(workplaceItemsListChanged);
        }
예제 #3
0
 void Start()
 {
     if (resetGameGroups == 0)
     {
         so = SaveManager.Load();
         so.groupsForTest.Clear();
         so.groupsForTest = new List <int>();
         SaveManager.Save(so);
     }
 }
예제 #4
0
        public Project GetProject(Guid id)
        {
            string path = Path.Combine(project_path, id.ToString());

            if (File.Exists(path))
            {
                return(SerializableObject.Load <Project>(path));
            }
            return(null);
        }
        /// <summary>
        /// Common Test code to try and serialize an object to a stream
        /// </summary>
        /// <param name="provider">
        /// The provider to use to perform the serialization
        /// </param>
        public static void Serialize_SerializableObjectToStream(SerializationProvider provider)
        {
            SerializableObject obj1 = new SerializableObject();

            using (MemoryStream memStream = new MemoryStream())
            {
                provider.Serialize(obj1, memStream);
                Assert.IsTrue(memStream.Position > 0);
            }
        }
예제 #6
0
        public ISerializableObject Serialize()
        {
            dynamic so = new SerializableObject(this.GetType());

            so.Tag           = this.Tag;
            so.Name          = this.Name;
            so.ExternalState = this.ExternalState;

            return(so);
        }
예제 #7
0
    public Actor Spawn(Type type, object outer, SpawnParameters spawnArgs)
    {
        if (!typeof(Actor).IsAssignableFrom(type))
        {
            throw new Exception("Can only spawn actors!");
        }
        int classID = SerializableObject.StaticClassIDSlow(type);

        return(InternalSpawn(null, type, classID, outer, spawnArgs));
    }
예제 #8
0
        public static void ConvertCategories(string inputPath, string outputPath)
        {
            Categories cats = SerializableObject.Load <Categories> (inputPath,
                                                                    SerializationType.Binary);
            Dictionary <TagSubCategory, List <LongoMatch.Core.Store.Tag> > ignore1;
            Dictionary <Category, LongoMatch.Core.Store.EventType>         ignore2;
            var dashboard = ConvertCategories(cats, out ignore1, out ignore2);

            outputPath = FixPath(outputPath);
            LongoMatch.Core.Common.Serializer.Save(dashboard, outputPath);
        }
예제 #9
0
        /// <summary>
        /// Send All The Users Critical Error And Close All Of The Connections
        /// </summary>
        public void Close()
        {
            Error error = new Error("Server Close", true);
            SerializableObject <Status> obj = new SerializableObject <Status>(Status.ServerError, error);

            foreach (NetUser u in users)
            {
                u.Send(obj);
                u.Connection.Close();
            }
        }
예제 #10
0
 public void SetMethod(Type targetType, string methodName)
 {
     methodInfo = new SerializableMethodInfo(targetType.GetMethod(methodName));
     ParameterInfo[] pInfos = methodInfo.methodInfo.GetParameters();
     parameters = new SerializableObject[pInfos.Length];
     for (int i = 0; i < parameters.Length; i++)
     {
         parameters[i] = new SerializableObject(pInfos[i].ParameterType);
     }
     target = targetGO.GetComponent(targetType);
 }
예제 #11
0
        public ISerializableObject Serialize()
        {
            dynamic so = new SerializableObject(this.GetType());

            so.MatchId = this.MatchId;
            so.GroupId = this.GroupId;
            so.Type    = this.Type;
            so.Sort    = this.Sort;

            return(so);
        }
예제 #12
0
        private byte[] SerializeObject(SerializableObject serializableObject)
        {
            var stream     = new MemoryStream();
            var serializer = new JsonSerializer();

            using (var writer = new StreamWriter(stream))
            {
                serializer.Serialize(writer, serializableObject);
            }
            return(stream.ToArray());
        }
    public void addToNotificationFunc()
    {
        //reset game
        so = SaveManager.Load();
        so.groupsForTest.Clear();
        SaveManager.Save(so);

        curEditPanel.SetActive(false);

        PlayerPrefs.SetInt("GroupsAddToNotif", 1);
    }
예제 #14
0
	public void ReplicateRPC(SerializableObject context, int rpcID, ObjectRPCSerializer serializer, params object[] args) {
		if (!_connection.isValid) {
			return;
		}

		Perf.Begin("ActorReplicationChannel.ReplicateRPC");

		if (isServer) {
			if (!didHandshake) {
				// client hasn't finished connecting
				Perf.End();
				return;
			}

			if ((clientLevel == null) || (clientLevel != _connection.world.currentLevel)) {
				Perf.End();
				return;
			}
		} else if (_connection.world.isTraveling) {
			Perf.End();
			return;
		}

		if (context.internal_GetReplicator(connection) == null) {
			// has not been replicated.
			Perf.End();
			return;
		}

		var actor = context as Actor;
		if ((actor != null) && isServer && serializer.rpcInfo.CheckRelevancy && !actor.IsNetRelevantFor(this)) {
			// not relevant
			Perf.End();
			return;
		}

		Assert.IsFalse((actor != null) ? actor.netTornOff : false);

		objectRefs.Clear();

		var netMsg = NetMsgs.ReplicatedObjectRPC.New(context.netID, (ushort)rpcID);
		serializer.Write(netMsg.archive, this, args);
		
		if (_connection.world is Server.ServerWorld) {
			// send objects in the argument list first
			ReplicateDependencies();
		} else {
			objectRefs.Clear();
		}

		_connection.SendReliable(netMsg);

		Perf.End();
	}
예제 #15
0
        /// <summary>
        /// Creates the default inspector GUI for the provided object.
        /// </summary>
        /// <param name="obj">Object whose fields to create the GUI for.</param>
        /// <param name="subType">
        /// If not null, the added fields will be limited to this particular type (not including any base types the actual
        /// object type might be a part of). If null, then fields for the entire class hierarchy of the provided object's
        /// type will be created.
        /// </param>
        /// <param name="overrideCallback">
        /// Optional callback that allows you to override the look of individual fields in the object. If non-null the
        /// callback will be called with information about every field in the provided object. If the callback returns
        /// non-null that inspectable field will be used for drawing the GUI, otherwise the default inspector field type
        /// will be used.
        /// </param>
        public void AddDefault(object obj, Type subType = null, FieldOverrideCallback overrideCallback = null)
        {
            if (obj == null)
            {
                return;
            }

            SerializableObject serializableObject = new SerializableObject(obj.GetType(), obj);

            AddDefault(serializableObject, subType, overrideCallback);
        }
 ///<summary>Saves state dict to a file.</summary>
 ///<param name = "state_dict">A dictionary containing a whole state of the module.</param>
 ///<param name = "fname">Output file name.</param>
 public static unsafe void save(SerializableObject obj, Stream s)
 {
     if ((object)obj.__as_tensor == null)
     {
         save((Dictionary <string, Tensor>)obj, s);
     }
     else
     {
         save((Tensor)obj, s);
     }
 }
예제 #17
0
        /// <summary>
        /// Requests a file for client to update
        /// </summary>
        /// <param name="connectionRequest">Connection Request Object</param>
        public void SendToServer(SerializableObject connectionRequest)
        {
            byte[] dataToSent = connectionRequest.BinarySerialization();
            clientSocket.Send(dataToSent);
            //clientSocket.Listen(10);
            //Socket server = clientSocket.Accept();

            recievingThread = new Thread(() => RecieveServerData(clientSocket));
            recievingThread.Start();
            Console.WriteLine("Server Conencted");
        }
예제 #18
0
        public ActivationNetworkSystem(string name, System.IO.FileInfo info) : base()
        {
            serializableObject = new SerializableObject <ActivationNetworkSystem>(this);
            sinapseDocument    = new SinapseDocument(name, info);

            Preprocess  = new FilterCollection();
            Postprocess = new FilterCollection();

            this.Name       = name;
            this.HasChanges = true;
        }
예제 #19
0
 public static Project Import(string file)
 {
     try {
         return(SerializableObject.Load <Project>(file));
     }
     catch (Exception e) {
         Log.Exception(e);
         throw new Exception(Catalog.GetString("The file you are trying to load " +
                                               "is not a valid project"));
     }
 }
예제 #20
0
	public ObjectRPCTable GetRPCTable(SerializableObject obj) {
		ObjectRPCTable table;
		if (!rpcTables.TryGetValue(obj.classID, out table)) {
			table = new ObjectRPCTable(obj.serverType, obj.clientType);
			rpcTables[obj.classID] = table;
		}

		table.Validate(obj);

		return table;
	}
예제 #21
0
        public static Categories Load(string filePath)
        {
            Categories cat = SerializableObject.LoadSafe <Categories>(filePath);

            if (cat.GamePeriods == null)
            {
                cat.GamePeriods = new List <string>();
                cat.GamePeriods.Add("1");
                cat.GamePeriods.Add("2");
            }
            return(cat);
        }
예제 #22
0
        public override ISerializableObject Serialize()
        {
            EnsureExternalState();

            dynamic so = new SerializableObject(this.GetType());

            so.CompetitorId    = this.CompetitorId;
            so.BtrCompetitorId = this.BtrCompetitorId;
            so.ExternalState   = this.ExternalState;

            return(so);
        }
예제 #23
0
 public Actor Spawn(ActorSpawnTag tag, object outer, SpawnParameters spawnArgs)
 {
     if (tag.type == null)
     {
         throw new Exception("ActorSpawnTag cannot load type: " + tag.typeName);
     }
     else
     {
         int classID = SerializableObject.StaticClassIDSlow(tag.type);
         return(InternalSpawn(tag, tag.type, classID, outer, spawnArgs));
     }
 }
예제 #24
0
        public void RecieveServerData(Socket server)
        {
            while (true)
            {
                byte[] buffer = new byte[server.ReceiveBufferSize];
                server.Receive(buffer);

                SerializableObject connectionReply = (SerializableObject)buffer.BinaryDeserialization();

                Console.WriteLine(connectionReply.ToConsoleString());
            }
        }
예제 #25
0
        public void AddProject(Project project)
        {
            string path = Path.Combine(project_path, project.UUID.ToString());

            project.Description.LastModified = DateTime.Now;
            if (File.Exists(path))
            {
                File.Delete(path);
            }
            SerializableObject.Save(project, path);
            SerializableObject.Save(project.Description, Path.Combine(desc_path, project.UUID.ToString()));
        }
예제 #26
0
    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            SaveManager.Save(so);
        }

        if (Input.GetKeyDown(KeyCode.Return))
        {
            so = SaveManager.Load();
        }
    }
예제 #27
0
    public SerializedObjectFields InternalGetReplicatedFields(SerializableObject obj)
    {
        SerializedObjectFields fields;

        if (_serializedFields.TryGetValue(obj.classID, out fields))
        {
            return(fields);
        }

        fields = new SerializedObjectFields(obj.GetType(), ReplicatedObjectFieldSerializerFactory.instance, true);
        return(fields);
    }
예제 #28
0
        public ActivationNetworkSystem(string name, System.IO.FileInfo info)
            : base()
        {
            serializableObject = new SerializableObject<ActivationNetworkSystem>(this);
            sinapseDocument = new SinapseDocument(name, info);

            Preprocess = new FilterCollection();
            Postprocess = new FilterCollection();

            this.Name = name;
            this.HasChanges = true;
        }
    // Update is called once per frame
    void Update()
    {
        so = SaveManager.Load();

        //get current times
        string day    = System.DateTime.Now.DayOfWeek.ToString();
        string date   = System.DateTime.Now.ToString("dd/MM/yyyy");
        string hour   = System.DateTime.Now.Hour.ToString();
        string minute = System.DateTime.Now.Minute.ToString("00");
        string second = System.DateTime.Now.Second.ToString();

        //updating time and date UI
        TimeDateText.GetComponent <Text>().text = (day + "\n" + date + "\n" + hour + ":" + minute);

        //performs the saving of the inputs from the user in the inputfield

        string saveText  = so.ownActivityContent[so.ownActivityContent.Count - 1]; //get text saved
        string textInput = ActivityInputField.GetComponent <InputField>().text;    //get user input

        //Check if the saved text is the same as in inputfield
        if (!(saveText == textInput))
        {
            time = totalTime;
            savingText.GetComponent <Text>().text = "Saving";
            savingImage.SetActive(true);
            savedImage.SetActive(false);

            //if not same update saved text
            if (so.ownActivityContent.Count > 0)
            {
                so.ownActivityContent[so.ownActivityContent.Count - 1] = ActivityInputField.GetComponent <InputField>().text;
            }

            if (so.dayActivityWritten.Count > 0)
            {
                so.dayActivityWritten[so.dayActivityWritten.Count - 1] = date;
            }
            SaveManager.Save(so);
        }

        //A delay for saving icon
        if (saveText == textInput)
        {
            time -= Time.deltaTime;

            if (time < 0)
            {
                savingText.GetComponent <Text>().text = "Saved";
                savingImage.SetActive(false);
                savedImage.SetActive(true);
            }
        }
    }
        /// <summary>
        /// Common Test code to try and deserialize a null or empty buffer
        /// </summary>
        /// <param name="provider">
        /// The provider to use to perform the serialization
        /// </param>
        public static void Deserialize_BufferNullOrEmpty(SerializationProvider provider)
        {
            byte[] buffer = null;

            SerializableObject obj1 = provider.Deserialize <SerializableObject>(buffer);

            Assert.IsNull(obj1);

            buffer = new byte[0];
            obj1   = provider.Deserialize <SerializableObject>(buffer);
            Assert.IsNull(obj1);
        }
예제 #31
0
    public void DeleteCardFunc()
    {
        so = SaveManager.Load();

        if (so.cardGroups[groupIndex].cards[cardIndex].cardCorrect == "Correct")
        {
            so.cardGroups[groupIndex].lastTestScore -= 1;
        }
        so.cardGroups[groupIndex].cards.RemoveAt(cardIndex);
        SaveManager.Save(so);
        SceneManager.LoadScene(SceneToLoad);
    }
예제 #32
0
        /// <summary>
        /// Creates new generic inspector field drawer for the specified object.
        /// </summary>
        /// <param name="obj">Object whose fields to create the GUI for.</param>
        /// <param name="parent">Parent Inspector to draw in.</param>
        /// <param name="layout">Parent layout that all the field GUI elements will be added to.</param>
        /// <param name="overrideCallback">
        /// Optional callback that allows you to override the look of individual fields in the object. If non-null the
        /// callback will be called with information about every field in the provided object. If the callback returns
        /// non-null that inspectable field will be used for drawing the GUI, otherwise the default inspector field type
        /// will be used.
        /// </param>
        public GenericInspectorDrawer(object obj, Inspector parent, GUILayoutY layout,
                                      InspectableField.FieldOverrideCallback overrideCallback = null)
        {
            if (obj == null)
            {
                return;
            }

            SerializableObject serializableObject = new SerializableObject(obj.GetType(), obj);

            Fields = InspectableField.CreateFields(serializableObject, parent, "", 0, layout, overrideCallback);
        }
예제 #33
0
        public void TestSerialization()
        {
            // Declare variables
            MemoryStream stream = null;

            // Create object
            var obj = new SerializableObject();

            // Set some values
            obj.StringValue = "SerializationHelperTest";
            obj.IntValue    = 1;
            obj.BoolValue   = false;
            obj.ObjectValue = DateTime.MinValue;

            // Create formatter
#if NET
            var serializer = new BinaryFormatter();
#else
            var serializer = SerializationHelper.GetDataContractSerializer(typeof(SerializableObject), obj.GetType(), "test", obj, false);
#endif

            #region Serialize to disk
            // Create stream
            using (stream = new MemoryStream())
            {
                // Serialize
#if NET
                serializer.Serialize(stream, obj);
#else
                serializer.WriteObject(stream, obj);
#endif
                #endregion

                #region Deserialize from disk
                // Reset stream position
                stream.Position = 0L;

                // Serialize
#if NET
                obj = (SerializableObject)serializer.Deserialize(stream);
#else
                obj = (SerializableObject)serializer.ReadObject(stream);
#endif
            }
            #endregion

            // Test values
            Assert.AreEqual("SerializationHelperTest", obj.StringValue);
            Assert.AreEqual(1, obj.IntValue, 1);
            Assert.AreEqual(false, obj.BoolValue);
            Assert.AreEqual(DateTime.MinValue, obj.ObjectValue);
        }
    void Update()
    {
        if (PrintCurrentValue)
        {
            PrintCurrentValue = false;
            Debug.Log("Current value: " + Obj.Object.ToString());
        }
        if(ResetObject)
        {
            ResetObject = false;

            switch (Type)
            {
                case SetType.Float:
                    Obj = new SerializableObject() { Object = FloatValue };
                    break;
                case SetType.Int:
                    Obj = new SerializableObject() { Object = IntValue };
                    break;
                case SetType.String:
                    Obj = new SerializableObject() { Object = StringValue };
                    break;
                case SetType.V3:
                    Obj = new SerializableObject() { Object = V3 };
                    break;
                case SetType.V2:
                    Obj = new SerializableObject() { Object = V2 };
                    break;
                case SetType.V4:
                    Obj = new SerializableObject() { Object = V4 };
                    break;
                case SetType.Quat:
                    Obj = new SerializableObject() { Object = Q };
                    break;
                case SetType.Null:
                    Obj = new SerializableObject();
                    break;
                case SetType.CustomClassNoUnity:
                    Obj = new SerializableObject() { Object = new CustomClassNoUnity(StringValue,FloatValue) };
                    break;
                case SetType.CustomClassUnity:
                    Obj = new SerializableObject() { Object = new CustomClassUnity(V3,V2) };
                    break;
                case SetType.Transform:
                    Obj = new SerializableObject() { Object = Tr };
                    break;
                case SetType.Queue:
                    Obj = new SerializableObject() { Object = Queue };
                    break;
            }
        }
    }
예제 #35
0
        /// <summary>
        ///   Creates a new Table Data Source object.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="info"></param>
        public TableDataSource(String name, System.IO.FileInfo info)
        {
            // Initialize simulated multiple-inheritance helpers
            this.serializableObject = new SerializableObject<TableDataSource>(this);
            this.sinapseDocument = new SinapseDocument(name, info);

            this.dataTable = new DataTable(name);
            this.Name = name;

            // Create the extra two columns for storing the Set and Subset
            createExtendedColumns();

            HasChanges = true;

            this.dataTable.ColumnChanged+= dataTable_Changed;
            this.dataTable.RowChanged += dataTable_Changed;
            this.dataTable.TableCleared += dataTable_Changed;
        }
예제 #36
0
 public ChildProxy()
 {
     _referencedObject = new ReferencedObject();
     _serializableObject = new SerializableObject();
     _nonSerializableObject = new NonSerializableObject();
 }
예제 #37
0
        public void BinarySerializableObject()
        {
            string xmlPath = TestBase.GetTestFilePath( "Storage", "TestBinarySerializableObject" );
            SerializableObject o = new SerializableObject();
            o.Name = "TestName";
            o.Power = 20;

            using( Stream wrt = new FileStream( xmlPath, FileMode.Create ) )
            {
                using( IStructuredWriter writer = SimpleStructuredWriter.CreateWriter( wrt, new SimpleServiceContainer() ) )
                {
                    writer.WriteObjectElement( "Before", 3712 );
                    writer.WriteObjectElement( "data", o );
                    writer.WriteObjectElement( "After", 3712 * 2 );
                }
            }
            using( Stream str = new FileStream( xmlPath, FileMode.Open ) )
            {
                SimpleServiceContainer s = new SimpleServiceContainer();
                s.Add( typeof( ISimpleTypeFinder ), SimpleTypeFinder.WeakDefault, null );
                using( IStructuredReader reader = SimpleStructuredReader.CreateReader( str, s ) )
                {
                    Assert.That( reader.ReadObjectElement( "Before" ), Is.EqualTo( 3712 ) );
                    
                    SerializableObject o2 = (SerializableObject)reader.ReadObjectElement( "data" );
                    Assert.AreEqual( o.Name, o2.Name );
                    Assert.AreEqual( o.Power, o2.Power );

                    Assert.That( reader.ReadObjectElement( "After" ), Is.EqualTo( 3712 * 2 ) );
                }
            }
        }
예제 #38
0
        public void ArrayListWithSerializableObjects()
        {
            string xmlPath = TestBase.GetTestFilePath( "Storage", "TestGenericListOfString" );
            ArrayList list = new ArrayList();
            SerializableObject firstObject = new SerializableObject() { Name = "Albert", Power = 34 };
            list.Add( firstObject );
            list.Add( new DateTime( 2009, 01, 11 ) );
            list.Add( "Franchement, les mecs, vous trouvez que c'est normal que ce soit Spi qui se cogne tous les tests unitaires ?" );

            using( Stream wrt = new FileStream( xmlPath, FileMode.Create ) )
            {
                using( IStructuredWriter writer = SimpleStructuredWriter.CreateWriter( wrt, new SimpleServiceContainer() ) )
                {
                    writer.WriteObjectElement( "data", list );
                    writer.WriteObjectElement( "After", 3712 * 2 );
                }
            }
            using( Stream str = new FileStream( xmlPath, FileMode.Open ) )
            {
                SimpleServiceContainer s = new SimpleServiceContainer();
                s.Add( typeof( ISimpleTypeFinder ), SimpleTypeFinder.WeakDefault, null );
                using( IStructuredReader reader = SimpleStructuredReader.CreateReader( str, s ) )
                {
                    ArrayList list2 = (ArrayList)reader.ReadObjectElement( "data" );
                    Assert.AreEqual( ((SerializableObject)list2[0]).Name, ((SerializableObject)list[0]).Name );
                    Assert.AreEqual( ((SerializableObject)list2[0]).Power, ((SerializableObject)list[0]).Power );
                    CheckExactTypeAndValue( typeof( DateTime ), list[1], list2[1] );
                    CheckExactTypeAndValue( typeof( string ), list[2], list2[2] );

                    Assert.That( reader.ReadObjectElement( "After" ), Is.EqualTo( 3712 * 2 ) );
                }
            }
        }
예제 #39
0
        public void TestSerialization()
        {
            // Declare variables
            MemoryStream stream = null;

            // Create object
            var obj = new SerializableObject();

            // Set some values
            obj.StringValue = "SerializationHelperTest";
            obj.IntValue = 1;
            obj.BoolValue = false;
            obj.ObjectValue = DateTime.MinValue;

            // Create formatter
#if NET
            var serializer = new BinaryFormatter();
#else
            var serializer = SerializationHelper.GetDataContractSerializer(typeof (SerializableObject), obj.GetType(), "test", obj, false);
#endif

            #region Serialize to disk
            // Create stream
            using (stream = new MemoryStream())
            {
                // Serialize
#if NET
                serializer.Serialize(stream, obj);
#else
                serializer.WriteObject(stream, obj);
#endif
                #endregion

                #region Deserialize from disk
                // Reset stream position
                stream.Position = 0L;

                // Serialize
#if NET
                obj = (SerializableObject)serializer.Deserialize(stream);
#else
                obj = (SerializableObject) serializer.ReadObject(stream);
#endif
            }
            #endregion

            // Test values
            Assert.AreEqual("SerializationHelperTest", obj.StringValue);
            Assert.AreEqual(1, obj.IntValue, 1);
            Assert.AreEqual(false, obj.BoolValue);
            Assert.AreEqual(DateTime.MinValue, obj.ObjectValue);
        }
예제 #40
0
 public void BugBinaryTooBigContent()
 {
     string xmlPath = TestBase.GetTestFilePath( "Storage", "BugBinaryTooBigContent" );
     SerializableObject original = new SerializableObject() { Name = "coucou", Power = 20 };
     using( Stream wrt = new FileStream( xmlPath, FileMode.Create ) )
     {
         using( IStructuredWriter writer = SimpleStructuredWriter.CreateWriter( wrt, new SimpleServiceContainer() ) )
         {
             writer.WriteObjectElement( "data", original );
         }
     }
     LoadAndModifyXml( xmlPath, d =>
     {
         var e = d.Root.Element( "data" );
         e.SetValue( e.Value.Insert( e.Value.Length / 2, "00FF00FF" ) );
     } );
     using( Stream str = new FileStream( xmlPath, FileMode.Open ) )
     {
         SimpleServiceContainer s = new SimpleServiceContainer();
         s.Add( typeof( ISimpleTypeFinder ), SimpleTypeFinder.WeakDefault, null );
         using( IStructuredReader reader = SimpleStructuredReader.CreateReader( str, s ) )
         {
             object obj = reader.ReadObjectElement( "data" );
         }
     }
 }
예제 #41
0
        public void BugBinarySizeDiffer()
        {
            string xmlPath = TestBase.GetTestFilePath( "Storage", "BugBinarySizeDiffer" );
            SerializableObject original = new SerializableObject() { Name = "coucou", Power = 20 };
            using( Stream wrt = new FileStream( xmlPath, FileMode.Create ) )
            {
                using( IStructuredWriter writer = SimpleStructuredWriter.CreateWriter( wrt, new SimpleServiceContainer() ) )
                {
                    writer.WriteObjectElement( "data", original );
                }
            }
            LoadAndModifyXml( xmlPath, d => d.Root.Element( "data" ).Attribute( "size" ).SetValue( "1" ) );

            using( Stream str = new FileStream( xmlPath, FileMode.Open ) )
            {
                SimpleServiceContainer s = new SimpleServiceContainer();
                s.Add( typeof( ISimpleTypeFinder ), SimpleTypeFinder.WeakDefault, null );
                using( IStructuredReader reader = SimpleStructuredReader.CreateReader( str, s ) )
                {
                    Assert.Throws<CKException>( () => reader.ReadObjectElement( "data" ) );
                }
            }
        }